Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(632)

Side by Side Diff: core/fxge/skia/fx_skia_device.cpp

Issue 1812263002: fix windows build; add blend modes (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: address comments Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fxge/skia/fx_skia_device.h ('k') | skia/skia_library.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "core/fxge/skia/fx_skia_device.h" 11 #include "core/fxge/skia/fx_skia_device.h"
12 12
13 #include "third_party/skia/include/core/SkCanvas.h" 13 #include "third_party/skia/include/core/SkCanvas.h"
14 #include "third_party/skia/include/core/SkColorPriv.h" 14 #include "third_party/skia/include/core/SkColorPriv.h"
15 #include "third_party/skia/include/core/SkPaint.h" 15 #include "third_party/skia/include/core/SkPaint.h"
16 #include "third_party/skia/include/core/SkPath.h" 16 #include "third_party/skia/include/core/SkPath.h"
17 #include "third_party/skia/include/core/SkPictureRecorder.h" 17 #include "third_party/skia/include/core/SkPictureRecorder.h"
18 #include "third_party/skia/include/core/SkStream.h" 18 #include "third_party/skia/include/core/SkStream.h"
19 #include "third_party/skia/include/core/SkTypeface.h" 19 #include "third_party/skia/include/core/SkTypeface.h"
20 #include "third_party/skia/include/effects/SkDashPathEffect.h" 20 #include "third_party/skia/include/effects/SkDashPathEffect.h"
21 21
22 namespace {
23
22 #define SHOW_SKIA_PATH 0 // set to 1 to print the path contents 24 #define SHOW_SKIA_PATH 0 // set to 1 to print the path contents
23 #define DRAW_SKIA_CLIP 0 // set to 1 to draw a green rectangle around the clip 25 #define DRAW_SKIA_CLIP 0 // set to 1 to draw a green rectangle around the clip
24 26
25 static void DebugShowSkiaPath(const SkPath& path) { 27 void DebugShowSkiaPath(const SkPath& path) {
26 #if SHOW_SKIA_PATH 28 #if SHOW_SKIA_PATH
27 char buffer[4096]; 29 char buffer[4096];
28 sk_bzero(buffer, sizeof(buffer)); 30 sk_bzero(buffer, sizeof(buffer));
29 SkMemoryWStream stream(buffer, sizeof(buffer)); 31 SkMemoryWStream stream(buffer, sizeof(buffer));
30 path.dump(&stream, false, false); 32 path.dump(&stream, false, false);
31 printf("%s\n", buffer); 33 printf("%s\n", buffer);
32 #endif // SHOW_SKIA_PATH 34 #endif // SHOW_SKIA_PATH
33 } 35 }
34 36
35 static void DebugShowCanvasMatrix(const SkCanvas* canvas) { 37 void DebugShowCanvasMatrix(const SkCanvas* canvas) {
36 #if SHOW_SKIA_PATH 38 #if SHOW_SKIA_PATH
37 SkMatrix matrix = canvas->getTotalMatrix(); 39 SkMatrix matrix = canvas->getTotalMatrix();
38 SkScalar m[9]; 40 SkScalar m[9];
39 matrix.get9(m); 41 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], 42 printf("(%g,%g,%g) (%g,%g,%g) (%g,%g,%g)\n", m[0], m[1], m[2], m[3], m[4],
41 m[7], m[8]); 43 m[5], m[6], m[7], m[8]);
42 #endif // SHOW_SKIA_PATH 44 #endif // SHOW_SKIA_PATH
43 } 45 }
44 46
45 #if DRAW_SKIA_CLIP 47 #if DRAW_SKIA_CLIP
46 48
47 static SkPaint DebugClipPaint() { 49 SkPaint DebugClipPaint() {
48 SkPaint paint; 50 SkPaint paint;
49 paint.setAntiAlias(true); 51 paint.setAntiAlias(true);
50 paint.setColor(SK_ColorGREEN); 52 paint.setColor(SK_ColorGREEN);
51 paint.setStyle(SkPaint::kStroke_Style); 53 paint.setStyle(SkPaint::kStroke_Style);
52 return paint; 54 return paint;
53 } 55 }
54 56
55 static void DebugDrawSkiaClipRect(SkCanvas* canvas, const SkRect& rect) { 57 void DebugDrawSkiaClipRect(SkCanvas* canvas, const SkRect& rect) {
56 SkPaint paint = DebugClipPaint(); 58 SkPaint paint = DebugClipPaint();
57 canvas->drawRect(rect, paint); 59 canvas->drawRect(rect, paint);
58 } 60 }
59 61
60 static void DebugDrawSkiaClipPath(SkCanvas* canvas, const SkPath& path) { 62 void DebugDrawSkiaClipPath(SkCanvas* canvas, const SkPath& path) {
61 SkPaint paint = DebugClipPaint(); 63 SkPaint paint = DebugClipPaint();
62 canvas->drawPath(path, paint); 64 canvas->drawPath(path, paint);
63 } 65 }
64 66
65 #else // DRAW_SKIA_CLIP 67 #else // DRAW_SKIA_CLIP
66 68
67 static void DebugDrawSkiaClipRect(SkCanvas* canvas, const SkRect& rect) {} 69 void DebugDrawSkiaClipRect(SkCanvas* canvas, const SkRect& rect) {}
68 static void DebugDrawSkiaClipPath(SkCanvas* canvas, const SkPath& path) {} 70 void DebugDrawSkiaClipPath(SkCanvas* canvas, const SkPath& path) {}
69 71
70 #endif // DRAW_SKIA_CLIP 72 #endif // DRAW_SKIA_CLIP
71 73
72 #undef SHOW_SKIA_PATH 74 #undef SHOW_SKIA_PATH
73 #undef DRAW_SKIA_CLIP 75 #undef DRAW_SKIA_CLIP
74 76
75 static SkPath BuildPath(const CFX_PathData* pPathData) { 77 SkPath BuildPath(const CFX_PathData* pPathData) {
76 SkPath skPath; 78 SkPath skPath;
77 const CFX_PathData* pFPath = pPathData; 79 const CFX_PathData* pFPath = pPathData;
78 int nPoints = pFPath->GetPointCount(); 80 int nPoints = pFPath->GetPointCount();
79 FX_PATHPOINT* pPoints = pFPath->GetPoints(); 81 FX_PATHPOINT* pPoints = pFPath->GetPoints();
80 for (int i = 0; i < nPoints; i++) { 82 for (int i = 0; i < nPoints; i++) {
81 FX_FLOAT x = pPoints[i].m_PointX; 83 FX_FLOAT x = pPoints[i].m_PointX;
82 FX_FLOAT y = pPoints[i].m_PointY; 84 FX_FLOAT y = pPoints[i].m_PointY;
83 int point_type = pPoints[i].m_Flag & FXPT_TYPE; 85 int point_type = pPoints[i].m_Flag & FXPT_TYPE;
84 if (point_type == FXPT_MOVETO) { 86 if (point_type == FXPT_MOVETO) {
85 skPath.moveTo(x, y); 87 skPath.moveTo(x, y);
86 } else if (point_type == FXPT_LINETO) { 88 } else if (point_type == FXPT_LINETO) {
87 skPath.lineTo(x, y); 89 skPath.lineTo(x, y);
88 } else if (point_type == FXPT_BEZIERTO) { 90 } else if (point_type == FXPT_BEZIERTO) {
89 FX_FLOAT x2 = pPoints[i + 1].m_PointX, y2 = pPoints[i + 1].m_PointY; 91 FX_FLOAT x2 = pPoints[i + 1].m_PointX, y2 = pPoints[i + 1].m_PointY;
90 FX_FLOAT x3 = pPoints[i + 2].m_PointX, y3 = pPoints[i + 2].m_PointY; 92 FX_FLOAT x3 = pPoints[i + 2].m_PointX, y3 = pPoints[i + 2].m_PointY;
91 skPath.cubicTo(x, y, x2, y2, x3, y3); 93 skPath.cubicTo(x, y, x2, y2, x3, y3);
92 i += 2; 94 i += 2;
93 } 95 }
94 if (pPoints[i].m_Flag & FXPT_CLOSEFIGURE) 96 if (pPoints[i].m_Flag & FXPT_CLOSEFIGURE)
95 skPath.close(); 97 skPath.close();
96 } 98 }
97 return skPath; 99 return skPath;
98 } 100 }
99 101
102 SkMatrix ToSkMatrix(const CFX_Matrix& m) {
103 SkMatrix skMatrix;
104 skMatrix.setAll(m.a, m.b, m.e, m.c, m.d, m.f, 0, 0, 1);
105 return skMatrix;
106 }
107
108 // use when pdf's y-axis points up insead of down
109 SkMatrix ToFlippedSkMatrix(const CFX_Matrix& m) {
110 SkMatrix skMatrix;
111 skMatrix.setAll(m.a, m.b, m.e, -m.c, -m.d, m.f, 0, 0, 1);
112 return skMatrix;
113 }
114
115 SkXfermode::Mode GetSkiaBlendMode(int blend_type) {
116 switch (blend_type) {
117 case FXDIB_BLEND_MULTIPLY:
118 return SkXfermode::kMultiply_Mode;
119 case FXDIB_BLEND_SCREEN:
120 return SkXfermode::kScreen_Mode;
121 case FXDIB_BLEND_OVERLAY:
122 return SkXfermode::kOverlay_Mode;
123 case FXDIB_BLEND_DARKEN:
124 return SkXfermode::kDarken_Mode;
125 case FXDIB_BLEND_LIGHTEN:
126 return SkXfermode::kLighten_Mode;
127 case FXDIB_BLEND_COLORDODGE:
128 return SkXfermode::kColorDodge_Mode;
129 case FXDIB_BLEND_COLORBURN:
130 return SkXfermode::kColorBurn_Mode;
131 case FXDIB_BLEND_HARDLIGHT:
132 return SkXfermode::kHardLight_Mode;
133 case FXDIB_BLEND_SOFTLIGHT:
134 return SkXfermode::kSoftLight_Mode;
135 case FXDIB_BLEND_DIFFERENCE:
136 return SkXfermode::kDifference_Mode;
137 case FXDIB_BLEND_EXCLUSION:
138 return SkXfermode::kExclusion_Mode;
139 case FXDIB_BLEND_HUE:
140 return SkXfermode::kHue_Mode;
141 case FXDIB_BLEND_SATURATION:
142 return SkXfermode::kSaturation_Mode;
143 case FXDIB_BLEND_COLOR:
144 return SkXfermode::kColor_Mode;
145 case FXDIB_BLEND_LUMINOSITY:
146 return SkXfermode::kLuminosity_Mode;
147 case FXDIB_BLEND_NORMAL:
148 default:
149 return SkXfermode::kSrcOver_Mode;
150 }
151 }
152
153 } // namespace
154
100 // convert a stroking path to scanlines 155 // convert a stroking path to scanlines
101 void CFX_SkiaDeviceDriver::PaintStroke(SkPaint* spaint, 156 void CFX_SkiaDeviceDriver::PaintStroke(SkPaint* spaint,
102 const CFX_GraphStateData* pGraphState, 157 const CFX_GraphStateData* pGraphState,
103 const SkMatrix& matrix) { 158 const SkMatrix& matrix) {
104 SkPaint::Cap cap; 159 SkPaint::Cap cap;
105 switch (pGraphState->m_LineCap) { 160 switch (pGraphState->m_LineCap) {
106 case CFX_GraphStateData::LineCapRound: 161 case CFX_GraphStateData::LineCapRound:
107 cap = SkPaint::kRound_Cap; 162 cap = SkPaint::kRound_Cap;
108 break; 163 break;
109 case CFX_GraphStateData::LineCapSquare: 164 case CFX_GraphStateData::LineCapSquare:
(...skipping 15 matching lines...) Expand all
125 join = SkPaint::kMiter_Join; 180 join = SkPaint::kMiter_Join;
126 break; 181 break;
127 } 182 }
128 SkMatrix inverse; 183 SkMatrix inverse;
129 if (!matrix.invert(&inverse)) 184 if (!matrix.invert(&inverse))
130 return; // give up if the matrix is degenerate, and not invertable 185 return; // give up if the matrix is degenerate, and not invertable
131 inverse.set(SkMatrix::kMTransX, 0); 186 inverse.set(SkMatrix::kMTransX, 0);
132 inverse.set(SkMatrix::kMTransY, 0); 187 inverse.set(SkMatrix::kMTransY, 0);
133 SkVector deviceUnits[2] = {{0, 1}, {1, 0}}; 188 SkVector deviceUnits[2] = {{0, 1}, {1, 0}};
134 inverse.mapPoints(deviceUnits, SK_ARRAY_COUNT(deviceUnits)); 189 inverse.mapPoints(deviceUnits, SK_ARRAY_COUNT(deviceUnits));
135 FX_FLOAT width = SkTMax(pGraphState->m_LineWidth, 190 FX_FLOAT width =
136 SkTMin(deviceUnits[0].length(), deviceUnits[1].length( ))); 191 SkTMax(pGraphState->m_LineWidth,
192 SkTMin(deviceUnits[0].length(), deviceUnits[1].length()));
137 if (pGraphState->m_DashArray) { 193 if (pGraphState->m_DashArray) {
138 int count = (pGraphState->m_DashCount + 1) / 2; 194 int count = (pGraphState->m_DashCount + 1) / 2;
139 SkScalar* intervals = FX_Alloc2D(SkScalar, count, sizeof(SkScalar)); 195 SkScalar* intervals = FX_Alloc2D(SkScalar, count, sizeof(SkScalar));
140 // Set dash pattern 196 // Set dash pattern
141 for (int i = 0; i < count; i++) { 197 for (int i = 0; i < count; i++) {
142 FX_FLOAT on = pGraphState->m_DashArray[i * 2]; 198 FX_FLOAT on = pGraphState->m_DashArray[i * 2];
143 if (on <= 0.000001f) 199 if (on <= 0.000001f)
144 on = 1.f / 10; 200 on = 1.f / 10;
145 FX_FLOAT off = i * 2 + 1 == pGraphState->m_DashCount 201 FX_FLOAT off = i * 2 + 1 == pGraphState->m_DashCount
146 ? on 202 ? on
147 : pGraphState->m_DashArray[i * 2 + 1]; 203 : pGraphState->m_DashArray[i * 2 + 1];
148 if (off < 0) 204 if (off < 0)
149 off = 0; 205 off = 0;
150 intervals[i * 2] = on; 206 intervals[i * 2] = on;
151 intervals[i * 2 + 1] = off; 207 intervals[i * 2 + 1] = off;
152 } 208 }
153 spaint->setPathEffect(SkDashPathEffect::Create(intervals, count * 2, 209 spaint->setPathEffect(
154 pGraphState->m_DashPhase)) 210 SkDashPathEffect::Make(intervals, count * 2, pGraphState->m_DashPhase));
155 ->unref();
156 } 211 }
157 spaint->setStyle(SkPaint::kStroke_Style); 212 spaint->setStyle(SkPaint::kStroke_Style);
158 spaint->setAntiAlias(true); 213 spaint->setAntiAlias(true);
159 spaint->setStrokeWidth(width); 214 spaint->setStrokeWidth(width);
160 spaint->setStrokeMiter(pGraphState->m_MiterLimit); 215 spaint->setStrokeMiter(pGraphState->m_MiterLimit);
161 spaint->setStrokeCap(cap); 216 spaint->setStrokeCap(cap);
162 spaint->setStrokeJoin(join); 217 spaint->setStrokeJoin(join);
163 } 218 }
164 219
165 CFX_SkiaDeviceDriver::CFX_SkiaDeviceDriver(CFX_DIBitmap* pBitmap, 220 CFX_SkiaDeviceDriver::CFX_SkiaDeviceDriver(CFX_DIBitmap* pBitmap,
(...skipping 30 matching lines...) Expand all
196 m_pCanvas = m_pRecorder->getRecordingCanvas(); 251 m_pCanvas = m_pRecorder->getRecordingCanvas();
197 m_ditherBits = 0; 252 m_ditherBits = 0;
198 } 253 }
199 254
200 CFX_SkiaDeviceDriver::~CFX_SkiaDeviceDriver() { 255 CFX_SkiaDeviceDriver::~CFX_SkiaDeviceDriver() {
201 if (!m_pRecorder) 256 if (!m_pRecorder)
202 delete m_pCanvas; 257 delete m_pCanvas;
203 delete m_pAggDriver; 258 delete m_pAggDriver;
204 } 259 }
205 260
206 static SkMatrix ToSkMatrix(const CFX_Matrix& m) {
207 SkMatrix skMatrix;
208 skMatrix.setAll(m.a, m.b, m.e, m.c, m.d, m.f, 0, 0, 1);
209 return skMatrix;
210 }
211
212 // use when pdf's y-axis points up insead of down
213 static SkMatrix ToFlippedSkMatrix(const CFX_Matrix& m) {
214 SkMatrix skMatrix;
215 skMatrix.setAll(m.a, m.b, m.e, -m.c, -m.d, m.f, 0, 0, 1);
216 return skMatrix;
217 }
218
219 FX_BOOL CFX_SkiaDeviceDriver::DrawDeviceText(int nChars, 261 FX_BOOL CFX_SkiaDeviceDriver::DrawDeviceText(int nChars,
220 const FXTEXT_CHARPOS* pCharPos, 262 const FXTEXT_CHARPOS* pCharPos,
221 CFX_Font* pFont, 263 CFX_Font* pFont,
222 CFX_FontCache* pCache, 264 CFX_FontCache* pCache,
223 const CFX_Matrix* pObject2Device, 265 const CFX_Matrix* pObject2Device,
224 FX_FLOAT font_size, 266 FX_FLOAT font_size,
225 FX_DWORD color, 267 FX_DWORD color,
226 int alpha_flag, 268 int alpha_flag,
227 void* pIccTransform) { 269 void* pIccTransform) {
228 SkAutoTUnref<SkTypeface> typeface(SkTypeface::CreateFromStream( 270 SkAutoTUnref<SkTypeface> typeface(SkTypeface::CreateFromStream(
229 new SkMemoryStream(pFont->GetFontData(), pFont->GetSize()))); 271 new SkMemoryStream(pFont->GetFontData(), pFont->GetSize())));
230 SkPaint paint; 272 SkPaint paint;
231 paint.setAntiAlias(true); 273 paint.setAntiAlias(true);
232 paint.setColor(color); 274 paint.setColor(color);
233 paint.setTypeface(typeface); 275 paint.setTypeface(typeface);
234 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); 276 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
235 paint.setTextSize(font_size); 277 paint.setTextSize(font_size);
278 paint.setSubpixelText(true);
236 m_pCanvas->save(); 279 m_pCanvas->save();
237 SkMatrix skMatrix = ToFlippedSkMatrix(*pObject2Device); 280 SkMatrix skMatrix = ToFlippedSkMatrix(*pObject2Device);
238 m_pCanvas->concat(skMatrix); 281 m_pCanvas->concat(skMatrix);
239 for (int index = 0; index < nChars; ++index) { 282 for (int index = 0; index < nChars; ++index) {
240 const FXTEXT_CHARPOS& cp = pCharPos[index]; 283 const FXTEXT_CHARPOS& cp = pCharPos[index];
241 uint16_t glyph = (uint16_t)cp.m_GlyphIndex; 284 uint16_t glyph = (uint16_t)cp.m_GlyphIndex;
242 m_pCanvas->drawText(&glyph, 2, cp.m_OriginX, cp.m_OriginY, paint); 285 m_pCanvas->drawText(&glyph, 2, cp.m_OriginX, cp.m_OriginY, paint);
243 } 286 }
244 m_pCanvas->restore(); 287 m_pCanvas->restore();
245 return TRUE; 288 return TRUE;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 int fill_mode, // fill mode, WINDING or ALTERNATE. 0 for not filled 381 int fill_mode, // fill mode, WINDING or ALTERNATE. 0 for not filled
339 int alpha_flag, 382 int alpha_flag,
340 void* pIccTransform, 383 void* pIccTransform,
341 int blend_type) { 384 int blend_type) {
342 SkIRect rect; 385 SkIRect rect;
343 rect.set(0, 0, GetDeviceCaps(FXDC_PIXEL_WIDTH), 386 rect.set(0, 0, GetDeviceCaps(FXDC_PIXEL_WIDTH),
344 GetDeviceCaps(FXDC_PIXEL_HEIGHT)); 387 GetDeviceCaps(FXDC_PIXEL_HEIGHT));
345 SkPath skPath = BuildPath(pPathData); 388 SkPath skPath = BuildPath(pPathData);
346 SkPaint spaint; 389 SkPaint spaint;
347 spaint.setAntiAlias(true); 390 spaint.setAntiAlias(true);
391 spaint.setXfermodeMode(GetSkiaBlendMode(blend_type));
348 m_pCanvas->save(); 392 m_pCanvas->save();
349 SkMatrix skMatrix = ToSkMatrix(*pObject2Device); 393 SkMatrix skMatrix = ToSkMatrix(*pObject2Device);
350 m_pCanvas->concat(skMatrix); 394 m_pCanvas->concat(skMatrix);
351 if ((fill_mode & 3) && fill_color) { 395 if ((fill_mode & 3) && fill_color) {
352 skPath.setFillType((fill_mode & 3) == FXFILL_WINDING 396 skPath.setFillType((fill_mode & 3) == FXFILL_WINDING
353 ? SkPath::kWinding_FillType 397 ? SkPath::kWinding_FillType
354 : SkPath::kEvenOdd_FillType); 398 : SkPath::kEvenOdd_FillType);
355 399
356 spaint.setStyle(SkPaint::kFill_Style); 400 spaint.setStyle(SkPaint::kFill_Style);
357 spaint.setColor(fill_color); 401 spaint.setColor(fill_color);
(...skipping 15 matching lines...) Expand all
373 } 417 }
374 418
375 FX_BOOL CFX_SkiaDeviceDriver::FillRect(const FX_RECT* pRect, 419 FX_BOOL CFX_SkiaDeviceDriver::FillRect(const FX_RECT* pRect,
376 FX_DWORD fill_color, 420 FX_DWORD fill_color,
377 int alpha_flag, 421 int alpha_flag,
378 void* pIccTransform, 422 void* pIccTransform,
379 int blend_type) { 423 int blend_type) {
380 SkPaint spaint; 424 SkPaint spaint;
381 spaint.setAntiAlias(true); 425 spaint.setAntiAlias(true);
382 spaint.setColor(fill_color); 426 spaint.setColor(fill_color);
427 spaint.setXfermodeMode(GetSkiaBlendMode(blend_type));
383 428
384 m_pCanvas->drawRect( 429 m_pCanvas->drawRect(
385 SkRect::MakeLTRB(pRect->left, pRect->top, pRect->right, pRect->bottom), 430 SkRect::MakeLTRB(pRect->left, pRect->top, pRect->right, pRect->bottom),
386 spaint); 431 spaint);
387 return TRUE; 432 return TRUE;
388 } 433 }
389 434
390 FX_BOOL CFX_SkiaDeviceDriver::GetClipBox(FX_RECT* pRect) { 435 FX_BOOL CFX_SkiaDeviceDriver::GetClipBox(FX_RECT* pRect) {
391 // TODO(caryclark) call m_canvas->getClipDeviceBounds() instead 436 // TODO(caryclark) call m_canvas->getClipDeviceBounds() instead
392 pRect->left = 0; 437 pRect->left = 0;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 const CFX_Matrix& m = *pMatrix; 551 const CFX_Matrix& m = *pMatrix;
507 // note that PDF's y-axis goes up; Skia's y-axis goes down 552 // note that PDF's y-axis goes up; Skia's y-axis goes down
508 if (landscape) 553 if (landscape)
509 skMatrix.setAll(-m.a, -m.b, m.e, m.c, m.d, m.f, 0, 0, 1); 554 skMatrix.setAll(-m.a, -m.b, m.e, m.c, m.d, m.f, 0, 0, 1);
510 else 555 else
511 skMatrix.setAll(m.a, m.b, 0, -m.c, -m.d, 0, 0, 0, 1); 556 skMatrix.setAll(m.a, m.b, 0, -m.c, -m.d, 0, 0, 0, 1);
512 m_pCanvas->concat(skMatrix); 557 m_pCanvas->concat(skMatrix);
513 SkPaint paint; 558 SkPaint paint;
514 paint.setAntiAlias(true); 559 paint.setAntiAlias(true);
515 paint.setFilterQuality(kHigh_SkFilterQuality); 560 paint.setFilterQuality(kHigh_SkFilterQuality);
561 paint.setXfermodeMode(GetSkiaBlendMode(blend_type));
562 paint.setAlpha(bitmap_alpha);
516 m_pCanvas->drawBitmap(skBitmap, 0, 0, &paint); 563 m_pCanvas->drawBitmap(skBitmap, 0, 0, &paint);
517 m_pCanvas->restore(); 564 m_pCanvas->restore();
518 return TRUE; 565 return TRUE;
519 } 566 }
520 567
521 FX_BOOL CFX_SkiaDeviceDriver::ContinueDIBits(void* pHandle, IFX_Pause* pPause) { 568 FX_BOOL CFX_SkiaDeviceDriver::ContinueDIBits(void* pHandle, IFX_Pause* pPause) {
522 return m_pAggDriver && m_pAggDriver->ContinueDIBits(pHandle, pPause); 569 return m_pAggDriver && m_pAggDriver->ContinueDIBits(pHandle, pPause);
523 } 570 }
524 571
525 void CFX_SkiaDeviceDriver::CancelDIBits(void* pHandle) { 572 void CFX_SkiaDeviceDriver::CancelDIBits(void* pHandle) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 SetDeviceDriver(pDriver); 621 SetDeviceDriver(pDriver);
575 return TRUE; 622 return TRUE;
576 } 623 }
577 624
578 CFX_SkiaDevice::~CFX_SkiaDevice() { 625 CFX_SkiaDevice::~CFX_SkiaDevice() {
579 if (m_bOwnedBitmap && GetBitmap()) 626 if (m_bOwnedBitmap && GetBitmap())
580 delete GetBitmap(); 627 delete GetBitmap();
581 } 628 }
582 629
583 #endif 630 #endif
OLDNEW
« no previous file with comments | « core/fxge/skia/fx_skia_device.h ('k') | skia/skia_library.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698