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

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

Issue 1513363002: Remove CFX_AffineMatrix/CPDF_Matrix (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Nits Created 5 years 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/src/fxge/skia/fx_skia_device.h ('k') | core/src/fxge/win32/dwrite_int.h » ('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 "SkDashPathEffect.h" 10 #include "SkDashPathEffect.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 proc(*devPathPtr, rect, blitter); 120 proc(*devPathPtr, rect, blitter);
121 } 121 }
122 122
123 class CSkia_PathData { 123 class CSkia_PathData {
124 public: 124 public:
125 CSkia_PathData() {} 125 CSkia_PathData() {}
126 ~CSkia_PathData() {} 126 ~CSkia_PathData() {}
127 SkPath m_PathData; 127 SkPath m_PathData;
128 128
129 void BuildPath(const CFX_PathData* pPathData, 129 void BuildPath(const CFX_PathData* pPathData,
130 const CFX_AffineMatrix* pObject2Device); 130 const CFX_Matrix* pObject2Device);
131 }; 131 };
132 132
133 void CSkia_PathData::BuildPath(const CFX_PathData* pPathData, 133 void CSkia_PathData::BuildPath(const CFX_PathData* pPathData,
134 const CFX_AffineMatrix* pObject2Device) { 134 const CFX_Matrix* pObject2Device) {
135 const CFX_PathData* pFPath = pPathData; 135 const CFX_PathData* pFPath = pPathData;
136 int nPoints = pFPath->GetPointCount(); 136 int nPoints = pFPath->GetPointCount();
137 FX_PATHPOINT* pPoints = pFPath->GetPoints(); 137 FX_PATHPOINT* pPoints = pFPath->GetPoints();
138 for (int i = 0; i < nPoints; i++) { 138 for (int i = 0; i < nPoints; i++) {
139 FX_FIXFLOAT x = pPoints[i].m_PointX, y = pPoints[i].m_PointY; 139 FX_FIXFLOAT x = pPoints[i].m_PointX, y = pPoints[i].m_PointY;
140 if (pObject2Device) 140 if (pObject2Device)
141 pObject2Device->Transform(x, y); 141 pObject2Device->Transform(x, y);
142 int point_type = pPoints[i].m_Flag & FXPT_TYPE; 142 int point_type = pPoints[i].m_Flag & FXPT_TYPE;
143 if (point_type == FXPT_MOVETO) { 143 if (point_type == FXPT_MOVETO) {
144 m_PathData.moveTo(x, y); 144 m_PathData.moveTo(x, y);
(...skipping 25 matching lines...) Expand all
170 } 170 }
171 if (pPoints[i].m_Flag & FXPT_CLOSEFIGURE) 171 if (pPoints[i].m_Flag & FXPT_CLOSEFIGURE)
172 m_PathData.close(); 172 m_PathData.close();
173 } 173 }
174 } 174 }
175 175
176 // convert a stroking path to scanlines 176 // convert a stroking path to scanlines
177 static void SkRasterizeStroke(SkPaint& spaint, 177 static void SkRasterizeStroke(SkPaint& spaint,
178 SkPath* dstPathData, 178 SkPath* dstPathData,
179 SkPath& path_data, 179 SkPath& path_data,
180 const CFX_AffineMatrix* pObject2Device, 180 const CFX_Matrix* pObject2Device,
181 const CFX_GraphStateData* pGraphState, 181 const CFX_GraphStateData* pGraphState,
182 FX_FIXFLOAT scale = FIX8_ONE, 182 FX_FIXFLOAT scale = FIX8_ONE,
183 FX_BOOL bStrokeAdjust = FALSE, 183 FX_BOOL bStrokeAdjust = FALSE,
184 FX_BOOL bTextMode = FALSE) { 184 FX_BOOL bTextMode = FALSE) {
185 SkPaint::Cap cap; 185 SkPaint::Cap cap;
186 switch (pGraphState->m_LineCap) { 186 switch (pGraphState->m_LineCap) {
187 case CFX_GraphStateData::LineCapRound: 187 case CFX_GraphStateData::LineCapRound:
188 cap = SkPaint::kRound_Cap; 188 cap = SkPaint::kRound_Cap;
189 break; 189 break;
190 case CFX_GraphStateData::LineCapSquare: 190 case CFX_GraphStateData::LineCapSquare:
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 int dither_bits, 262 int dither_bits,
263 FX_BOOL bRgbByteOrder, 263 FX_BOOL bRgbByteOrder,
264 CFX_DIBitmap* pOriDevice, 264 CFX_DIBitmap* pOriDevice,
265 FX_BOOL bGroupKnockout) { 265 FX_BOOL bGroupKnockout) {
266 m_pAggDriver = new CFX_AggDeviceDriver(pBitmap, dither_bits, bRgbByteOrder, 266 m_pAggDriver = new CFX_AggDeviceDriver(pBitmap, dither_bits, bRgbByteOrder,
267 pOriDevice, bGroupKnockout); 267 pOriDevice, bGroupKnockout);
268 } 268 }
269 CFX_SkiaDeviceDriver::~CFX_SkiaDeviceDriver() { 269 CFX_SkiaDeviceDriver::~CFX_SkiaDeviceDriver() {
270 delete m_pAggDriver; 270 delete m_pAggDriver;
271 } 271 }
272 FX_BOOL CFX_SkiaDeviceDriver::DrawDeviceText( 272 FX_BOOL CFX_SkiaDeviceDriver::DrawDeviceText(int nChars,
273 int nChars, 273 const FXTEXT_CHARPOS* pCharPos,
274 const FXTEXT_CHARPOS* pCharPos, 274 CFX_Font* pFont,
275 CFX_Font* pFont, 275 CFX_FontCache* pCache,
276 CFX_FontCache* pCache, 276 const CFX_Matrix* pObject2Device,
277 const CFX_AffineMatrix* pObject2Device, 277 FX_FIXFLOAT font_size,
278 FX_FIXFLOAT font_size, 278 FX_DWORD color,
279 FX_DWORD color, 279 int alpha_flag,
280 int alpha_flag, 280 void* pIccTransform) {
281 void* pIccTransform) {
282 return m_pAggDriver->DrawDeviceText(nChars, pCharPos, pFont, pCache, 281 return m_pAggDriver->DrawDeviceText(nChars, pCharPos, pFont, pCache,
283 pObject2Device, font_size, color, 282 pObject2Device, font_size, color,
284 alpha_flag, pIccTransform); 283 alpha_flag, pIccTransform);
285 } 284 }
286 int CFX_SkiaDeviceDriver::GetDeviceCaps(int caps_id) { 285 int CFX_SkiaDeviceDriver::GetDeviceCaps(int caps_id) {
287 return m_pAggDriver->GetDeviceCaps(caps_id); 286 return m_pAggDriver->GetDeviceCaps(caps_id);
288 } 287 }
289 void CFX_SkiaDeviceDriver::SaveState() { 288 void CFX_SkiaDeviceDriver::SaveState() {
290 m_pAggDriver->SaveState(); 289 m_pAggDriver->SaveState();
291 } 290 }
(...skipping 29 matching lines...) Expand all
321 render.Init(pThisLayer, clip_box.fLeft, clip_box.fTop); 320 render.Init(pThisLayer, clip_box.fLeft, clip_box.fTop);
322 321
323 SkRasterClip rasterClip(clip_box); 322 SkRasterClip rasterClip(clip_box);
324 SuperBlitter_skia::DrawPath(skPath, (SkBlitter*)&render, rasterClip, *spaint); 323 SuperBlitter_skia::DrawPath(skPath, (SkBlitter*)&render, rasterClip, *spaint);
325 324
326 // Finally, we have got the mask that we need, intersect with current clip 325 // Finally, we have got the mask that we need, intersect with current clip
327 // region 326 // region
328 m_pAggDriver->m_pClipRgn->IntersectMaskF(clip_box.fLeft, clip_box.fTop, mask); 327 m_pAggDriver->m_pClipRgn->IntersectMaskF(clip_box.fLeft, clip_box.fTop, mask);
329 } 328 }
330 FX_BOOL CFX_SkiaDeviceDriver::SetClip_PathFill( 329 FX_BOOL CFX_SkiaDeviceDriver::SetClip_PathFill(
331 const CFX_PathData* pPathData, // path info 330 const CFX_PathData* pPathData, // path info
332 const CFX_AffineMatrix* pObject2Device, // optional transformation 331 const CFX_Matrix* pObject2Device, // optional transformation
333 int fill_mode // fill mode, WINDING or ALTERNATE 332 int fill_mode // fill mode, WINDING or ALTERNATE
334 ) { 333 ) {
335 if (m_pAggDriver->m_pClipRgn == NULL) 334 if (m_pAggDriver->m_pClipRgn == NULL)
336 m_pAggDriver->m_pClipRgn = new CFX_ClipRgn( 335 m_pAggDriver->m_pClipRgn = new CFX_ClipRgn(
337 GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT)); 336 GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT));
338 337
339 if (pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) { 338 if (pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) {
340 CFX_FloatRect rectf; 339 CFX_FloatRect rectf;
341 if (pPathData->IsRect(pObject2Device, &rectf)) { 340 if (pPathData->IsRect(pObject2Device, &rectf)) {
342 rectf.Intersect( 341 rectf.Intersect(
343 CFX_FloatRect(0, 0, (FX_FIXFLOAT)GetDeviceCaps(FXDC_PIXEL_WIDTH), 342 CFX_FloatRect(0, 0, (FX_FIXFLOAT)GetDeviceCaps(FXDC_PIXEL_WIDTH),
(...skipping 14 matching lines...) Expand all
358 spaint.setColor(0xffffffff); 357 spaint.setColor(0xffffffff);
359 spaint.setAntiAlias(TRUE); 358 spaint.setAntiAlias(TRUE);
360 spaint.setStyle(SkPaint::kFill_Style); 359 spaint.setStyle(SkPaint::kFill_Style);
361 360
362 SetClipMask(path_data.m_PathData, &spaint); 361 SetClipMask(path_data.m_PathData, &spaint);
363 362
364 return TRUE; 363 return TRUE;
365 } 364 }
366 365
367 FX_BOOL CFX_SkiaDeviceDriver::SetClip_PathStroke( 366 FX_BOOL CFX_SkiaDeviceDriver::SetClip_PathStroke(
368 const CFX_PathData* pPathData, // path info 367 const CFX_PathData* pPathData, // path info
369 const CFX_AffineMatrix* pObject2Device, // optional transformation 368 const CFX_Matrix* pObject2Device, // optional transformation
370 const CFX_GraphStateData* pGraphState // graphic state, for pen attributes 369 const CFX_GraphStateData* pGraphState // graphic state, for pen attributes
371 ) { 370 ) {
372 if (m_pAggDriver->m_pClipRgn == NULL) 371 if (m_pAggDriver->m_pClipRgn == NULL)
373 m_pAggDriver->m_pClipRgn = new CFX_ClipRgn( 372 m_pAggDriver->m_pClipRgn = new CFX_ClipRgn(
374 GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT)); 373 GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT));
375 374
376 // build path data 375 // build path data
377 CSkia_PathData path_data; 376 CSkia_PathData path_data;
378 path_data.BuildPath(pPathData, NULL); 377 path_data.BuildPath(pPathData, NULL);
379 path_data.m_PathData.setFillType(SkPath::kWinding_FillType); 378 path_data.m_PathData.setFillType(SkPath::kWinding_FillType);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 return FALSE; 417 return FALSE;
419 418
420 SkRasterClip rasterClip(rect); 419 SkRasterClip rasterClip(rect);
421 SuperBlitter_skia::DrawPath(skPath, (SkBlitter*)&render, rasterClip, 420 SuperBlitter_skia::DrawPath(skPath, (SkBlitter*)&render, rasterClip,
422 origPaint); 421 origPaint);
423 422
424 return TRUE; 423 return TRUE;
425 } 424 }
426 425
427 FX_BOOL CFX_SkiaDeviceDriver::DrawPath( 426 FX_BOOL CFX_SkiaDeviceDriver::DrawPath(
428 const CFX_PathData* pPathData, // path info 427 const CFX_PathData* pPathData, // path info
429 const CFX_AffineMatrix* pObject2Device, // optional transformation 428 const CFX_Matrix* pObject2Device, // optional transformation
430 const CFX_GraphStateData* pGraphState, // graphic state, for pen attributes 429 const CFX_GraphStateData* pGraphState, // graphic state, for pen attributes
431 FX_DWORD fill_color, // fill color 430 FX_DWORD fill_color, // fill color
432 FX_DWORD stroke_color, // stroke color 431 FX_DWORD stroke_color, // stroke color
433 int fill_mode, // fill mode, WINDING or ALTERNATE. 0 for not filled 432 int fill_mode, // fill mode, WINDING or ALTERNATE. 0 for not filled
434 int alpha_flag, 433 int alpha_flag,
435 void* pIccTransform) { 434 void* pIccTransform) {
436 if (GetBuffer() == NULL) 435 if (GetBuffer() == NULL)
437 return TRUE; 436 return TRUE;
438 FOXIT_DEBUG1("CFX_SkiaDeviceDriver::DrawPath: entering"); 437 FOXIT_DEBUG1("CFX_SkiaDeviceDriver::DrawPath: entering");
439 SkIRect rect; 438 SkIRect rect;
(...skipping 25 matching lines...) Expand all
465 int stroke_alpha = FXGETFLAG_COLORTYPE(alpha_flag) 464 int stroke_alpha = FXGETFLAG_COLORTYPE(alpha_flag)
466 ? FXGETFLAG_ALPHA_STROKE(alpha_flag) 465 ? FXGETFLAG_ALPHA_STROKE(alpha_flag)
467 : FXARGB_A(stroke_color); 466 : FXARGB_A(stroke_color);
468 467
469 if (pGraphState && stroke_alpha) { 468 if (pGraphState && stroke_alpha) {
470 // We split the matrix into two parts: first part doing the scaling, so we 469 // We split the matrix into two parts: first part doing the scaling, so we
471 // won't have the 470 // won't have the
472 // flatness problem, second part doing the transformation, so we don't have 471 // flatness problem, second part doing the transformation, so we don't have
473 // stroking geo problem. 472 // stroking geo problem.
474 // TESTDOC: Bug #5253 - test[1].pdf 473 // TESTDOC: Bug #5253 - test[1].pdf
475 CFX_AffineMatrix matrix1, matrix2; 474 CFX_Matrix matrix1, matrix2;
476 if (pObject2Device) { 475 if (pObject2Device) {
477 matrix1.a = FXSYS_fabs(pObject2Device->a) > FXSYS_fabs(pObject2Device->b) 476 matrix1.a = FXSYS_fabs(pObject2Device->a) > FXSYS_fabs(pObject2Device->b)
478 ? FXSYS_fabs(pObject2Device->a) 477 ? FXSYS_fabs(pObject2Device->a)
479 : FXSYS_fabs(pObject2Device->b); 478 : FXSYS_fabs(pObject2Device->b);
480 matrix1.d = matrix1.a; // FXSYS_fabs(pObject2Device->c) > 479 matrix1.d = matrix1.a; // FXSYS_fabs(pObject2Device->c) >
481 // FXSYS_fabs(pObject2Device->d) ? 480 // FXSYS_fabs(pObject2Device->d) ?
482 // pObject2Device->c : pObject2Device->d; 481 // pObject2Device->c : pObject2Device->d;
483 matrix2.Set(pObject2Device->a / matrix1.a, pObject2Device->b / matrix1.a, 482 matrix2.Set(pObject2Device->a / matrix1.a, pObject2Device->b / matrix1.a,
484 pObject2Device->c / matrix1.d, pObject2Device->d / matrix1.d, 483 pObject2Device->c / matrix1.d, pObject2Device->d / matrix1.d,
485 pObject2Device->e, pObject2Device->f); 484 pObject2Device->e, pObject2Device->f);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 int alpha_flag, 558 int alpha_flag,
560 void* pIccTransform) { 559 void* pIccTransform) {
561 return m_pAggDriver->StretchDIBits(pSource, argb, dest_left, dest_top, 560 return m_pAggDriver->StretchDIBits(pSource, argb, dest_left, dest_top,
562 dest_width, dest_height, pClipRect, flags, 561 dest_width, dest_height, pClipRect, flags,
563 alpha_flag, pIccTransform); 562 alpha_flag, pIccTransform);
564 } 563 }
565 564
566 FX_BOOL CFX_SkiaDeviceDriver::StartDIBits(const CFX_DIBSource* pSource, 565 FX_BOOL CFX_SkiaDeviceDriver::StartDIBits(const CFX_DIBSource* pSource,
567 int bitmap_alpha, 566 int bitmap_alpha,
568 FX_DWORD argb, 567 FX_DWORD argb,
569 const CFX_AffineMatrix* pMatrix, 568 const CFX_Matrix* pMatrix,
570 FX_DWORD render_flags, 569 FX_DWORD render_flags,
571 void*& handle, 570 void*& handle,
572 int alpha_flag, 571 int alpha_flag,
573 void* pIccTransform) { 572 void* pIccTransform) {
574 return m_pAggDriver->StartDIBits(pSource, bitmap_alpha, argb, pMatrix, 573 return m_pAggDriver->StartDIBits(pSource, bitmap_alpha, argb, pMatrix,
575 render_flags, handle, alpha_flag, 574 render_flags, handle, alpha_flag,
576 pIccTransform); 575 pIccTransform);
577 } 576 }
578 577
579 FX_BOOL CFX_SkiaDeviceDriver::ContinueDIBits(void* pHandle, IFX_Pause* pPause) { 578 FX_BOOL CFX_SkiaDeviceDriver::ContinueDIBits(void* pHandle, IFX_Pause* pPause) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 new CFX_SkiaDeviceDriver(pBitmap, dither_bits, FALSE, pOriDevice, FALSE); 617 new CFX_SkiaDeviceDriver(pBitmap, dither_bits, FALSE, pOriDevice, FALSE);
619 SetDeviceDriver(pDriver); 618 SetDeviceDriver(pDriver);
620 return TRUE; 619 return TRUE;
621 } 620 }
622 CFX_SkiaDevice::~CFX_SkiaDevice() { 621 CFX_SkiaDevice::~CFX_SkiaDevice() {
623 if (m_bOwnedBitmap && GetBitmap()) 622 if (m_bOwnedBitmap && GetBitmap())
624 delete GetBitmap(); 623 delete GetBitmap();
625 } 624 }
626 625
627 #endif 626 #endif
OLDNEW
« no previous file with comments | « core/src/fxge/skia/fx_skia_device.h ('k') | core/src/fxge/win32/dwrite_int.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698