| 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 "SkData.h" | 9 #include "SkData.h" |
| 10 #include "SkDeflate.h" | 10 #include "SkDeflate.h" |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 | 339 |
| 340 // Write to a temporary buffer to get the compressed length. | 340 // Write to a temporary buffer to get the compressed length. |
| 341 SkDynamicMemoryWStream buffer; | 341 SkDynamicMemoryWStream buffer; |
| 342 SkDeflateWStream deflateWStream(&buffer); | 342 SkDeflateWStream deflateWStream(&buffer); |
| 343 if (alpha) { | 343 if (alpha) { |
| 344 bitmap_alpha_to_a8(bitmap, &deflateWStream); | 344 bitmap_alpha_to_a8(bitmap, &deflateWStream); |
| 345 } else { | 345 } else { |
| 346 bitmap_to_pdf_pixels(bitmap, &deflateWStream); | 346 bitmap_to_pdf_pixels(bitmap, &deflateWStream); |
| 347 } | 347 } |
| 348 deflateWStream.finalize(); // call before detachAsStream(). | 348 deflateWStream.finalize(); // call before detachAsStream(). |
| 349 SkAutoTDelete<SkStreamAsset> asset(buffer.detachAsStream()); | 349 std::unique_ptr<SkStreamAsset> asset(buffer.detachAsStream()); |
| 350 | 350 |
| 351 SkPDFDict pdfDict("XObject"); | 351 SkPDFDict pdfDict("XObject"); |
| 352 pdfDict.insertName("Subtype", "Image"); | 352 pdfDict.insertName("Subtype", "Image"); |
| 353 pdfDict.insertInt("Width", bitmap.width()); | 353 pdfDict.insertInt("Width", bitmap.width()); |
| 354 pdfDict.insertInt("Height", bitmap.height()); | 354 pdfDict.insertInt("Height", bitmap.height()); |
| 355 if (alpha) { | 355 if (alpha) { |
| 356 pdfDict.insertName("ColorSpace", "DeviceGray"); | 356 pdfDict.insertName("ColorSpace", "DeviceGray"); |
| 357 } else if (bitmap.colorType() == kIndex_8_SkColorType) { | 357 } else if (bitmap.colorType() == kIndex_8_SkColorType) { |
| 358 SkASSERT(1 == pdf_color_component_count(bitmap.colorType())); | 358 SkASSERT(1 == pdf_color_component_count(bitmap.colorType())); |
| 359 pdfDict.insertObject("ColorSpace", | 359 pdfDict.insertObject("ColorSpace", |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 | 511 |
| 512 sk_sp<SkPDFObject> smask; | 512 sk_sp<SkPDFObject> smask; |
| 513 if (!image_compute_is_opaque(image.get())) { | 513 if (!image_compute_is_opaque(image.get())) { |
| 514 smask = sk_make_sp<PDFAlphaBitmap>(image); | 514 smask = sk_make_sp<PDFAlphaBitmap>(image); |
| 515 } | 515 } |
| 516 #ifdef SK_PDF_IMAGE_STATS | 516 #ifdef SK_PDF_IMAGE_STATS |
| 517 gRegularImageObjects.fetch_add(1); | 517 gRegularImageObjects.fetch_add(1); |
| 518 #endif | 518 #endif |
| 519 return sk_make_sp<PDFDefaultBitmap>(std::move(image), std::move(smask)); | 519 return sk_make_sp<PDFDefaultBitmap>(std::move(image), std::move(smask)); |
| 520 } | 520 } |
| OLD | NEW |