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

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

Issue 1771073002: SkPDF: s/SkAutoTUnref/sk_sp/g (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 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/doc/SkDocument_PDF.cpp ('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 "SkData.h" 9 #include "SkData.h"
10 #include "SkDeflate.h" 10 #include "SkDeflate.h"
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
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.get(), true, nullptr, objNumMap, subs) ; 390 emit_image_xobject(stream, fImage.get(), true, nullptr, objNumMap, subs) ;
391 } 391 }
392 392
393 private: 393 private:
394 SkAutoTUnref<const SkImage> fImage; 394 sk_sp<const SkImage> fImage;
395 }; 395 };
396 396
397 } // namespace 397 } // namespace
398 398
399 //////////////////////////////////////////////////////////////////////////////// 399 ////////////////////////////////////////////////////////////////////////////////
400 400
401 namespace { 401 namespace {
402 class PDFDefaultBitmap final : 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.get(), false, fSMask.get(), objNumMap, subs); 407 emit_image_xobject(stream, fImage.get(), false, fSMask.get(), 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());
413 SkASSERT(obj); 413 SkASSERT(obj);
414 catalog->addObjectRecursively(obj, subs); 414 catalog->addObjectRecursively(obj, subs);
415 } 415 }
416 } 416 }
417 PDFDefaultBitmap(const SkImage* image, SkPDFObject* smask) 417 PDFDefaultBitmap(const SkImage* image, SkPDFObject* smask)
418 : fImage(SkRef(image)), fSMask(smask) {} 418 : fImage(SkRef(image)), fSMask(smask) {}
419 419
420 private: 420 private:
421 SkAutoTUnref<const SkImage> fImage; 421 sk_sp<const SkImage> fImage;
422 const SkAutoTUnref<SkPDFObject> fSMask; 422 const sk_sp<SkPDFObject> fSMask;
423 }; 423 };
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 final : public SkPDFObject { 434 class PDFJpegBitmap final : public SkPDFObject {
435 public: 435 public:
436 SkISize fSize; 436 SkISize fSize;
437 SkAutoTUnref<SkData> fData; 437 sk_sp<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 };
445 445
446 void PDFJpegBitmap::emitObject(SkWStream* stream, 446 void PDFJpegBitmap::emitObject(SkWStream* stream,
447 const SkPDFObjNumMap& objNumMap, 447 const SkPDFObjNumMap& objNumMap,
(...skipping 15 matching lines...) Expand all
463 pdf_stream_begin(stream); 463 pdf_stream_begin(stream);
464 stream->write(fData->data(), fData->size()); 464 stream->write(fData->data(), fData->size());
465 pdf_stream_end(stream); 465 pdf_stream_end(stream);
466 } 466 }
467 } // namespace 467 } // namespace
468 468
469 //////////////////////////////////////////////////////////////////////////////// 469 ////////////////////////////////////////////////////////////////////////////////
470 470
471 SkPDFObject* SkPDFCreateBitmapObject(const SkImage* image, 471 SkPDFObject* SkPDFCreateBitmapObject(const SkImage* image,
472 SkPixelSerializer* pixelSerializer) { 472 SkPixelSerializer* pixelSerializer) {
473 SkAutoTUnref<SkData> data(image->refEncoded()); 473 sk_sp<SkData> data(image->refEncoded());
474 SkJFIFInfo info; 474 SkJFIFInfo info;
475 if (data && SkIsJFIF(data.get(), &info) && 475 if (data && SkIsJFIF(data.get(), &info) &&
476 (!pixelSerializer || 476 (!pixelSerializer ||
477 pixelSerializer->useEncodedData(data->data(), data->size()))) { 477 pixelSerializer->useEncodedData(data->data(), data->size()))) {
478 // If there is a SkPixelSerializer, give it a chance to 478 // If there is a SkPixelSerializer, give it a chance to
479 // re-encode the JPEG with more compression by returning false 479 // re-encode the JPEG with more compression by returning false
480 // from useEncodedData. 480 // from useEncodedData.
481 bool yuv = info.fType == SkJFIFInfo::kYCbCr; 481 bool yuv = info.fType == SkJFIFInfo::kYCbCr;
482 if (info.fSize == image->dimensions()) { // Sanity check. 482 if (info.fSize == image->dimensions()) { // Sanity check.
483 // hold on to data, not image. 483 // hold on to data, not image.
(...skipping 18 matching lines...) Expand all
502 } 502 }
503 } 503 }
504 504
505 SkPDFObject* smask = 505 SkPDFObject* smask =
506 image_compute_is_opaque(image) ? nullptr : new PDFAlphaBitmap(image) ; 506 image_compute_is_opaque(image) ? nullptr : new PDFAlphaBitmap(image) ;
507 #ifdef SK_PDF_IMAGE_STATS 507 #ifdef SK_PDF_IMAGE_STATS
508 gRegularImageObjects.fetch_add(1); 508 gRegularImageObjects.fetch_add(1);
509 #endif 509 #endif
510 return new PDFDefaultBitmap(image, smask); 510 return new PDFDefaultBitmap(image, smask);
511 } 511 }
OLDNEW
« no previous file with comments | « src/doc/SkDocument_PDF.cpp ('k') | src/pdf/SkPDFCanon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698