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

Unified Diff: src/pdf/SkPDFFormXObject.cpp

Issue 18585002: Implemented transparent gradients (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fixes isValid() in SkPDFGradientShader, fixes tinybitmap regression Created 7 years, 6 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..a5ac6a4d1a36e8286b60bb0c687bccedc8364eaa 100644
--- a/src/pdf/SkPDFFormXObject.cpp
+++ b/src/pdf/SkPDFFormXObject.cpp
@@ -26,8 +26,6 @@ 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());
@@ -44,10 +42,37 @@ SkPDFFormXObject::SkPDFFormXObject(SkPDFDevice* device) {
insert("Matrix", SkPDFUtils::MatrixToArray(inverse))->unref();
}
+ commonInit(NULL);
vandebo (ex-Chrome) 2013/07/08 19:02:25 nit: move to line 28
ducky 2013/07/09 02:56:23 Done.
+}
+
+/**
+ * Creates a FormXObject from a content stream and associated resources.
+ */
+SkPDFFormXObject::SkPDFFormXObject(SkData* content, SkRect bbox,
+ SkPDFResourceDict* resourceDict) {
+ SkTSet<SkPDFObject*> emptySet;
+ SkSafeUnref(this->insert("BBox", SkPDFUtils::RectToArray(bbox)));
+ insert("Resources", resourceDict);
+ resourceDict->ref();
+ resourceDict->getResources(emptySet, &fResources);
+
+ setData(content);
+
+ commonInit("DeviceRGB");
+}
+
+void SkPDFFormXObject::commonInit(const char colorSpace[]) {
vandebo (ex-Chrome) 2013/07/08 19:02:25 pass as much as possible into init. i.e. bbox and
ducky 2013/07/09 02:56:23 Done. Though, it's still not a completely clean so
vandebo (ex-Chrome) 2013/07/09 17:47:44 As you pointed out at a different point, you proba
ducky 2013/07/10 21:42:26 Fixed. Ownership is no longer transferred, and the
+ insertName("Type", "XObject");
+ insertName("Subtype", "Form");
+
// 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