[PDF] Don't draw empty layers.
Review URL: http://codereview.appspot.com/4527072
git-svn-id: http://skia.googlecode.com/svn/trunk@1410 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index 316cd7c..10b4ede 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -918,6 +918,13 @@
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 @@
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,