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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 | 373 |
374 pdf_stream_begin(stream); | 374 pdf_stream_begin(stream); |
375 stream->writeStream(asset.get(), asset->getLength()); | 375 stream->writeStream(asset.get(), asset->getLength()); |
376 pdf_stream_end(stream); | 376 pdf_stream_end(stream); |
377 } | 377 } |
378 | 378 |
379 //////////////////////////////////////////////////////////////////////////////// | 379 //////////////////////////////////////////////////////////////////////////////// |
380 | 380 |
381 namespace { | 381 namespace { |
382 // This SkPDFObject only outputs the alpha layer of the given bitmap. | 382 // This SkPDFObject only outputs the alpha layer of the given bitmap. |
383 class PDFAlphaBitmap : public SkPDFObject { | 383 class PDFAlphaBitmap final : public SkPDFObject { |
384 public: | 384 public: |
385 PDFAlphaBitmap(const SkImage* image) : fImage(SkRef(image)) {} | 385 PDFAlphaBitmap(const SkImage* image) : fImage(SkRef(image)) {} |
386 ~PDFAlphaBitmap() {} | 386 ~PDFAlphaBitmap() {} |
387 void emitObject(SkWStream* stream, | 387 void emitObject(SkWStream* stream, |
388 const SkPDFObjNumMap& objNumMap, | 388 const SkPDFObjNumMap& objNumMap, |
389 const SkPDFSubstituteMap& subs) const override { | 389 const SkPDFSubstituteMap& subs) const override { |
390 emit_image_xobject(stream, fImage, true, nullptr, objNumMap, subs); | 390 emit_image_xobject(stream, fImage, true, nullptr, objNumMap, subs); |
391 } | 391 } |
392 | 392 |
393 private: | 393 private: |
394 SkAutoTUnref<const SkImage> fImage; | 394 SkAutoTUnref<const SkImage> fImage; |
395 }; | 395 }; |
396 | 396 |
397 } // namespace | 397 } // namespace |
398 | 398 |
399 //////////////////////////////////////////////////////////////////////////////// | 399 //////////////////////////////////////////////////////////////////////////////// |
400 | 400 |
401 namespace { | 401 namespace { |
402 class PDFDefaultBitmap : public SkPDFObject { | 402 class PDFDefaultBitmap final : public SkPDFObject { |
403 public: | 403 public: |
404 void emitObject(SkWStream* stream, | 404 void emitObject(SkWStream* stream, |
405 const SkPDFObjNumMap& objNumMap, | 405 const SkPDFObjNumMap& objNumMap, |
406 const SkPDFSubstituteMap& subs) const override { | 406 const SkPDFSubstituteMap& subs) const override { |
407 emit_image_xobject(stream, fImage, false, fSMask, objNumMap, subs); | 407 emit_image_xobject(stream, fImage, false, fSMask, objNumMap, subs); |
408 } | 408 } |
409 void addResources(SkPDFObjNumMap* catalog, | 409 void addResources(SkPDFObjNumMap* catalog, |
410 const SkPDFSubstituteMap& subs) const override { | 410 const SkPDFSubstituteMap& subs) const override { |
411 if (fSMask.get()) { | 411 if (fSMask.get()) { |
412 SkPDFObject* obj = subs.getSubstitute(fSMask.get()); | 412 SkPDFObject* obj = subs.getSubstitute(fSMask.get()); |
(...skipping 11 matching lines...) Expand all Loading... |
424 } // namespace | 424 } // namespace |
425 | 425 |
426 //////////////////////////////////////////////////////////////////////////////// | 426 //////////////////////////////////////////////////////////////////////////////// |
427 | 427 |
428 namespace { | 428 namespace { |
429 /** | 429 /** |
430 * This PDFObject assumes that its constructor was handed YUV or | 430 * This PDFObject assumes that its constructor was handed YUV or |
431 * Grayscale JFIF Jpeg-encoded data that can be directly embedded | 431 * Grayscale JFIF Jpeg-encoded data that can be directly embedded |
432 * into a PDF. | 432 * into a PDF. |
433 */ | 433 */ |
434 class PDFJpegBitmap : public SkPDFObject { | 434 class PDFJpegBitmap final : public SkPDFObject { |
435 public: | 435 public: |
436 SkISize fSize; | 436 SkISize fSize; |
437 SkAutoTUnref<SkData> fData; | 437 SkAutoTUnref<SkData> fData; |
438 bool fIsYUV; | 438 bool fIsYUV; |
439 PDFJpegBitmap(SkISize size, SkData* data, bool isYUV) | 439 PDFJpegBitmap(SkISize size, SkData* data, bool isYUV) |
440 : fSize(size), fData(SkRef(data)), fIsYUV(isYUV) {} | 440 : fSize(size), fData(SkRef(data)), fIsYUV(isYUV) {} |
441 void emitObject(SkWStream*, | 441 void emitObject(SkWStream*, |
442 const SkPDFObjNumMap&, | 442 const SkPDFObjNumMap&, |
443 const SkPDFSubstituteMap&) const override; | 443 const SkPDFSubstituteMap&) const override; |
444 }; | 444 }; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 return new PDFJpegBitmap(info.fSize, data, yuv); | 481 return new PDFJpegBitmap(info.fSize, data, yuv); |
482 } | 482 } |
483 } | 483 } |
484 SkPDFObject* smask = | 484 SkPDFObject* smask = |
485 image_compute_is_opaque(image) ? nullptr : new PDFAlphaBitmap(image)
; | 485 image_compute_is_opaque(image) ? nullptr : new PDFAlphaBitmap(image)
; |
486 #ifdef SK_PDF_IMAGE_STATS | 486 #ifdef SK_PDF_IMAGE_STATS |
487 gRegularImageObjects.fetch_add(1); | 487 gRegularImageObjects.fetch_add(1); |
488 #endif | 488 #endif |
489 return new PDFDefaultBitmap(image, smask); | 489 return new PDFDefaultBitmap(image, smask); |
490 } | 490 } |
OLD | NEW |