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 "core/include/fxge/fx_ge.h" | 5 #include "core/include/fxge/fx_ge.h" |
6 | 6 |
7 #if defined(_SKIA_SUPPORT_) | 7 #if defined(_SKIA_SUPPORT_) |
8 #include "core/include/fxcodec/fx_codec.h" | 8 #include "core/include/fxcodec/fx_codec.h" |
9 | 9 |
10 #include "core/fxge/agg/fx_agg_driver.h" | 10 #include "core/fxge/agg/fx_agg_driver.h" |
(...skipping 14 matching lines...) Expand all Loading... | |
25 static void DebugShowSkiaPath(const SkPath& path) { | 25 static void DebugShowSkiaPath(const SkPath& path) { |
26 #if SHOW_SKIA_PATH | 26 #if SHOW_SKIA_PATH |
27 char buffer[4096]; | 27 char buffer[4096]; |
28 sk_bzero(buffer, sizeof(buffer)); | 28 sk_bzero(buffer, sizeof(buffer)); |
29 SkMemoryWStream stream(buffer, sizeof(buffer)); | 29 SkMemoryWStream stream(buffer, sizeof(buffer)); |
30 path.dump(&stream, false, false); | 30 path.dump(&stream, false, false); |
31 printf("%s\n", buffer); | 31 printf("%s\n", buffer); |
32 #endif // SHOW_SKIA_PATH | 32 #endif // SHOW_SKIA_PATH |
33 } | 33 } |
34 | 34 |
35 static void DebugShowCanvasMatrix(const SkCanvas* canvas) { | |
36 #if SHOW_SKIA_PATH | |
37 SkMatrix matrix = canvas->getTotalMatrix(); | |
38 SkScalar m[9]; | |
39 matrix.get9(m); | |
40 printf("(%g,%g,%g) (%g,%g,%g) (%g,%g,%g)\n", m[0], m[1], m[2], m[3], m[4], m[5 ], m[6], | |
41 m[7], m[8]); | |
42 #endif // SHOW_SKIA_PATH | |
43 } | |
44 | |
35 #if DRAW_SKIA_CLIP | 45 #if DRAW_SKIA_CLIP |
36 | 46 |
37 static SkPaint DebugClipPaint() { | 47 static SkPaint DebugClipPaint() { |
38 SkPaint paint; | 48 SkPaint paint; |
39 paint.setAntiAlias(true); | 49 paint.setAntiAlias(true); |
40 paint.setColor(SK_ColorGREEN); | 50 paint.setColor(SK_ColorGREEN); |
41 paint.setStyle(SkPaint::kStroke_Style); | 51 paint.setStyle(SkPaint::kStroke_Style); |
42 return paint; | 52 return paint; |
43 } | 53 } |
44 | 54 |
(...skipping 10 matching lines...) Expand all Loading... | |
55 #else // DRAW_SKIA_CLIP | 65 #else // DRAW_SKIA_CLIP |
56 | 66 |
57 static void DebugDrawSkiaClipRect(SkCanvas* canvas, const SkRect& rect) {} | 67 static void DebugDrawSkiaClipRect(SkCanvas* canvas, const SkRect& rect) {} |
58 static void DebugDrawSkiaClipPath(SkCanvas* canvas, const SkPath& path) {} | 68 static void DebugDrawSkiaClipPath(SkCanvas* canvas, const SkPath& path) {} |
59 | 69 |
60 #endif // DRAW_SKIA_CLIP | 70 #endif // DRAW_SKIA_CLIP |
61 | 71 |
62 #undef SHOW_SKIA_PATH | 72 #undef SHOW_SKIA_PATH |
63 #undef DRAW_SKIA_CLIP | 73 #undef DRAW_SKIA_CLIP |
64 | 74 |
65 static SkPath BuildPath(const CFX_PathData* pPathData, | 75 static SkPath BuildPath(const CFX_PathData* pPathData) { |
66 const CFX_Matrix* pObject2Device) { | |
67 SkPath skPath; | 76 SkPath skPath; |
68 const CFX_PathData* pFPath = pPathData; | 77 const CFX_PathData* pFPath = pPathData; |
69 int nPoints = pFPath->GetPointCount(); | 78 int nPoints = pFPath->GetPointCount(); |
70 FX_PATHPOINT* pPoints = pFPath->GetPoints(); | 79 FX_PATHPOINT* pPoints = pFPath->GetPoints(); |
71 for (int i = 0; i < nPoints; i++) { | 80 for (int i = 0; i < nPoints; i++) { |
72 FX_FLOAT x = pPoints[i].m_PointX; | 81 FX_FLOAT x = pPoints[i].m_PointX; |
73 FX_FLOAT y = pPoints[i].m_PointY; | 82 FX_FLOAT y = pPoints[i].m_PointY; |
74 if (pObject2Device) | |
75 pObject2Device->Transform(x, y); | |
76 int point_type = pPoints[i].m_Flag & FXPT_TYPE; | 83 int point_type = pPoints[i].m_Flag & FXPT_TYPE; |
77 if (point_type == FXPT_MOVETO) { | 84 if (point_type == FXPT_MOVETO) { |
78 skPath.moveTo(x, y); | 85 skPath.moveTo(x, y); |
79 } else if (point_type == FXPT_LINETO) { | 86 } else if (point_type == FXPT_LINETO) { |
80 skPath.lineTo(x, y); | 87 skPath.lineTo(x, y); |
81 } else if (point_type == FXPT_BEZIERTO) { | 88 } else if (point_type == FXPT_BEZIERTO) { |
82 FX_FLOAT x2 = pPoints[i + 1].m_PointX, y2 = pPoints[i + 1].m_PointY; | 89 FX_FLOAT x2 = pPoints[i + 1].m_PointX, y2 = pPoints[i + 1].m_PointY; |
83 FX_FLOAT x3 = pPoints[i + 2].m_PointX, y3 = pPoints[i + 2].m_PointY; | 90 FX_FLOAT x3 = pPoints[i + 2].m_PointX, y3 = pPoints[i + 2].m_PointY; |
84 if (pObject2Device) { | |
85 pObject2Device->Transform(x2, y2); | |
86 pObject2Device->Transform(x3, y3); | |
87 } | |
88 skPath.cubicTo(x, y, x2, y2, x3, y3); | 91 skPath.cubicTo(x, y, x2, y2, x3, y3); |
89 i += 2; | 92 i += 2; |
90 } | 93 } |
91 if (pPoints[i].m_Flag & FXPT_CLOSEFIGURE) | 94 if (pPoints[i].m_Flag & FXPT_CLOSEFIGURE) |
92 skPath.close(); | 95 skPath.close(); |
93 } | 96 } |
94 return skPath; | 97 return skPath; |
95 } | 98 } |
96 | 99 |
97 // convert a stroking path to scanlines | 100 // convert a stroking path to scanlines |
98 void CFX_SkiaDeviceDriver::PaintStroke(SkPaint* spaint, | 101 void CFX_SkiaDeviceDriver::PaintStroke(SkPaint* spaint, |
99 const CFX_GraphStateData* pGraphState) { | 102 const CFX_GraphStateData* pGraphState, |
103 const SkMatrix& matrix) { | |
100 SkPaint::Cap cap; | 104 SkPaint::Cap cap; |
101 switch (pGraphState->m_LineCap) { | 105 switch (pGraphState->m_LineCap) { |
102 case CFX_GraphStateData::LineCapRound: | 106 case CFX_GraphStateData::LineCapRound: |
103 cap = SkPaint::kRound_Cap; | 107 cap = SkPaint::kRound_Cap; |
104 break; | 108 break; |
105 case CFX_GraphStateData::LineCapSquare: | 109 case CFX_GraphStateData::LineCapSquare: |
106 cap = SkPaint::kSquare_Cap; | 110 cap = SkPaint::kSquare_Cap; |
107 break; | 111 break; |
108 default: | 112 default: |
109 cap = SkPaint::kButt_Cap; | 113 cap = SkPaint::kButt_Cap; |
110 break; | 114 break; |
111 } | 115 } |
112 SkPaint::Join join; | 116 SkPaint::Join join; |
113 switch (pGraphState->m_LineJoin) { | 117 switch (pGraphState->m_LineJoin) { |
114 case CFX_GraphStateData::LineJoinRound: | 118 case CFX_GraphStateData::LineJoinRound: |
115 join = SkPaint::kRound_Join; | 119 join = SkPaint::kRound_Join; |
116 break; | 120 break; |
117 case CFX_GraphStateData::LineJoinBevel: | 121 case CFX_GraphStateData::LineJoinBevel: |
118 join = SkPaint::kBevel_Join; | 122 join = SkPaint::kBevel_Join; |
119 break; | 123 break; |
120 default: | 124 default: |
121 join = SkPaint::kMiter_Join; | 125 join = SkPaint::kMiter_Join; |
122 break; | 126 break; |
123 } | 127 } |
124 FX_FLOAT width = pGraphState->m_LineWidth; | 128 SkMatrix inverse; |
125 | 129 if (!matrix.invert(&inverse)) { |
130 return; // give up if the matrix is degenerate, and not invertable | |
131 } | |
dsinclair
2016/03/17 14:39:31
nit: no {}'s on single line body
caryclark
2016/03/17 15:52:51
Done.
| |
132 inverse.set(SkMatrix::kMTransX, 0); | |
133 inverse.set(SkMatrix::kMTransY, 0); | |
134 SkVector deviceUnits[2] = {{0, 1}, {1, 0}}; | |
135 inverse.mapPoints(deviceUnits, SK_ARRAY_COUNT(deviceUnits)); | |
136 FX_FLOAT width = SkTMax(pGraphState->m_LineWidth, | |
137 SkTMin(deviceUnits[0].length(), deviceUnits[1].length( ))); | |
126 if (pGraphState->m_DashArray) { | 138 if (pGraphState->m_DashArray) { |
127 int count = (pGraphState->m_DashCount + 1) / 2; | 139 int count = (pGraphState->m_DashCount + 1) / 2; |
128 SkScalar* intervals = FX_Alloc2D(SkScalar, count, sizeof(SkScalar)); | 140 SkScalar* intervals = FX_Alloc2D(SkScalar, count, sizeof(SkScalar)); |
129 // Set dash pattern | 141 // Set dash pattern |
130 for (int i = 0; i < count; i++) { | 142 for (int i = 0; i < count; i++) { |
131 FX_FLOAT on = pGraphState->m_DashArray[i * 2]; | 143 FX_FLOAT on = pGraphState->m_DashArray[i * 2]; |
132 if (on <= 0.000001f) | 144 if (on <= 0.000001f) |
133 on = 1.f / 10; | 145 on = 1.f / 10; |
134 FX_FLOAT off = i * 2 + 1 == pGraphState->m_DashCount | 146 FX_FLOAT off = i * 2 + 1 == pGraphState->m_DashCount |
135 ? on | 147 ? on |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
185 m_pCanvas = m_pRecorder->getRecordingCanvas(); | 197 m_pCanvas = m_pRecorder->getRecordingCanvas(); |
186 m_ditherBits = 0; | 198 m_ditherBits = 0; |
187 } | 199 } |
188 | 200 |
189 CFX_SkiaDeviceDriver::~CFX_SkiaDeviceDriver() { | 201 CFX_SkiaDeviceDriver::~CFX_SkiaDeviceDriver() { |
190 if (!m_pRecorder) | 202 if (!m_pRecorder) |
191 delete m_pCanvas; | 203 delete m_pCanvas; |
192 delete m_pAggDriver; | 204 delete m_pAggDriver; |
193 } | 205 } |
194 | 206 |
207 static SkMatrix ToSkMatrix(const CFX_Matrix& m) { | |
208 SkMatrix skMatrix; | |
209 skMatrix.setAll(m.a, m.b, m.e, m.c, m.d, m.f, 0, 0, 1); | |
210 return skMatrix; | |
211 } | |
212 | |
213 // use when pdf's y-axis points up insead of down | |
214 static SkMatrix ToFlippedSkMatrix(const CFX_Matrix& m) { | |
215 SkMatrix skMatrix; | |
216 skMatrix.setAll(m.a, m.b, m.e, -m.c, -m.d, m.f, 0, 0, 1); | |
217 return skMatrix; | |
218 } | |
219 | |
195 FX_BOOL CFX_SkiaDeviceDriver::DrawDeviceText(int nChars, | 220 FX_BOOL CFX_SkiaDeviceDriver::DrawDeviceText(int nChars, |
196 const FXTEXT_CHARPOS* pCharPos, | 221 const FXTEXT_CHARPOS* pCharPos, |
197 CFX_Font* pFont, | 222 CFX_Font* pFont, |
198 CFX_FontCache* pCache, | 223 CFX_FontCache* pCache, |
199 const CFX_Matrix* pObject2Device, | 224 const CFX_Matrix* pObject2Device, |
200 FX_FLOAT font_size, | 225 FX_FLOAT font_size, |
201 FX_DWORD color, | 226 FX_DWORD color, |
202 int alpha_flag, | 227 int alpha_flag, |
203 void* pIccTransform) { | 228 void* pIccTransform) { |
204 SkAutoTUnref<SkTypeface> typeface(SkTypeface::CreateFromStream( | 229 SkAutoTUnref<SkTypeface> typeface(SkTypeface::CreateFromStream( |
205 new SkMemoryStream(pFont->GetFontData(), pFont->GetSize()))); | 230 new SkMemoryStream(pFont->GetFontData(), pFont->GetSize()))); |
206 SkPaint paint; | 231 SkPaint paint; |
207 paint.setAntiAlias(true); | 232 paint.setAntiAlias(true); |
208 paint.setColor(color); | 233 paint.setColor(color); |
209 paint.setTypeface(typeface); | 234 paint.setTypeface(typeface); |
210 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); | 235 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); |
211 paint.setTextSize(font_size); | 236 paint.setTextSize(font_size); |
212 m_pCanvas->save(); | 237 m_pCanvas->save(); |
213 SkMatrix skMatrix; | 238 SkMatrix skMatrix = ToFlippedSkMatrix(*pObject2Device); |
214 const CFX_Matrix& m = *pObject2Device; | |
215 // note that PDF's y-axis goes up; Skia's y-axis goes down | |
216 skMatrix.setAll(m.a, m.b, m.e, -m.c, -m.d, m.f, 0, 0, 1); | |
217 m_pCanvas->concat(skMatrix); | 239 m_pCanvas->concat(skMatrix); |
218 for (int index = 0; index < nChars; ++index) { | 240 for (int index = 0; index < nChars; ++index) { |
219 const FXTEXT_CHARPOS& cp = pCharPos[index]; | 241 const FXTEXT_CHARPOS& cp = pCharPos[index]; |
220 uint16_t glyph = (uint16_t)cp.m_GlyphIndex; | 242 uint16_t glyph = (uint16_t)cp.m_GlyphIndex; |
221 m_pCanvas->drawText(&glyph, 2, cp.m_OriginX, cp.m_OriginY, paint); | 243 m_pCanvas->drawText(&glyph, 2, cp.m_OriginX, cp.m_OriginY, paint); |
222 } | 244 } |
223 m_pCanvas->restore(); | 245 m_pCanvas->restore(); |
224 return TRUE; | 246 return TRUE; |
225 } | 247 } |
226 | 248 |
(...skipping 14 matching lines...) Expand all Loading... | |
241 return FXRC_GET_BITS | FXRC_ALPHA_PATH | FXRC_ALPHA_IMAGE | | 263 return FXRC_GET_BITS | FXRC_ALPHA_PATH | FXRC_ALPHA_IMAGE | |
242 FXRC_BLEND_MODE | FXRC_SOFT_CLIP | FXRC_ALPHA_OUTPUT; | 264 FXRC_BLEND_MODE | FXRC_SOFT_CLIP | FXRC_ALPHA_OUTPUT; |
243 case FXDC_DITHER_BITS: | 265 case FXDC_DITHER_BITS: |
244 return m_ditherBits; | 266 return m_ditherBits; |
245 } | 267 } |
246 return 0; | 268 return 0; |
247 } | 269 } |
248 | 270 |
249 void CFX_SkiaDeviceDriver::SaveState() { | 271 void CFX_SkiaDeviceDriver::SaveState() { |
250 m_pCanvas->save(); | 272 m_pCanvas->save(); |
251 if (m_pAggDriver) | |
252 m_pAggDriver->SaveState(); | |
253 } | 273 } |
254 | 274 |
255 void CFX_SkiaDeviceDriver::RestoreState(FX_BOOL bKeepSaved) { | 275 void CFX_SkiaDeviceDriver::RestoreState(FX_BOOL bKeepSaved) { |
256 if (m_pAggDriver) | |
257 m_pAggDriver->RestoreState(bKeepSaved); | |
258 m_pCanvas->restore(); | 276 m_pCanvas->restore(); |
259 if (bKeepSaved) | 277 if (bKeepSaved) |
260 m_pCanvas->save(); | 278 m_pCanvas->save(); |
261 } | 279 } |
262 | 280 |
263 void CFX_SkiaDeviceDriver::SetClipMask( | |
264 agg::rasterizer_scanline_aa& rasterizer) { | |
265 if (m_pAggDriver) | |
266 m_pAggDriver->SetClipMask(rasterizer); | |
267 } | |
268 | |
269 FX_BOOL CFX_SkiaDeviceDriver::SetClip_PathFill( | 281 FX_BOOL CFX_SkiaDeviceDriver::SetClip_PathFill( |
270 const CFX_PathData* pPathData, // path info | 282 const CFX_PathData* pPathData, // path info |
271 const CFX_Matrix* pObject2Device, // flips object's y-axis | 283 const CFX_Matrix* pObject2Device, // flips object's y-axis |
272 int fill_mode // fill mode, WINDING or ALTERNATE | 284 int fill_mode // fill mode, WINDING or ALTERNATE |
273 ) { | 285 ) { |
274 if (pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) { | 286 if (pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) { |
275 CFX_FloatRect rectf; | 287 CFX_FloatRect rectf; |
276 if (pPathData->IsRect(pObject2Device, &rectf)) { | 288 if (pPathData->IsRect(pObject2Device, &rectf)) { |
277 rectf.Intersect( | 289 rectf.Intersect( |
278 CFX_FloatRect(0, 0, (FX_FLOAT)GetDeviceCaps(FXDC_PIXEL_WIDTH), | 290 CFX_FloatRect(0, 0, (FX_FLOAT)GetDeviceCaps(FXDC_PIXEL_WIDTH), |
279 (FX_FLOAT)GetDeviceCaps(FXDC_PIXEL_HEIGHT))); | 291 (FX_FLOAT)GetDeviceCaps(FXDC_PIXEL_HEIGHT))); |
280 // note that PDF's y-axis goes up; Skia's y-axis goes down | 292 // note that PDF's y-axis goes up; Skia's y-axis goes down |
281 SkRect skClipRect = | 293 SkRect skClipRect = |
282 SkRect::MakeLTRB(rectf.left, rectf.bottom, rectf.right, rectf.top); | 294 SkRect::MakeLTRB(rectf.left, rectf.bottom, rectf.right, rectf.top); |
283 DebugDrawSkiaClipRect(m_pCanvas, skClipRect); | 295 DebugDrawSkiaClipRect(m_pCanvas, skClipRect); |
284 m_pCanvas->clipRect(skClipRect); | 296 m_pCanvas->clipRect(skClipRect); |
285 return TRUE; | 297 return TRUE; |
286 } | 298 } |
287 } | 299 } |
288 SkPath skClipPath = BuildPath(pPathData, pObject2Device); | 300 SkPath skClipPath = BuildPath(pPathData); |
289 skClipPath.setFillType((fill_mode & 3) == FXFILL_WINDING | 301 skClipPath.setFillType((fill_mode & 3) == FXFILL_WINDING |
290 ? SkPath::kWinding_FillType | 302 ? SkPath::kWinding_FillType |
291 : SkPath::kEvenOdd_FillType); | 303 : SkPath::kEvenOdd_FillType); |
304 SkMatrix skMatrix = ToSkMatrix(*pObject2Device); | |
305 skClipPath.transform(skMatrix); | |
292 DebugShowSkiaPath(skClipPath); | 306 DebugShowSkiaPath(skClipPath); |
293 DebugDrawSkiaClipPath(m_pCanvas, skClipPath); | 307 DebugDrawSkiaClipPath(m_pCanvas, skClipPath); |
294 m_pCanvas->clipPath(skClipPath); | 308 m_pCanvas->clipPath(skClipPath); |
295 | 309 |
296 return TRUE; | 310 return TRUE; |
297 } | 311 } |
298 | 312 |
299 FX_BOOL CFX_SkiaDeviceDriver::SetClip_PathStroke( | 313 FX_BOOL CFX_SkiaDeviceDriver::SetClip_PathStroke( |
300 const CFX_PathData* pPathData, // path info | 314 const CFX_PathData* pPathData, // path info |
301 const CFX_Matrix* pObject2Device, // optional transformation | 315 const CFX_Matrix* pObject2Device, // optional transformation |
302 const CFX_GraphStateData* pGraphState // graphic state, for pen attributes | 316 const CFX_GraphStateData* pGraphState // graphic state, for pen attributes |
303 ) { | 317 ) { |
304 // build path data | 318 // build path data |
305 SkPath skPath = BuildPath(pPathData, NULL); | 319 SkPath skPath = BuildPath(pPathData); |
306 skPath.setFillType(SkPath::kWinding_FillType); | 320 skPath.setFillType(SkPath::kWinding_FillType); |
307 | 321 |
322 SkMatrix skMatrix = ToSkMatrix(*pObject2Device); | |
308 SkPaint spaint; | 323 SkPaint spaint; |
309 PaintStroke(&spaint, pGraphState); | 324 PaintStroke(&spaint, pGraphState, skMatrix); |
310 SkPath dst_path; | 325 SkPath dst_path; |
311 spaint.getFillPath(skPath, &dst_path); | 326 spaint.getFillPath(skPath, &dst_path); |
327 dst_path.transform(skMatrix); | |
312 DebugDrawSkiaClipPath(m_pCanvas, dst_path); | 328 DebugDrawSkiaClipPath(m_pCanvas, dst_path); |
313 m_pCanvas->clipPath(dst_path); | 329 m_pCanvas->clipPath(dst_path); |
314 return TRUE; | 330 return TRUE; |
315 } | 331 } |
316 | 332 |
317 FX_BOOL CFX_SkiaDeviceDriver::RenderRasterizer( | |
318 agg::rasterizer_scanline_aa& rasterizer, | |
319 FX_DWORD color, | |
320 FX_BOOL bFullCover, | |
321 FX_BOOL bGroupKnockout, | |
322 int alpha_flag, | |
323 void* pIccTransform) { | |
324 return m_pAggDriver && | |
325 m_pAggDriver->RenderRasterizer(rasterizer, color, bFullCover, | |
326 bGroupKnockout, alpha_flag, | |
327 pIccTransform); | |
328 } | |
329 | |
330 FX_BOOL CFX_SkiaDeviceDriver::DrawPath( | 333 FX_BOOL CFX_SkiaDeviceDriver::DrawPath( |
331 const CFX_PathData* pPathData, // path info | 334 const CFX_PathData* pPathData, // path info |
332 const CFX_Matrix* pObject2Device, // optional transformation | 335 const CFX_Matrix* pObject2Device, // optional transformation |
333 const CFX_GraphStateData* pGraphState, // graphic state, for pen attributes | 336 const CFX_GraphStateData* pGraphState, // graphic state, for pen attributes |
334 FX_DWORD fill_color, // fill color | 337 FX_DWORD fill_color, // fill color |
335 FX_DWORD stroke_color, // stroke color | 338 FX_DWORD stroke_color, // stroke color |
336 int fill_mode, // fill mode, WINDING or ALTERNATE. 0 for not filled | 339 int fill_mode, // fill mode, WINDING or ALTERNATE. 0 for not filled |
337 int alpha_flag, | 340 int alpha_flag, |
338 void* pIccTransform, | 341 void* pIccTransform, |
339 int blend_type) { | 342 int blend_type) { |
340 SkIRect rect; | 343 SkIRect rect; |
341 rect.set(0, 0, GetDeviceCaps(FXDC_PIXEL_WIDTH), | 344 rect.set(0, 0, GetDeviceCaps(FXDC_PIXEL_WIDTH), |
342 GetDeviceCaps(FXDC_PIXEL_HEIGHT)); | 345 GetDeviceCaps(FXDC_PIXEL_HEIGHT)); |
343 SkPath skPath = BuildPath(pPathData, pObject2Device); | 346 SkPath skPath = BuildPath(pPathData); |
344 SkPaint spaint; | 347 SkPaint spaint; |
345 spaint.setAntiAlias(true); | 348 spaint.setAntiAlias(true); |
349 m_pCanvas->save(); | |
350 SkMatrix skMatrix = ToSkMatrix(*pObject2Device); | |
351 m_pCanvas->concat(skMatrix); | |
346 if ((fill_mode & 3) && fill_color) { | 352 if ((fill_mode & 3) && fill_color) { |
347 skPath.setFillType((fill_mode & 3) == FXFILL_WINDING | 353 skPath.setFillType((fill_mode & 3) == FXFILL_WINDING |
348 ? SkPath::kWinding_FillType | 354 ? SkPath::kWinding_FillType |
349 : SkPath::kEvenOdd_FillType); | 355 : SkPath::kEvenOdd_FillType); |
350 | 356 |
351 spaint.setStyle(SkPaint::kFill_Style); | 357 spaint.setStyle(SkPaint::kFill_Style); |
352 spaint.setColor(fill_color); | 358 spaint.setColor(fill_color); |
353 m_pCanvas->drawPath(skPath, spaint); | 359 m_pCanvas->drawPath(skPath, spaint); |
354 } | 360 } |
355 int stroke_alpha = FXGETFLAG_COLORTYPE(alpha_flag) | 361 int stroke_alpha = FXGETFLAG_COLORTYPE(alpha_flag) |
356 ? FXGETFLAG_ALPHA_STROKE(alpha_flag) | 362 ? FXGETFLAG_ALPHA_STROKE(alpha_flag) |
357 : FXARGB_A(stroke_color); | 363 : FXARGB_A(stroke_color); |
358 | 364 |
359 if (pGraphState && stroke_alpha) { | 365 if (pGraphState && stroke_alpha) { |
360 spaint.setColor(stroke_color); | 366 spaint.setColor(stroke_color); |
361 PaintStroke(&spaint, pGraphState); | 367 PaintStroke(&spaint, pGraphState, skMatrix); |
368 DebugShowSkiaPath(skPath); | |
369 DebugShowCanvasMatrix(m_pCanvas); | |
362 m_pCanvas->drawPath(skPath, spaint); | 370 m_pCanvas->drawPath(skPath, spaint); |
363 } | 371 } |
364 | 372 m_pCanvas->restore(); |
365 return TRUE; | 373 return TRUE; |
366 } | 374 } |
367 | 375 |
368 FX_BOOL CFX_SkiaDeviceDriver::SetPixel(int x, | |
369 int y, | |
370 FX_DWORD color, | |
371 int alpha_flag, | |
372 void* pIccTransform) { | |
373 return m_pAggDriver && | |
374 m_pAggDriver->SetPixel(x, y, color, alpha_flag, pIccTransform); | |
375 } | |
376 | |
377 FX_BOOL CFX_SkiaDeviceDriver::FillRect(const FX_RECT* pRect, | 376 FX_BOOL CFX_SkiaDeviceDriver::FillRect(const FX_RECT* pRect, |
378 FX_DWORD fill_color, | 377 FX_DWORD fill_color, |
379 int alpha_flag, | 378 int alpha_flag, |
380 void* pIccTransform, | 379 void* pIccTransform, |
381 int blend_type) { | 380 int blend_type) { |
382 SkPaint spaint; | 381 SkPaint spaint; |
383 spaint.setAntiAlias(true); | 382 spaint.setAntiAlias(true); |
384 spaint.setColor(fill_color); | 383 spaint.setColor(fill_color); |
385 | 384 |
386 m_pCanvas->drawRect( | 385 m_pCanvas->drawRect( |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
507 m_pCanvas->concat(skMatrix); | 506 m_pCanvas->concat(skMatrix); |
508 const CFX_Matrix& m = *pMatrix; | 507 const CFX_Matrix& m = *pMatrix; |
509 // note that PDF's y-axis goes up; Skia's y-axis goes down | 508 // note that PDF's y-axis goes up; Skia's y-axis goes down |
510 if (landscape) | 509 if (landscape) |
511 skMatrix.setAll(-m.a, -m.b, m.e, m.c, m.d, m.f, 0, 0, 1); | 510 skMatrix.setAll(-m.a, -m.b, m.e, m.c, m.d, m.f, 0, 0, 1); |
512 else | 511 else |
513 skMatrix.setAll(m.a, m.b, 0, -m.c, -m.d, 0, 0, 0, 1); | 512 skMatrix.setAll(m.a, m.b, 0, -m.c, -m.d, 0, 0, 0, 1); |
514 m_pCanvas->concat(skMatrix); | 513 m_pCanvas->concat(skMatrix); |
515 SkPaint paint; | 514 SkPaint paint; |
516 paint.setAntiAlias(true); | 515 paint.setAntiAlias(true); |
517 paint.setFilterQuality(kLow_SkFilterQuality); | 516 paint.setFilterQuality(kHigh_SkFilterQuality); |
518 m_pCanvas->drawBitmap(skBitmap, 0, 0, &paint); | 517 m_pCanvas->drawBitmap(skBitmap, 0, 0, &paint); |
519 m_pCanvas->restore(); | 518 m_pCanvas->restore(); |
520 return TRUE; | 519 return TRUE; |
521 } | 520 } |
522 | 521 |
523 FX_BOOL CFX_SkiaDeviceDriver::ContinueDIBits(void* pHandle, IFX_Pause* pPause) { | 522 FX_BOOL CFX_SkiaDeviceDriver::ContinueDIBits(void* pHandle, IFX_Pause* pPause) { |
524 return m_pAggDriver && m_pAggDriver->ContinueDIBits(pHandle, pPause); | 523 return m_pAggDriver && m_pAggDriver->ContinueDIBits(pHandle, pPause); |
525 } | 524 } |
526 | 525 |
527 void CFX_SkiaDeviceDriver::CancelDIBits(void* pHandle) { | 526 void CFX_SkiaDeviceDriver::CancelDIBits(void* pHandle) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
576 SetDeviceDriver(pDriver); | 575 SetDeviceDriver(pDriver); |
577 return TRUE; | 576 return TRUE; |
578 } | 577 } |
579 | 578 |
580 CFX_SkiaDevice::~CFX_SkiaDevice() { | 579 CFX_SkiaDevice::~CFX_SkiaDevice() { |
581 if (m_bOwnedBitmap && GetBitmap()) | 580 if (m_bOwnedBitmap && GetBitmap()) |
582 delete GetBitmap(); | 581 delete GetBitmap(); |
583 } | 582 } |
584 | 583 |
585 #endif | 584 #endif |
OLD | NEW |