Skip to content

Commit

Permalink
porting for macosx
Browse files Browse the repository at this point in the history
  • Loading branch information
博然 committed Oct 24, 2019
1 parent df5d663 commit 9f0fadd
Show file tree
Hide file tree
Showing 15 changed files with 675 additions and 47 deletions.
54 changes: 34 additions & 20 deletions build/configs.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
{
'configurations': {
'Debug': {
'defines': [
'_DEBUG',
],
'conditions': [
['OS=="win"', {
'defines': [
'_DEBUG',
'ENABLE_FAST_COPY=1',
'ENABLE_SYSTEM_MALLOC=1',
],
'msvs_configuration_attributes': {
'ConfigurationType': '2',
'CharacterSet': '1',
Expand Down Expand Up @@ -41,12 +39,19 @@
},
},
}],
['OS=="macosx"', {
'xcode_settings': {
'ALWAYS_SEARCH_USER_PATHS': 'NO',
'CLANG_ENABLE_OBJC_WEAK': 'YES',
'CLANG_ADDRESS_SANITIZER_CONTAINER_OVERFLOW': 'YES',
'DEAD_CODE_STRIPPING': 'NO',
'ONLY_ACTIVE_ARCH': 'YES',
'ENABLE_TESTABILITY': 'YES',
'GCC_UNROLL_LOOPS': 'NO',
'GCC_OPTIMIZATION_LEVEL': '0',
},
}],
['OS=="linux"', {
'defines': [
'_DEBUG',
'ENABLE_FREE_TYPE2=1',
'ENABLE_FONT_CONFIG=1',
],
'cflags_cc': [
'-O0',
'-Wall',
Expand All @@ -67,13 +72,11 @@
],
},
'Release': {
'defines': [
'NDEBUG',
],
'conditions': [
['OS=="win"', {
'defines': [
'NDEBUG',
'ENABLE_FAST_COPY=1',
'ENABLE_SYSTEM_MALLOC=1',
],
'msvs_configuration_attributes': {
'ConfigurationType': '2',
'CharacterSet': '1',
Expand Down Expand Up @@ -109,12 +112,23 @@
},
},
}],
['OS=="macosx"', {
'xcode_settings': {
'ALWAYS_SEARCH_USER_PATHS': 'NO',
'CLANG_ENABLE_CODE_COVERAGE': 'NO',
'GCC_GENERATE_DEBUGGING_SYMBOLS': 'NO',
'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES',
'CLANG_ENABLE_OBJC_WEAK': 'YES',
'CLANG_ADDRESS_SANITIZER_CONTAINER_OVERFLOW': 'NO',
'DEAD_CODE_STRIPPING': 'YES',
'ONLY_ACTIVE_ARCH': 'NO',
'LLVM_LTO': 'YES',
'ENABLE_TESTABILITY': 'NO',
'GCC_UNROLL_LOOPS': 'YES',
'GCC_OPTIMIZATION_LEVEL': '3',
},
}],
['OS=="linux"', {
'defines': [
'NDEBUG',
'ENABLE_FREE_TYPE2=1',
'ENABLE_FONT_CONFIG=1',
],
'cflags_cc': [
'-O3',
'-Wall',
Expand Down
14 changes: 13 additions & 1 deletion build/defines.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,29 @@
# Contact: [email protected]

{

'conditions': [
['OS=="win"', {
'defines': [
'WIN32',
'DLL_EXPORT',
'ENABLE_FAST_COPY=1',
'ENABLE_SYSTEM_MALLOC=1',
'__SSE2__=1',
'_HAS_EXCEPTIONS=0',
'_USE_MATH_DEFINES',
'_CRT_SECURE_NO_WARNINGS',
],
}],
['OS=="linux"', {
'defines': [
'ENABLE_FREE_TYPE2=1',
'ENABLE_FONT_CONFIG=1',
],
}],
['OS=="macosx" or OS=="ios"', {
'defines': [
'ENABLE_SYSTEM_MALLOC=1',
],
}],
],
}
File renamed without changes.
5 changes: 5 additions & 0 deletions build_macosx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

./tools/gyp/gyp --depth=./ picasso.gyp -f xcode -DOS=macosx --generator-output=proj
echo "Please change dir to \"proj\" and open picasso.xcodeproj with Xcode"
echo "...\n"
File renamed without changes.
520 changes: 520 additions & 0 deletions proj/picasso.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>picasso2_sw.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
1 change: 0 additions & 1 deletion src/core/curve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

namespace picasso {

const scalar curve_distance_epsilon = FLT_TO_SCALAR(1e-30f);
const scalar curve_collinearity_epsilon = FLT_TO_SCALAR(1e-30f);
const scalar curve_angle_tolerance_epsilon = FLT_TO_SCALAR(0.01f);

Expand Down
51 changes: 51 additions & 0 deletions src/gfx/gfx_font_adapter_dummy.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* Picasso - a vector graphics library
*
* Copyright (C) 2019 Zhang Ji Peng
* Contact: [email protected]
*/

#include <stdio.h>
#include "common.h"
#include "convert.h"
#include "gfx_font_adapter.h"
#include "gfx_trans_affine.h"

#if !defined(WIN32) && !ENABLE(FREE_TYPE2)

// dummy font interface
namespace gfx {

gfx_font_adapter::gfx_font_adapter(const char* name, int charset, scalar size, scalar weight,
bool italic, bool hint, bool flip, bool a, const abstract_trans_affine* mtx) { }
gfx_font_adapter::~gfx_font_adapter() { }
void gfx_font_adapter::active(void) { }
void gfx_font_adapter::deactive(void) { }
void gfx_font_adapter::add_kerning(unsigned int first, unsigned int second, scalar* x, scalar* y) { }
bool gfx_font_adapter::prepare_glyph(unsigned int code) { return false; }
void gfx_font_adapter::write_glyph_to(byte* buffer) { }
void* gfx_font_adapter::create_storage(byte* buf, unsigned int len, scalar x, scalar y) { return NULL; }
void gfx_font_adapter::destroy_storage(void*) { }
void gfx_font_adapter::translate_storage(void* storage, scalar x, scalar y) { }
scalar gfx_font_adapter::height(void) const { return 0; }
scalar gfx_font_adapter::ascent(void) const { return 0; }
scalar gfx_font_adapter::descent(void) const { return 0; }
scalar gfx_font_adapter::leading(void) const { return 0; }
unsigned int gfx_font_adapter::units_per_em(void) const { return 0; }
unsigned int gfx_font_adapter::glyph_index(void) const { return 0; }
unsigned int gfx_font_adapter::data_size(void) const { return 0; }
glyph_type gfx_font_adapter::data_type(void) const { return glyph_type_invalid; }
const rect& gfx_font_adapter::bounds(void) const { static rect r; return r; }
scalar gfx_font_adapter::advance_x(void) const { return 0; }
scalar gfx_font_adapter::advance_y(void) const { return 0; }

}

bool platform_font_init(void)
{
return true;
}

void platform_font_shutdown(void)
{
}
#endif
20 changes: 0 additions & 20 deletions src/include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,4 @@ typedef long long int int64_t;
// special types
typedef uint8_t byte;

// aligned attribute
#if COMPILER(MSVC)
#define ALIGNED(x) __declspec(align(x))
#elif COMPILER(GCC)
#define ALIGNED(x) __attribute__((aligned((x))))
#else
#define ALIGNED(x)
#endif

// force inline
#if COMPILER(MSVC)
#define _FORCE_INLINE_ __forceinline
#elif COMPILER(GCC)
#if __GNUC__ == 2 && __GNUC_MINOR__ < 96
#define _FORCE_INLINE_ inline
#else
#define _FORCE_INLINE_ __attribute__((always_inline))
#endif
#endif

#endif /*_COMMON_H_*/
8 changes: 4 additions & 4 deletions src/include/memory_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
#undef new
#undef delete

inline void* operator new (size_t size) { return mem_malloc(size); }
inline void* operator new[] (size_t size) { return mem_malloc(size); }
inline void operator delete (void* p) { mem_free(p); }
inline void operator delete[] (void* p) { mem_free(p); }
MAYBE_INLINE void* operator new (size_t size) { return mem_malloc(size); }
MAYBE_INLINE void* operator new[] (size_t size) { return mem_malloc(size); }
MAYBE_INLINE void operator delete (void* p) { mem_free(p); }
MAYBE_INLINE void operator delete[] (void* p) { mem_free(p); }

#endif /*ENABLE(SYSTEM_MALLOC)*/

Expand Down
27 changes: 26 additions & 1 deletion src/include/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
#define COMPILER_CLANG 1
#endif


/* CPU(X86) - i386 / x86 32-bit */
#if defined(__i386__) \
|| defined(i386) \
Expand Down Expand Up @@ -103,4 +102,30 @@
#define unlikely(X) (X)
#endif

// aligned attribute
#if COMPILER(MSVC)
#define ALIGNED(x) __declspec(align(x))
#elif COMPILER(GCC)
#define ALIGNED(x) __attribute__((aligned((x))))
#else
#define ALIGNED(x)
#endif

// force inline
#if COMPILER(MSVC)
#define _FORCE_INLINE_ __forceinline
#elif COMPILER(GCC)
#if __GNUC__ == 2 && __GNUC_MINOR__ < 96
#define _FORCE_INLINE_ inline
#else
#define _FORCE_INLINE_ __attribute__((always_inline))
#endif
#endif

#if COMPILER(CLANG)
#define MAYBE_INLINE
#else
#define MAYBE_INLINE inline
#endif

#endif /*_PLATFORM_H_*/
1 change: 1 addition & 0 deletions src/src.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
'gfx/gfx_font_adapter.h',
'gfx/gfx_font_adapter_freetype2.cpp',
'gfx/gfx_font_adapter_win32.cpp',
'gfx/gfx_font_adapter_dummy.cpp',
'gfx/gfx_font_load_freetype2.cpp',
'gfx/gfx_gamma_function.h',
'gfx/gfx_gradient_adapter.cpp',
Expand Down

0 comments on commit 9f0fadd

Please sign in to comment.