[PDF] Don't draw empty layers.
authorvandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 24 May 2011 17:38:01 +0000 (17:38 +0000)
committervandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 24 May 2011 17:38:01 +0000 (17:38 +0000)
Review URL: http://codereview.appspot.com/4527072

git-svn-id: http://skia.googlecode.com/svn/trunk@1410 2bbb7eff-a529-9590-31e7-b0007b416f81

src/pdf/SkPDFDevice.cpp

index 316cd7c..10b4ede 100644 (file)
@@ -918,6 +918,13 @@ void SkPDFDevice::drawDevice(const SkDraw& d, SkDevice* device, int x, int y,
         return;
     }
 
+    // Assume that a vector capable device means that it's a PDF Device.
+    SkPDFDevice* pdfDevice = static_cast<SkPDFDevice*>(device);
+    if (!pdfDevice->fContentEntries.get() ||
+            !pdfDevice->fContentEntries->fContent.getOffset()) {
+        return;
+    }
+
     SkMatrix matrix;
     matrix.setTranslate(SkIntToScalar(x), SkIntToScalar(y));
     ContentEntryAccessor content(this, d.fClipStack, *d.fClip, matrix, paint);
@@ -925,8 +932,6 @@ void SkPDFDevice::drawDevice(const SkDraw& d, SkDevice* device, int x, int y,
         return;
     }
 
-    // Assume that a vector capable device means that it's a PDF Device.
-    SkPDFDevice* pdfDevice = static_cast<SkPDFDevice*>(device);
     SkPDFFormXObject* xobject = new SkPDFFormXObject(pdfDevice);
     fXObjectResources.push(xobject);  // Transfer reference.
     SkPDFUtils::DrawFormXObject(fXObjectResources.count() - 1,