Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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(SkPDFCanon* canon, |
| 251 const SkBitmap& bm, | 251 const SkBitmap& bm, |
| 252 SkPDFObject* smask) | 252 SkPDFObject* smask) |
| 253 : fCanon(canon), fBitmap(bm), fSMask(smask) {} | 253 : fCanon(canon), fBitmap(bm), fSMask(smask) {} |
| 254 | 254 |
| 255 SkPDFBitmap::~SkPDFBitmap() { fCanon->removeBitmap(this); } | 255 SkPDFBitmap::~SkPDFBitmap() {} |
| 256 | 256 |
| 257 //////////////////////////////////////////////////////////////////////////////// | 257 //////////////////////////////////////////////////////////////////////////////// |
| 258 static bool is_transparent(const SkBitmap& bm) { | 258 static bool is_transparent(const SkBitmap& bm) { |
| 259 SkAutoLockPixels autoLockPixels(bm); | 259 SkAutoLockPixels autoLockPixels(bm); |
| 260 if (NULL == bm.getPixels()) { | 260 if (NULL == bm.getPixels()) { |
| 261 return true; | 261 return true; |
| 262 } | 262 } |
| 263 SkASSERT(kN32_SkColorType == bm.colorType()); | 263 SkASSERT(kN32_SkColorType == bm.colorType()); |
| 264 for (int y = 0; y < bm.height(); ++y) { | 264 for (int y = 0; y < bm.height(); ++y) { |
| 265 U8CPU alpha = 0; | 265 U8CPU alpha = 0; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 SkPDFObject* smask = NULL; | 306 SkPDFObject* smask = NULL; |
| 307 if (!bm.isOpaque() && !SkBitmap::ComputeIsOpaque(bm)) { | 307 if (!bm.isOpaque() && !SkBitmap::ComputeIsOpaque(bm)) { |
| 308 if (is_transparent(bm)) { | 308 if (is_transparent(bm)) { |
| 309 return NULL; | 309 return NULL; |
| 310 } | 310 } |
| 311 // PDFAlphaBitmaps do not get directly canonicalized (they | 311 // PDFAlphaBitmaps do not get directly canonicalized (they |
| 312 // are refed by the SkPDFBitmap). | 312 // are refed by the SkPDFBitmap). |
| 313 smask = SkNEW_ARGS(PDFAlphaBitmap, (bm)); | 313 smask = SkNEW_ARGS(PDFAlphaBitmap, (bm)); |
| 314 } | 314 } |
| 315 pdfBitmap = SkNEW_ARGS(SkPDFBitmap, (canon, bm, smask)); | 315 pdfBitmap = SkNEW_ARGS(SkPDFBitmap, (canon, bm, smask)); |
| 316 canon->addBitmap(pdfBitmap); | 316 canon->addBitmap(SkRef(pdfBitmap)); |
|
mtklein
2015/02/27 19:50:17
This seems to distribute the responsibility for re
hal.canary
2015/02/27 20:13:42
Done.
| |
| 317 return pdfBitmap; | 317 return pdfBitmap; |
| 318 } | 318 } |
| OLD | NEW |