| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <utility> | 6 #include <utility> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "core/fpdfapi/page/cpdf_meshstream.h" | 9 #include "core/fpdfapi/page/cpdf_meshstream.h" |
| 10 #include "core/fpdfapi/page/cpdf_shadingpattern.h" | 10 #include "core/fpdfapi/page/cpdf_shadingpattern.h" |
| (...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1031 SkASSERT(m_clipIndex >= 0); | 1031 SkASSERT(m_clipIndex >= 0); |
| 1032 } while (m_commands[m_clipIndex] != Clip::kSave); | 1032 } while (m_commands[m_clipIndex] != Clip::kSave); |
| 1033 m_pDriver->SkiaCanvas()->restore(); | 1033 m_pDriver->SkiaCanvas()->restore(); |
| 1034 } | 1034 } |
| 1035 while (m_clipIndex < limit) { | 1035 while (m_clipIndex < limit) { |
| 1036 if (Clip::kSave == m_commands[m_clipIndex]) { | 1036 if (Clip::kSave == m_commands[m_clipIndex]) { |
| 1037 m_pDriver->SkiaCanvas()->save(); | 1037 m_pDriver->SkiaCanvas()->save(); |
| 1038 } else { | 1038 } else { |
| 1039 SkASSERT(Clip::kPath == m_commands[m_clipIndex]); | 1039 SkASSERT(Clip::kPath == m_commands[m_clipIndex]); |
| 1040 m_pDriver->SkiaCanvas()->clipPath(m_clips[m_clipIndex], | 1040 m_pDriver->SkiaCanvas()->clipPath(m_clips[m_clipIndex], |
| 1041 SkCanvas::kIntersect_Op, true); | 1041 kIntersect_SkClipOp, true); |
| 1042 } | 1042 } |
| 1043 ++m_clipIndex; | 1043 ++m_clipIndex; |
| 1044 } | 1044 } |
| 1045 } | 1045 } |
| 1046 | 1046 |
| 1047 void Flush() { | 1047 void Flush() { |
| 1048 if (m_debugDisable) | 1048 if (m_debugDisable) |
| 1049 return; | 1049 return; |
| 1050 Dump(__func__); | 1050 Dump(__func__); |
| 1051 if (Accumulator::kPath == m_type || Accumulator::kText == m_type) { | 1051 if (Accumulator::kPath == m_type || Accumulator::kText == m_type) { |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1442 CFX_FloatRect rectf; | 1442 CFX_FloatRect rectf; |
| 1443 if (pPathData->IsRect(deviceMatrix, &rectf)) { | 1443 if (pPathData->IsRect(deviceMatrix, &rectf)) { |
| 1444 rectf.Intersect( | 1444 rectf.Intersect( |
| 1445 CFX_FloatRect(0, 0, (FX_FLOAT)GetDeviceCaps(FXDC_PIXEL_WIDTH), | 1445 CFX_FloatRect(0, 0, (FX_FLOAT)GetDeviceCaps(FXDC_PIXEL_WIDTH), |
| 1446 (FX_FLOAT)GetDeviceCaps(FXDC_PIXEL_HEIGHT))); | 1446 (FX_FLOAT)GetDeviceCaps(FXDC_PIXEL_HEIGHT))); |
| 1447 // note that PDF's y-axis goes up; Skia's y-axis goes down | 1447 // note that PDF's y-axis goes up; Skia's y-axis goes down |
| 1448 if (!cached) { | 1448 if (!cached) { |
| 1449 SkRect skClipRect = | 1449 SkRect skClipRect = |
| 1450 SkRect::MakeLTRB(rectf.left, rectf.bottom, rectf.right, rectf.top); | 1450 SkRect::MakeLTRB(rectf.left, rectf.bottom, rectf.right, rectf.top); |
| 1451 DebugDrawSkiaClipRect(m_pCanvas, skClipRect); | 1451 DebugDrawSkiaClipRect(m_pCanvas, skClipRect); |
| 1452 m_pCanvas->clipRect(skClipRect, SkCanvas::kIntersect_Op, true); | 1452 m_pCanvas->clipRect(skClipRect, kIntersect_SkClipOp, true); |
| 1453 } | 1453 } |
| 1454 | 1454 |
| 1455 #ifdef _SKIA_SUPPORT_PATHS_ | 1455 #ifdef _SKIA_SUPPORT_PATHS_ |
| 1456 FX_RECT rect = rectf.GetOuterRect(); | 1456 FX_RECT rect = rectf.GetOuterRect(); |
| 1457 m_pClipRgn->IntersectRect(rect); | 1457 m_pClipRgn->IntersectRect(rect); |
| 1458 #endif // _SKIA_SUPPORT_PATHS_ | 1458 #endif // _SKIA_SUPPORT_PATHS_ |
| 1459 DebugShowCanvasClip(m_pCanvas); | 1459 DebugShowCanvasClip(m_pCanvas); |
| 1460 return true; | 1460 return true; |
| 1461 } | 1461 } |
| 1462 } | 1462 } |
| 1463 SkPath skClipPath = BuildPath(pPathData); | 1463 SkPath skClipPath = BuildPath(pPathData); |
| 1464 skClipPath.setFillType((fill_mode & 3) == FXFILL_ALTERNATE | 1464 skClipPath.setFillType((fill_mode & 3) == FXFILL_ALTERNATE |
| 1465 ? SkPath::kEvenOdd_FillType | 1465 ? SkPath::kEvenOdd_FillType |
| 1466 : SkPath::kWinding_FillType); | 1466 : SkPath::kWinding_FillType); |
| 1467 SkMatrix skMatrix = ToSkMatrix(*deviceMatrix); | 1467 SkMatrix skMatrix = ToSkMatrix(*deviceMatrix); |
| 1468 skClipPath.transform(skMatrix); | 1468 skClipPath.transform(skMatrix); |
| 1469 DebugShowSkiaPath(skClipPath); | 1469 DebugShowSkiaPath(skClipPath); |
| 1470 if (!cached) { | 1470 if (!cached) { |
| 1471 DebugDrawSkiaClipPath(m_pCanvas, skClipPath); | 1471 DebugDrawSkiaClipPath(m_pCanvas, skClipPath); |
| 1472 m_pCanvas->clipPath(skClipPath, SkCanvas::kIntersect_Op, true); | 1472 m_pCanvas->clipPath(skClipPath, kIntersect_SkClipOp, true); |
| 1473 } | 1473 } |
| 1474 #ifdef _SKIA_SUPPORT_PATHS_ | 1474 #ifdef _SKIA_SUPPORT_PATHS_ |
| 1475 FX_RECT clipBox(0, 0, GetDeviceCaps(FXDC_PIXEL_WIDTH), | 1475 FX_RECT clipBox(0, 0, GetDeviceCaps(FXDC_PIXEL_WIDTH), |
| 1476 GetDeviceCaps(FXDC_PIXEL_HEIGHT)); | 1476 GetDeviceCaps(FXDC_PIXEL_HEIGHT)); |
| 1477 SetClipMask(clipBox, skClipPath); | 1477 SetClipMask(clipBox, skClipPath); |
| 1478 #endif // _SKIA_SUPPORT_PATHS_ | 1478 #endif // _SKIA_SUPPORT_PATHS_ |
| 1479 DebugShowCanvasClip(m_pCanvas); | 1479 DebugShowCanvasClip(m_pCanvas); |
| 1480 return true; | 1480 return true; |
| 1481 } | 1481 } |
| 1482 | 1482 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1496 // build path data | 1496 // build path data |
| 1497 SkPath skPath = BuildPath(pPathData); | 1497 SkPath skPath = BuildPath(pPathData); |
| 1498 SkMatrix skMatrix = ToSkMatrix(*pObject2Device); | 1498 SkMatrix skMatrix = ToSkMatrix(*pObject2Device); |
| 1499 SkPaint skPaint; | 1499 SkPaint skPaint; |
| 1500 PaintStroke(&skPaint, pGraphState, skMatrix); | 1500 PaintStroke(&skPaint, pGraphState, skMatrix); |
| 1501 SkPath dst_path; | 1501 SkPath dst_path; |
| 1502 skPaint.getFillPath(skPath, &dst_path); | 1502 skPaint.getFillPath(skPath, &dst_path); |
| 1503 dst_path.transform(skMatrix); | 1503 dst_path.transform(skMatrix); |
| 1504 if (!cached) { | 1504 if (!cached) { |
| 1505 DebugDrawSkiaClipPath(m_pCanvas, dst_path); | 1505 DebugDrawSkiaClipPath(m_pCanvas, dst_path); |
| 1506 m_pCanvas->clipPath(dst_path, SkCanvas::kIntersect_Op, true); | 1506 m_pCanvas->clipPath(dst_path, kIntersect_SkClipOp, true); |
| 1507 } | 1507 } |
| 1508 #ifdef _SKIA_SUPPORT_PATHS_ | 1508 #ifdef _SKIA_SUPPORT_PATHS_ |
| 1509 FX_RECT clipBox(0, 0, GetDeviceCaps(FXDC_PIXEL_WIDTH), | 1509 FX_RECT clipBox(0, 0, GetDeviceCaps(FXDC_PIXEL_WIDTH), |
| 1510 GetDeviceCaps(FXDC_PIXEL_HEIGHT)); | 1510 GetDeviceCaps(FXDC_PIXEL_HEIGHT)); |
| 1511 SetClipMask(clipBox, dst_path); | 1511 SetClipMask(clipBox, dst_path); |
| 1512 #endif // _SKIA_SUPPORT_PATHS_ | 1512 #endif // _SKIA_SUPPORT_PATHS_ |
| 1513 DebugShowCanvasClip(m_pCanvas); | 1513 DebugShowCanvasClip(m_pCanvas); |
| 1514 return true; | 1514 return true; |
| 1515 } | 1515 } |
| 1516 | 1516 |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1738 if (!pStream) | 1738 if (!pStream) |
| 1739 return false; | 1739 return false; |
| 1740 CPDF_MeshStream stream(shadingType, pPattern->GetFuncs(), pStream, | 1740 CPDF_MeshStream stream(shadingType, pPattern->GetFuncs(), pStream, |
| 1741 pPattern->GetCS()); | 1741 pPattern->GetCS()); |
| 1742 if (!stream.Load()) | 1742 if (!stream.Load()) |
| 1743 return false; | 1743 return false; |
| 1744 SkPoint cubics[12]; | 1744 SkPoint cubics[12]; |
| 1745 SkColor colors[4]; | 1745 SkColor colors[4]; |
| 1746 m_pCanvas->save(); | 1746 m_pCanvas->save(); |
| 1747 if (!skClip.isEmpty()) | 1747 if (!skClip.isEmpty()) |
| 1748 m_pCanvas->clipPath(skClip, SkCanvas::kIntersect_Op, true); | 1748 m_pCanvas->clipPath(skClip, kIntersect_SkClipOp, true); |
| 1749 m_pCanvas->concat(skMatrix); | 1749 m_pCanvas->concat(skMatrix); |
| 1750 while (!stream.BitStream()->IsEOF()) { | 1750 while (!stream.BitStream()->IsEOF()) { |
| 1751 uint32_t flag = stream.GetFlag(); | 1751 uint32_t flag = stream.GetFlag(); |
| 1752 int iStartPoint = flag ? 4 : 0; | 1752 int iStartPoint = flag ? 4 : 0; |
| 1753 int iStartColor = flag ? 2 : 0; | 1753 int iStartColor = flag ? 2 : 0; |
| 1754 if (flag) { | 1754 if (flag) { |
| 1755 SkPoint tempCubics[4]; | 1755 SkPoint tempCubics[4]; |
| 1756 for (int i = 0; i < (int)SK_ARRAY_COUNT(tempCubics); i++) | 1756 for (int i = 0; i < (int)SK_ARRAY_COUNT(tempCubics); i++) |
| 1757 tempCubics[i] = cubics[(flag * 3 + i) % 12]; | 1757 tempCubics[i] = cubics[(flag * 3 + i) % 12]; |
| 1758 FXSYS_memcpy(cubics, tempCubics, sizeof(tempCubics)); | 1758 FXSYS_memcpy(cubics, tempCubics, sizeof(tempCubics)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1769 colors[i] = SkColorSetARGBInline(0xFF, (U8CPU)(r * 255), | 1769 colors[i] = SkColorSetARGBInline(0xFF, (U8CPU)(r * 255), |
| 1770 (U8CPU)(g * 255), (U8CPU)(b * 255)); | 1770 (U8CPU)(g * 255), (U8CPU)(b * 255)); |
| 1771 } | 1771 } |
| 1772 m_pCanvas->drawPatch(cubics, colors, nullptr, paint); | 1772 m_pCanvas->drawPatch(cubics, colors, nullptr, paint); |
| 1773 } | 1773 } |
| 1774 m_pCanvas->restore(); | 1774 m_pCanvas->restore(); |
| 1775 return true; | 1775 return true; |
| 1776 } | 1776 } |
| 1777 m_pCanvas->save(); | 1777 m_pCanvas->save(); |
| 1778 if (!skClip.isEmpty()) | 1778 if (!skClip.isEmpty()) |
| 1779 m_pCanvas->clipPath(skClip, SkCanvas::kIntersect_Op, true); | 1779 m_pCanvas->clipPath(skClip, kIntersect_SkClipOp, true); |
| 1780 m_pCanvas->concat(skMatrix); | 1780 m_pCanvas->concat(skMatrix); |
| 1781 m_pCanvas->drawPath(skPath, paint); | 1781 m_pCanvas->drawPath(skPath, paint); |
| 1782 m_pCanvas->restore(); | 1782 m_pCanvas->restore(); |
| 1783 return true; | 1783 return true; |
| 1784 } | 1784 } |
| 1785 | 1785 |
| 1786 uint8_t* CFX_SkiaDeviceDriver::GetBuffer() const { | 1786 uint8_t* CFX_SkiaDeviceDriver::GetBuffer() const { |
| 1787 return m_pBitmap->GetBuffer(); | 1787 return m_pBitmap->GetBuffer(); |
| 1788 } | 1788 } |
| 1789 | 1789 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1908 #ifdef _SKIA_SUPPORT_ | 1908 #ifdef _SKIA_SUPPORT_ |
| 1909 m_pCache->FlushForDraw(); | 1909 m_pCache->FlushForDraw(); |
| 1910 if (!m_pBitmap->GetBuffer()) | 1910 if (!m_pBitmap->GetBuffer()) |
| 1911 return true; | 1911 return true; |
| 1912 CFX_Matrix m(dest_width, 0, 0, -dest_height, dest_left, | 1912 CFX_Matrix m(dest_width, 0, 0, -dest_height, dest_left, |
| 1913 dest_top + dest_height); | 1913 dest_top + dest_height); |
| 1914 | 1914 |
| 1915 m_pCanvas->save(); | 1915 m_pCanvas->save(); |
| 1916 SkRect skClipRect = SkRect::MakeLTRB(pClipRect->left, pClipRect->bottom, | 1916 SkRect skClipRect = SkRect::MakeLTRB(pClipRect->left, pClipRect->bottom, |
| 1917 pClipRect->right, pClipRect->top); | 1917 pClipRect->right, pClipRect->top); |
| 1918 m_pCanvas->clipRect(skClipRect, SkCanvas::kIntersect_Op, true); | 1918 m_pCanvas->clipRect(skClipRect, kIntersect_SkClipOp, true); |
| 1919 void* dummy; | 1919 void* dummy; |
| 1920 bool result = StartDIBits(pSource, 0xFF, argb, &m, 0, dummy, blend_type); | 1920 bool result = StartDIBits(pSource, 0xFF, argb, &m, 0, dummy, blend_type); |
| 1921 m_pCanvas->restore(); | 1921 m_pCanvas->restore(); |
| 1922 | 1922 |
| 1923 return result; | 1923 return result; |
| 1924 #endif // _SKIA_SUPPORT_ | 1924 #endif // _SKIA_SUPPORT_ |
| 1925 | 1925 |
| 1926 #ifdef _SKIA_SUPPORT_PATHS_ | 1926 #ifdef _SKIA_SUPPORT_PATHS_ |
| 1927 if (dest_width == pSource->GetWidth() && | 1927 if (dest_width == pSource->GetWidth() && |
| 1928 dest_height == pSource->GetHeight()) { | 1928 dest_height == pSource->GetHeight()) { |
| (...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3094 } | 3094 } |
| 3095 } | 3095 } |
| 3096 if (m_pDevice->GetBPP() == 1) { | 3096 if (m_pDevice->GetBPP() == 1) { |
| 3097 composite_span = &CFX_Renderer::CompositeSpan1bpp; | 3097 composite_span = &CFX_Renderer::CompositeSpan1bpp; |
| 3098 } | 3098 } |
| 3099 return true; | 3099 return true; |
| 3100 } | 3100 } |
| 3101 }; | 3101 }; |
| 3102 | 3102 |
| 3103 #endif // _SKIA_SUPPORT_PATHS_ | 3103 #endif // _SKIA_SUPPORT_PATHS_ |
| OLD | NEW |