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

Unified Diff: src/pdf/SkPDFFormXObject.cpp

Issue 18585002: Implemented transparent gradients (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Addresses more stylistic issues. 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
Index: src/pdf/SkPDFFormXObject.cpp
diff --git a/src/pdf/SkPDFFormXObject.cpp b/src/pdf/SkPDFFormXObject.cpp
index 884e6db2e4a1535c20d6f1dd62e87e637eceb2c1..f48a119f45645f6815a8943ea4717d52c69b5fbd 100644
--- a/src/pdf/SkPDFFormXObject.cpp
+++ b/src/pdf/SkPDFFormXObject.cpp
@@ -26,10 +26,7 @@ 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", device->getResourceDict());
+ init(NULL, device->getResourceDict(), device->copyMediaBox());
// 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
@@ -43,11 +40,41 @@ SkPDFFormXObject::SkPDFFormXObject(SkPDFDevice* device) {
}
insert("Matrix", SkPDFUtils::MatrixToArray(inverse))->unref();
}
+}
+
+/**
+ * Creates a FormXObject from a content stream and associated resources.
+ */
+SkPDFFormXObject::SkPDFFormXObject(SkData* content, SkRect bbox,
+ SkPDFResourceDict* resourceDict) {
+ SkTSet<SkPDFObject*> emptySet;
+ resourceDict->ref();
vandebo (ex-Chrome) 2013/07/09 17:47:44 This ref is for the call to init, right? It shoul
ducky 2013/07/10 21:42:26 Done. The insert call should actually handle refin
+ resourceDict->getResources(emptySet, &fResources);
+
+ setData(content);
+
+ init("DeviceRGB", resourceDict, SkPDFUtils::RectToArray(bbox));
+}
+
+/**
+ * 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);
+ SkSafeUnref(this->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());
}

Powered by Google App Engine
This is Rietveld 408576698