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

Unified Diff: src/pdf/SkPDFFormXObject.cpp

Issue 18585002: Implemented transparent gradients (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: 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..c309d5e85ca909f19d90928959d212aec16beab9 100644
--- a/src/pdf/SkPDFFormXObject.cpp
+++ b/src/pdf/SkPDFFormXObject.cpp
@@ -16,6 +16,16 @@
#include "SkStream.h"
#include "SkTypes.h"
+static SkPDFArray* rectToArray(SkRect rect) {
vandebo (ex-Chrome) 2013/07/03 17:07:01 Put this in SkPDFUtil and use it in SkPDFDevice::c
ducky 2013/07/03 23:32:09 Done.
+ SkPDFArray* mediaBox = SkNEW(SkPDFArray);
+ mediaBox->reserve(4);
+ mediaBox->appendScalar(rect.left());
+ mediaBox->appendScalar(rect.top());
+ mediaBox->appendScalar(rect.right());
+ mediaBox->appendScalar(rect.bottom());
+ return mediaBox;
+}
+
SkPDFFormXObject::SkPDFFormXObject(SkPDFDevice* device) {
// We don't want to keep around device because we'd have two copies
// of content, so reference or copy everything we need (content and
@@ -52,6 +62,31 @@ SkPDFFormXObject::SkPDFFormXObject(SkPDFDevice* device) {
insert("Group", group.get());
}
+/**
+ * Creates a FormXObject from a content stream and associated resources.
+ */
+SkPDFFormXObject::SkPDFFormXObject(SkStream* content,
+ SkPDFDict* resourceDict,
+ SkTSet<SkPDFObject*>& resources,
+ SkRect bbox) {
+ setData(content);
vandebo (ex-Chrome) 2013/07/03 17:07:01 This whole body can be shared with the other const
ducky 2013/07/03 23:32:09 Done.
+ resourceDict->ref();
vandebo (ex-Chrome) 2013/07/03 17:07:01 This should be next to where the reference is used
ducky 2013/07/03 23:32:09 Done.
+
+ insertName("Type", "XObject");
+ insertName("Subtype", "Form");
+ SkSafeUnref(this->insert("BBox", rectToArray(bbox)));
+ insert("Resources", resourceDict);
+ fResources = resources;
+
+ // 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");
+ group->insertName("CS", "DeviceRGB");
+ group->insert("I", new SkPDFBool(true))->unref(); // Isolated.
+ insert("Group", group.get());
+}
+
SkPDFFormXObject::~SkPDFFormXObject() {
fResources.unrefAll();
}

Powered by Google App Engine
This is Rietveld 408576698