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

Side by Side Diff: src/pdf/SkPDFBitmap.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: 2015-02-27 (Friday) 15:27:08 EST 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
« no previous file with comments | « src/pdf/SkPDFBitmap.h ('k') | src/pdf/SkPDFCanon.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 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 "SkColorPriv.h" 8 #include "SkColorPriv.h"
9 #include "SkFlate.h" 9 #include "SkFlate.h"
10 #include "SkPDFBitmap.h" 10 #include "SkPDFBitmap.h"
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 if (fSMask) { 240 if (fSMask) {
241 pdfDict.insert("SMask", new SkPDFObjRef(fSMask))->unref(); 241 pdfDict.insert("SMask", new SkPDFObjRef(fSMask))->unref();
242 } 242 }
243 if (deflate) { 243 if (deflate) {
244 pdfDict.insertName("Filter", "FlateDecode"); 244 pdfDict.insertName("Filter", "FlateDecode");
245 } 245 }
246 pdfDict.insertInt("Length", length); 246 pdfDict.insertInt("Length", length);
247 pdfDict.emitObject(stream, catalog); 247 pdfDict.emitObject(stream, catalog);
248 } 248 }
249 249
250 SkPDFBitmap::SkPDFBitmap(SkPDFCanon* canon, 250 SkPDFBitmap::SkPDFBitmap(const SkBitmap& bm,
251 const SkBitmap& bm,
252 SkPDFObject* smask) 251 SkPDFObject* smask)
253 : fCanon(canon), fBitmap(bm), fSMask(smask) {} 252 : fBitmap(bm), fSMask(smask) {}
254 253
255 SkPDFBitmap::~SkPDFBitmap() { fCanon->removeBitmap(this); } 254 SkPDFBitmap::~SkPDFBitmap() {}
256 255
257 //////////////////////////////////////////////////////////////////////////////// 256 ////////////////////////////////////////////////////////////////////////////////
258 static bool is_transparent(const SkBitmap& bm) { 257 static bool is_transparent(const SkBitmap& bm) {
259 SkAutoLockPixels autoLockPixels(bm); 258 SkAutoLockPixels autoLockPixels(bm);
260 if (NULL == bm.getPixels()) { 259 if (NULL == bm.getPixels()) {
261 return true; 260 return true;
262 } 261 }
263 SkASSERT(kN32_SkColorType == bm.colorType()); 262 SkASSERT(kN32_SkColorType == bm.colorType());
264 for (int y = 0; y < bm.height(); ++y) { 263 for (int y = 0; y < bm.height(); ++y) {
265 U8CPU alpha = 0; 264 U8CPU alpha = 0;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 } 304 }
306 SkPDFObject* smask = NULL; 305 SkPDFObject* smask = NULL;
307 if (!bm.isOpaque() && !SkBitmap::ComputeIsOpaque(bm)) { 306 if (!bm.isOpaque() && !SkBitmap::ComputeIsOpaque(bm)) {
308 if (is_transparent(bm)) { 307 if (is_transparent(bm)) {
309 return NULL; 308 return NULL;
310 } 309 }
311 // PDFAlphaBitmaps do not get directly canonicalized (they 310 // PDFAlphaBitmaps do not get directly canonicalized (they
312 // are refed by the SkPDFBitmap). 311 // are refed by the SkPDFBitmap).
313 smask = SkNEW_ARGS(PDFAlphaBitmap, (bm)); 312 smask = SkNEW_ARGS(PDFAlphaBitmap, (bm));
314 } 313 }
315 pdfBitmap = SkNEW_ARGS(SkPDFBitmap, (canon, bm, smask)); 314 pdfBitmap = SkNEW_ARGS(SkPDFBitmap, (bm, smask));
316 canon->addBitmap(pdfBitmap); 315 canon->addBitmap(pdfBitmap);
317 return pdfBitmap; 316 return pdfBitmap;
318 } 317 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFBitmap.h ('k') | src/pdf/SkPDFCanon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698