From ecc238c9487288e1f3bfe8973245011f2eb0bcf2 Mon Sep 17 00:00:00 2001 From: Cary Clark Date: Wed, 5 Jul 2017 13:23:57 -0400 Subject: set clip rect MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit clip rect should mirror existing construction Also found tracing. Keep the clip rect in sync with its expected value for compatibility. R=dsinclair@chromium.org,npm@chromium.org Bug: 736703 Change-Id: I57bab209f5e1febb5fbcd91860b43296063f1f80 Reviewed-on: https://pdfium-review.googlesource.com/7275 Reviewed-by: Nicolás Peña Commit-Queue: Cary Clark --- core/fxge/skia/fx_skia_device.cpp | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp index ab026f6cc4..2d60f74e86 100644 --- a/core/fxge/skia/fx_skia_device.cpp +++ b/core/fxge/skia/fx_skia_device.cpp @@ -861,12 +861,29 @@ class SkiaState { if (m_debugDisable) return false; Dump(__func__); - SkPath skClipPath = BuildPath(pPathData); - skClipPath.setFillType((fill_mode & 3) == FXFILL_ALTERNATE - ? SkPath::kEvenOdd_FillType - : SkPath::kWinding_FillType); - SkMatrix skMatrix = ToSkMatrix(*pMatrix); - skClipPath.transform(skMatrix); + SkPath skClipPath; + if (pPathData->GetPoints().size() == 5 || + pPathData->GetPoints().size() == 4) { + CFX_FloatRect rectf; + if (pPathData->IsRect(pMatrix, &rectf)) { + rectf.Intersect(CFX_FloatRect( + 0, 0, + static_cast(m_pDriver->GetDeviceCaps(FXDC_PIXEL_WIDTH)), + static_cast(m_pDriver->GetDeviceCaps(FXDC_PIXEL_HEIGHT)))); + FX_RECT outer = rectf.GetOuterRect(); + // note that PDF's y-axis goes up; Skia's y-axis goes down + skClipPath.addRect({(float)outer.left, (float)outer.bottom, + (float)outer.right, (float)outer.top}); + } + } + if (skClipPath.isEmpty()) { + skClipPath = BuildPath(pPathData); + skClipPath.setFillType((fill_mode & 3) == FXFILL_ALTERNATE + ? SkPath::kEvenOdd_FillType + : SkPath::kWinding_FillType); + SkMatrix skMatrix = ToSkMatrix(*pMatrix); + skClipPath.transform(skMatrix); + } return SetClip(skClipPath); } -- cgit v1.2.3