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

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

Issue 510423005: make allocPixels throw on failure (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 3 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/pdf/SkPDFDevice.cpp ('k') | src/utils/SkPDFRasterizer.cpp » ('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 2010 The Android Open Source Project 2 * Copyright 2010 The Android Open Source Project
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 "SkPDFImage.h" 8 #include "SkPDFImage.h"
9 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 return SkPackARGB4444(SK_AlphaOPAQUE & 0x0F, 0, 0, 0); 368 return SkPackARGB4444(SK_AlphaOPAQUE & 0x0F, 0, 0, 0);
369 } else { 369 } else {
370 return SkPackARGB4444(SK_AlphaOPAQUE & 0x0F, 370 return SkPackARGB4444(SK_AlphaOPAQUE & 0x0F,
371 r / count, g / count, b / count); 371 r / count, g / count, b / count);
372 } 372 }
373 } 373 }
374 374
375 static SkBitmap unpremultiply_bitmap(const SkBitmap& bitmap, 375 static SkBitmap unpremultiply_bitmap(const SkBitmap& bitmap,
376 const SkIRect& srcRect) { 376 const SkIRect& srcRect) {
377 SkBitmap outBitmap; 377 SkBitmap outBitmap;
378 SkAssertResult(outBitmap.allocPixels( 378 outBitmap.allocPixels(bitmap.info().makeWH(srcRect.width(), srcRect.height() ));
379 bitmap.info().makeWH(srcRect.width(), srcRect.height())));
380 int dstRow = 0; 379 int dstRow = 0;
381 380
382 SkAutoLockPixels outBitmapPixelLock(outBitmap); 381 SkAutoLockPixels outBitmapPixelLock(outBitmap);
383 SkAutoLockPixels bitmapPixelLock(bitmap); 382 SkAutoLockPixels bitmapPixelLock(bitmap);
384 switch (bitmap.colorType()) { 383 switch (bitmap.colorType()) {
385 case kARGB_4444_SkColorType: { 384 case kARGB_4444_SkColorType: {
386 for (int y = srcRect.fTop; y < srcRect.fBottom; y++) { 385 for (int y = srcRect.fTop; y < srcRect.fBottom; y++) {
387 uint16_t* dst = outBitmap.getAddr16(0, dstRow); 386 uint16_t* dst = outBitmap.getAddr16(0, dstRow);
388 uint16_t* src = bitmap.getAddr16(0, y); 387 uint16_t* src = bitmap.getAddr16(0, y);
389 for (int x = srcRect.fLeft; x < srcRect.fRight; x++) { 388 for (int x = srcRect.fLeft; x < srcRect.fRight; x++) {
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 SkPicture::EncodeBitmap encoder) { 709 SkPicture::EncodeBitmap encoder) {
711 if (SkIRect::MakeWH(bitmap.width(), bitmap.height()) == subset) { 710 if (SkIRect::MakeWH(bitmap.width(), bitmap.height()) == subset) {
712 SkAutoTUnref<SkData> encodedData(ref_encoded_data(bitmap)); 711 SkAutoTUnref<SkData> encodedData(ref_encoded_data(bitmap));
713 if (is_jfif_jpeg(encodedData)) { 712 if (is_jfif_jpeg(encodedData)) {
714 return SkNEW_ARGS(PDFJPEGImage, 713 return SkNEW_ARGS(PDFJPEGImage,
715 (encodedData, bitmap.width(), bitmap.height())); 714 (encodedData, bitmap.width(), bitmap.height()));
716 } 715 }
717 } 716 }
718 return SkPDFImage::CreateImage(bitmap, subset, encoder); 717 return SkPDFImage::CreateImage(bitmap, subset, encoder);
719 } 718 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFDevice.cpp ('k') | src/utils/SkPDFRasterizer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698