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

Side by Side Diff: src/core/SkPictureShader.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/core/SkCanvas.cpp ('k') | src/core/SkScalerContext.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 2014 Google Inc. 2 * Copyright 2014 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 "SkPictureShader.h" 8 #include "SkPictureShader.h"
9 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } 100 }
101 101
102 // The actual scale, compensating for rounding & clamping. 102 // The actual scale, compensating for rounding & clamping.
103 SkSize tileScale = SkSize::Make(SkIntToScalar(tileSize.width()) / fTile.widt h(), 103 SkSize tileScale = SkSize::Make(SkIntToScalar(tileSize.width()) / fTile.widt h(),
104 SkIntToScalar(tileSize.height()) / fTile.hei ght()); 104 SkIntToScalar(tileSize.height()) / fTile.hei ght());
105 105
106 SkAutoMutexAcquire ama(fCachedBitmapShaderMutex); 106 SkAutoMutexAcquire ama(fCachedBitmapShaderMutex);
107 107
108 if (!fCachedBitmapShader || tileScale != fCachedTileScale) { 108 if (!fCachedBitmapShader || tileScale != fCachedTileScale) {
109 SkBitmap bm; 109 SkBitmap bm;
110 if (!bm.allocN32Pixels(tileSize.width(), tileSize.height())) { 110 if (!bm.tryAllocN32Pixels(tileSize.width(), tileSize.height())) {
111 return NULL; 111 return NULL;
112 } 112 }
113 bm.eraseColor(SK_ColorTRANSPARENT); 113 bm.eraseColor(SK_ColorTRANSPARENT);
114 114
115 SkCanvas canvas(bm); 115 SkCanvas canvas(bm);
116 canvas.scale(tileScale.width(), tileScale.height()); 116 canvas.scale(tileScale.width(), tileScale.height());
117 canvas.translate(fTile.x(), fTile.y()); 117 canvas.translate(fTile.x(), fTile.y());
118 canvas.drawPicture(fPicture); 118 canvas.drawPicture(fPicture);
119 119
120 fCachedTileScale = tileScale; 120 fCachedTileScale = tileScale;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 return bitmapShader->asNewEffect(context, paint, NULL, paintColor, effect); 222 return bitmapShader->asNewEffect(context, paint, NULL, paintColor, effect);
223 } 223 }
224 #else 224 #else
225 bool SkPictureShader::asNewEffect(GrContext* context, const SkPaint& paint, 225 bool SkPictureShader::asNewEffect(GrContext* context, const SkPaint& paint,
226 const SkMatrix* localMatrix, GrColor* paintCol or, 226 const SkMatrix* localMatrix, GrColor* paintCol or,
227 GrEffect** effect) const { 227 GrEffect** effect) const {
228 SkDEBUGFAIL("Should not call in GPU-less build"); 228 SkDEBUGFAIL("Should not call in GPU-less build");
229 return false; 229 return false;
230 } 230 }
231 #endif 231 #endif
OLDNEW
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/core/SkScalerContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698