OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "../../../include/fxge/fx_ge.h" | 5 #include "../../../include/fxge/fx_ge.h" |
6 //#define _SKIA_SUPPORT_ | 6 //#define _SKIA_SUPPORT_ |
7 #if defined(_SKIA_SUPPORT_) | 7 #if defined(_SKIA_SUPPORT_) |
8 #include "../../../include/fxcodec/fx_codec.h" | 8 #include "../../../include/fxcodec/fx_codec.h" |
9 | 9 |
10 | |
11 //#define _FOXIT_DEBUG_ | 10 //#define _FOXIT_DEBUG_ |
12 //#define _FOXIT_BENCHMARK_ | 11 //#define _FOXIT_BENCHMARK_ |
13 | 12 |
14 extern "C" { | 13 extern "C" { |
15 » extern void FX_OUTPUT_LOG_FUNC(const char*, ...); | 14 extern void FX_OUTPUT_LOG_FUNC(const char*, ...); |
16 » extern int FX_GET_TICK_FUNC(); | 15 extern int FX_GET_TICK_FUNC(); |
17 }; | 16 }; |
18 | 17 |
19 #ifdef _FOXIT_DEBUG_ | 18 #ifdef _FOXIT_DEBUG_ |
20 #define FOXIT_DEBUG1(msg) FX_OUTPUT_LOG_FUNC(msg) | 19 #define FOXIT_DEBUG1(msg) FX_OUTPUT_LOG_FUNC(msg) |
21 #define FOXIT_DEBUG2(msg,para) FX_OUTPUT_LOG_FUNC(msg,para) | 20 #define FOXIT_DEBUG2(msg, para) FX_OUTPUT_LOG_FUNC(msg, para) |
22 #define FOXIT_DEBUG3(msg,para1,para2) FX_OUTPUT_LOG_FUNC(msg,para1,para2) | 21 #define FOXIT_DEBUG3(msg, para1, para2) FX_OUTPUT_LOG_FUNC(msg, para1, para2) |
23 #define FOXIT_DEBUG4(msg,para1,para2,para3) FX_OUTPUT_LOG_FUNC(msg,para1,para2,p
ara3) | 22 #define FOXIT_DEBUG4(msg, para1, para2, para3) \ |
24 #define FOXIT_DEBUG5(msg,para1,para2,para3,param4) FX_OUTPUT_LOG_FUNC(msg,para1,
para2,para3,param4) | 23 FX_OUTPUT_LOG_FUNC(msg, para1, para2, para3) |
| 24 #define FOXIT_DEBUG5(msg, para1, para2, para3, param4) \ |
| 25 FX_OUTPUT_LOG_FUNC(msg, para1, para2, para3, param4) |
25 #else | 26 #else |
26 #define FOXIT_DEBUG1(msg) | 27 #define FOXIT_DEBUG1(msg) |
27 #define FOXIT_DEBUG2(msg,para) | 28 #define FOXIT_DEBUG2(msg, para) |
28 #define FOXIT_DEBUG3(msg,para1,para2) | 29 #define FOXIT_DEBUG3(msg, para1, para2) |
29 #define FOXIT_DEBUG4(msg,para1,para2,para3) | 30 #define FOXIT_DEBUG4(msg, para1, para2, para3) |
30 #define FOXIT_DEBUG5(msg,para1,para2,para3,param4) | 31 #define FOXIT_DEBUG5(msg, para1, para2, para3, param4) |
31 #endif | 32 #endif |
32 | 33 |
33 #include "SkDashPathEffect.h" | 34 #include "SkDashPathEffect.h" |
34 #include "SkTLazy.h" | 35 #include "SkTLazy.h" |
35 #include "SkScan.h" | 36 #include "SkScan.h" |
36 #include "SkRasterClip.h" | 37 #include "SkRasterClip.h" |
37 #include "SkStroke.h" | 38 #include "SkStroke.h" |
38 | 39 |
39 | |
40 #include "fx_skia_blitter_new.h" | 40 #include "fx_skia_blitter_new.h" |
41 #include "../agg/fx_agg_driver.h" | 41 #include "../agg/fx_agg_driver.h" |
42 #include "fx_skia_device.h" | 42 #include "fx_skia_device.h" |
43 /// Run-length-encoded supersampling antialiased blitter. | 43 /// Run-length-encoded supersampling antialiased blitter. |
44 class SuperBlitter_skia | 44 class SuperBlitter_skia { |
45 { | 45 public: |
46 public: | 46 static void DrawPath(const SkPath& srcPath, |
47 » static void DrawPath(const SkPath& srcPath, SkBlitter* blitter, const S
kRasterClip& rect, const SkPaint& origPaint); | 47 SkBlitter* blitter, |
| 48 const SkRasterClip& rect, |
| 49 const SkPaint& origPaint); |
48 }; | 50 }; |
49 FX_BOOL FxSkDrawTreatAsHairline(const SkPaint& paint, SkScalar* coverage) { | 51 FX_BOOL FxSkDrawTreatAsHairline(const SkPaint& paint, SkScalar* coverage) { |
50 » if (SkPaint::kStroke_Style != paint.getStyle()) | 52 if (SkPaint::kStroke_Style != paint.getStyle()) |
51 » » return FALSE; | 53 return FALSE; |
52 » FXSYS_assert(coverage); | 54 FXSYS_assert(coverage); |
53 » SkScalar strokeWidth = paint.getStrokeWidth(); | 55 SkScalar strokeWidth = paint.getStrokeWidth(); |
54 » if (0 == strokeWidth) { | 56 if (0 == strokeWidth) { |
55 » » *coverage = SK_Scalar1; | 57 *coverage = SK_Scalar1; |
56 » » return TRUE; | 58 return TRUE; |
57 » } | 59 } |
58 » // if we get here, we need to try to fake a thick-stroke with a modulate
d | 60 // if we get here, we need to try to fake a thick-stroke with a modulated |
59 » // hairline | 61 // hairline |
60 » if (!paint.isAntiAlias()) | 62 if (!paint.isAntiAlias()) |
61 » » return FALSE; | 63 return FALSE; |
62 » if (strokeWidth <= SK_Scalar1) { | 64 if (strokeWidth <= SK_Scalar1) { |
63 » » *coverage = strokeWidth; | 65 *coverage = strokeWidth; |
64 » » return TRUE; | 66 return TRUE; |
65 » } | 67 } |
66 » return FALSE; | 68 return FALSE; |
67 } | 69 } |
68 | 70 |
69 void SuperBlitter_skia::DrawPath(const SkPath& srcPath, SkBlitter* blitter, cons
t SkRasterClip& rect, const SkPaint& origPaint) | 71 void SuperBlitter_skia::DrawPath(const SkPath& srcPath, |
70 { | 72 SkBlitter* blitter, |
71 » SkPath*»» pathPtr = (SkPath*)&srcPath; | 73 const SkRasterClip& rect, |
72 » bool» » doFill = true; | 74 const SkPaint& origPaint) { |
73 » SkPath» » tmpPath; | 75 SkPath* pathPtr = (SkPath*)&srcPath; |
74 » SkTCopyOnFirstWrite<SkPaint> paint(origPaint); | 76 bool doFill = true; |
75 » { | 77 SkPath tmpPath; |
76 » » SkScalar coverage; | 78 SkTCopyOnFirstWrite<SkPaint> paint(origPaint); |
77 » » if (FxSkDrawTreatAsHairline(origPaint, &coverage)) { | 79 { |
78 » » » if (SK_Scalar1 == coverage) { | 80 SkScalar coverage; |
79 » » » » paint.writable()->setStrokeWidth(0); | 81 if (FxSkDrawTreatAsHairline(origPaint, &coverage)) { |
80 » » » } else if (1) {//xfermodeSupportsCoverageAsAlpha(xfer),
we not use blend mode here, xfer aways NULL. | 82 if (SK_Scalar1 == coverage) { |
81 » » » » U8CPU newAlpha; | 83 paint.writable()->setStrokeWidth(0); |
82 » » » » // this is the old technique, which we preserve
for now so | 84 } else if (1) { // xfermodeSupportsCoverageAsAlpha(xfer), we not use |
83 » » » » // we don't change previous results (testing) | 85 // blend mode here, xfer aways NULL. |
84 » » » » // the new way seems fine, its just (a tiny bit)
different | 86 U8CPU newAlpha; |
85 » » » » int scale = (int)SkScalarMul(coverage, 256); | 87 // this is the old technique, which we preserve for now so |
86 » » » » newAlpha = origPaint.getAlpha() * scale >> 8; | 88 // we don't change previous results (testing) |
87 » » » » SkPaint* writablePaint = paint.writable(); | 89 // the new way seems fine, its just (a tiny bit) different |
88 » » » » writablePaint->setStrokeWidth(0); | 90 int scale = (int)SkScalarMul(coverage, 256); |
89 » » » » writablePaint->setAlpha(newAlpha); | 91 newAlpha = origPaint.getAlpha() * scale >> 8; |
90 » » » } | 92 SkPaint* writablePaint = paint.writable(); |
91 » » } | 93 writablePaint->setStrokeWidth(0); |
92 » } | 94 writablePaint->setAlpha(newAlpha); |
93 » if (paint->getPathEffect() || paint->getStyle() != SkPaint::kFill_Style)
{ | 95 } |
94 » » SkIRect devBounds = rect.getBounds(); | 96 } |
95 » » // outset to have slop for antialasing and hairlines | 97 } |
96 » » devBounds.outset(1, 1); | 98 if (paint->getPathEffect() || paint->getStyle() != SkPaint::kFill_Style) { |
97 » » SkRect cullRect = SkRect::Make(devBounds); | 99 SkIRect devBounds = rect.getBounds(); |
98 » » doFill = paint->getFillPath(*pathPtr, &tmpPath, &cullRect); | 100 // outset to have slop for antialasing and hairlines |
99 » » pathPtr = &tmpPath; | 101 devBounds.outset(1, 1); |
100 » } | 102 SkRect cullRect = SkRect::Make(devBounds); |
101 » // avoid possibly allocating a new path in transform if we can | 103 doFill = paint->getFillPath(*pathPtr, &tmpPath, &cullRect); |
102 » SkPath* devPathPtr = pathPtr; | 104 pathPtr = &tmpPath; |
103 » void (*proc)(const SkPath&, const SkRasterClip&, SkBlitter*); | 105 } |
104 » if (doFill) { | 106 // avoid possibly allocating a new path in transform if we can |
105 » » if (paint->isAntiAlias()) { | 107 SkPath* devPathPtr = pathPtr; |
106 » » » proc = SkScan::AntiFillPath; | 108 void (*proc)(const SkPath&, const SkRasterClip&, SkBlitter*); |
107 » » } else { | 109 if (doFill) { |
108 » » » proc = SkScan::FillPath; | 110 if (paint->isAntiAlias()) { |
109 » » } | 111 proc = SkScan::AntiFillPath; |
110 » } else {» // hairline | 112 } else { |
111 » » if (paint->isAntiAlias()) { | 113 proc = SkScan::FillPath; |
112 » » » proc = SkScan::AntiHairPath; | 114 } |
113 » » } else { | 115 } else { // hairline |
114 » » » proc = SkScan::HairPath; | 116 if (paint->isAntiAlias()) { |
115 » » } | 117 proc = SkScan::AntiHairPath; |
116 » } | 118 } else { |
117 » proc(*devPathPtr, rect, blitter); | 119 proc = SkScan::HairPath; |
118 } | 120 } |
119 | 121 } |
120 class CSkia_PathData | 122 proc(*devPathPtr, rect, blitter); |
121 { | 123 } |
122 public: | 124 |
123 » CSkia_PathData() {} | 125 class CSkia_PathData { |
124 » ~CSkia_PathData() {} | 126 public: |
125 » SkPath» » » m_PathData; | 127 CSkia_PathData() {} |
126 | 128 ~CSkia_PathData() {} |
127 » void» » » BuildPath(const CFX_PathData* pPathData, const C
FX_AffineMatrix* pObject2Device); | 129 SkPath m_PathData; |
| 130 |
| 131 void BuildPath(const CFX_PathData* pPathData, |
| 132 const CFX_AffineMatrix* pObject2Device); |
128 }; | 133 }; |
129 | 134 |
130 void CSkia_PathData::BuildPath(const CFX_PathData* pPathData, const CFX_AffineMa
trix* pObject2Device) | 135 void CSkia_PathData::BuildPath(const CFX_PathData* pPathData, |
131 { | 136 const CFX_AffineMatrix* pObject2Device) { |
132 » const CFX_PathData* pFPath = pPathData; | 137 const CFX_PathData* pFPath = pPathData; |
133 » int nPoints = pFPath->GetPointCount(); | 138 int nPoints = pFPath->GetPointCount(); |
134 » FX_PATHPOINT* pPoints = pFPath->GetPoints(); | 139 FX_PATHPOINT* pPoints = pFPath->GetPoints(); |
135 » for (int i = 0; i < nPoints; i ++) { | 140 for (int i = 0; i < nPoints; i++) { |
136 » » FX_FIXFLOAT x = pPoints[i].m_PointX, y = pPoints[i].m_PointY; | 141 FX_FIXFLOAT x = pPoints[i].m_PointX, y = pPoints[i].m_PointY; |
137 » » if (pObject2Device) pObject2Device->Transform(x, y); | 142 if (pObject2Device) |
138 » » int point_type = pPoints[i].m_Flag & FXPT_TYPE; | 143 pObject2Device->Transform(x, y); |
139 » » if (point_type == FXPT_MOVETO) { | 144 int point_type = pPoints[i].m_Flag & FXPT_TYPE; |
140 » » » m_PathData.moveTo(x, y); | 145 if (point_type == FXPT_MOVETO) { |
141 » » } else if (point_type == FXPT_LINETO) { | 146 m_PathData.moveTo(x, y); |
142 » » » if (pPoints[i-1].m_Flag == FXPT_MOVETO && (i == nPoints-
1 || pPoints[i+1].m_Flag == FXPT_MOVETO) && | 147 } else if (point_type == FXPT_LINETO) { |
143 » » » » » FXSYS_abs(pPoints[i].m_PointX - pPoints[
i-1].m_PointX) < 0.4f && FXSYS_abs(pPoints[i].m_PointY - pPoints[i-1].m_PointY)<
0.4f) | 148 if (pPoints[i - 1].m_Flag == FXPT_MOVETO && |
144 » » » » // PDF line includes the destination point, unli
ke Windows line. | 149 (i == nPoints - 1 || pPoints[i + 1].m_Flag == FXPT_MOVETO) && |
145 » » » » // We received some PDF which actually draws zer
o length lines. TESTDOC: summer cha show.pdf | 150 FXSYS_abs(pPoints[i].m_PointX - pPoints[i - 1].m_PointX) < 0.4f && |
146 » » » » // Therefore, we have to extend the line by 0.4
pixel here. | 151 FXSYS_abs(pPoints[i].m_PointY - pPoints[i - 1].m_PointY) < 0.4f) |
147 » » » » // But only for standalone segment. TESTDOC: bug
#1434 - maze.pdf; TESTDOC: bug#1508 di704P_QIG_111.pdf | 152 // PDF line includes the destination point, unlike Windows line. |
148 » » » » x += 0.4; | 153 // We received some PDF which actually draws zero length lines. TESTDOC: |
149 » » » // TODO: we should actually tell skia vertex generator t
o process zero length stroked line | 154 // summer cha show.pdf |
150 » » » // (only butts are drawn) | 155 // Therefore, we have to extend the line by 0.4 pixel here. |
151 » » » m_PathData.lineTo(x, y); | 156 // But only for standalone segment. TESTDOC: bug #1434 - maze.pdf; |
152 » » } else if (point_type == FXPT_BEZIERTO) { | 157 // TESTDOC: bug#1508 di704P_QIG_111.pdf |
153 » » » FX_FIXFLOAT x2 = pPoints[i+1].m_PointX, y2 = pPoints[i+1
].m_PointY; | 158 x += 0.4; |
154 » » » FX_FIXFLOAT x3 = pPoints[i+2].m_PointX, y3 = pPoints[i+2
].m_PointY; | 159 // TODO: we should actually tell skia vertex generator to process zero |
155 » » » if (pObject2Device){ | 160 // length stroked line |
156 » » » » pObject2Device->Transform(x2, y2); | 161 // (only butts are drawn) |
157 » » » » pObject2Device->Transform(x3, y3); | 162 m_PathData.lineTo(x, y); |
158 » » » } | 163 } else if (point_type == FXPT_BEZIERTO) { |
159 » » » m_PathData.cubicTo(x, y, x2, y2, x3, y3); | 164 FX_FIXFLOAT x2 = pPoints[i + 1].m_PointX, y2 = pPoints[i + 1].m_PointY; |
160 » » » i += 2; | 165 FX_FIXFLOAT x3 = pPoints[i + 2].m_PointX, y3 = pPoints[i + 2].m_PointY; |
161 » » } | 166 if (pObject2Device) { |
162 » » if (pPoints[i].m_Flag & FXPT_CLOSEFIGURE) m_PathData.close(); | 167 pObject2Device->Transform(x2, y2); |
163 » } | 168 pObject2Device->Transform(x3, y3); |
| 169 } |
| 170 m_PathData.cubicTo(x, y, x2, y2, x3, y3); |
| 171 i += 2; |
| 172 } |
| 173 if (pPoints[i].m_Flag & FXPT_CLOSEFIGURE) |
| 174 m_PathData.close(); |
| 175 } |
164 } | 176 } |
165 | 177 |
166 // convert a stroking path to scanlines | 178 // convert a stroking path to scanlines |
167 static void SkRasterizeStroke(SkPaint& spaint, SkPath* dstPathData, SkPath& path
_data, | 179 static void SkRasterizeStroke(SkPaint& spaint, |
168 const CFX_AffineMatrix* pObject2Device, | 180 SkPath* dstPathData, |
169 const CFX_GraphStateData* pGraphState,
FX_FIXFLOAT scale = FIX8_ONE, | 181 SkPath& path_data, |
170 FX_BOOL bStrokeAdjust = FALSE, FX_BOOL
bTextMode = FALSE) | 182 const CFX_AffineMatrix* pObject2Device, |
171 { | 183 const CFX_GraphStateData* pGraphState, |
172 SkPaint::Cap cap; | 184 FX_FIXFLOAT scale = FIX8_ONE, |
173 switch (pGraphState->m_LineCap) { | 185 FX_BOOL bStrokeAdjust = FALSE, |
174 case CFX_GraphStateData::LineCapRound: | 186 FX_BOOL bTextMode = FALSE) { |
175 cap = SkPaint::kRound_Cap; | 187 SkPaint::Cap cap; |
176 break; | 188 switch (pGraphState->m_LineCap) { |
177 case CFX_GraphStateData::LineCapSquare: | 189 case CFX_GraphStateData::LineCapRound: |
178 cap = SkPaint::kSquare_Cap; | 190 cap = SkPaint::kRound_Cap; |
179 break; | 191 break; |
180 default: | 192 case CFX_GraphStateData::LineCapSquare: |
181 cap = SkPaint::kButt_Cap; | 193 cap = SkPaint::kSquare_Cap; |
182 break; | 194 break; |
183 } | 195 default: |
184 SkPaint::Join join; | 196 cap = SkPaint::kButt_Cap; |
185 switch (pGraphState->m_LineJoin) { | 197 break; |
186 case CFX_GraphStateData::LineJoinRound: | 198 } |
187 join = SkPaint::kRound_Join; | 199 SkPaint::Join join; |
188 break; | 200 switch (pGraphState->m_LineJoin) { |
189 case CFX_GraphStateData::LineJoinBevel: | 201 case CFX_GraphStateData::LineJoinRound: |
190 join = SkPaint::kBevel_Join; | 202 join = SkPaint::kRound_Join; |
191 break; | 203 break; |
192 default: | 204 case CFX_GraphStateData::LineJoinBevel: |
193 join = SkPaint::kMiter_Join; | 205 join = SkPaint::kBevel_Join; |
194 break; | 206 break; |
195 } | 207 default: |
196 FX_FIXFLOAT width = pGraphState->m_LineWidth*scale; | 208 join = SkPaint::kMiter_Join; |
197 FX_FIXFLOAT unit = fix32_to_8(fixdiv_8_8_to_32(FIX8_ONE, (pObject2Device
->GetXUnit() + pObject2Device->GetYUnit()) / 2)); | 209 break; |
198 if (width <= unit) width = unit; | 210 } |
199 | 211 FX_FIXFLOAT width = pGraphState->m_LineWidth * scale; |
200 if (pGraphState->m_DashArray == NULL) { | 212 FX_FIXFLOAT unit = fix32_to_8(fixdiv_8_8_to_32( |
201 SkStroke stroker; | 213 FIX8_ONE, (pObject2Device->GetXUnit() + pObject2Device->GetYUnit()) / 2)); |
202 stroker.setCap(cap); | 214 if (width <= unit) |
203 stroker.setJoin(join); | 215 width = unit; |
204 stroker.setMiterLimit(pGraphState->m_MiterLimit); | 216 |
205 stroker.setWidth(width); | 217 if (pGraphState->m_DashArray == NULL) { |
206 stroker.setDoFill(FALSE); | 218 SkStroke stroker; |
207 stroker.strokePath(path_data, dstPathData); | 219 stroker.setCap(cap); |
208 SkMatrix smatrix; | 220 stroker.setJoin(join); |
209 smatrix.setAll(pObject2Device->a, pObject2Device->c, pObject2Dev
ice->e, pObject2Device->b, pObject2Device->d, pObject2Device->f, 0, 0, 1); | 221 stroker.setMiterLimit(pGraphState->m_MiterLimit); |
210 dstPathData->transform(smatrix); | 222 stroker.setWidth(width); |
211 } else { | 223 stroker.setDoFill(FALSE); |
212 int count = (pGraphState->m_DashCount+1)/2; | 224 stroker.strokePath(path_data, dstPathData); |
213 SkScalar* intervals = FX_Alloc2D(SkScalar, count, sizeof(SkScala
r)); | 225 SkMatrix smatrix; |
214 // Set dash pattern | 226 smatrix.setAll(pObject2Device->a, pObject2Device->c, pObject2Device->e, |
215 for (int i = 0; i < count; i ++) { | 227 pObject2Device->b, pObject2Device->d, pObject2Device->f, 0, |
216 FX_FIXFLOAT on = pGraphState->m_DashArray[i*2]; | 228 0, 1); |
217 if (on <= 0.000001f) on = FIX8_ONE/10; | 229 dstPathData->transform(smatrix); |
218 FX_FIXFLOAT off = i*2+1 == pGraphState->m_DashCount ? on
: | 230 } else { |
219 pGraphState->m_DashArray[i*2+1]; | 231 int count = (pGraphState->m_DashCount + 1) / 2; |
220 if (off < 0) off = 0; | 232 SkScalar* intervals = FX_Alloc2D(SkScalar, count, sizeof(SkScalar)); |
221 intervals[i*2]=on*scale; | 233 // Set dash pattern |
222 intervals[i*2+1]=off*scale; | 234 for (int i = 0; i < count; i++) { |
223 } | 235 FX_FIXFLOAT on = pGraphState->m_DashArray[i * 2]; |
224 SkDashPathEffect* pEffect = new SkDashPathEffect(intervals,count
*2, pGraphState->m_DashPhase*scale); | 236 if (on <= 0.000001f) |
225 spaint.setPathEffect(pEffect)->unref(); | 237 on = FIX8_ONE / 10; |
226 spaint.setStrokeWidth(width); | 238 FX_FIXFLOAT off = i * 2 + 1 == pGraphState->m_DashCount |
227 spaint.setStrokeMiter(pGraphState->m_MiterLimit); | 239 ? on |
228 spaint.setStrokeCap(cap); | 240 : pGraphState->m_DashArray[i * 2 + 1]; |
229 spaint.setStrokeJoin(join); | 241 if (off < 0) |
230 spaint.getFillPath(path_data, dstPathData); | 242 off = 0; |
231 SkMatrix smatrix; | 243 intervals[i * 2] = on * scale; |
232 smatrix.setAll(pObject2Device->a, pObject2Device->c, pObject2Dev
ice->e, pObject2Device->b, pObject2Device->d, pObject2Device->f, 0, 0, 1); | 244 intervals[i * 2 + 1] = off * scale; |
233 dstPathData->transform(smatrix); | 245 } |
234 FX_Free(intervals); | 246 SkDashPathEffect* pEffect = new SkDashPathEffect( |
235 } | 247 intervals, count * 2, pGraphState->m_DashPhase * scale); |
236 } | 248 spaint.setPathEffect(pEffect)->unref(); |
237 | 249 spaint.setStrokeWidth(width); |
238 CFX_SkiaDeviceDriver::CFX_SkiaDeviceDriver(CFX_DIBitmap* pBitmap, int dither_bit
s, FX_BOOL bRgbByteOrder, CFX_DIBitmap* pOriDevice, FX_BOOL bGroupKnockout) | 250 spaint.setStrokeMiter(pGraphState->m_MiterLimit); |
239 { | 251 spaint.setStrokeCap(cap); |
240 m_pAggDriver = new CFX_AggDeviceDriver(pBitmap, dither_bits, bRgbByteOrd
er, pOriDevice, bGroupKnockout); | 252 spaint.setStrokeJoin(join); |
241 } | 253 spaint.getFillPath(path_data, dstPathData); |
242 CFX_SkiaDeviceDriver::~CFX_SkiaDeviceDriver() | 254 SkMatrix smatrix; |
243 { | 255 smatrix.setAll(pObject2Device->a, pObject2Device->c, pObject2Device->e, |
244 delete m_pAggDriver; | 256 pObject2Device->b, pObject2Device->d, pObject2Device->f, 0, |
245 } | 257 0, 1); |
246 FX_BOOL CFX_SkiaDeviceDriver::DrawDeviceText(int nChars, const FXTEXT_CHARPOS* p
CharPos, CFX_Font* pFont, | 258 dstPathData->transform(smatrix); |
247 CFX_FontCache* pCache, const CFX_AffineMatrix* pObject2Device, F
X_FIXFLOAT font_size, FX_DWORD color, | 259 FX_Free(intervals); |
248 int alpha_flag, void* pIccTransform) | 260 } |
249 { | 261 } |
250 return m_pAggDriver->DrawDeviceText(nChars, pCharPos, pFont,pCache, pObj
ect2Device, font_size, color, | 262 |
251 alpha_flag, pIccTransform); | 263 CFX_SkiaDeviceDriver::CFX_SkiaDeviceDriver(CFX_DIBitmap* pBitmap, |
252 } | 264 int dither_bits, |
253 int CFX_SkiaDeviceDriver::GetDeviceCaps(int caps_id) | 265 FX_BOOL bRgbByteOrder, |
254 { | 266 CFX_DIBitmap* pOriDevice, |
255 return m_pAggDriver->GetDeviceCaps(caps_id); | 267 FX_BOOL bGroupKnockout) { |
256 } | 268 m_pAggDriver = new CFX_AggDeviceDriver(pBitmap, dither_bits, bRgbByteOrder, |
257 void CFX_SkiaDeviceDriver::SaveState() | 269 pOriDevice, bGroupKnockout); |
258 { | 270 } |
259 m_pAggDriver->SaveState(); | 271 CFX_SkiaDeviceDriver::~CFX_SkiaDeviceDriver() { |
260 } | 272 delete m_pAggDriver; |
261 | 273 } |
262 void CFX_SkiaDeviceDriver::RestoreState(FX_BOOL bKeepSaved) | 274 FX_BOOL CFX_SkiaDeviceDriver::DrawDeviceText( |
263 { | 275 int nChars, |
264 m_pAggDriver->RestoreState(bKeepSaved); | 276 const FXTEXT_CHARPOS* pCharPos, |
265 } | 277 CFX_Font* pFont, |
266 void CFX_SkiaDeviceDriver::SetClipMask(rasterizer_scanline_aa& rasterizer) | 278 CFX_FontCache* pCache, |
267 { | 279 const CFX_AffineMatrix* pObject2Device, |
268 m_pAggDriver->SetClipMask(rasterizer); | 280 FX_FIXFLOAT font_size, |
269 } | 281 FX_DWORD color, |
270 void CFX_SkiaDeviceDriver::SetClipMask(SkPath& skPath, SkPaint* spaint) | 282 int alpha_flag, |
271 { | 283 void* pIccTransform) { |
272 SkIRect clip_box; | 284 return m_pAggDriver->DrawDeviceText(nChars, pCharPos, pFont, pCache, |
273 clip_box.set(0, 0, fix0_to_8(GetDeviceCaps(FXDC_PIXEL_WIDTH)), fix0_to_8
(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); | 285 pObject2Device, font_size, color, |
274 clip_box.intersect(m_pAggDriver->m_pClipRgn->GetBox().left, m_pAggDriver
->m_pClipRgn->GetBox().top, | 286 alpha_flag, pIccTransform); |
275 m_pAggDriver->m_pClipRgn->GetBox().right, m_pAggDriver->m_pClipR
gn->GetBox().bottom); | 287 } |
276 | 288 int CFX_SkiaDeviceDriver::GetDeviceCaps(int caps_id) { |
277 SkPath* pathPtr = &skPath; | 289 return m_pAggDriver->GetDeviceCaps(caps_id); |
278 | 290 } |
279 SkRect path_rect = skPath.getBounds(); | 291 void CFX_SkiaDeviceDriver::SaveState() { |
280 | 292 m_pAggDriver->SaveState(); |
281 clip_box.intersect(FXSYS_floor(path_rect.fLeft), FXSYS_floor(path_rect.f
Top), FXSYS_floor(path_rect.fRight)+1, FXSYS_floor(path_rect.fBottom)+1); | 293 } |
282 CFX_DIBitmapRef mask; | 294 |
283 CFX_DIBitmap* pThisLayer = mask.New(); | 295 void CFX_SkiaDeviceDriver::RestoreState(FX_BOOL bKeepSaved) { |
284 pThisLayer->Create(clip_box.width(), clip_box.height(), FXDIB_8bppMask); | 296 m_pAggDriver->RestoreState(bKeepSaved); |
285 pThisLayer->Clear(0); | 297 } |
286 | 298 void CFX_SkiaDeviceDriver::SetClipMask(rasterizer_scanline_aa& rasterizer) { |
287 CFX_SkiaA8Renderer render; | 299 m_pAggDriver->SetClipMask(rasterizer); |
288 render.Init(pThisLayer, clip_box.fLeft, clip_box.fTop); | 300 } |
289 | 301 void CFX_SkiaDeviceDriver::SetClipMask(SkPath& skPath, SkPaint* spaint) { |
290 SkRasterClip rasterClip(clip_box); | 302 SkIRect clip_box; |
291 SuperBlitter_skia::DrawPath(skPath, (SkBlitter*)&render, rasterClip, *sp
aint); | 303 clip_box.set(0, 0, fix0_to_8(GetDeviceCaps(FXDC_PIXEL_WIDTH)), |
292 | 304 fix0_to_8(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); |
293 // Finally, we have got the mask that we need, intersect with current cl
ip region | 305 clip_box.intersect(m_pAggDriver->m_pClipRgn->GetBox().left, |
294 m_pAggDriver->m_pClipRgn->IntersectMaskF(clip_box.fLeft, clip_box.fTop,
mask); | 306 m_pAggDriver->m_pClipRgn->GetBox().top, |
295 | 307 m_pAggDriver->m_pClipRgn->GetBox().right, |
296 } | 308 m_pAggDriver->m_pClipRgn->GetBox().bottom); |
297 FX_BOOL CFX_SkiaDeviceDriver::SetClip_PathFill(const CFX_PathData* pPathData,
// path info | 309 |
298 const CFX_AffineMatrix* pObject2
Device, // optional transformation | 310 SkPath* pathPtr = &skPath; |
299 int fill_mode // fill mode, WI
NDING or ALTERNATE | 311 |
300 ) | 312 SkRect path_rect = skPath.getBounds(); |
301 { | 313 |
302 if (m_pAggDriver->m_pClipRgn == NULL) | 314 clip_box.intersect(FXSYS_floor(path_rect.fLeft), FXSYS_floor(path_rect.fTop), |
303 m_pAggDriver->m_pClipRgn = new CFX_ClipRgn(GetDeviceCaps(FXDC_PI
XEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT)); | 315 FXSYS_floor(path_rect.fRight) + 1, |
304 | 316 FXSYS_floor(path_rect.fBottom) + 1); |
305 if (pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4)
{ | 317 CFX_DIBitmapRef mask; |
306 CFX_FloatRect rectf; | 318 CFX_DIBitmap* pThisLayer = mask.New(); |
307 if (pPathData->IsRect(pObject2Device, &rectf)) { | 319 pThisLayer->Create(clip_box.width(), clip_box.height(), FXDIB_8bppMask); |
308 rectf.Intersect(CFX_FloatRect(0, 0, (FX_FIXFLOAT)GetDevi
ceCaps(FXDC_PIXEL_WIDTH), (FX_FIXFLOAT)GetDeviceCaps(FXDC_PIXEL_HEIGHT))); | 320 pThisLayer->Clear(0); |
309 FX_RECT rect = rectf.GetOutterRect(); | 321 |
310 m_pAggDriver->m_pClipRgn->IntersectRect(rect); | 322 CFX_SkiaA8Renderer render; |
311 return TRUE; | 323 render.Init(pThisLayer, clip_box.fLeft, clip_box.fTop); |
312 } | 324 |
313 } | 325 SkRasterClip rasterClip(clip_box); |
314 CSkia_PathData path_data; | 326 SuperBlitter_skia::DrawPath(skPath, (SkBlitter*)&render, rasterClip, *spaint); |
315 path_data.BuildPath(pPathData, pObject2Device); | 327 |
316 path_data.m_PathData.close(); | 328 // Finally, we have got the mask that we need, intersect with current clip |
317 path_data.m_PathData.setFillType((fill_mode&3) == FXFILL_WINDING? SkPath
::kWinding_FillType:SkPath::kEvenOdd_FillType); | 329 // region |
318 | 330 m_pAggDriver->m_pClipRgn->IntersectMaskF(clip_box.fLeft, clip_box.fTop, mask); |
319 SkPaint spaint; | 331 } |
320 spaint.setColor(0xffffffff); | 332 FX_BOOL CFX_SkiaDeviceDriver::SetClip_PathFill( |
321 spaint.setAntiAlias(TRUE); | 333 const CFX_PathData* pPathData, // path info |
322 spaint.setStyle(SkPaint::kFill_Style); | 334 const CFX_AffineMatrix* pObject2Device, // optional transformation |
323 | 335 int fill_mode // fill mode, WINDING or ALTERNATE |
324 SetClipMask(path_data.m_PathData, &spaint); | 336 ) { |
325 | 337 if (m_pAggDriver->m_pClipRgn == NULL) |
326 return TRUE; | 338 m_pAggDriver->m_pClipRgn = new CFX_ClipRgn( |
327 } | 339 GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT)); |
328 | 340 |
329 FX_BOOL CFX_SkiaDeviceDriver::SetClip_PathStroke(const CFX_PathData* pPathData,
// path info | 341 if (pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) { |
330 const CFX_AffineMatrix* pObject2
Device, // optional transformation | 342 CFX_FloatRect rectf; |
331 const CFX_GraphStateData* pGraph
State // graphic state, for pen attributes | 343 if (pPathData->IsRect(pObject2Device, &rectf)) { |
332 ) | 344 rectf.Intersect( |
333 { | 345 CFX_FloatRect(0, 0, (FX_FIXFLOAT)GetDeviceCaps(FXDC_PIXEL_WIDTH), |
334 if (m_pAggDriver->m_pClipRgn == NULL) | 346 (FX_FIXFLOAT)GetDeviceCaps(FXDC_PIXEL_HEIGHT))); |
335 m_pAggDriver->m_pClipRgn = new CFX_ClipRgn(GetDeviceCaps(FXDC_PI
XEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT)); | 347 FX_RECT rect = rectf.GetOutterRect(); |
336 | 348 m_pAggDriver->m_pClipRgn->IntersectRect(rect); |
337 // build path data | 349 return TRUE; |
338 CSkia_PathData path_data; | 350 } |
339 path_data.BuildPath(pPathData, NULL); | 351 } |
340 path_data.m_PathData.setFillType(SkPath::kWinding_FillType); | 352 CSkia_PathData path_data; |
341 | 353 path_data.BuildPath(pPathData, pObject2Device); |
342 SkPaint spaint; | 354 path_data.m_PathData.close(); |
343 spaint.setColor(0xffffffff); | 355 path_data.m_PathData.setFillType((fill_mode & 3) == FXFILL_WINDING |
344 spaint.setStyle(SkPaint::kStroke_Style); | 356 ? SkPath::kWinding_FillType |
345 spaint.setAntiAlias(TRUE); | 357 : SkPath::kEvenOdd_FillType); |
346 | 358 |
347 SkPath dst_path; | 359 SkPaint spaint; |
348 SkRasterizeStroke(spaint, &dst_path, path_data.m_PathData, pObject2Devic
e, pGraphState, 1, FALSE, 0); | 360 spaint.setColor(0xffffffff); |
349 spaint.setStyle(SkPaint::kFill_Style); | 361 spaint.setAntiAlias(TRUE); |
350 SetClipMask(dst_path, &spaint); | 362 spaint.setStyle(SkPaint::kFill_Style); |
351 | 363 |
352 return TRUE; | 364 SetClipMask(path_data.m_PathData, &spaint); |
353 } | 365 |
354 FX_BOOL CFX_SkiaDeviceDriver::RenderRasterizer(rasterizer_scanline_aa& rasterize
r, FX_DWORD color, FX_BOOL bFullCover, FX_BOOL bGroupKnockout, | 366 return TRUE; |
355
int alpha_flag, void* pIccTransform) | 367 } |
356 { | 368 |
357 return m_pAggDriver->RenderRasterizer(rasterizer, color, bFullCover, bGr
oupKnockout,alpha_flag, pIccTransform); | 369 FX_BOOL CFX_SkiaDeviceDriver::SetClip_PathStroke( |
358 } | 370 const CFX_PathData* pPathData, // path info |
359 FX_BOOL CFX_SkiaDeviceDriver::RenderRasterizerSkia(SkPath& skPath, const SkPaint
& origPaint, SkIRect& rect, FX_DWORD color, FX_BOOL bFullCover, FX_BOOL bGroupKn
ockout, | 371 const CFX_AffineMatrix* pObject2Device, // optional transformation |
360 int alpha_flag, void* pI
ccTransform, FX_BOOL bFill) | 372 const CFX_GraphStateData* pGraphState // graphic state, for pen attributes |
361 { | 373 ) { |
362 CFX_DIBitmap* pt = bGroupKnockout?m_pAggDriver->GetBackDrop():NULL; | 374 if (m_pAggDriver->m_pClipRgn == NULL) |
363 CFX_SkiaRenderer render; | 375 m_pAggDriver->m_pClipRgn = new CFX_ClipRgn( |
364 if (!render.Init(m_pAggDriver->m_pBitmap, pt, m_pAggDriver->m_pClipRgn,
color, bFullCover, m_pAggDriver->m_bRgbByteOrder, alpha_flag, pIccTransform)) | 376 GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT)); |
365 return FALSE; | 377 |
366 | 378 // build path data |
367 SkRasterClip rasterClip(rect); | 379 CSkia_PathData path_data; |
368 SuperBlitter_skia::DrawPath(skPath, (SkBlitter*)&render, rasterClip, or
igPaint); | 380 path_data.BuildPath(pPathData, NULL); |
369 | 381 path_data.m_PathData.setFillType(SkPath::kWinding_FillType); |
370 return TRUE; | 382 |
371 | 383 SkPaint spaint; |
372 } | 384 spaint.setColor(0xffffffff); |
373 | 385 spaint.setStyle(SkPaint::kStroke_Style); |
374 FX_BOOL CFX_SkiaDeviceDriver::DrawPath(const CFX_PathData* pPathData, // path
info | 386 spaint.setAntiAlias(TRUE); |
375 const CFX_AffineMatrix* pObject2
Device, // optional transformation | 387 |
376 const CFX_GraphStateData* pGraph
State, // graphic state, for pen attributes | 388 SkPath dst_path; |
377 FX_DWORD fill_color,
// fill color | 389 SkRasterizeStroke(spaint, &dst_path, path_data.m_PathData, pObject2Device, |
378 FX_DWORD stroke_color,
// stroke color | 390 pGraphState, 1, FALSE, 0); |
379 int fill_mode,
// fill mode, WINDING or ALTERNATE. 0 for not filled | 391 spaint.setStyle(SkPaint::kFill_Style); |
380 int alpha_flag, | 392 SetClipMask(dst_path, &spaint); |
381 void* pIccTransform | 393 |
382 ) | 394 return TRUE; |
383 { | 395 } |
384 if (GetBuffer() == NULL) return TRUE; | 396 FX_BOOL CFX_SkiaDeviceDriver::RenderRasterizer( |
385 FOXIT_DEBUG1("CFX_SkiaDeviceDriver::DrawPath: entering"); | 397 rasterizer_scanline_aa& rasterizer, |
386 SkIRect rect; | 398 FX_DWORD color, |
387 rect.set(0, 0, GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceCaps(FXDC_PIXEL
_HEIGHT)); | 399 FX_BOOL bFullCover, |
388 if ((fill_mode & 3) && fill_color) { | 400 FX_BOOL bGroupKnockout, |
389 // We have to transform before building path data, otherwise we'
ll have flatting problem | 401 int alpha_flag, |
390 // when we enlarge a small path (flatten before transformed) | 402 void* pIccTransform) { |
391 // TESTDOC: Bug #5115 - DS_S1Dimpact_lr.pdf | 403 return m_pAggDriver->RenderRasterizer( |
392 // build path data | 404 rasterizer, color, bFullCover, bGroupKnockout, alpha_flag, pIccTransform); |
393 CSkia_PathData path_data; | 405 } |
394 path_data.BuildPath(pPathData, pObject2Device); | 406 FX_BOOL CFX_SkiaDeviceDriver::RenderRasterizerSkia(SkPath& skPath, |
395 //path_data.m_PathData.close(); | 407 const SkPaint& origPaint, |
396 path_data.m_PathData.setFillType((fill_mode&3) == FXFILL_WINDING
? SkPath::kWinding_FillType:SkPath::kEvenOdd_FillType); | 408 SkIRect& rect, |
397 | 409 FX_DWORD color, |
398 SkPaint spaint; | 410 FX_BOOL bFullCover, |
399 spaint.setAntiAlias(TRUE); | 411 FX_BOOL bGroupKnockout, |
400 spaint.setStyle(SkPaint::kFill_Style); | 412 int alpha_flag, |
401 spaint.setColor(fill_color); | 413 void* pIccTransform, |
402 if (!RenderRasterizerSkia(path_data.m_PathData, spaint, rect, fi
ll_color, fill_mode & FXFILL_FULLCOVER, FALSE, alpha_flag, pIccTransform)) | 414 FX_BOOL bFill) { |
403 return FALSE; | 415 CFX_DIBitmap* pt = bGroupKnockout ? m_pAggDriver->GetBackDrop() : NULL; |
404 } | 416 CFX_SkiaRenderer render; |
405 | 417 if (!render.Init(m_pAggDriver->m_pBitmap, pt, m_pAggDriver->m_pClipRgn, color, |
406 int stroke_alpha = FXGETFLAG_COLORTYPE(alpha_flag) ? FXGETFLAG_ALPHA_STR
OKE(alpha_flag) : FXARGB_A(stroke_color); | 418 bFullCover, m_pAggDriver->m_bRgbByteOrder, alpha_flag, |
407 | 419 pIccTransform)) |
408 if (pGraphState && stroke_alpha) { | 420 return FALSE; |
409 // We split the matrix into two parts: first part doing the scal
ing, so we won't have the | 421 |
410 // flatness problem, second part doing the transformation, so we
don't have stroking geo problem. | 422 SkRasterClip rasterClip(rect); |
411 // TESTDOC: Bug #5253 - test[1].pdf | 423 SuperBlitter_skia::DrawPath(skPath, (SkBlitter*)&render, rasterClip, |
412 CFX_AffineMatrix matrix1, matrix2; | 424 origPaint); |
413 if (pObject2Device) { | 425 |
414 matrix1.a = FXSYS_fabs(pObject2Device->a) > FXSYS_fabs(p
Object2Device->b) ? | 426 return TRUE; |
415 FXSYS_fabs(pObject2Device->a) : FXSYS_fa
bs(pObject2Device->b); | 427 } |
416 matrix1.d = matrix1.a;//FXSYS_fabs(pObject2Device->c) >
FXSYS_fabs(pObject2Device->d) ? | 428 |
417 //pObject2Device->c : pObject2Device->d; | 429 FX_BOOL CFX_SkiaDeviceDriver::DrawPath( |
418 matrix2.Set(pObject2Device->a/matrix1.a, pObject2Device-
>b/matrix1.a, | 430 const CFX_PathData* pPathData, // path info |
419 pObject2Device->c/matrix1.d, pObject2Dev
ice->d/matrix1.d, | 431 const CFX_AffineMatrix* pObject2Device, // optional transformation |
420 pObject2Device->e, pObject2Device->f); | 432 const CFX_GraphStateData* pGraphState, // graphic state, for pen attributes |
421 } | 433 FX_DWORD fill_color, // fill color |
422 // build path data | 434 FX_DWORD stroke_color, // stroke color |
423 CSkia_PathData path_data; | 435 int fill_mode, // fill mode, WINDING or ALTERNATE. 0 for not filled |
424 path_data.BuildPath(pPathData, &matrix1); | 436 int alpha_flag, |
425 path_data.m_PathData.setFillType(SkPath::kWinding_FillType); | 437 void* pIccTransform) { |
426 | 438 if (GetBuffer() == NULL) |
427 SkPaint spaint; | 439 return TRUE; |
428 spaint.setColor(stroke_color); | 440 FOXIT_DEBUG1("CFX_SkiaDeviceDriver::DrawPath: entering"); |
429 spaint.setStyle(SkPaint::kStroke_Style); | 441 SkIRect rect; |
430 spaint.setAntiAlias(TRUE); | 442 rect.set(0, 0, GetDeviceCaps(FXDC_PIXEL_WIDTH), |
431 SkPath dst_path; | 443 GetDeviceCaps(FXDC_PIXEL_HEIGHT)); |
432 SkRasterizeStroke(spaint, &dst_path, path_data.m_PathData, &matr
ix2, pGraphState, matrix1.a, FALSE, 0); | 444 if ((fill_mode & 3) && fill_color) { |
433 spaint.setStyle(SkPaint::kFill_Style); | 445 // We have to transform before building path data, otherwise we'll have |
434 int fill_flag = FXGETFLAG_COLORTYPE(alpha_flag)<<8 | FXGETFLAG_A
LPHA_STROKE(alpha_flag); | 446 // flatting problem |
435 | 447 // when we enlarge a small path (flatten before transformed) |
436 if (!RenderRasterizerSkia(dst_path, spaint, rect, stroke_color,
fill_mode & FXFILL_FULLCOVER, FALSE, fill_flag, pIccTransform, FALSE)) | 448 // TESTDOC: Bug #5115 - DS_S1Dimpact_lr.pdf |
437 return FALSE; | 449 // build path data |
438 | 450 CSkia_PathData path_data; |
439 } | 451 path_data.BuildPath(pPathData, pObject2Device); |
440 | 452 // path_data.m_PathData.close(); |
441 return TRUE; | 453 path_data.m_PathData.setFillType((fill_mode & 3) == FXFILL_WINDING |
442 } | 454 ? SkPath::kWinding_FillType |
443 | 455 : SkPath::kEvenOdd_FillType); |
444 FX_BOOL CFX_SkiaDeviceDriver::SetPixel(int x, int y, FX_DWORD color, | 456 |
445 int alpha_flag, void* pIccTransf
orm) | 457 SkPaint spaint; |
446 { | 458 spaint.setAntiAlias(TRUE); |
447 return m_pAggDriver->SetPixel(x, y, color, alpha_flag, pIccTransform); | 459 spaint.setStyle(SkPaint::kFill_Style); |
448 } | 460 spaint.setColor(fill_color); |
449 | 461 if (!RenderRasterizerSkia(path_data.m_PathData, spaint, rect, fill_color, |
450 FX_BOOL CFX_SkiaDeviceDriver::FillRect(const FX_RECT* pRect, FX_DWORD fill_color
, int alpha_flag, void* pIccTransform) | 462 fill_mode & FXFILL_FULLCOVER, FALSE, alpha_flag, |
451 { | 463 pIccTransform)) |
452 return m_pAggDriver->FillRect(pRect, fill_color, alpha_flag, pIccTransfo
rm); | 464 return FALSE; |
453 } | 465 } |
454 | 466 |
455 FX_BOOL CFX_SkiaDeviceDriver::GetClipBox(FX_RECT* pRect) | 467 int stroke_alpha = FXGETFLAG_COLORTYPE(alpha_flag) |
456 { | 468 ? FXGETFLAG_ALPHA_STROKE(alpha_flag) |
457 return m_pAggDriver->GetClipBox(pRect); | 469 : FXARGB_A(stroke_color); |
458 } | 470 |
459 | 471 if (pGraphState && stroke_alpha) { |
460 FX_BOOL CFX_SkiaDeviceDriver::GetDIBits(CFX_DIBitmap* pBitmap, int left, int top
, void* pIccTransform, FX_BOOL bDEdge) | 472 // We split the matrix into two parts: first part doing the scaling, so we |
461 { | 473 // won't have the |
462 return m_pAggDriver->GetDIBits(pBitmap, left, top, pIccTransform, bDEdge
); | 474 // flatness problem, second part doing the transformation, so we don't have |
463 } | 475 // stroking geo problem. |
464 | 476 // TESTDOC: Bug #5253 - test[1].pdf |
465 FX_BOOL CFX_SkiaDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap, FX_DWORD a
rgb, const FX_RECT* pSrcRect, int left, int top, int blend_type, | 477 CFX_AffineMatrix matrix1, matrix2; |
466 int a
lpha_flag, void* pIccTransform) | 478 if (pObject2Device) { |
467 { | 479 matrix1.a = FXSYS_fabs(pObject2Device->a) > FXSYS_fabs(pObject2Device->b) |
468 return m_pAggDriver->SetDIBits(pBitmap, argb, pSrcRect, left, top, blend
_type, alpha_flag, pIccTransform); | 480 ? FXSYS_fabs(pObject2Device->a) |
469 } | 481 : FXSYS_fabs(pObject2Device->b); |
470 | 482 matrix1.d = matrix1.a; // FXSYS_fabs(pObject2Device->c) > |
471 FX_BOOL CFX_SkiaDeviceDriver::StretchDIBits(const CFX_DIBSource* pSource, FX_DWO
RD argb, int dest_left, int dest_top, | 483 // FXSYS_fabs(pObject2Device->d) ? |
472 int dest_width, int dest
_height, const FX_RECT* pClipRect, FX_DWORD flags, | 484 // pObject2Device->c : pObject2Device->d; |
473 int alpha_flag, void* pI
ccTransform) | 485 matrix2.Set(pObject2Device->a / matrix1.a, pObject2Device->b / matrix1.a, |
474 { | 486 pObject2Device->c / matrix1.d, pObject2Device->d / matrix1.d, |
475 return m_pAggDriver->StretchDIBits(pSource, argb, dest_left, dest_top, | 487 pObject2Device->e, pObject2Device->f); |
476 dest_width, dest_height,
pClipRect, flags, | 488 } |
477 alpha_flag, pIccTransfor
m); | 489 // build path data |
478 } | 490 CSkia_PathData path_data; |
479 | 491 path_data.BuildPath(pPathData, &matrix1); |
480 FX_BOOL CFX_SkiaDeviceDriver::StartDIBits(const CFX_DIBSource* pSource, int bitm
ap_alpha, FX_DWORD argb, | 492 path_data.m_PathData.setFillType(SkPath::kWinding_FillType); |
481 const CFX_AffineMatrix* pMatrix,
FX_DWORD render_flags, void*& handle, | 493 |
482 int alpha_flag, void* pIccTransf
orm) | 494 SkPaint spaint; |
483 { | 495 spaint.setColor(stroke_color); |
484 return m_pAggDriver->StartDIBits(pSource, bitmap_alpha, argb, | 496 spaint.setStyle(SkPaint::kStroke_Style); |
485 pMatrix, render_flags, handle, a
lpha_flag, pIccTransform); | 497 spaint.setAntiAlias(TRUE); |
486 } | 498 SkPath dst_path; |
487 | 499 SkRasterizeStroke(spaint, &dst_path, path_data.m_PathData, &matrix2, |
488 FX_BOOL CFX_SkiaDeviceDriver::ContinueDIBits(void* pHandle, IFX_Pause* pPause) | 500 pGraphState, matrix1.a, FALSE, 0); |
489 { | 501 spaint.setStyle(SkPaint::kFill_Style); |
490 return m_pAggDriver->ContinueDIBits(pHandle, pPause); | 502 int fill_flag = FXGETFLAG_COLORTYPE(alpha_flag) << 8 | |
491 } | 503 FXGETFLAG_ALPHA_STROKE(alpha_flag); |
492 | 504 |
493 void CFX_SkiaDeviceDriver::CancelDIBits(void* pHandle) | 505 if (!RenderRasterizerSkia(dst_path, spaint, rect, stroke_color, |
494 { | 506 fill_mode & FXFILL_FULLCOVER, FALSE, fill_flag, |
495 m_pAggDriver->CancelDIBits(pHandle); | 507 pIccTransform, FALSE)) |
496 } | 508 return FALSE; |
497 | 509 } |
498 CFX_SkiaDevice::CFX_SkiaDevice() | 510 |
499 { | 511 return TRUE; |
500 m_bOwnedBitmap = FALSE; | 512 } |
501 } | 513 |
502 | 514 FX_BOOL CFX_SkiaDeviceDriver::SetPixel(int x, |
503 FX_BOOL CFX_SkiaDevice::Attach(CFX_DIBitmap* pBitmap, int dither_bits, FX_BOOL b
RgbByteOrder, CFX_DIBitmap* pOriDevice, FX_BOOL bGroupKnockout) | 515 int y, |
504 { | 516 FX_DWORD color, |
505 if (pBitmap == NULL) | 517 int alpha_flag, |
506 return FALSE; | 518 void* pIccTransform) { |
507 SetBitmap(pBitmap); | 519 return m_pAggDriver->SetPixel(x, y, color, alpha_flag, pIccTransform); |
508 CFX_SkiaDeviceDriver* pDriver = new CFX_SkiaDeviceDriver(pBitmap, dither
_bits, bRgbByteOrder, pOriDevice, bGroupKnockout); | 520 } |
509 SetDeviceDriver(pDriver); | 521 |
510 return TRUE; | 522 FX_BOOL CFX_SkiaDeviceDriver::FillRect(const FX_RECT* pRect, |
511 } | 523 FX_DWORD fill_color, |
512 | 524 int alpha_flag, |
513 FX_BOOL CFX_SkiaDevice::Create(int width, int height, FXDIB_Format format, int d
ither_bits, CFX_DIBitmap* pOriDevice) | 525 void* pIccTransform) { |
514 { | 526 return m_pAggDriver->FillRect(pRect, fill_color, alpha_flag, pIccTransform); |
515 m_bOwnedBitmap = TRUE; | 527 } |
516 CFX_DIBitmap* pBitmap = new CFX_DIBitmap; | 528 |
517 if (!pBitmap->Create(width, height, format)) { | 529 FX_BOOL CFX_SkiaDeviceDriver::GetClipBox(FX_RECT* pRect) { |
518 delete pBitmap; | 530 return m_pAggDriver->GetClipBox(pRect); |
519 return FALSE; | 531 } |
520 } | 532 |
521 SetBitmap(pBitmap); | 533 FX_BOOL CFX_SkiaDeviceDriver::GetDIBits(CFX_DIBitmap* pBitmap, |
522 CFX_SkiaDeviceDriver* pDriver = new CFX_SkiaDeviceDriver(pBitmap, dithe
r_bits, FALSE, pOriDevice, FALSE); | 534 int left, |
523 SetDeviceDriver(pDriver); | 535 int top, |
524 return TRUE; | 536 void* pIccTransform, |
525 } | 537 FX_BOOL bDEdge) { |
526 CFX_SkiaDevice::~CFX_SkiaDevice() | 538 return m_pAggDriver->GetDIBits(pBitmap, left, top, pIccTransform, bDEdge); |
527 { | 539 } |
528 if (m_bOwnedBitmap && GetBitmap()) delete GetBitmap(); | 540 |
| 541 FX_BOOL CFX_SkiaDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap, |
| 542 FX_DWORD argb, |
| 543 const FX_RECT* pSrcRect, |
| 544 int left, |
| 545 int top, |
| 546 int blend_type, |
| 547 int alpha_flag, |
| 548 void* pIccTransform) { |
| 549 return m_pAggDriver->SetDIBits(pBitmap, argb, pSrcRect, left, top, blend_type, |
| 550 alpha_flag, pIccTransform); |
| 551 } |
| 552 |
| 553 FX_BOOL CFX_SkiaDeviceDriver::StretchDIBits(const CFX_DIBSource* pSource, |
| 554 FX_DWORD argb, |
| 555 int dest_left, |
| 556 int dest_top, |
| 557 int dest_width, |
| 558 int dest_height, |
| 559 const FX_RECT* pClipRect, |
| 560 FX_DWORD flags, |
| 561 int alpha_flag, |
| 562 void* pIccTransform) { |
| 563 return m_pAggDriver->StretchDIBits(pSource, argb, dest_left, dest_top, |
| 564 dest_width, dest_height, pClipRect, flags, |
| 565 alpha_flag, pIccTransform); |
| 566 } |
| 567 |
| 568 FX_BOOL CFX_SkiaDeviceDriver::StartDIBits(const CFX_DIBSource* pSource, |
| 569 int bitmap_alpha, |
| 570 FX_DWORD argb, |
| 571 const CFX_AffineMatrix* pMatrix, |
| 572 FX_DWORD render_flags, |
| 573 void*& handle, |
| 574 int alpha_flag, |
| 575 void* pIccTransform) { |
| 576 return m_pAggDriver->StartDIBits(pSource, bitmap_alpha, argb, pMatrix, |
| 577 render_flags, handle, alpha_flag, |
| 578 pIccTransform); |
| 579 } |
| 580 |
| 581 FX_BOOL CFX_SkiaDeviceDriver::ContinueDIBits(void* pHandle, IFX_Pause* pPause) { |
| 582 return m_pAggDriver->ContinueDIBits(pHandle, pPause); |
| 583 } |
| 584 |
| 585 void CFX_SkiaDeviceDriver::CancelDIBits(void* pHandle) { |
| 586 m_pAggDriver->CancelDIBits(pHandle); |
| 587 } |
| 588 |
| 589 CFX_SkiaDevice::CFX_SkiaDevice() { |
| 590 m_bOwnedBitmap = FALSE; |
| 591 } |
| 592 |
| 593 FX_BOOL CFX_SkiaDevice::Attach(CFX_DIBitmap* pBitmap, |
| 594 int dither_bits, |
| 595 FX_BOOL bRgbByteOrder, |
| 596 CFX_DIBitmap* pOriDevice, |
| 597 FX_BOOL bGroupKnockout) { |
| 598 if (pBitmap == NULL) |
| 599 return FALSE; |
| 600 SetBitmap(pBitmap); |
| 601 CFX_SkiaDeviceDriver* pDriver = new CFX_SkiaDeviceDriver( |
| 602 pBitmap, dither_bits, bRgbByteOrder, pOriDevice, bGroupKnockout); |
| 603 SetDeviceDriver(pDriver); |
| 604 return TRUE; |
| 605 } |
| 606 |
| 607 FX_BOOL CFX_SkiaDevice::Create(int width, |
| 608 int height, |
| 609 FXDIB_Format format, |
| 610 int dither_bits, |
| 611 CFX_DIBitmap* pOriDevice) { |
| 612 m_bOwnedBitmap = TRUE; |
| 613 CFX_DIBitmap* pBitmap = new CFX_DIBitmap; |
| 614 if (!pBitmap->Create(width, height, format)) { |
| 615 delete pBitmap; |
| 616 return FALSE; |
| 617 } |
| 618 SetBitmap(pBitmap); |
| 619 CFX_SkiaDeviceDriver* pDriver = |
| 620 new CFX_SkiaDeviceDriver(pBitmap, dither_bits, FALSE, pOriDevice, FALSE); |
| 621 SetDeviceDriver(pDriver); |
| 622 return TRUE; |
| 623 } |
| 624 CFX_SkiaDevice::~CFX_SkiaDevice() { |
| 625 if (m_bOwnedBitmap && GetBitmap()) |
| 626 delete GetBitmap(); |
529 } | 627 } |
530 | 628 |
531 #endif | 629 #endif |
OLD | NEW |