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

Side by Side Diff: src/pdf/SkPDFDevice.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/lazy/SkDiscardablePixelRef.cpp ('k') | src/pdf/SkPDFImage.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 2011 Google Inc. 2 * Copyright 2011 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 "SkPDFDevice.h" 8 #include "SkPDFDevice.h"
9 9
10 #include "SkAnnotation.h" 10 #include "SkAnnotation.h"
(...skipping 2102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2113 2113
2114 // TODO(edisonn): A better approach would be to use a bitmap shader 2114 // TODO(edisonn): A better approach would be to use a bitmap shader
2115 // (in clamp mode) and draw a rect over the entire bounding box. Then 2115 // (in clamp mode) and draw a rect over the entire bounding box. Then
2116 // intersect perspectiveOutline to the clip. That will avoid introducing 2116 // intersect perspectiveOutline to the clip. That will avoid introducing
2117 // alpha to the image while still giving good behavior at the edge of 2117 // alpha to the image while still giving good behavior at the edge of
2118 // the image. Avoiding alpha will reduce the pdf size and generation 2118 // the image. Avoiding alpha will reduce the pdf size and generation
2119 // CPU time some. 2119 // CPU time some.
2120 2120
2121 const int w = SkScalarCeilToInt(physicalPerspectiveOutline.getBounds().w idth()); 2121 const int w = SkScalarCeilToInt(physicalPerspectiveOutline.getBounds().w idth());
2122 const int h = SkScalarCeilToInt(physicalPerspectiveOutline.getBounds().h eight()); 2122 const int h = SkScalarCeilToInt(physicalPerspectiveOutline.getBounds().h eight());
2123 if (!perspectiveBitmap.allocPixels(SkImageInfo::MakeN32Premul(w, h))) { 2123 if (!perspectiveBitmap.tryAllocN32Pixels(w, h)) {
2124 return; 2124 return;
2125 } 2125 }
2126 perspectiveBitmap.eraseColor(SK_ColorTRANSPARENT); 2126 perspectiveBitmap.eraseColor(SK_ColorTRANSPARENT);
2127 2127
2128 SkCanvas canvas(perspectiveBitmap); 2128 SkCanvas canvas(perspectiveBitmap);
2129 2129
2130 SkScalar deltaX = bounds.left(); 2130 SkScalar deltaX = bounds.left();
2131 SkScalar deltaY = bounds.top(); 2131 SkScalar deltaY = bounds.top();
2132 2132
2133 SkMatrix offsetMatrix = origMatrix; 2133 SkMatrix offsetMatrix = origMatrix;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2185 SkAutoTUnref<SkPDFObject> image( 2185 SkAutoTUnref<SkPDFObject> image(
2186 SkPDFCreateImageObject(*bitmap, subset, fEncoder)); 2186 SkPDFCreateImageObject(*bitmap, subset, fEncoder));
2187 if (!image) { 2187 if (!image) {
2188 return; 2188 return;
2189 } 2189 }
2190 2190
2191 SkPDFUtils::DrawFormXObject(this->addXObjectResource(image.get()), 2191 SkPDFUtils::DrawFormXObject(this->addXObjectResource(image.get()),
2192 &content.entry()->fContent); 2192 &content.entry()->fContent);
2193 } 2193 }
2194 2194
OLDNEW
« no previous file with comments | « src/lazy/SkDiscardablePixelRef.cpp ('k') | src/pdf/SkPDFImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698