Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Unified Diff: src/pdf/SkPDFFormXObject.cpp

Issue 18585002: Implemented transparent gradients (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Merge new SkPDFResourceDict method names Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pdf/SkPDFFormXObject.h ('k') | src/pdf/SkPDFGraphicState.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFFormXObject.cpp
diff --git a/src/pdf/SkPDFFormXObject.cpp b/src/pdf/SkPDFFormXObject.cpp
index 6958e276edd6b269d32b1791e5dcddbc8e029708..1635b0ff9649d102ec7e21e7638f9ddaf582003b 100644
--- a/src/pdf/SkPDFFormXObject.cpp
+++ b/src/pdf/SkPDFFormXObject.cpp
@@ -28,10 +28,8 @@ SkPDFFormXObject::SkPDFFormXObject(SkPDFDevice* device) {
SkAutoTUnref<SkStream> content(device->content());
setData(content.get());
- insertName("Type", "XObject");
- insertName("Subtype", "Form");
- SkSafeUnref(this->insert("BBox", device->copyMediaBox()));
- insert("Resources", resourceDict);
+ SkAutoTUnref<SkPDFArray> bboxArray(device->copyMediaBox());
+ init(NULL, resourceDict, bboxArray);
// We invert the initial transform and apply that to the xobject so that
// it doesn't get applied twice. We can't just undo it because it's
@@ -45,11 +43,41 @@ SkPDFFormXObject::SkPDFFormXObject(SkPDFDevice* device) {
}
insert("Matrix", SkPDFUtils::MatrixToArray(inverse))->unref();
}
+}
+
+/**
+ * Creates a FormXObject from a content stream and associated resources.
+ */
+SkPDFFormXObject::SkPDFFormXObject(SkStream* content, SkRect bbox,
+ SkPDFResourceDict* resourceDict) {
+ SkTSet<SkPDFObject*> emptySet;
+ resourceDict->getReferencedResources(emptySet, &fResources, false);
+
+ setData(content);
+
+ SkAutoTUnref<SkPDFArray> bboxArray(SkPDFUtils::RectToArray(bbox));
+ init("DeviceRGB", resourceDict, bboxArray);
+}
+
+/**
+ * Common initialization code.
+ * Note that bbox is unreferenced here, so calling code does not need worry.
+ */
+void SkPDFFormXObject::init(const char* colorSpace,
+ SkPDFDict* resourceDict, SkPDFArray* bbox) {
+ insertName("Type", "XObject");
+ insertName("Subtype", "Form");
+ insert("Resources", resourceDict);
+ insert("BBox", bbox);
// Right now SkPDFFormXObject is only used for saveLayer, which implies
// isolated blending. Do this conditionally if that changes.
SkAutoTUnref<SkPDFDict> group(new SkPDFDict("Group"));
group->insertName("S", "Transparency");
+
+ if (colorSpace != NULL) {
+ group->insertName("CS", colorSpace);
+ }
group->insert("I", new SkPDFBool(true))->unref(); // Isolated.
insert("Group", group.get());
}
« no previous file with comments | « src/pdf/SkPDFFormXObject.h ('k') | src/pdf/SkPDFGraphicState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698