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

Side by Side Diff: src/effects/SkColorFilterImageFilter.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 2012 The Android Open Source Project 2 * Copyright 2012 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 "SkColorFilterImageFilter.h" 8 #include "SkColorFilterImageFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 return false; 106 return false;
107 } 107 }
108 108
109 SkIRect bounds; 109 SkIRect bounds;
110 src.getBounds(&bounds); 110 src.getBounds(&bounds);
111 if (!this->applyCropRect(&bounds, matrix)) { 111 if (!this->applyCropRect(&bounds, matrix)) {
112 return false; 112 return false;
113 } 113 }
114 114
115 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds .height())); 115 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds .height()));
116 if (NULL == device.get()) {
117 return false;
118 }
116 SkCanvas canvas(device.get()); 119 SkCanvas canvas(device.get());
117 SkPaint paint; 120 SkPaint paint;
118 121
119 paint.setXfermodeMode(SkXfermode::kSrc_Mode); 122 paint.setXfermodeMode(SkXfermode::kSrc_Mode);
120 paint.setColorFilter(fColorFilter); 123 paint.setColorFilter(fColorFilter);
121 canvas.drawSprite(src, -bounds.fLeft, -bounds.fTop, &paint); 124 canvas.drawSprite(src, -bounds.fLeft, -bounds.fTop, &paint);
122 125
123 *result = device.get()->accessBitmap(false); 126 *result = device.get()->accessBitmap(false);
124 loc->fX += bounds.fLeft; 127 loc->fX += bounds.fLeft;
125 loc->fY += bounds.fTop; 128 loc->fY += bounds.fTop;
126 return true; 129 return true;
127 } 130 }
128 131
129 bool SkColorFilterImageFilter::asColorFilter(SkColorFilter** filter) const { 132 bool SkColorFilterImageFilter::asColorFilter(SkColorFilter** filter) const {
130 if (!cropRectIsSet()) { 133 if (!cropRectIsSet()) {
131 if (filter) { 134 if (filter) {
132 *filter = fColorFilter; 135 *filter = fColorFilter;
133 fColorFilter->ref(); 136 fColorFilter->ref();
134 } 137 }
135 return true; 138 return true;
136 } 139 }
137 return false; 140 return false;
138 } 141 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698