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

Side by Side Diff: src/effects/SkRectShaderImageFilter.cpp

Issue 92793002: Fixed bad bitmap size crashes (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Changed getSize name to getAllocatedSizeInBytes Created 7 years 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 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 "SkRectShaderImageFilter.h" 8 #include "SkRectShaderImageFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 SkBitmap* result, 55 SkBitmap* result,
56 SkIPoint* offset) { 56 SkIPoint* offset) {
57 SkIRect bounds; 57 SkIRect bounds;
58 source.getBounds(&bounds); 58 source.getBounds(&bounds);
59 if (!this->applyCropRect(&bounds, ctm)) { 59 if (!this->applyCropRect(&bounds, ctm)) {
60 return false; 60 return false;
61 } 61 }
62 62
63 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), 63 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(),
64 bounds.height())); 64 bounds.height()));
65 if (NULL == device.get()) {
66 return false;
67 }
65 SkCanvas canvas(device.get()); 68 SkCanvas canvas(device.get());
66 SkPaint paint; 69 SkPaint paint;
67 paint.setShader(fShader); 70 paint.setShader(fShader);
68 SkMatrix matrix; 71 SkMatrix matrix;
69 matrix.setTranslate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop )); 72 matrix.setTranslate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop ));
70 fShader->setLocalMatrix(matrix); 73 fShader->setLocalMatrix(matrix);
71 SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()), SkIntToScalar(bo unds.height())); 74 SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()), SkIntToScalar(bo unds.height()));
72 canvas.drawRect(rect, paint); 75 canvas.drawRect(rect, paint);
73 *result = device.get()->accessBitmap(false); 76 *result = device.get()->accessBitmap(false);
74 offset->fX += bounds.fLeft; 77 offset->fX += bounds.fLeft;
75 offset->fY += bounds.fTop; 78 offset->fY += bounds.fTop;
76 return true; 79 return true;
77 } 80 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698