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

Side by Side Diff: src/effects/SkOffsetImageFilter.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 "SkOffsetImageFilter.h" 8 #include "SkOffsetImageFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 30 matching lines...) Expand all
41 } 41 }
42 42
43 SkIRect bounds; 43 SkIRect bounds;
44 src.getBounds(&bounds); 44 src.getBounds(&bounds);
45 45
46 if (!applyCropRect(&bounds, matrix)) { 46 if (!applyCropRect(&bounds, matrix)) {
47 return false; 47 return false;
48 } 48 }
49 49
50 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bo unds.height())); 50 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bo unds.height()));
51 if (NULL == device.get()) {
52 return false;
53 }
51 SkCanvas canvas(device); 54 SkCanvas canvas(device);
52 SkPaint paint; 55 SkPaint paint;
53 paint.setXfermodeMode(SkXfermode::kSrc_Mode); 56 paint.setXfermodeMode(SkXfermode::kSrc_Mode);
54 canvas.drawBitmap(src, fOffset.fX - bounds.left(), fOffset.fY - bounds.t op(), &paint); 57 canvas.drawBitmap(src, fOffset.fX - bounds.left(), fOffset.fY - bounds.t op(), &paint);
55 *result = device->accessBitmap(false); 58 *result = device->accessBitmap(false);
56 loc->fX += bounds.left(); 59 loc->fX += bounds.left();
57 loc->fY += bounds.top(); 60 loc->fY += bounds.top();
58 } 61 }
59 return true; 62 return true;
60 } 63 }
(...skipping 17 matching lines...) Expand all
78 const CropRect* cropRect) : INHERITED(i nput, cropRect) { 81 const CropRect* cropRect) : INHERITED(i nput, cropRect) {
79 fOffset.set(dx, dy); 82 fOffset.set(dx, dy);
80 } 83 }
81 84
82 SkOffsetImageFilter::SkOffsetImageFilter(SkFlattenableReadBuffer& buffer) 85 SkOffsetImageFilter::SkOffsetImageFilter(SkFlattenableReadBuffer& buffer)
83 : INHERITED(1, buffer) { 86 : INHERITED(1, buffer) {
84 buffer.readPoint(&fOffset); 87 buffer.readPoint(&fOffset);
85 buffer.validate(SkScalarIsFinite(fOffset.fX) && 88 buffer.validate(SkScalarIsFinite(fOffset.fX) &&
86 SkScalarIsFinite(fOffset.fY)); 89 SkScalarIsFinite(fOffset.fY));
87 } 90 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698