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

Side by Side Diff: src/core/SkCanvas.cpp

Issue 189913021: Implement support for a Context parameter in image filters (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Revert all but the Context changes. Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkBitmapDevice.cpp ('k') | src/core/SkDeviceImageFilterProxy.h » ('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 /* 2 /*
3 * Copyright 2008 The Android Open Source Project 3 * Copyright 2008 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 paint = &looper.paint(); 1157 paint = &looper.paint();
1158 SkImageFilter* filter = paint->getImageFilter(); 1158 SkImageFilter* filter = paint->getImageFilter();
1159 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; 1159 SkIPoint pos = { x - iter.getX(), y - iter.getY() };
1160 if (filter && !dstDev->canHandleImageFilter(filter)) { 1160 if (filter && !dstDev->canHandleImageFilter(filter)) {
1161 SkDeviceImageFilterProxy proxy(dstDev); 1161 SkDeviceImageFilterProxy proxy(dstDev);
1162 SkBitmap dst; 1162 SkBitmap dst;
1163 SkIPoint offset = SkIPoint::Make(0, 0); 1163 SkIPoint offset = SkIPoint::Make(0, 0);
1164 const SkBitmap& src = srcDev->accessBitmap(false); 1164 const SkBitmap& src = srcDev->accessBitmap(false);
1165 SkMatrix matrix = *iter.fMatrix; 1165 SkMatrix matrix = *iter.fMatrix;
1166 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); 1166 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y));
1167 if (filter->filterImage(&proxy, src, matrix, &dst, &offset)) { 1167 SkIRect clipBounds = SkIRect::MakeWH(srcDev->width(), srcDev->height ());
1168 SkImageFilter::Context ctx(matrix, clipBounds);
1169 if (filter->filterImage(&proxy, src, ctx, &dst, &offset)) {
1168 SkPaint tmpUnfiltered(*paint); 1170 SkPaint tmpUnfiltered(*paint);
1169 tmpUnfiltered.setImageFilter(NULL); 1171 tmpUnfiltered.setImageFilter(NULL);
1170 dstDev->drawSprite(iter, dst, pos.x() + offset.x(), pos.y() + of fset.y(), 1172 dstDev->drawSprite(iter, dst, pos.x() + offset.x(), pos.y() + of fset.y(),
1171 tmpUnfiltered); 1173 tmpUnfiltered);
1172 } 1174 }
1173 } else { 1175 } else {
1174 dstDev->drawDevice(iter, srcDev, pos.x(), pos.y(), *paint); 1176 dstDev->drawDevice(iter, srcDev, pos.x(), pos.y(), *paint);
1175 } 1177 }
1176 } 1178 }
1177 LOOPER_END 1179 LOOPER_END
(...skipping 17 matching lines...) Expand all
1195 while (iter.next()) { 1197 while (iter.next()) {
1196 paint = &looper.paint(); 1198 paint = &looper.paint();
1197 SkImageFilter* filter = paint->getImageFilter(); 1199 SkImageFilter* filter = paint->getImageFilter();
1198 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; 1200 SkIPoint pos = { x - iter.getX(), y - iter.getY() };
1199 if (filter && !iter.fDevice->canHandleImageFilter(filter)) { 1201 if (filter && !iter.fDevice->canHandleImageFilter(filter)) {
1200 SkDeviceImageFilterProxy proxy(iter.fDevice); 1202 SkDeviceImageFilterProxy proxy(iter.fDevice);
1201 SkBitmap dst; 1203 SkBitmap dst;
1202 SkIPoint offset = SkIPoint::Make(0, 0); 1204 SkIPoint offset = SkIPoint::Make(0, 0);
1203 SkMatrix matrix = *iter.fMatrix; 1205 SkMatrix matrix = *iter.fMatrix;
1204 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); 1206 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y));
1205 if (filter->filterImage(&proxy, bitmap, matrix, &dst, &offset)) { 1207 SkIRect clipBounds = SkIRect::MakeWH(bitmap.width(), bitmap.height() );
1208 SkImageFilter::Context ctx(matrix, clipBounds);
1209 if (filter->filterImage(&proxy, bitmap, ctx, &dst, &offset)) {
1206 SkPaint tmpUnfiltered(*paint); 1210 SkPaint tmpUnfiltered(*paint);
1207 tmpUnfiltered.setImageFilter(NULL); 1211 tmpUnfiltered.setImageFilter(NULL);
1208 iter.fDevice->drawSprite(iter, dst, pos.x() + offset.x(), pos.y( ) + offset.y(), 1212 iter.fDevice->drawSprite(iter, dst, pos.x() + offset.x(), pos.y( ) + offset.y(),
1209 tmpUnfiltered); 1213 tmpUnfiltered);
1210 } 1214 }
1211 } else { 1215 } else {
1212 iter.fDevice->drawSprite(iter, bitmap, pos.x(), pos.y(), *paint); 1216 iter.fDevice->drawSprite(iter, bitmap, pos.x(), pos.y(), *paint);
1213 } 1217 }
1214 } 1218 }
1215 LOOPER_END 1219 LOOPER_END
(...skipping 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after
2538 if (!bitmap.allocPixels(info)) { 2542 if (!bitmap.allocPixels(info)) {
2539 return NULL; 2543 return NULL;
2540 } 2544 }
2541 2545
2542 // should this functionality be moved into allocPixels()? 2546 // should this functionality be moved into allocPixels()?
2543 if (!bitmap.info().isOpaque()) { 2547 if (!bitmap.info().isOpaque()) {
2544 bitmap.eraseColor(0); 2548 bitmap.eraseColor(0);
2545 } 2549 }
2546 return SkNEW_ARGS(SkCanvas, (bitmap)); 2550 return SkNEW_ARGS(SkCanvas, (bitmap));
2547 } 2551 }
OLDNEW
« no previous file with comments | « src/core/SkBitmapDevice.cpp ('k') | src/core/SkDeviceImageFilterProxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698