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

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

Issue 1505763003: SkDocument::setDCTEncoder() for old versions of webkit (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-12-09 (Wednesday) 13:41:21 EST Created 5 years 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/pdf/SkPDFBitmap.h ('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 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 pdfDict.insertInt("Length", SkToInt(fData->size())); 461 pdfDict.insertInt("Length", SkToInt(fData->size()));
462 pdfDict.emitObject(stream, objNumMap, substituteMap); 462 pdfDict.emitObject(stream, objNumMap, substituteMap);
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 SkAutoTUnref<SkData> data(image->refEncoded()); 473 SkAutoTUnref<SkData> data(image->refEncoded());
473 SkJFIFInfo info; 474 SkJFIFInfo info;
474 if (data && SkIsJFIF(data, &info)) { 475 if (data && SkIsJFIF(data, &info)) {
475 bool yuv = info.fType == SkJFIFInfo::kYCbCr; 476 bool yuv = info.fType == SkJFIFInfo::kYCbCr;
476 if (info.fSize == image->dimensions()) { // Sanity check. 477 if (info.fSize == image->dimensions()) { // Sanity check.
477 // hold on to data, not image. 478 // hold on to data, not image.
478 #ifdef SK_PDF_IMAGE_STATS 479 #ifdef SK_PDF_IMAGE_STATS
479 gJpegImageObjects.fetch_add(1); 480 gJpegImageObjects.fetch_add(1);
480 #endif 481 #endif
481 return new PDFJpegBitmap(info.fSize, data, yuv); 482 return new PDFJpegBitmap(info.fSize, data, yuv);
482 } 483 }
483 } 484 }
485
486 if (pixelSerializer) {
487 SkBitmap bm;
488 SkAutoPixmapUnlock apu;
489 if (as_IB(image)->getROPixels(&bm) && bm.requestLock(&apu)) {
490 data.reset(pixelSerializer->encode(apu.pixmap()));
491 if (data && SkIsJFIF(data, &info)) {
492 bool yuv = info.fType == SkJFIFInfo::kYCbCr;
493 if (info.fSize == image->dimensions()) { // Sanity check.
494 return new PDFJpegBitmap(info.fSize, data, yuv);
495 }
496 }
497 }
498 }
499
484 SkPDFObject* smask = 500 SkPDFObject* smask =
485 image_compute_is_opaque(image) ? nullptr : new PDFAlphaBitmap(image) ; 501 image_compute_is_opaque(image) ? nullptr : new PDFAlphaBitmap(image) ;
486 #ifdef SK_PDF_IMAGE_STATS 502 #ifdef SK_PDF_IMAGE_STATS
487 gRegularImageObjects.fetch_add(1); 503 gRegularImageObjects.fetch_add(1);
488 #endif 504 #endif
489 return new PDFDefaultBitmap(image, smask); 505 return new PDFDefaultBitmap(image, smask);
490 } 506 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFBitmap.h ('k') | src/pdf/SkPDFCanon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698