[PDF] Add support for xfermodes / blend modes.
- Change SkGraphicState to track and set the blend mode (xfermode) for modes built in to PDF (non porter duff modes + src over).
- Add SkXfermode::asMode() to retrieve xfermode as an enum for non porter duff modes.
- Move SkXfermode.cpp around a bit to support asMode() -- Generally move utility functions toward the top of the file.
- Make SkPDFFormXObject an isolated transparency group, as it used for saveLayer, which draws on transparent, not the device background.
- Set the graphic state in drawDevice and drawBitmap in order to get the right xfermode and alpha.
Review URL: http://codereview.appspot.com/4131043
git-svn-id: http://skia.googlecode.com/svn/trunk@774 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/pdf/SkPDFFormXObject.cpp b/src/pdf/SkPDFFormXObject.cpp
index 346bce6..ef839a3 100644
--- a/src/pdf/SkPDFFormXObject.cpp
+++ b/src/pdf/SkPDFFormXObject.cpp
@@ -39,6 +39,14 @@
insert("Subtype", new SkPDFName("Form"))->unref();
insert("BBox", device->getMediaBox().get());
insert("Resources", device->getResourceDict().get());
+
+ // Right now SkPDFFormXObject is only used for saveLayer, which implies
+ // isolated blending. Do this conditionally if that changes.
+ SkRefPtr<SkPDFDict> group = new SkPDFDict("Group");
+ group->unref(); // SkRefPtr and new both took a reference.
+ group->insert("S", new SkPDFName("Transparency"))->unref();
+ group->insert("I", new SkPDFBool(true))->unref(); // Isolated.
+ insert("Group", group.get());
}
SkPDFFormXObject::~SkPDFFormXObject() {