Chromium Code Reviews| Index: src/pdf/SkPDFFormXObject.cpp |
| diff --git a/src/pdf/SkPDFFormXObject.cpp b/src/pdf/SkPDFFormXObject.cpp |
| index f31b90b79c389be4c46952261f59de25b16921b3..8484d71a0952ad219dd003bac77fecbc971314dd 100644 |
| --- a/src/pdf/SkPDFFormXObject.cpp |
| +++ b/src/pdf/SkPDFFormXObject.cpp |
| @@ -28,10 +28,8 @@ SkPDFFormXObject::SkPDFFormXObject(SkPDFDevice* device) { |
| SkAutoTUnref<SkData> content(device->copyContentToData()); |
| 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(SkData* content, SkRect bbox, |
| + SkPDFResourceDict* resourceDict) { |
| + SkTSet<SkPDFObject*> emptySet; |
| + resourceDict->getResources(emptySet, &fResources, false); |
| + |
| + setData(content); |
| + |
| + SkAutoTUnref<SkPDFArray> bboxArray(SkPDFUtils::RectToArray(bbox)); |
| + init("DeviceRGB", resourceDict, bboxArray); |
|
vandebo (ex-Chrome)
2013/07/11 22:22:23
Is CS required here? I think table 7.13 of the 1.
ducky
2013/07/12 03:40:00
Yep, looks like it's required when in luminosity m
vandebo (ex-Chrome)
2013/07/12 21:41:43
Converting to DeviceGray would require changing th
|
| +} |
| + |
| +/** |
| + * 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()); |
| } |