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

Side by Side Diff: src/effects/SkXfermodeImageFilter.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 The Android Open Source Project 2 * Copyright 2013 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 "SkXfermodeImageFilter.h" 8 #include "SkXfermodeImageFilter.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkDevice.h" 10 #include "SkDevice.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 background.getBounds(&bounds); 65 background.getBounds(&bounds);
66 if (!applyCropRect(&bounds, ctm)) { 66 if (!applyCropRect(&bounds, ctm)) {
67 return false; 67 return false;
68 } 68 }
69 backgroundOffset.fX -= bounds.left(); 69 backgroundOffset.fX -= bounds.left();
70 backgroundOffset.fY -= bounds.top(); 70 backgroundOffset.fY -= bounds.top();
71 foregroundOffset.fX -= bounds.left(); 71 foregroundOffset.fX -= bounds.left();
72 foregroundOffset.fY -= bounds.top(); 72 foregroundOffset.fY -= bounds.top();
73 73
74 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds .height())); 74 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds .height()));
75 if (NULL == device.get()) {
76 return false;
77 }
75 SkCanvas canvas(device); 78 SkCanvas canvas(device);
76 SkPaint paint; 79 SkPaint paint;
77 paint.setXfermodeMode(SkXfermode::kSrc_Mode); 80 paint.setXfermodeMode(SkXfermode::kSrc_Mode);
78 canvas.drawBitmap(background, SkIntToScalar(backgroundOffset.fX), 81 canvas.drawBitmap(background, SkIntToScalar(backgroundOffset.fX),
79 SkIntToScalar(backgroundOffset.fY), &paint); 82 SkIntToScalar(backgroundOffset.fY), &paint);
80 paint.setXfermode(fMode); 83 paint.setXfermode(fMode);
81 canvas.drawBitmap(foreground, SkIntToScalar(foregroundOffset.fX), 84 canvas.drawBitmap(foreground, SkIntToScalar(foregroundOffset.fX),
82 SkIntToScalar(foregroundOffset.fY), &paint); 85 SkIntToScalar(foregroundOffset.fY), &paint);
83 *dst = device->accessBitmap(false); 86 *dst = device->accessBitmap(false);
84 offset->fX += bounds.left(); 87 offset->fX += bounds.left();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 foregroundPaint.setBlendFunc(sk_blend_to_grblend(sm), sk_blend_to_grblen d(dm)); 152 foregroundPaint.setBlendFunc(sk_blend_to_grblend(sm), sk_blend_to_grblen d(dm));
150 foregroundPaint.addColorTextureEffect(foregroundTex, foregroundMatrix); 153 foregroundPaint.addColorTextureEffect(foregroundTex, foregroundMatrix);
151 context->drawRect(foregroundPaint, srcRect); 154 context->drawRect(foregroundPaint, srcRect);
152 } 155 }
153 offset->fX += backgroundOffset.fX; 156 offset->fX += backgroundOffset.fX;
154 offset->fY += backgroundOffset.fY; 157 offset->fY += backgroundOffset.fY;
155 return SkImageFilterUtils::WrapTexture(dst, src.width(), src.height(), resul t); 158 return SkImageFilterUtils::WrapTexture(dst, src.width(), src.height(), resul t);
156 } 159 }
157 160
158 #endif 161 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698