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

Side by Side Diff: src/effects/SkBlurImageFilter.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/effects/SkAlphaThresholdFilter.cpp ('k') | src/effects/SkDisplacementMapEffect.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 The Android Open Source Project 2 * Copyright 2011 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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkBlurImageFilter.h" 9 #include "SkBlurImageFilter.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 SkIRect srcBounds, dstBounds; 165 SkIRect srcBounds, dstBounds;
166 if (!this->applyCropRect(ctx, proxy, src, &srcOffset, &srcBounds, &src)) { 166 if (!this->applyCropRect(ctx, proxy, src, &srcOffset, &srcBounds, &src)) {
167 return false; 167 return false;
168 } 168 }
169 169
170 SkAutoLockPixels alp(src); 170 SkAutoLockPixels alp(src);
171 if (!src.getPixels()) { 171 if (!src.getPixels()) {
172 return false; 172 return false;
173 } 173 }
174 174
175 if (!dst->allocPixels(src.info().makeWH(srcBounds.width(), srcBounds.height( )))) { 175 if (!dst->tryAllocPixels(src.info().makeWH(srcBounds.width(), srcBounds.heig ht()))) {
176 return false; 176 return false;
177 } 177 }
178 dst->getBounds(&dstBounds); 178 dst->getBounds(&dstBounds);
179 179
180 SkVector sigma = SkVector::Make(fSigma.width(), fSigma.height()); 180 SkVector sigma = SkVector::Make(fSigma.width(), fSigma.height());
181 ctx.ctm().mapVectors(&sigma, 1); 181 ctx.ctm().mapVectors(&sigma, 1);
182 sigma.fX = SkMinScalar(sigma.fX, MAX_SIGMA); 182 sigma.fX = SkMinScalar(sigma.fX, MAX_SIGMA);
183 sigma.fY = SkMinScalar(sigma.fY, MAX_SIGMA); 183 sigma.fY = SkMinScalar(sigma.fY, MAX_SIGMA);
184 184
185 int kernelSizeX, kernelSizeX3, lowOffsetX, highOffsetX; 185 int kernelSizeX, kernelSizeX3, lowOffsetX, highOffsetX;
186 int kernelSizeY, kernelSizeY3, lowOffsetY, highOffsetY; 186 int kernelSizeY, kernelSizeY3, lowOffsetY, highOffsetY;
187 getBox3Params(sigma.x(), &kernelSizeX, &kernelSizeX3, &lowOffsetX, &highOffs etX); 187 getBox3Params(sigma.x(), &kernelSizeX, &kernelSizeX3, &lowOffsetX, &highOffs etX);
188 getBox3Params(sigma.y(), &kernelSizeY, &kernelSizeY3, &lowOffsetY, &highOffs etY); 188 getBox3Params(sigma.y(), &kernelSizeY, &kernelSizeY3, &lowOffsetY, &highOffs etY);
189 189
190 if (kernelSizeX < 0 || kernelSizeY < 0) { 190 if (kernelSizeX < 0 || kernelSizeY < 0) {
191 return false; 191 return false;
192 } 192 }
193 193
194 if (kernelSizeX == 0 && kernelSizeY == 0) { 194 if (kernelSizeX == 0 && kernelSizeY == 0) {
195 src.copyTo(dst, dst->colorType()); 195 src.copyTo(dst, dst->colorType());
196 offset->fX = srcBounds.fLeft; 196 offset->fX = srcBounds.fLeft;
197 offset->fY = srcBounds.fTop; 197 offset->fY = srcBounds.fTop;
198 return true; 198 return true;
199 } 199 }
200 200
201 SkBitmap temp; 201 SkBitmap temp;
202 if (!temp.allocPixels(dst->info())) { 202 if (!temp.tryAllocPixels(dst->info())) {
203 return false; 203 return false;
204 } 204 }
205 205
206 offset->fX = srcBounds.fLeft; 206 offset->fX = srcBounds.fLeft;
207 offset->fY = srcBounds.fTop; 207 offset->fY = srcBounds.fTop;
208 srcBounds.offset(-srcOffset); 208 srcBounds.offset(-srcOffset);
209 const SkPMColor* s = src.getAddr32(srcBounds.left(), srcBounds.top()); 209 const SkPMColor* s = src.getAddr32(srcBounds.left(), srcBounds.top());
210 SkPMColor* t = temp.getAddr32(0, 0); 210 SkPMColor* t = temp.getAddr32(0, 0);
211 SkPMColor* d = dst->getAddr32(0, 0); 211 SkPMColor* d = dst->getAddr32(0, 0);
212 int w = dstBounds.width(), h = dstBounds.height(); 212 int w = dstBounds.width(), h = dstBounds.height();
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 true, 291 true,
292 sigma.x(), 292 sigma.x(),
293 sigma.y())); 293 sigma.y()));
294 WrapTexture(tex, rect.width(), rect.height(), result); 294 WrapTexture(tex, rect.width(), rect.height(), result);
295 return true; 295 return true;
296 #else 296 #else
297 SkDEBUGFAIL("Should not call in GPU-less build"); 297 SkDEBUGFAIL("Should not call in GPU-less build");
298 return false; 298 return false;
299 #endif 299 #endif
300 } 300 }
OLDNEW
« no previous file with comments | « src/effects/SkAlphaThresholdFilter.cpp ('k') | src/effects/SkDisplacementMapEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698