mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-25 06:39:58 +00:00
Add dependency with pixman library
This commit is contained in:
parent
d68f1fa1b8
commit
0cf597c0f4
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "third_party/pixman"]
|
||||
path = third_party/pixman
|
||||
url = git@github.com:aseprite/pixman.git
|
@ -42,6 +42,7 @@ option(USE_SHARED_LIBPNG "Use your installed copy of libpng" off)
|
||||
option(USE_SHARED_LIBLOADPNG "Use your installed copy of libloadpng" off)
|
||||
option(USE_SHARED_TINYXML "Use your installed copy of tinyxml" off)
|
||||
option(USE_SHARED_GTEST "Use your installed copy of gtest" off)
|
||||
option(USE_SHARED_PIXMAN "Use your installed copy of pixman" off)
|
||||
option(USE_SHARED_ALLEGRO4 "Use shared Allegro 4 library (without resize support)" off)
|
||||
option(ENABLE_MEMLEAK "Enable memory-leaks detector (only for developers)" off)
|
||||
option(ENABLE_UPDATER "Enable automatic check for updates" on)
|
||||
@ -88,6 +89,7 @@ set(LIBJPEG_DIR ${CMAKE_SOURCE_DIR}/third_party/jpeg)
|
||||
set(LIBPNG_DIR ${CMAKE_SOURCE_DIR}/third_party/libpng)
|
||||
set(LOADPNG_DIR ${CMAKE_SOURCE_DIR}/third_party/loadpng)
|
||||
set(MONGOOSE_DIR ${CMAKE_SOURCE_DIR}/third_party/mongoose)
|
||||
set(PIXMAN_DIR ${CMAKE_SOURCE_DIR}/third_party/pixman)
|
||||
set(TINYXML_DIR ${CMAKE_SOURCE_DIR}/third_party/tinyxml)
|
||||
set(ZLIB_DIR ${CMAKE_SOURCE_DIR}/third_party/zlib)
|
||||
|
||||
|
@ -123,6 +123,18 @@ else()
|
||||
include_directories(${LOADPNG_DIR})
|
||||
endif()
|
||||
|
||||
if(USE_SHARED_PIXMAN)
|
||||
find_library(LIBPIXMAN_LIBRARY NAMES pixman)
|
||||
find_path(LIBPIXMAN_INCLUDE_DIR NAMES pixman.h)
|
||||
|
||||
set(libs3rdparty ${libs3rdparty} ${LIBPIXMAN_LIBRARY})
|
||||
include_directories(${LIBPIXMAN_INCLUDE_DIR})
|
||||
else()
|
||||
set(libs3rdparty ${libs3rdparty} pixman)
|
||||
include_directories(${PIXMAN_DIR}/pixman)
|
||||
include_directories(${CMAKE_BINARY_DIR})
|
||||
endif()
|
||||
|
||||
######################################################################
|
||||
# Add C++11 support only for our code (avoid Allegro)
|
||||
|
||||
|
@ -272,10 +272,10 @@ void ToolLoopManager::calculateDirtyArea(ToolLoop* loop, const Points& points, R
|
||||
break;
|
||||
}
|
||||
|
||||
Rect outsideBounds = outside.getBounds();
|
||||
Rect outsideBounds = outside.bounds();
|
||||
if (outsideBounds.x < 0) outside.offset(w * (1+((-outsideBounds.x) / w)), 0);
|
||||
if (outsideBounds.y < 0) outside.offset(0, h * (1+((-outsideBounds.y) / h)));
|
||||
int x1 = outside.getBounds().x;
|
||||
int x1 = outside.bounds().x;
|
||||
|
||||
while (true) {
|
||||
Region in_sprite;
|
||||
@ -283,7 +283,7 @@ void ToolLoopManager::calculateDirtyArea(ToolLoop* loop, const Points& points, R
|
||||
outside.createSubtraction(outside, in_sprite);
|
||||
dirty_area.createUnion(dirty_area, in_sprite);
|
||||
|
||||
outsideBounds = outside.getBounds();
|
||||
outsideBounds = outside.bounds();
|
||||
if (outsideBounds.isEmpty())
|
||||
break;
|
||||
else if (outsideBounds.x+outsideBounds.w > w)
|
||||
|
@ -265,7 +265,7 @@ public:
|
||||
|
||||
void updateDirtyArea() override
|
||||
{
|
||||
m_dirtyBounds = m_dirtyBounds.createUnion(m_dirtyArea.getBounds());
|
||||
m_dirtyBounds = m_dirtyBounds.createUnion(m_dirtyArea.bounds());
|
||||
m_document->notifySpritePixelsModified(m_sprite, m_dirtyArea);
|
||||
}
|
||||
|
||||
|
@ -2,3 +2,5 @@
|
||||
*Copyright (C) 2001-2014 David Capello*
|
||||
|
||||
> Distributed under [MIT license](LICENSE.txt)
|
||||
|
||||
The gfx::Region class depends on pixman library.
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -8,6 +8,8 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <pixman.h>
|
||||
|
||||
#include "gfx/region.h"
|
||||
#include "gfx/point.h"
|
||||
#include <limits>
|
||||
@ -18,44 +20,16 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// Anonymous namespace to include pixman-region.c. Macros doesn't respect
|
||||
// namespaces but anyway they are defined inside it just for reference
|
||||
// (to know that they are needed only for pixman-region.c).
|
||||
namespace {
|
||||
|
||||
#define PREFIX(x) pixman_region32##x
|
||||
#define PIXMAN_EXPORT
|
||||
#define _pixman_log_error(x, y) while (0) { }
|
||||
#define critical_if_fail assert
|
||||
|
||||
typedef int64_t overflow_int_t;
|
||||
typedef gfx::details::Box box_type_t;
|
||||
typedef gfx::details::RegionData region_data_type_t;
|
||||
typedef gfx::details::Region region_type_t;
|
||||
typedef bool pixman_bool_t;
|
||||
|
||||
#ifndef UINT32_MAX
|
||||
#define UINT32_MAX std::numeric_limits<uint32_t>::max()
|
||||
#endif
|
||||
|
||||
#define PIXMAN_REGION_MAX std::numeric_limits<int>::max()
|
||||
#define PIXMAN_REGION_MIN std::numeric_limits<int>::min()
|
||||
|
||||
typedef gfx::Region::Overlap pixman_region_overlap_t;
|
||||
const gfx::Region::Overlap PIXMAN_REGION_OUT = gfx::Region::Out;
|
||||
const gfx::Region::Overlap PIXMAN_REGION_IN = gfx::Region::In;
|
||||
const gfx::Region::Overlap PIXMAN_REGION_PART = gfx::Region::Part;
|
||||
|
||||
pixman_bool_t
|
||||
PREFIX(_union)(region_type_t *new_reg,
|
||||
region_type_t *reg1,
|
||||
region_type_t *reg2);
|
||||
|
||||
#include "gfx/pixman/pixman-region.c"
|
||||
}
|
||||
|
||||
namespace gfx {
|
||||
|
||||
inline Rect to_rect(const pixman_box32& extends)
|
||||
{
|
||||
return Rect(
|
||||
extends.x1, extends.y1,
|
||||
extends.x2 - extends.x1,
|
||||
extends.y2 - extends.y1);
|
||||
}
|
||||
|
||||
Region::Region()
|
||||
{
|
||||
pixman_region32_init(&m_region);
|
||||
@ -83,7 +57,7 @@ Region::~Region()
|
||||
Region& Region::operator=(const Rect& rect)
|
||||
{
|
||||
if (!rect.isEmpty()) {
|
||||
box_type_t box = { rect.x, rect.y, rect.x2(), rect.y2() };
|
||||
pixman_box32 box = { rect.x, rect.y, rect.x2(), rect.y2() };
|
||||
pixman_region32_reset(&m_region, &box);
|
||||
}
|
||||
else
|
||||
@ -100,28 +74,28 @@ Region& Region::operator=(const Region& copy)
|
||||
Region::iterator Region::begin()
|
||||
{
|
||||
iterator it;
|
||||
it.m_ptr = PIXREGION_RECTS(&m_region);
|
||||
it.m_ptr = pixman_region32_rectangles(&m_region, NULL);
|
||||
return it;
|
||||
}
|
||||
|
||||
Region::iterator Region::end()
|
||||
{
|
||||
iterator it;
|
||||
it.m_ptr = PIXREGION_RECTS(&m_region) + PIXREGION_NUMRECTS(&m_region);
|
||||
it.m_ptr = pixman_region32_rectangles(&m_region, NULL) + size();
|
||||
return it;
|
||||
}
|
||||
|
||||
Region::const_iterator Region::begin() const
|
||||
{
|
||||
const_iterator it;
|
||||
it.m_ptr = PIXREGION_RECTS(&m_region);
|
||||
it.m_ptr = pixman_region32_rectangles(&m_region, NULL);
|
||||
return it;
|
||||
}
|
||||
|
||||
Region::const_iterator Region::end() const
|
||||
{
|
||||
const_iterator it;
|
||||
it.m_ptr = PIXREGION_RECTS(&m_region) + PIXREGION_NUMRECTS(&m_region);
|
||||
it.m_ptr = pixman_region32_rectangles(&m_region, NULL) + size();
|
||||
return it;
|
||||
}
|
||||
|
||||
@ -130,14 +104,14 @@ bool Region::isEmpty() const
|
||||
return pixman_region32_not_empty(&m_region) ? false: true;
|
||||
}
|
||||
|
||||
Rect Region::getBounds() const
|
||||
Rect Region::bounds() const
|
||||
{
|
||||
return m_region.extents;
|
||||
return to_rect(*pixman_region32_extents(&m_region));
|
||||
}
|
||||
|
||||
size_t Region::size() const
|
||||
{
|
||||
return PIXREGION_NUMRECTS(&m_region);
|
||||
return pixman_region32_n_rects(&m_region);
|
||||
}
|
||||
|
||||
void Region::clear()
|
||||
@ -180,20 +154,20 @@ bool Region::contains(const PointT<int>& pt) const
|
||||
|
||||
Region::Overlap Region::contains(const Rect& rect) const
|
||||
{
|
||||
box_type_t box = { rect.x, rect.y, rect.x2(), rect.y2() };
|
||||
return pixman_region32_contains_rectangle(&m_region, &box);
|
||||
pixman_box32 box = { rect.x, rect.y, rect.x2(), rect.y2() };
|
||||
return (Region::Overlap)pixman_region32_contains_rectangle(&m_region, &box);
|
||||
}
|
||||
|
||||
Rect Region::operator[](int i)
|
||||
{
|
||||
assert(i >= 0 && i < PIXREGION_NUMRECTS(&m_region));
|
||||
return Rect(PIXREGION_RECTS(&m_region)[i]);
|
||||
assert(i >= 0 && i < (int)size());
|
||||
return to_rect(pixman_region32_rectangles(&m_region, NULL)[i]);
|
||||
}
|
||||
|
||||
const Rect Region::operator[](int i) const
|
||||
{
|
||||
assert(i >= 0 && i < PIXREGION_NUMRECTS(&m_region));
|
||||
return Rect(PIXREGION_RECTS(&m_region)[i]);
|
||||
assert(i >= 0 && i < (int)size());
|
||||
return to_rect(pixman_region32_rectangles(&m_region, NULL)[i]);
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
|
@ -20,24 +20,22 @@ namespace gfx {
|
||||
|
||||
namespace details {
|
||||
|
||||
#ifdef PIXMAN_VERSION_MAJOR
|
||||
typedef struct pixman_box32 Box;
|
||||
typedef struct pixman_region32 Region;
|
||||
#else
|
||||
struct Box {
|
||||
int x1, y1, x2, y2;
|
||||
int32_t x1, y1, x2, y2;
|
||||
|
||||
operator Rect() const {
|
||||
return Rect(x1, y1, x2-x1, y2-y1);
|
||||
}
|
||||
};
|
||||
|
||||
struct RegionData {
|
||||
long size;
|
||||
long numRects;
|
||||
// From here this struct has an array of rectangles (Box[size])
|
||||
};
|
||||
|
||||
struct Region {
|
||||
Box extents;
|
||||
RegionData* data;
|
||||
void* data;
|
||||
};
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
class RegionIterator : public std::iterator<std::forward_iterator_tag, T> {
|
||||
@ -83,7 +81,7 @@ namespace gfx {
|
||||
const_iterator end() const;
|
||||
|
||||
bool isEmpty() const;
|
||||
Rect getBounds() const;
|
||||
Rect bounds() const;
|
||||
size_t size() const;
|
||||
|
||||
void clear();
|
||||
|
4
third_party/CMakeLists.txt
vendored
4
third_party/CMakeLists.txt
vendored
@ -43,3 +43,7 @@ endif()
|
||||
if(ENABLE_WEBSERVER)
|
||||
add_subdirectory(mongoose)
|
||||
endif()
|
||||
|
||||
if(NOT USE_SHARED_PIXMAN)
|
||||
add_subdirectory(pixman-cmake)
|
||||
endif()
|
||||
|
1
third_party/pixman
vendored
Submodule
1
third_party/pixman
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 87eea99e443b389c978cf37efc52788bf03a0ee0
|
48
third_party/pixman-cmake/CMakeLists.txt
vendored
Normal file
48
third_party/pixman-cmake/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
# Copyright (C) 2014 by David Capello
|
||||
|
||||
add_definitions(-DHAVE_CONFIG_H)
|
||||
|
||||
set(PIXMAN_VERSION_MAJOR 0)
|
||||
set(PIXMAN_VERSION_MINOR 32)
|
||||
set(PIXMAN_VERSION_MICRO 6)
|
||||
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../pixman/pixman/pixman-version.h.in"
|
||||
"${CMAKE_BINARY_DIR}/pixman-version.h")
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../pixman/pixman
|
||||
${CMAKE_BINARY_DIR})
|
||||
|
||||
add_library(pixman
|
||||
../pixman/pixman/pixman.c
|
||||
../pixman/pixman/pixman-access.c
|
||||
../pixman/pixman/pixman-access-accessors.c
|
||||
../pixman/pixman/pixman-bits-image.c
|
||||
../pixman/pixman/pixman-combine32.c
|
||||
../pixman/pixman/pixman-combine-float.c
|
||||
../pixman/pixman/pixman-conical-gradient.c
|
||||
../pixman/pixman/pixman-filter.c
|
||||
../pixman/pixman/pixman-x86.c
|
||||
../pixman/pixman/pixman-mips.c
|
||||
../pixman/pixman/pixman-arm.c
|
||||
../pixman/pixman/pixman-ppc.c
|
||||
../pixman/pixman/pixman-edge.c
|
||||
../pixman/pixman/pixman-edge-accessors.c
|
||||
../pixman/pixman/pixman-fast-path.c
|
||||
../pixman/pixman/pixman-glyph.c
|
||||
../pixman/pixman/pixman-general.c
|
||||
../pixman/pixman/pixman-gradient-walker.c
|
||||
../pixman/pixman/pixman-image.c
|
||||
../pixman/pixman/pixman-implementation.c
|
||||
../pixman/pixman/pixman-linear-gradient.c
|
||||
../pixman/pixman/pixman-matrix.c
|
||||
../pixman/pixman/pixman-noop.c
|
||||
../pixman/pixman/pixman-radial-gradient.c
|
||||
../pixman/pixman/pixman-region16.c
|
||||
../pixman/pixman/pixman-region32.c
|
||||
../pixman/pixman/pixman-solid-fill.c
|
||||
../pixman/pixman/pixman-timer.c
|
||||
../pixman/pixman/pixman-trap.c
|
||||
../pixman/pixman/pixman-utils.c)
|
1
third_party/pixman-cmake/config.h
vendored
Normal file
1
third_party/pixman-cmake/config.h
vendored
Normal file
@ -0,0 +1 @@
|
||||
#define PACKAGE "pixman"
|
50
third_party/pixman-cmake/pixman-version.h.cmake
vendored
Normal file
50
third_party/pixman-cmake/pixman-version.h.cmake
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright © 2008 Red Hat, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy,
|
||||
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Author: Carl D. Worth <cworth@cworth.org>
|
||||
*/
|
||||
|
||||
#ifndef PIXMAN_VERSION_H__
|
||||
#define PIXMAN_VERSION_H__
|
||||
|
||||
#ifndef PIXMAN_H__
|
||||
# error pixman-version.h should only be included by pixman.h
|
||||
#endif
|
||||
|
||||
#define PIXMAN_VERSION_MAJOR @PIXMAN_VERSION_MAJOR@
|
||||
#define PIXMAN_VERSION_MINOR @PIXMAN_VERSION_MINOR@
|
||||
#define PIXMAN_VERSION_MICRO @PIXMAN_VERSION_MICRO@
|
||||
|
||||
#define PIXMAN_VERSION_STRING "@PIXMAN_VERSION_MAJOR@.@PIXMAN_VERSION_MINOR@.@PIXMAN_VERSION_MICRO@"
|
||||
|
||||
#define PIXMAN_VERSION_ENCODE(major, minor, micro) ( \
|
||||
((major) * 10000) \
|
||||
+ ((minor) * 100) \
|
||||
+ ((micro) * 1))
|
||||
|
||||
#define PIXMAN_VERSION PIXMAN_VERSION_ENCODE( \
|
||||
PIXMAN_VERSION_MAJOR, \
|
||||
PIXMAN_VERSION_MINOR, \
|
||||
PIXMAN_VERSION_MICRO)
|
||||
|
||||
#endif /* PIXMAN_VERSION_H__ */
|
Loading…
x
Reference in New Issue
Block a user