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

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

Issue 2384283002: update skia to latest sources (Closed)
Patch Set: merge with tot Created 4 years, 2 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 | « DEPS ('k') | skia/BUILD.gn » ('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 #if defined(_SKIA_SUPPORT_) 5 #if defined(_SKIA_SUPPORT_)
6 #include <algorithm> 6 #include <algorithm>
7 #include <vector> 7 #include <vector>
8 8
9 #include "core/fxcodec/fx_codec.h" 9 #include "core/fxcodec/fx_codec.h"
10 #include "core/fxcrt/fx_memory.h" 10 #include "core/fxcrt/fx_memory.h"
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 if (m_commands[index] == Clip::kSave) 720 if (m_commands[index] == Clip::kSave)
721 pDriver->SkiaCanvas()->restore(); 721 pDriver->SkiaCanvas()->restore();
722 } 722 }
723 723
724 if (m_commandIndex > 0) 724 if (m_commandIndex > 0)
725 pDriver->SkiaCanvas()->save(); 725 pDriver->SkiaCanvas()->save();
726 while (index > 0 && m_commands[index] != Clip::kSave) 726 while (index > 0 && m_commands[index] != Clip::kSave)
727 --index; 727 --index;
728 while (++index < m_commandIndex) { 728 while (++index < m_commandIndex) {
729 SkASSERT(m_commands[index] == Clip::kPath); 729 SkASSERT(m_commands[index] == Clip::kPath);
730 pDriver->SkiaCanvas()->clipPath(m_clips[index], SkRegion::kIntersect_Op, 730 pDriver->SkiaCanvas()->clipPath(m_clips[index], SkCanvas::kIntersect_Op,
731 true); 731 true);
732 } 732 }
733 m_commands.setCount(m_commandIndex); 733 m_commands.setCount(m_commandIndex);
734 m_clips.resize_back(m_commandIndex); 734 m_clips.resize_back(m_commandIndex);
735 } 735 }
736 736
737 // returns true if caller should apply command to skia canvas 737 // returns true if caller should apply command to skia canvas
738 bool ClipSave(CFX_SkiaDeviceDriver* pDriver) { 738 bool ClipSave(CFX_SkiaDeviceDriver* pDriver) {
739 if (m_debugDisable) 739 if (m_debugDisable)
740 return false; 740 return false;
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 if (pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) { 1077 if (pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) {
1078 CFX_FloatRect rectf; 1078 CFX_FloatRect rectf;
1079 if (pPathData->IsRect(deviceMatrix, &rectf)) { 1079 if (pPathData->IsRect(deviceMatrix, &rectf)) {
1080 rectf.Intersect( 1080 rectf.Intersect(
1081 CFX_FloatRect(0, 0, (FX_FLOAT)GetDeviceCaps(FXDC_PIXEL_WIDTH), 1081 CFX_FloatRect(0, 0, (FX_FLOAT)GetDeviceCaps(FXDC_PIXEL_WIDTH),
1082 (FX_FLOAT)GetDeviceCaps(FXDC_PIXEL_HEIGHT))); 1082 (FX_FLOAT)GetDeviceCaps(FXDC_PIXEL_HEIGHT)));
1083 // note that PDF's y-axis goes up; Skia's y-axis goes down 1083 // note that PDF's y-axis goes up; Skia's y-axis goes down
1084 SkRect skClipRect = 1084 SkRect skClipRect =
1085 SkRect::MakeLTRB(rectf.left, rectf.bottom, rectf.right, rectf.top); 1085 SkRect::MakeLTRB(rectf.left, rectf.bottom, rectf.right, rectf.top);
1086 DebugDrawSkiaClipRect(m_pCanvas, skClipRect); 1086 DebugDrawSkiaClipRect(m_pCanvas, skClipRect);
1087 m_pCanvas->clipRect(skClipRect, SkRegion::kIntersect_Op, true); 1087 m_pCanvas->clipRect(skClipRect, SkCanvas::kIntersect_Op, true);
1088 return TRUE; 1088 return TRUE;
1089 } 1089 }
1090 } 1090 }
1091 SkPath skClipPath = BuildPath(pPathData); 1091 SkPath skClipPath = BuildPath(pPathData);
1092 skClipPath.setFillType((fill_mode & 3) == FXFILL_ALTERNATE 1092 skClipPath.setFillType((fill_mode & 3) == FXFILL_ALTERNATE
1093 ? SkPath::kEvenOdd_FillType 1093 ? SkPath::kEvenOdd_FillType
1094 : SkPath::kWinding_FillType); 1094 : SkPath::kWinding_FillType);
1095 SkMatrix skMatrix = ToSkMatrix(*deviceMatrix); 1095 SkMatrix skMatrix = ToSkMatrix(*deviceMatrix);
1096 skClipPath.transform(skMatrix); 1096 skClipPath.transform(skMatrix);
1097 DebugShowSkiaPath(skClipPath); 1097 DebugShowSkiaPath(skClipPath);
1098 DebugDrawSkiaClipPath(m_pCanvas, skClipPath); 1098 DebugDrawSkiaClipPath(m_pCanvas, skClipPath);
1099 m_pCanvas->clipPath(skClipPath, SkRegion::kIntersect_Op, true); 1099 m_pCanvas->clipPath(skClipPath, SkCanvas::kIntersect_Op, true);
1100 1100
1101 return TRUE; 1101 return TRUE;
1102 } 1102 }
1103 1103
1104 FX_BOOL CFX_SkiaDeviceDriver::SetClip_PathStroke( 1104 FX_BOOL CFX_SkiaDeviceDriver::SetClip_PathStroke(
1105 const CFX_PathData* pPathData, // path info 1105 const CFX_PathData* pPathData, // path info
1106 const CFX_Matrix* pObject2Device, // optional transformation 1106 const CFX_Matrix* pObject2Device, // optional transformation
1107 const CFX_GraphStateData* pGraphState // graphic state, for pen attributes 1107 const CFX_GraphStateData* pGraphState // graphic state, for pen attributes
1108 ) { 1108 ) {
1109 if (m_pCache->SetClipStroke(pPathData, pObject2Device, pGraphState, this)) 1109 if (m_pCache->SetClipStroke(pPathData, pObject2Device, pGraphState, this))
1110 return TRUE; 1110 return TRUE;
1111 // build path data 1111 // build path data
1112 SkPath skPath = BuildPath(pPathData); 1112 SkPath skPath = BuildPath(pPathData);
1113 SkMatrix skMatrix = ToSkMatrix(*pObject2Device); 1113 SkMatrix skMatrix = ToSkMatrix(*pObject2Device);
1114 SkPaint skPaint; 1114 SkPaint skPaint;
1115 PaintStroke(&skPaint, pGraphState, skMatrix); 1115 PaintStroke(&skPaint, pGraphState, skMatrix);
1116 SkPath dst_path; 1116 SkPath dst_path;
1117 skPaint.getFillPath(skPath, &dst_path); 1117 skPaint.getFillPath(skPath, &dst_path);
1118 dst_path.transform(skMatrix); 1118 dst_path.transform(skMatrix);
1119 DebugDrawSkiaClipPath(m_pCanvas, dst_path); 1119 DebugDrawSkiaClipPath(m_pCanvas, dst_path);
1120 m_pCanvas->clipPath(dst_path, SkRegion::kIntersect_Op, true); 1120 m_pCanvas->clipPath(dst_path, SkCanvas::kIntersect_Op, true);
1121 return TRUE; 1121 return TRUE;
1122 } 1122 }
1123 1123
1124 FX_BOOL CFX_SkiaDeviceDriver::DrawPath( 1124 FX_BOOL CFX_SkiaDeviceDriver::DrawPath(
1125 const CFX_PathData* pPathData, // path info 1125 const CFX_PathData* pPathData, // path info
1126 const CFX_Matrix* pObject2Device, // optional transformation 1126 const CFX_Matrix* pObject2Device, // optional transformation
1127 const CFX_GraphStateData* pGraphState, // graphic state, for pen attributes 1127 const CFX_GraphStateData* pGraphState, // graphic state, for pen attributes
1128 uint32_t fill_color, // fill color 1128 uint32_t fill_color, // fill color
1129 uint32_t stroke_color, // stroke color 1129 uint32_t stroke_color, // stroke color
1130 int fill_mode, // fill mode, WINDING or ALTERNATE. 0 for not filled 1130 int fill_mode, // fill mode, WINDING or ALTERNATE. 0 for not filled
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1324 skClip.transform(skMatrix); 1324 skClip.transform(skMatrix);
1325 } 1325 }
1326 SkMatrix inverse; 1326 SkMatrix inverse;
1327 if (!skMatrix.invert(&inverse)) 1327 if (!skMatrix.invert(&inverse))
1328 return false; 1328 return false;
1329 skPath.addRect(skRect); 1329 skPath.addRect(skRect);
1330 skPath.transform(inverse); 1330 skPath.transform(inverse);
1331 } 1331 }
1332 m_pCanvas->save(); 1332 m_pCanvas->save();
1333 if (!skClip.isEmpty()) 1333 if (!skClip.isEmpty())
1334 m_pCanvas->clipPath(skClip, SkRegion::kIntersect_Op, true); 1334 m_pCanvas->clipPath(skClip, SkCanvas::kIntersect_Op, true);
1335 m_pCanvas->concat(skMatrix); 1335 m_pCanvas->concat(skMatrix);
1336 m_pCanvas->drawPath(skPath, paint); 1336 m_pCanvas->drawPath(skPath, paint);
1337 m_pCanvas->restore(); 1337 m_pCanvas->restore();
1338 return true; 1338 return true;
1339 } 1339 }
1340 1340
1341 uint8_t* CFX_SkiaDeviceDriver::GetBuffer() const { 1341 uint8_t* CFX_SkiaDeviceDriver::GetBuffer() const {
1342 return m_pBitmap->GetBuffer(); 1342 return m_pBitmap->GetBuffer();
1343 } 1343 }
1344 1344
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 uint32_t flags, 1413 uint32_t flags,
1414 int blend_type) { 1414 int blend_type) {
1415 if (!m_pBitmap->GetBuffer()) 1415 if (!m_pBitmap->GetBuffer())
1416 return TRUE; 1416 return TRUE;
1417 CFX_Matrix m(dest_width, 0, 0, -dest_height, dest_left, 1417 CFX_Matrix m(dest_width, 0, 0, -dest_height, dest_left,
1418 dest_top + dest_height); 1418 dest_top + dest_height);
1419 1419
1420 m_pCanvas->save(); 1420 m_pCanvas->save();
1421 SkRect skClipRect = SkRect::MakeLTRB(pClipRect->left, pClipRect->bottom, 1421 SkRect skClipRect = SkRect::MakeLTRB(pClipRect->left, pClipRect->bottom,
1422 pClipRect->right, pClipRect->top); 1422 pClipRect->right, pClipRect->top);
1423 m_pCanvas->clipRect(skClipRect, SkRegion::kIntersect_Op, true); 1423 m_pCanvas->clipRect(skClipRect, SkCanvas::kIntersect_Op, true);
1424 void* dummy; 1424 void* dummy;
1425 FX_BOOL result = StartDIBits(pSource, 0xFF, argb, &m, 0, dummy, blend_type); 1425 FX_BOOL result = StartDIBits(pSource, 0xFF, argb, &m, 0, dummy, blend_type);
1426 m_pCanvas->restore(); 1426 m_pCanvas->restore();
1427 1427
1428 return result; 1428 return result;
1429 } 1429 }
1430 1430
1431 FX_BOOL CFX_SkiaDeviceDriver::StartDIBits(const CFX_DIBSource* pSource, 1431 FX_BOOL CFX_SkiaDeviceDriver::StartDIBits(const CFX_DIBSource* pSource,
1432 int bitmap_alpha, 1432 int bitmap_alpha,
1433 uint32_t argb, 1433 uint32_t argb,
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1672 SkA32Assert(a); 1672 SkA32Assert(a);
1673 SkASSERT(r <= a); 1673 SkASSERT(r <= a);
1674 SkASSERT(g <= a); 1674 SkASSERT(g <= a);
1675 SkASSERT(b <= a); 1675 SkASSERT(b <= a);
1676 } 1676 }
1677 } 1677 }
1678 #endif 1678 #endif
1679 } 1679 }
1680 1680
1681 #endif 1681 #endif
OLDNEW
« no previous file with comments | « DEPS ('k') | skia/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698