initial clean up of pdf clipping
authorMike Reed <reed@google.com>
Tue, 21 Feb 2017 18:54:30 +0000 (13:54 -0500)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Tue, 21 Feb 2017 19:35:15 +0000 (19:35 +0000)
clipstack is always available, canvas checks for empty clips up-front

Next step is to clarify if PDF wants to use Regions or Clipstack for its clipping (but not both)

Change-Id: Iaf1fa35160291e08c33ff61114557deff72304b3
Reviewed-on: https://skia-review.googlesource.com/8692
Reviewed-by: Hal Canary <halcanary@google.com>
Commit-Queue: Mike Reed <reed@google.com>

src/pdf/SkPDFDevice.cpp

index cc85bf4..2dff42e 100644 (file)
@@ -915,15 +915,12 @@ void SkPDFDevice::drawImage(const SkDraw& draw,
                             SkScalar y,
                             const SkPaint& srcPaint) {
     SkPaint paint = srcPaint;
-    if (!image) {
+    if (!image || draw.fRC->isEmpty()) {
         return;
     }
     if (image->isOpaque()) {
         replace_srcmode_on_opaque_paint(&paint);
     }
-    if (draw.fRC->isEmpty()) {
-        return;
-    }
     SkImageSubset imageSubset(sk_ref_sp(const_cast<SkImage*>(image)));
     if (!imageSubset.isValid()) {
         return;
@@ -1758,23 +1755,6 @@ SkPDFDevice::ContentEntry* SkPDFDevice::setUpContentEntry(const SkClipStack* cli
         return nullptr;
     }
 
-    // The clip stack can come from an SkDraw where it is technically optional.
-    SkClipStack synthesizedClipStack;
-    if (clipStack == nullptr) {
-        if (clipRegion == fExistingClipRegion) {
-            clipStack = &fExistingClipStack;
-        } else {
-            // GraphicStackState::updateClip expects the clip stack to have
-            // fExistingClip as a prefix, so start there, then set the clip
-            // to the passed region.
-            synthesizedClipStack = fExistingClipStack;
-            SkPath clipPath;
-            clipRegion.getBoundaryPath(&clipPath);
-            synthesizedClipStack.clipPath(clipPath, SkMatrix::I(), kReplace_SkClipOp, false);
-            clipStack = &synthesizedClipStack;
-        }
-    }
-
     SkBlendMode blendMode = paint.getBlendMode();
 
     // For the following modes, we want to handle source and destination