Mercurial > MadButterfly
annotate src/graph_engine_skia.cpp @ 497:6abc53f00792 Android_Skia
It may not need to call unref() for xfermode object.
unref() makes compile-time fault. It seems Skia don't want we to call
it. It is removed temporary and should be reviewed, later.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Thu, 26 Nov 2009 15:03:01 +0800 |
parents | 9e36e06fcc18 |
children | b106fa78a090 |
rev | line source |
---|---|
482
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
1 /*! \page ge_layer Graphic Engine Layer |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
2 * |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
3 * Graphic Engine Layer is an abstract of graphic engine; likes Cairo |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
4 * and Skia. It provides portability for the rest of MadButterfly. |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
5 * |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
6 * The basic stratage of interface of graphic engine layer is defined |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
7 * according purpose of MadButterfly. For example, MadButterfly wants |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
8 * a function that can clear a canvas, we define a clear function. |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
9 * Never define a indirectly way to finish the function. Never define |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
10 * a way to finish the function for the reason that some engine |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
11 * require you to finish the task in that procedure. It avoids |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
12 * binding graphic engine layer with any behavior of a graphic engine, |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
13 * and provides more compatible with other engines, to define |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
14 * interface of graphic engine layer according purpose of |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
15 * MadButterfly. |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
16 * |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
17 * \section ge_mem Graphic Engine Layer Memory Management |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
18 * |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
19 * MadButterfly is responsible for management of objects and memory |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
20 * blocks returned by graphic engine layer, even for graphic engines |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
21 * that have management model. MadButterfly supposes memory blocks |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
22 * only be released when they are no more used. MadBufferfly is |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
23 * responsible for release them. So, even a graphic engine has |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
24 * reference count with objects, MadButterfly still keep a reference |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
25 * for every object returned by the engine until no one will use it. |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
26 * |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
27 * \section ge_transform Transformation of Coordination System |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
28 * |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
29 * Points of pathes are transformed when it is added to the canvas |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
30 * with the transformation matrix at the time. So, changes of |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
31 * transformation matrix of an canvas will not affect points that had |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
32 * been added. It only affects points been added when the matrix is |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
33 * setted. |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
34 */ |
472
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
35 #include <stdio.h> |
479
9a867333018b
mbe_create() and mbe_destroy() pass the compilation.
Thinker K.F. Li <thinker@branda.to>
parents:
473
diff
changeset
|
36 #include <SkCanvas.h> |
472
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
37 #include <SkBitmap.h> |
495
9e36e06fcc18
Include SkRegion.h for graph_engine_skia.cpp
Thinker K.F. Li <thinker@branda.to>
parents:
483
diff
changeset
|
38 #include <SkRegion.h> |
472
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
39 #include <SkShader.h> |
482
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
40 #include <SkDevice.h> |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
41 #include <SkGradientShader.h> |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
42 #include <SkXfermode.h> |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
43 #include <SkColorFilter.h> |
472
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
44 |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
45 #define C_START extern "C" { |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
46 #define C_END } |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
47 |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
48 C_START |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
49 |
468
ae784a86ba82
C++ instead of C to bridge to Skia
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
50 #include "mb_graph_engine_skia.h" |
ae784a86ba82
C++ instead of C to bridge to Skia
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
51 #include "mb_shapes.h" |
482
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
52 #include "mb_img_ldr.h" |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
53 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
54 /*! \brief Source pattern |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
55 * |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
56 * For Skia, source pattern is SkShader with some decoration. Since |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
57 * SkShade will repeative tiling or extenting edge color, it can not |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
58 * stop tiling and extenting for fixed size bitmap. So, we need to |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
59 * translate mbe_paint() into a drawing of a rectangle. |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
60 */ |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
61 struct _mbe_pattern_t { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
62 SkShader *shader; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
63 int w, h; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
64 int has_size; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
65 co_aix matrix[6]; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
66 }; |
472
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
67 |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
68 struct _mbe_scaled_font_t { |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
69 struct _mb_font_face_t *face; |
473
ba64f928542b
Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents:
472
diff
changeset
|
70 co_aix fnt_mtx[6]; |
ba64f928542b
Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents:
472
diff
changeset
|
71 co_aix ctm[6]; |
479
9a867333018b
mbe_create() and mbe_destroy() pass the compilation.
Thinker K.F. Li <thinker@branda.to>
parents:
473
diff
changeset
|
72 }; |
472
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
73 struct _mbe_font_face_t {}; |
482
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
74 /*! \brief MadButterfly Graphic Engine Context. |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
75 * |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
76 * A context comprises source pattern, target surface, path, |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
77 * line-width, and transform matrix. |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
78 */ |
472
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
79 struct _mbe_t { |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
80 SkCanvas *canvas; |
482
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
81 SkPath *path, *subpath; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
82 SkPaint *paint; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
83 SkRegion *saved_region; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
84 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
85 struct _mbe_states_t *states; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
86 }; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
87 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
88 struct _mbe_states_t { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
89 mbe_pattern_t *ptn; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
90 int ptn_owned; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
91 co_aix line_width; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
92 co_aix matrix[6]; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
93 struct _mbe_states_t *next; |
469
4dc0be6c044a
Add copy and clear graphic engine functions.
Thinker K.F. Li <thinker@branda.to>
parents:
468
diff
changeset
|
94 }; |
468
ae784a86ba82
C++ instead of C to bridge to Skia
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
95 |
ae784a86ba82
C++ instead of C to bridge to Skia
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
96 #ifndef ASSERT |
ae784a86ba82
C++ instead of C to bridge to Skia
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
97 #define ASSERT(x) |
ae784a86ba82
C++ instead of C to bridge to Skia
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
98 #endif |
472
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
99 |
482
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
100 #define PI 3.1415926535897931 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
101 |
483
d984a6672be7
Fix bug of translate between co_aix and SkScalar.
Thinker K.F. Li <thinker@branda.to>
parents:
482
diff
changeset
|
102 #define CO_AIX_2_SKSCALAR(a) ((SkScalar)a) |
d984a6672be7
Fix bug of translate between co_aix and SkScalar.
Thinker K.F. Li <thinker@branda.to>
parents:
482
diff
changeset
|
103 #define SKSCALAR_2_CO_AIX(a) ((co_aix)(a)) |
482
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
104 #define MB_MATRIX_2_SKMATRIX(sk, mb) { \ |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
105 (sk).setScaleX(CO_AIX_2_SKSCALAR((mb)[0])); \ |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
106 (sk).setSkewX(CO_AIX_2_SKSCALAR((mb)[1])); \ |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
107 (sk).setTranslateX(CO_AIX_2_SKSCALAR((mb)[2])); \ |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
108 (sk).setSkewY(CO_AIX_2_SKSCALAR((mb)[3])); \ |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
109 (sk).setScaleY(CO_AIX_2_SKSCALAR((mb)[4])); \ |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
110 (sk).setTranslateY(CO_AIX_2_SKSCALAR((mb)[5])); \ |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
111 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
112 #define SKMATRIX_2_MB_MATRIX(mb, sk) { \ |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
113 (mb)[0] = SKSCALAR_2_CO_AIX((sk).getScaleX()); \ |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
114 (mb)[1] = SKSCALAR_2_CO_AIX((sk).getSkewX()); \ |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
115 (mb)[2] = SKSCALAR_2_CO_AIX((sk).getTranslateX()); \ |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
116 (mb)[3] = SKSCALAR_2_CO_AIX((sk).getSkewY()); \ |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
117 (mb)[4] = SKSCALAR_2_CO_AIX((sk).getScaleY()); \ |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
118 (mb)[5] = SKSCALAR_2_CO_AIX((sk).getTranslateY()); \ |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
119 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
120 #define MBSTOP_2_SKCOLOR(c) \ |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
121 ((((int)((c)->a * 255)) << 24) | \ |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
122 (((int)((c)->r * 255)) << 16) | \ |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
123 (((int)((c)->g * 255)) << 8) | \ |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
124 (((int)((c)->b * 255)))) |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
125 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
126 static const co_aix id_matrix[6] = { 1, 0, 0, 0, 1, 0 }; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
127 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
128 static void |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
129 _prepare_sized_pattern(mbe_t *mbe, mbe_pattern_t *ptn) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
130 SkCanvas *canvas = mbe->canvas; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
131 SkPath path; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
132 co_aix x, y; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
133 co_aix reverse[6]; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
134 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
135 *mbe->saved_region = canvas->getTotalClip(); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
136 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
137 compute_reverse(ptn->matrix, reverse); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
138 x = 0; y = 0; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
139 matrix_trans_pos(reverse, &x, &y); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
140 path.moveTo(CO_AIX_2_SKSCALAR(x), CO_AIX_2_SKSCALAR(y)); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
141 x = 0; y = ptn->h; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
142 matrix_trans_pos(reverse, &x, &y); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
143 path.moveTo(CO_AIX_2_SKSCALAR(x), CO_AIX_2_SKSCALAR(y)); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
144 x = ptn->w; y = ptn->h; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
145 matrix_trans_pos(reverse, &x, &y); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
146 path.moveTo(CO_AIX_2_SKSCALAR(x), CO_AIX_2_SKSCALAR(y)); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
147 path.close(); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
148 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
149 canvas->clipPath(path, SkRegion::kIntersect_Op); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
150 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
151 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
152 static void |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
153 _finish_sized_pattern(mbe_t *mbe) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
154 SkCanvas *canvas = mbe->canvas; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
155 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
156 canvas->setClipRegion(*mbe->saved_region); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
157 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
158 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
159 static void |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
160 _canvas_device_region(SkCanvas *canvas, SkRegion *region) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
161 SkDevice *device; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
162 int w, h; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
163 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
164 device = canvas->getDevice(); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
165 w = device->width(); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
166 h = device->height(); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
167 region->setRect(0, 0, w, h); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
168 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
169 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
170 static void |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
171 _update_path(mbe_t *mbe) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
172 SkPath *path = mbe->path; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
173 SkPath *subpath = mbe->subpath; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
174 SkMatrix canvas_matrix; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
175 SkPoint point; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
176 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
177 MB_MATRIX_2_SKMATRIX(canvas_matrix, mbe->states->matrix); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
178 path->addPath(*subpath, canvas_matrix); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
179 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
180 subpath->getLastPt(&point); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
181 subpath->rewind(); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
182 subpath->moveTo(point); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
183 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
184 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
185 /* |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
186 * When a function want to use the paint associated with a canvas to |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
187 * draw, it should call _prepare_paint() can make the paint ready. |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
188 * And, call _finish_paint() when the paint is no more used. |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
189 */ |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
190 static void |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
191 _prepare_paint(mbe_t *mbe, SkPaint::Style style) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
192 SkPaint *paint = mbe->paint; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
193 mbe_pattern_t *ptn = mbe->states->ptn; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
194 SkShader *shader = ptn->shader; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
195 co_aix matrix[6]; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
196 SkMatrix skmatrix; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
197 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
198 paint->setStyle(style); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
199 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
200 /* Local matrix of SkShader is a mapping from source pattern to |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
201 * user space. Unlikely, for Cairo is a mapping from user space |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
202 * to source pattern. |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
203 */ |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
204 matrix_mul(mbe->states->matrix, ptn->matrix, matrix); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
205 MB_MATRIX_2_SKMATRIX(skmatrix, matrix); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
206 shader->setLocalMatrix(skmatrix); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
207 paint->setShader(shader); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
208 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
209 if(style == SkPaint::kStroke_Style) |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
210 paint->setStrokeWidth(CO_AIX_2_SKSCALAR(mbe->states->line_width)); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
211 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
212 if(ptn->has_size) |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
213 _prepare_sized_pattern(mbe, ptn); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
214 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
215 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
216 static void |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
217 _finish_paint(mbe_t *mbe) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
218 mbe_pattern_t *ptn = mbe->states->ptn; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
219 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
220 mbe->paint->reset(); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
221 if(ptn->has_size) |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
222 _finish_sized_pattern(mbe); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
223 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
224 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
225 mbe_pattern_t *mbe_pattern_create_for_surface(mbe_surface_t *surface) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
226 mbe_pattern_t *ptn; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
227 SkBitmap *bitmap = (SkBitmap *)surface; |
472
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
228 |
482
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
229 ptn = (mbe_pattern_t *)malloc(sizeof(mbe_pattern_t)); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
230 ptn->shader = SkShader::CreateBitmapShader(*bitmap, |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
231 SkShader::kClamp_TileMode, |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
232 SkShader::kClamp_TileMode); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
233 if(ptn->shader == NULL) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
234 free(ptn); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
235 return NULL; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
236 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
237 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
238 ptn->has_size = 1; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
239 ptn->w = bitmap->width(); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
240 ptn->h = bitmap->height(); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
241 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
242 memcpy(ptn->matrix, id_matrix, sizeof(co_aix) * 6); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
243 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
244 return ptn; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
245 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
246 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
247 mbe_pattern_t * |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
248 mbe_pattern_create_radial(co_aix cx0, co_aix cy0, co_aix radius0, |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
249 co_aix cx1, co_aix cy1, co_aix radius1, |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
250 grad_stop_t *stops, int stop_cnt) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
251 mbe_pattern_t *ptn; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
252 SkColor *colors; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
253 SkScalar *poses; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
254 grad_stop_t *stop; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
255 SkPoint center; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
256 int i; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
257 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
258 ptn = (mbe_pattern_t *)malloc(sizeof(mbe_pattern_t)); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
259 colors = new SkColor[stop_cnt]; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
260 poses = new SkScalar[stop_cnt]; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
261 if(ptn == NULL || colors == NULL || poses == NULL) |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
262 goto fail; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
263 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
264 center.set(CO_AIX_2_SKSCALAR(cx1), CO_AIX_2_SKSCALAR(cy1)); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
265 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
266 stop = stops; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
267 for(i = 0; i < stop_cnt; i++) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
268 colors[i] = MBSTOP_2_SKCOLOR(stop); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
269 poses[i] = CO_AIX_2_SKSCALAR(stop->offset); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
270 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
271 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
272 /* |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
273 * cx0, cy0 and radius0 is not used. Since Skia is still not |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
274 * support two circles radial. And, SVG 1.2 is also not support |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
275 * two circles. |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
276 */ |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
277 ptn->shader = |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
278 SkGradientShader::CreateRadial(center, CO_AIX_2_SKSCALAR(radius1), |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
279 colors, poses, stop_cnt, |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
280 SkShader::kClamp_TileMode); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
281 if(ptn->shader == NULL) |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
282 goto fail; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
283 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
284 memcpy(ptn->matrix, id_matrix, sizeof(co_aix) * 6); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
285 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
286 delete colors; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
287 delete poses; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
288 return ptn; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
289 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
290 fail: |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
291 if(ptn) free(ptn); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
292 if(colors) delete colors; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
293 if(poses) delete poses; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
294 return NULL; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
295 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
296 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
297 mbe_pattern_t * |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
298 mbe_pattern_create_linear(co_aix x0, co_aix y0, |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
299 co_aix x1, co_aix y1, |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
300 grad_stop_t *stops, int stop_cnt) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
301 mbe_pattern_t *ptn; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
302 SkColor *colors; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
303 SkScalar *poses; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
304 grad_stop_t *stop; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
305 SkPoint points[2]; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
306 int i; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
307 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
308 ptn = (mbe_pattern_t *)malloc(sizeof(mbe_pattern_t)); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
309 colors = new SkColor[stop_cnt]; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
310 poses = new SkScalar[stop_cnt]; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
311 if(ptn == NULL || colors == NULL || poses == NULL) |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
312 goto fail; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
313 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
314 points[0].set(CO_AIX_2_SKSCALAR(x0), CO_AIX_2_SKSCALAR(y0)); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
315 points[1].set(CO_AIX_2_SKSCALAR(x1), CO_AIX_2_SKSCALAR(y1)); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
316 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
317 stop = stops; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
318 for(i = 0; i < stop_cnt; i++) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
319 colors[i] = MBSTOP_2_SKCOLOR(stop); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
320 poses[i] = CO_AIX_2_SKSCALAR(stop->offset); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
321 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
322 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
323 /* |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
324 * cx0, cy0 and radius0 is not used. Since Skia is still not |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
325 * support two circles radial. And, SVG 1.2 is also not support |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
326 * two circles. |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
327 */ |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
328 ptn->shader = |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
329 SkGradientShader::CreateLinear(points, colors, poses, stop_cnt, |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
330 SkShader::kClamp_TileMode); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
331 if(ptn->shader == NULL) |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
332 goto fail; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
333 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
334 memcpy(ptn->matrix, id_matrix, sizeof(co_aix) * 6); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
335 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
336 delete colors; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
337 delete poses; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
338 return ptn; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
339 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
340 fail: |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
341 if(ptn) free(ptn); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
342 if(colors) delete colors; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
343 if(poses) delete poses; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
344 return NULL; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
345 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
346 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
347 void mbe_pattern_set_matrix(mbe_pattern_t *ptn, const co_aix matrix[6]) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
348 SkMatrix skmatrix; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
349 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
350 MB_MATRIX_2_SKMATRIX(skmatrix, matrix); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
351 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
352 ptn->shader->setLocalMatrix(skmatrix); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
353 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
354 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
355 void mbe_pattern_destroy(mbe_pattern_t *ptn) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
356 if(ptn->shader) |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
357 delete ptn->shader; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
358 free(ptn); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
359 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
360 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
361 int mbe_image_surface_get_stride(mbe_surface_t *surface) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
362 return ((SkBitmap *)surface)->rowBytes(); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
363 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
364 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
365 int mbe_image_surface_get_height(mbe_surface_t *surface) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
366 return ((SkBitmap *)surface)->height(); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
367 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
368 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
369 int mbe_image_surface_get_width(mbe_surface_t *surface) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
370 return ((SkBitmap *)surface)->width(); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
371 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
372 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
373 unsigned char *mbe_image_surface_get_data(mbe_surface_t *surface) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
374 return (unsigned char *)((SkBitmap *)surface)->getPixels(); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
375 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
376 |
472
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
377 mbe_surface_t *mbe_image_surface_create_from_png(const char *filename) {} |
482
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
378 |
472
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
379 mbe_surface_t * |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
380 mbe_image_surface_create_for_data(unsigned char *data, |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
381 mb_img_fmt_t fmt, |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
382 int width, int height, |
482
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
383 int stride) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
384 SkBitmap *bitmap; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
385 SkBitmap::Config cfg; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
386 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
387 switch(fmt) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
388 case MB_IFMT_ARGB32: |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
389 cfg = SkBitmap::kARGB_8888_Config; break; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
390 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
391 case MB_IFMT_A8: |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
392 cfg = SkBitmap::kA8_Config; break; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
393 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
394 case MB_IFMT_A1: |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
395 cfg = SkBitmap::kA1_Config; break; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
396 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
397 case MB_IFMT_RGB16_565: |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
398 cfg = SkBitmap::kRGB_565_Config; break; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
399 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
400 case MB_IFMT_RGB24: |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
401 default: |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
402 return NULL; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
403 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
404 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
405 bitmap = new SkBitmap(); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
406 if(bitmap == NULL) |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
407 return NULL; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
408 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
409 bitmap->setConfig(cfg, width, height, stride); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
410 bitmap->setPixels(data); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
411 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
412 return (mbe_surface_t *)bitmap; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
413 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
414 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
415 mb_img_fmt_t mbe_image_surface_get_format(mbe_surface_t *surface) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
416 SkBitmap *bitmap = (SkBitmap *)surface; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
417 mb_img_fmt_t fmt; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
418 SkBitmap::Config cfg; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
419 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
420 cfg = bitmap->getConfig(); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
421 switch(cfg) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
422 case SkBitmap::kARGB_8888_Config: |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
423 fmt = MB_IFMT_ARGB32; break; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
424 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
425 case SkBitmap::kA8_Config: |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
426 fmt = MB_IFMT_A8; break; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
427 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
428 case SkBitmap::kA1_Config: |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
429 fmt = MB_IFMT_A1; break; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
430 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
431 case SkBitmap::kRGB_565_Config: |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
432 fmt = MB_IFMT_RGB16_565; break; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
433 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
434 default: |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
435 fmt = MB_IFMT_DUMMY; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
436 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
437 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
438 return fmt; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
439 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
440 |
472
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
441 mbe_surface_t * |
482
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
442 mbe_image_surface_create(mb_img_fmt_t fmt, int width, int height) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
443 SkBitmap *bitmap; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
444 SkBitmap::Config cfg; |
472
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
445 |
482
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
446 switch(fmt) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
447 case MB_IFMT_ARGB32: |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
448 cfg = SkBitmap::kARGB_8888_Config; break; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
449 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
450 case MB_IFMT_A8: |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
451 cfg = SkBitmap::kA8_Config; break; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
452 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
453 case MB_IFMT_A1: |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
454 cfg = SkBitmap::kA1_Config; break; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
455 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
456 case MB_IFMT_RGB16_565: |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
457 cfg = SkBitmap::kRGB_565_Config; break; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
458 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
459 case MB_IFMT_RGB24: |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
460 default: |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
461 return NULL; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
462 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
463 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
464 bitmap = new SkBitmap(); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
465 if(bitmap == NULL) |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
466 return NULL; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
467 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
468 bitmap->setConfig(cfg, width, height); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
469 bitmap->allocPixels(); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
470 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
471 return (mbe_surface_t *)bitmap; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
472 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
473 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
474 mbe_scaled_font_t *mbe_scaled_font_reference(mbe_scaled_font_t *scaled) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
475 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
476 |
472
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
477 void mbe_scaled_font_destroy(mbe_scaled_font_t *scaled) {} |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
478 mbe_font_face_t *mbe_font_face_reference(mbe_font_face_t *face) {} |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
479 mbe_scaled_font_t * |
473
ba64f928542b
Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents:
472
diff
changeset
|
480 mbe_scaled_font_create(mbe_font_face_t *face, co_aix fnt_mtx[6], |
ba64f928542b
Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents:
472
diff
changeset
|
481 co_aix ctm[6]) {} |
472
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
482 mbe_scaled_font_t *mbe_get_scaled_font(mbe_t *canvas) {} |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
483 void mbe_scaled_font_text_extents(mbe_scaled_font_t *scaled, |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
484 const char *txt, |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
485 mbe_text_extents_t *extents) {} |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
486 |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
487 void mbe_font_face_destroy(mbe_font_face_t *face) {} |
482
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
488 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
489 void mbe_paint_with_alpha(mbe_t *canvas, co_aix alpha) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
490 SkPaint *paint = canvas->paint; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
491 SkColorFilter *filter; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
492 SkColor color; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
493 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
494 color = ((uint32_t)(alpha * 255)) << 24; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
495 filter = |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
496 SkColorFilter::CreatePorterDuffFilter(color, |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
497 SkPorterDuff::kSrcOver_Mode); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
498 mbe_paint(canvas); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
499 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
500 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
501 |
472
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
502 void mbe_surface_destroy(mbe_surface_t *surface) {} |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
503 void mbe_set_source_rgba(mbe_t *canvas, |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
504 co_aix r, co_aix g, co_aix b, co_aix a) {} |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
505 void mbe_set_scaled_font(mbe_t *canvas, |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
506 const mbe_scaled_font_t *scaled) {} |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
507 void mbe_set_source_rgb(mbe_t *canvas, co_aix r, co_aix g, co_aix b) {} |
482
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
508 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
509 void mbe_set_line_width(mbe_t *canvas, co_aix width) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
510 canvas->states->line_width = width; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
511 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
512 |
472
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
513 mbe_font_face_t *mbe_get_font_face(mbe_t *canvas) {} |
482
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
514 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
515 void mbe_fill_preserve(mbe_t *canvas) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
516 mbe_pattern_t *ptn = canvas->states->ptn; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
517 SkPaint *paint = canvas->paint; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
518 SkPath *path = canvas->path; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
519 SkRegion *saved_clip = NULL; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
520 co_aix x, y; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
521 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
522 ASSERT(paint); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
523 ASSERT(ptn); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
524 ASSERT(path); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
525 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
526 if(!canvas->subpath->isEmpty()) |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
527 _update_path(canvas); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
528 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
529 _prepare_paint(canvas, SkPaint::kFill_Style); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
530 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
531 canvas->canvas->drawPath(*path, *paint); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
532 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
533 _finish_paint(canvas); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
534 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
535 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
536 void mbe_set_source(mbe_t *canvas, mbe_pattern_t *source) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
537 canvas->states->ptn = source; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
538 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
539 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
540 void mbe_reset_clip(mbe_t *canvas) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
541 SkRegion clip; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
542 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
543 _canvas_device_region(canvas->canvas, &clip); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
544 canvas->canvas->setClipRegion(clip); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
545 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
546 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
547 mbe_surface_t *mbe_get_target(mbe_t *canvas) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
548 return (mbe_surface_t *)&canvas->canvas->getDevice()->accessBitmap(false); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
549 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
550 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
551 void mbe_close_path(mbe_t *canvas) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
552 canvas->subpath->close(); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
553 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
554 |
472
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
555 void mbe_text_path(mbe_t *canvas, const char *txt) {} |
482
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
556 |
472
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
557 void mbe_rectangle(mbe_t *canvas, co_aix x, co_aix y, |
482
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
558 co_aix width, co_aix height) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
559 SkPath *subpath = canvas->subpath; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
560 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
561 subpath->addRect(CO_AIX_2_SKSCALAR(x), CO_AIX_2_SKSCALAR(y), |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
562 CO_AIX_2_SKSCALAR(x + width), |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
563 CO_AIX_2_SKSCALAR(y + height)); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
564 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
565 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
566 int mbe_in_stroke(mbe_t *canvas, co_aix x, co_aix y) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
567 return 0; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
568 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
569 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
570 void mbe_new_path(mbe_t *canvas) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
571 canvas->subpath->reset(); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
572 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
573 |
472
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
574 void mbe_curve_to(mbe_t *canvas, co_aix x1, co_aix y1, |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
575 co_aix x2, co_aix y2, |
482
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
576 co_aix x3, co_aix y3) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
577 SkPath *subpath = canvas->subpath; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
578 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
579 subpath->cubicTo(CO_AIX_2_SKSCALAR(x1), CO_AIX_2_SKSCALAR(y1), |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
580 CO_AIX_2_SKSCALAR(x2), CO_AIX_2_SKSCALAR(y2), |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
581 CO_AIX_2_SKSCALAR(x3), CO_AIX_2_SKSCALAR(y3)); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
582 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
583 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
584 void mbe_restore(mbe_t *canvas) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
585 struct _mbe_states_t *states; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
586 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
587 _update_path(canvas); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
588 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
589 states = canvas->states; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
590 ASSERT(states->next); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
591 canvas->states = states->next; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
592 free(states); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
593 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
594 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
595 void mbe_move_to(mbe_t *canvas, co_aix x, co_aix y) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
596 canvas->subpath->moveTo(CO_AIX_2_SKSCALAR(x), |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
597 CO_AIX_2_SKSCALAR(y)); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
598 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
599 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
600 void mbe_line_to(mbe_t *canvas, co_aix x, co_aix y) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
601 canvas->subpath->lineTo(CO_AIX_2_SKSCALAR(x), |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
602 CO_AIX_2_SKSCALAR(y)); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
603 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
604 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
605 int mbe_in_fill(mbe_t *canvas, co_aix x, co_aix y) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
606 SkRegion region, dev_region; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
607 bool in_fill; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
608 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
609 if(!canvas->subpath->isEmpty()) |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
610 _update_path(canvas); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
611 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
612 _canvas_device_region(canvas->canvas, &dev_region); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
613 region.setPath(*canvas->path, dev_region); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
614 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
615 in_fill = region.contains(x, y); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
616 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
617 return in_fill; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
618 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
619 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
620 void mbe_stroke(mbe_t *canvas) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
621 SkPath *path = canvas->path; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
622 SkPaint *paint = canvas->paint; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
623 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
624 ASSERT(ptn); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
625 ASSERT(path); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
626 ASSERT(paint); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
627 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
628 if(!canvas->subpath->isEmpty()) |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
629 _update_path(canvas); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
630 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
631 _prepare_paint(canvas, SkPaint::kStroke_Style); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
632 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
633 canvas->canvas->drawPath(*path, *paint); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
634 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
635 _finish_paint(canvas); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
636 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
637 path->reset(); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
638 } |
472
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
639 |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
640 mbe_t *mbe_create(mbe_surface_t *target) { |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
641 mbe_t *mbe; |
482
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
642 struct _mbe_states_t *states; |
479
9a867333018b
mbe_create() and mbe_destroy() pass the compilation.
Thinker K.F. Li <thinker@branda.to>
parents:
473
diff
changeset
|
643 SkBitmap *bitmap = (SkBitmap *)target; |
472
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
644 |
479
9a867333018b
mbe_create() and mbe_destroy() pass the compilation.
Thinker K.F. Li <thinker@branda.to>
parents:
473
diff
changeset
|
645 mbe = (mbe_t *)malloc(sizeof(mbe_t)); |
472
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
646 if(mbe == NULL) |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
647 return NULL; |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
648 |
482
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
649 mbe->states = (struct _mbe_states_t *) |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
650 malloc(sizeof(struct _mbe_states_t)); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
651 states = mbe->states; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
652 if(states == NULL) { |
479
9a867333018b
mbe_create() and mbe_destroy() pass the compilation.
Thinker K.F. Li <thinker@branda.to>
parents:
473
diff
changeset
|
653 free(mbe); |
9a867333018b
mbe_create() and mbe_destroy() pass the compilation.
Thinker K.F. Li <thinker@branda.to>
parents:
473
diff
changeset
|
654 return NULL; |
9a867333018b
mbe_create() and mbe_destroy() pass the compilation.
Thinker K.F. Li <thinker@branda.to>
parents:
473
diff
changeset
|
655 } |
9a867333018b
mbe_create() and mbe_destroy() pass the compilation.
Thinker K.F. Li <thinker@branda.to>
parents:
473
diff
changeset
|
656 |
482
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
657 mbe->canvas = new SkCanvas(*bitmap); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
658 mbe->path = new SkPath(); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
659 mbe->subpath = new SkPath(); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
660 mbe->saved_region = new SkRegion(); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
661 mbe->paint = new SkPaint(); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
662 states->ptn = NULL; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
663 states->ptn_owned = 0; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
664 states->line_width = 0; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
665 states->next = NULL; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
666 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
667 if(mbe->canvas == NULL || mbe->path == NULL || |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
668 mbe->subpath == NULL || mbe->paint == NULL || |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
669 mbe->saved_region == NULL) |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
670 goto fail; |
472
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
671 |
482
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
672 memcpy(states->matrix, id_matrix, sizeof(co_aix) * 6); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
673 |
472
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
674 return mbe; |
482
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
675 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
676 fail: |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
677 if(mbe->canvas) delete mbe->canvas; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
678 if(mbe->path) delete mbe->path; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
679 if(mbe->subpath) delete mbe->subpath; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
680 if(mbe->paint) delete mbe->paint; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
681 if(mbe->saved_region) delete mbe->saved_region; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
682 free(states); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
683 free(mbe); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
684 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
685 return NULL; |
472
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
686 } |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
687 |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
688 void mbe_destroy(mbe_t *canvas) { |
482
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
689 struct _mbe_states_t *states; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
690 |
479
9a867333018b
mbe_create() and mbe_destroy() pass the compilation.
Thinker K.F. Li <thinker@branda.to>
parents:
473
diff
changeset
|
691 delete canvas->canvas; |
482
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
692 delete canvas->path; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
693 delete canvas->subpath; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
694 delete canvas->paint; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
695 delete canvas->saved_region; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
696 while(canvas->states) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
697 states = canvas->states; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
698 canvas->states = states->next; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
699 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
700 if(states->ptn && states->ptn_owned) |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
701 mbe_pattern_destroy(states->ptn); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
702 free(states); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
703 } |
472
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
704 free(canvas); |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
705 } |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
706 |
482
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
707 void mbe_paint(mbe_t *canvas) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
708 SkPaint *paint = canvas->paint; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
709 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
710 ASSERT(paint); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
711 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
712 _prepare_paint(canvas, SkPaint::kFill_Style); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
713 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
714 canvas->canvas->drawPaint(*paint); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
715 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
716 _finish_paint(canvas); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
717 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
718 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
719 void mbe_save(mbe_t *canvas) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
720 struct _mbe_states_t *states; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
721 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
722 states = (struct _mbe_states_t *)malloc(sizeof(struct _mbe_states_t)); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
723 ASSERT(states); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
724 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
725 memcpy(states, canvas->states, sizeof(struct _mbe_states_t)); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
726 states->next = canvas->states; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
727 canvas->states = states; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
728 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
729 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
730 void mbe_fill(mbe_t *canvas) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
731 mbe_fill_preserve(canvas); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
732 canvas->path->reset(); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
733 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
734 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
735 void mbe_clip(mbe_t *canvas) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
736 if(!canvas->subpath->isEmpty()) |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
737 _update_path(canvas); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
738 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
739 canvas->canvas->clipPath(*canvas->path, SkRegion::kIntersect_Op); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
740 canvas->path->reset(); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
741 } |
472
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
742 |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
743 mbe_font_face_t * mbe_query_font_face(const char *family, |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
744 int slant, int weight) {} |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
745 void mbe_free_font_face(mbe_font_face_t *face) {} |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
746 |
482
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
747 void mbe_clear(mbe_t *canvas) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
748 SkColor color = 0; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
749 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
750 canvas->canvas->drawColor(color, SkPorterDuff::kClear_Mode); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
751 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
752 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
753 void mbe_copy_source(mbe_t *canvas) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
754 SkPaint *paint = canvas->paint; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
755 SkXfermode *mode; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
756 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
757 _prepare_paint(canvas, SkPaint::kFill_Style); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
758 mode = SkPorterDuff::CreateXfermode(SkPorterDuff::kSrc_Mode); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
759 paint->setXfermode(mode); |
497
6abc53f00792
It may not need to call unref() for xfermode object.
Thinker K.F. Li <thinker@branda.to>
parents:
495
diff
changeset
|
760 /* mode->unref(); */ |
482
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
761 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
762 canvas->canvas->drawPaint(*paint); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
763 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
764 _finish_paint(canvas); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
765 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
766 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
767 void mbe_transform(mbe_t *mbe, co_aix matrix[6]) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
768 _update_path(mbe); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
769 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
770 matrix_mul(matrix, mbe->states->matrix, mbe->states->matrix); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
771 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
772 |
472
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
773 void mbe_arc(mbe_t *mbe, co_aix x, co_aix y, co_aix radius, |
482
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
774 co_aix angle_start, co_aix angle_stop) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
775 SkPoint point; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
776 SkPath *subpath = mbe->subpath; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
777 SkRect rect; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
778 SkScalar x0, y0; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
779 SkScalar ang_start, ang_stop; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
780 SkScalar sweep; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
781 SkScalar r; /* radius */ |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
782 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
783 subpath->getLastPt(&point); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
784 x0 = point.fX; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
785 y0 = point.fX; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
786 r = CO_AIX_2_SKSCALAR(radius); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
787 ang_start = CO_AIX_2_SKSCALAR(angle_start * 180 / PI); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
788 ang_stop = CO_AIX_2_SKSCALAR(angle_stop * 180 / PI); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
789 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
790 /* Skia can only draw an arc in clockwise directly. We negative |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
791 * start and stop point to draw the arc in the mirror along x-axis |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
792 * in a sub-path. Then, the sub-path are reflected along x-axis, |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
793 * again. We get a right path, and add it to the path of mbe_t. |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
794 */ |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
795 if(ang_start > ang_stop) { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
796 SkPath tmppath; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
797 SkMatrix matrix; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
798 co_aix reflect[6] = { 1, 0, 0, |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
799 0, -1, 0}; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
800 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
801 rect.set(-r, -r, r, r); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
802 sweep = ang_start - ang_stop; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
803 tmppath.arcTo(rect, -ang_start, sweep, false); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
804 |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
805 reflect[2] = x; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
806 reflect[5] = y; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
807 MB_MATRIX_2_SKMATRIX(matrix, reflect); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
808 subpath->addPath(tmppath, matrix); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
809 } else { |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
810 rect.set(x0 - r, y0 - r, x0 + r, y0 + r); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
811 sweep = ang_stop - ang_start; |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
812 subpath->arcTo(rect, ang_start, sweep, false); |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
813 } |
d38aca825822
Import more functions for Skia graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
479
diff
changeset
|
814 } |
472
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
815 |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
816 |
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
817 C_END |