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

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

Issue 966863002: PDF: Canon now owns a reference to all interned objects (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkData.h" 8 #include "SkData.h"
9 #include "SkLazyPtr.h" 9 #include "SkLazyPtr.h"
10 #include "SkPDFCanon.h" 10 #include "SkPDFCanon.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 const char* bXfermodeString = as_blend_mode(bXfermodeName); 105 const char* bXfermodeString = as_blend_mode(bXfermodeName);
106 SkASSERT(bXfermodeString != NULL); 106 SkASSERT(bXfermodeString != NULL);
107 107
108 return strcmp(aXfermodeString, bXfermodeString) == 0; 108 return strcmp(aXfermodeString, bXfermodeString) == 0;
109 } 109 }
110 110
111 bool SkPDFGraphicState::equals(const SkPaint& paint) const { 111 bool SkPDFGraphicState::equals(const SkPaint& paint) const {
112 return equivalent(paint, fPaint); 112 return equivalent(paint, fPaint);
113 } 113 }
114 114
115 SkPDFGraphicState::~SkPDFGraphicState() { 115 SkPDFGraphicState::~SkPDFGraphicState() {}
116 if (fCanon) {
117 fCanon->removeGraphicState(this);
118 }
119 }
120 116
121 void SkPDFGraphicState::emitObject(SkWStream* stream, SkPDFCatalog* catalog) { 117 void SkPDFGraphicState::emitObject(SkWStream* stream, SkPDFCatalog* catalog) {
122 populateDict(); 118 populateDict();
123 SkPDFDict::emitObject(stream, catalog); 119 SkPDFDict::emitObject(stream, catalog);
124 } 120 }
125 121
126 // static 122 // static
127 SkPDFGraphicState* SkPDFGraphicState::GetGraphicStateForPaint( 123 SkPDFGraphicState* SkPDFGraphicState::GetGraphicStateForPaint(
128 SkPDFCanon* canon, const SkPaint& paint) { 124 SkPDFCanon* canon, const SkPaint& paint) {
129 SkASSERT(canon); 125 SkASSERT(canon);
130 SkPDFGraphicState* pdfGraphicState = canon->findGraphicState(paint); 126 SkPDFGraphicState* pdfGraphicState = canon->findGraphicState(paint);
131 if (pdfGraphicState) { 127 if (pdfGraphicState) {
132 return SkRef(pdfGraphicState); 128 return SkRef(pdfGraphicState);
133 } 129 }
134 pdfGraphicState = new SkPDFGraphicState(canon, paint); 130 pdfGraphicState = new SkPDFGraphicState(canon, paint);
135 canon->addGraphicState(pdfGraphicState); 131 canon->addGraphicState(SkRef(pdfGraphicState));
136 return pdfGraphicState; 132 return pdfGraphicState;
137 } 133 }
138 134
139 namespace { 135 namespace {
140 SkPDFObject* create_invert_function() { 136 SkPDFObject* create_invert_function() {
141 // Acrobat crashes if we use a type 0 function, kpdf crashes if we use 137 // Acrobat crashes if we use a type 0 function, kpdf crashes if we use
142 // a type 2 function, so we use a type 4 function. 138 // a type 2 function, so we use a type 4 function.
143 SkAutoTUnref<SkPDFArray> domainAndRange(new SkPDFArray); 139 SkAutoTUnref<SkPDFArray> domainAndRange(new SkPDFArray);
144 domainAndRange->reserve(2); 140 domainAndRange->reserve(2);
145 domainAndRange->appendInt(0); 141 domainAndRange->appendInt(0);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 fPaint.getXfermode()->asMode(&xfermode); 243 fPaint.getXfermode()->asMode(&xfermode);
248 // If we don't support the mode, just use kSrcOver_Mode. 244 // If we don't support the mode, just use kSrcOver_Mode.
249 if (xfermode < 0 || xfermode > SkXfermode::kLastMode || 245 if (xfermode < 0 || xfermode > SkXfermode::kLastMode ||
250 as_blend_mode(xfermode) == NULL) { 246 as_blend_mode(xfermode) == NULL) {
251 xfermode = SkXfermode::kSrcOver_Mode; 247 xfermode = SkXfermode::kSrcOver_Mode;
252 NOT_IMPLEMENTED("unsupported xfermode", false); 248 NOT_IMPLEMENTED("unsupported xfermode", false);
253 } 249 }
254 insertName("BM", as_blend_mode(xfermode)); 250 insertName("BM", as_blend_mode(xfermode));
255 } 251 }
256 } 252 }
OLDNEW
« src/pdf/SkPDFBitmap.cpp ('K') | « src/pdf/SkPDFFont.cpp ('k') | src/pdf/SkPDFShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698