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

Side by Side Diff: src/pdf/SkPDFFormXObject.cpp

Issue 1068343003: SkPDF: ResourceDict replaced by factory function (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-04-08 (Wednesday) 17:35:39 EDT Created 5 years, 8 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 unified diff | Download patch
« no previous file with comments | « src/pdf/SkPDFFormXObject.h ('k') | src/pdf/SkPDFResourceDict.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2010 The Android Open Source Project 3 * Copyright 2010 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkPDFFormXObject.h" 10 #include "SkPDFFormXObject.h"
11 11
12 #include "SkMatrix.h" 12 #include "SkMatrix.h"
13 #include "SkPDFDevice.h" 13 #include "SkPDFDevice.h"
14 #include "SkPDFResourceDict.h"
15 #include "SkPDFUtils.h" 14 #include "SkPDFUtils.h"
16 #include "SkStream.h" 15 #include "SkStream.h"
17 #include "SkTypes.h" 16 #include "SkTypes.h"
18 17
19 SkPDFFormXObject::SkPDFFormXObject(SkPDFDevice* device) { 18 SkPDFFormXObject::SkPDFFormXObject(SkPDFDevice* device) {
20 // We don't want to keep around device because we'd have two copies 19 // We don't want to keep around device because we'd have two copies
21 // of content, so reference or copy everything we need (content and 20 // of content, so reference or copy everything we need (content and
22 // resources). 21 // resources).
23 SkAutoTUnref<SkPDFResourceDict> resourceDict(device->createResourceDict()); 22 SkAutoTUnref<SkPDFDict> resourceDict(device->createResourceDict());
24 23
25 SkAutoTDelete<SkStreamAsset> content(device->content()); 24 SkAutoTDelete<SkStreamAsset> content(device->content());
26 this->setData(content.get()); 25 this->setData(content.get());
27 26
28 SkAutoTUnref<SkPDFArray> bboxArray(device->copyMediaBox()); 27 SkAutoTUnref<SkPDFArray> bboxArray(device->copyMediaBox());
29 this->init(NULL, resourceDict.get(), bboxArray); 28 this->init(NULL, resourceDict.get(), bboxArray);
30 29
31 // We invert the initial transform and apply that to the xobject so that 30 // We invert the initial transform and apply that to the xobject so that
32 // it doesn't get applied twice. We can't just undo it because it's 31 // it doesn't get applied twice. We can't just undo it because it's
33 // embedded in things like shaders and images. 32 // embedded in things like shaders and images.
34 if (!device->initialTransform().isIdentity()) { 33 if (!device->initialTransform().isIdentity()) {
35 SkMatrix inverse; 34 SkMatrix inverse;
36 if (!device->initialTransform().invert(&inverse)) { 35 if (!device->initialTransform().invert(&inverse)) {
37 // The initial transform should be invertible. 36 // The initial transform should be invertible.
38 SkASSERT(false); 37 SkASSERT(false);
39 inverse.reset(); 38 inverse.reset();
40 } 39 }
41 insert("Matrix", SkPDFUtils::MatrixToArray(inverse))->unref(); 40 insert("Matrix", SkPDFUtils::MatrixToArray(inverse))->unref();
42 } 41 }
43 } 42 }
44 43
45 /** 44 /**
46 * Creates a FormXObject from a content stream and associated resources. 45 * Creates a FormXObject from a content stream and associated resources.
47 */ 46 */
48 SkPDFFormXObject::SkPDFFormXObject(SkStream* content, SkRect bbox, 47 SkPDFFormXObject::SkPDFFormXObject(SkStream* content, SkRect bbox,
49 SkPDFResourceDict* resourceDict) { 48 SkPDFDict* resourceDict) {
50 setData(content); 49 setData(content);
51 50
52 SkAutoTUnref<SkPDFArray> bboxArray(SkPDFUtils::RectToArray(bbox)); 51 SkAutoTUnref<SkPDFArray> bboxArray(SkPDFUtils::RectToArray(bbox));
53 init("DeviceRGB", resourceDict, bboxArray); 52 init("DeviceRGB", resourceDict, bboxArray);
54 } 53 }
55 54
56 /** 55 /**
57 * Common initialization code. 56 * Common initialization code.
58 * Note that bbox is unreferenced here, so calling code does not need worry. 57 * Note that bbox is unreferenced here, so calling code does not need worry.
59 */ 58 */
(...skipping 10 matching lines...) Expand all
70 group->insertName("S", "Transparency"); 69 group->insertName("S", "Transparency");
71 70
72 if (colorSpace != NULL) { 71 if (colorSpace != NULL) {
73 group->insertName("CS", colorSpace); 72 group->insertName("CS", colorSpace);
74 } 73 }
75 group->insert("I", new SkPDFBool(true))->unref(); // Isolated. 74 group->insert("I", new SkPDFBool(true))->unref(); // Isolated.
76 insert("Group", group.get()); 75 insert("Group", group.get());
77 } 76 }
78 77
79 SkPDFFormXObject::~SkPDFFormXObject() {} 78 SkPDFFormXObject::~SkPDFFormXObject() {}
OLDNEW
« no previous file with comments | « src/pdf/SkPDFFormXObject.h ('k') | src/pdf/SkPDFResourceDict.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698