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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 pdf_stream_end(stream); | 432 pdf_stream_end(stream); |
433 } | 433 } |
434 } // namespace | 434 } // namespace |
435 | 435 |
436 //////////////////////////////////////////////////////////////////////////////// | 436 //////////////////////////////////////////////////////////////////////////////// |
437 | 437 |
438 SkPDFBitmap* SkPDFBitmap::Create(SkPDFCanon* canon, const SkBitmap& bitmap) { | 438 SkPDFBitmap* SkPDFBitmap::Create(SkPDFCanon* canon, const SkBitmap& bitmap) { |
439 SkASSERT(canon); | 439 SkASSERT(canon); |
440 if (!SkColorTypeIsValid(bitmap.colorType()) || | 440 if (!SkColorTypeIsValid(bitmap.colorType()) || |
441 kUnknown_SkColorType == bitmap.colorType()) { | 441 kUnknown_SkColorType == bitmap.colorType()) { |
442 return NULL; | 442 return nullptr; |
443 } | 443 } |
444 SkBitmap copy; | 444 SkBitmap copy; |
445 const SkBitmap& bm = immutable_bitmap(bitmap, ©); | 445 const SkBitmap& bm = immutable_bitmap(bitmap, ©); |
446 if (bm.drawsNothing()) { | 446 if (bm.drawsNothing()) { |
447 return NULL; | 447 return nullptr; |
448 } | 448 } |
449 if (SkPDFBitmap* canonBitmap = canon->findBitmap(bm)) { | 449 if (SkPDFBitmap* canonBitmap = canon->findBitmap(bm)) { |
450 return SkRef(canonBitmap); | 450 return SkRef(canonBitmap); |
451 } | 451 } |
452 | 452 |
453 if (bm.pixelRef() && bm.pixelRefOrigin().isZero() && | 453 if (bm.pixelRef() && bm.pixelRefOrigin().isZero() && |
454 bm.dimensions() == bm.pixelRef()->info().dimensions()) { | 454 bm.dimensions() == bm.pixelRef()->info().dimensions()) { |
455 // Requires the bitmap to be backed by lazy pixels. | 455 // Requires the bitmap to be backed by lazy pixels. |
456 SkAutoTUnref<SkData> data(bm.pixelRef()->refEncodedData()); | 456 SkAutoTUnref<SkData> data(bm.pixelRef()->refEncodedData()); |
457 SkJFIFInfo info; | 457 SkJFIFInfo info; |
458 if (data && SkIsJFIF(data, &info)) { | 458 if (data && SkIsJFIF(data, &info)) { |
459 bool yuv = info.fType == SkJFIFInfo::kYCbCr; | 459 bool yuv = info.fType == SkJFIFInfo::kYCbCr; |
460 SkPDFBitmap* pdfBitmap = new PDFJpegBitmap(bm, data, yuv); | 460 SkPDFBitmap* pdfBitmap = new PDFJpegBitmap(bm, data, yuv); |
461 canon->addBitmap(pdfBitmap); | 461 canon->addBitmap(pdfBitmap); |
462 return pdfBitmap; | 462 return pdfBitmap; |
463 } | 463 } |
464 } | 464 } |
465 | 465 |
466 SkPDFObject* smask = NULL; | 466 SkPDFObject* smask = nullptr; |
467 if (!bm.isOpaque() && !SkBitmap::ComputeIsOpaque(bm)) { | 467 if (!bm.isOpaque() && !SkBitmap::ComputeIsOpaque(bm)) { |
468 smask = new PDFAlphaBitmap(bm); | 468 smask = new PDFAlphaBitmap(bm); |
469 } | 469 } |
470 SkPDFBitmap* pdfBitmap = new PDFDefaultBitmap(bm, smask); | 470 SkPDFBitmap* pdfBitmap = new PDFDefaultBitmap(bm, smask); |
471 canon->addBitmap(pdfBitmap); | 471 canon->addBitmap(pdfBitmap); |
472 return pdfBitmap; | 472 return pdfBitmap; |
473 } | 473 } |
OLD | NEW |