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

Side by Side Diff: src/utils/SkPDFRasterizer.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/SkPDFImage.cpp ('k') | src/utils/mac/SkCreateCGImageRef.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 /* 2 /*
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #ifdef SK_BUILD_FOR_WIN32 9 #ifdef SK_BUILD_FOR_WIN32
10 #pragma warning(push) 10 #pragma warning(push)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 if (!image.is_valid() || image.format() != poppler::image::format_argb32) { 44 if (!image.is_valid() || image.format() != poppler::image::format_argb32) {
45 return false; 45 return false;
46 } 46 }
47 47
48 int width = image.width(), height = image.height(); 48 int width = image.width(), height = image.height();
49 size_t rowSize = image.bytes_per_row(); 49 size_t rowSize = image.bytes_per_row();
50 char *imgData = image.data(); 50 char *imgData = image.data();
51 51
52 SkBitmap bitmap; 52 SkBitmap bitmap;
53 if (!bitmap.allocPixels(SkImageInfo::MakeN32Premul(width, height))) { 53 if (!bitmap.tryAllocN32Pixels(width, height)) {
54 return false; 54 return false;
55 } 55 }
56 bitmap.eraseColor(SK_ColorWHITE); 56 bitmap.eraseColor(SK_ColorWHITE);
57 SkPMColor* bitmapPixels = (SkPMColor*)bitmap.getPixels(); 57 SkPMColor* bitmapPixels = (SkPMColor*)bitmap.getPixels();
58 58
59 // do pixel-by-pixel copy to deal with RGBA ordering conversions 59 // do pixel-by-pixel copy to deal with RGBA ordering conversions
60 for (int y = 0; y < height; y++) { 60 for (int y = 0; y < height; y++) {
61 char *rowData = imgData; 61 char *rowData = imgData;
62 for (int x = 0; x < width; x++) { 62 for (int x = 0; x < width; x++) {
63 uint8_t a = rowData[3]; 63 uint8_t a = rowData[3];
(...skipping 13 matching lines...) Expand all
77 77
78 return true; 78 return true;
79 } 79 }
80 #endif // SK_BUILD_POPPLER 80 #endif // SK_BUILD_POPPLER
81 81
82 #ifdef SK_BUILD_NATIVE_PDF_RENDERER 82 #ifdef SK_BUILD_NATIVE_PDF_RENDERER
83 bool SkNativeRasterizePDF(SkStream* pdf, SkBitmap* output) { 83 bool SkNativeRasterizePDF(SkStream* pdf, SkBitmap* output) {
84 return SkPDFNativeRenderToBitmap(pdf, output); 84 return SkPDFNativeRenderToBitmap(pdf, output);
85 } 85 }
86 #endif // SK_BUILD_NATIVE_PDF_RENDERER 86 #endif // SK_BUILD_NATIVE_PDF_RENDERER
OLDNEW
« no previous file with comments | « src/pdf/SkPDFImage.cpp ('k') | src/utils/mac/SkCreateCGImageRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698