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

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

Issue 230653005: Implement intra-frame cacheing in image filters. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Set minChildren to 2 by default; comment it. Created 6 years, 8 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
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 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 SkImageFilter* filter = paint->getImageFilter(); 1251 SkImageFilter* filter = paint->getImageFilter();
1252 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; 1252 SkIPoint pos = { x - iter.getX(), y - iter.getY() };
1253 if (filter && !dstDev->canHandleImageFilter(filter)) { 1253 if (filter && !dstDev->canHandleImageFilter(filter)) {
1254 SkDeviceImageFilterProxy proxy(dstDev); 1254 SkDeviceImageFilterProxy proxy(dstDev);
1255 SkBitmap dst; 1255 SkBitmap dst;
1256 SkIPoint offset = SkIPoint::Make(0, 0); 1256 SkIPoint offset = SkIPoint::Make(0, 0);
1257 const SkBitmap& src = srcDev->accessBitmap(false); 1257 const SkBitmap& src = srcDev->accessBitmap(false);
1258 SkMatrix matrix = *iter.fMatrix; 1258 SkMatrix matrix = *iter.fMatrix;
1259 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y() )); 1259 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y() ));
1260 SkIRect clipBounds = SkIRect::MakeWH(srcDev->width(), srcDev->height ()); 1260 SkIRect clipBounds = SkIRect::MakeWH(srcDev->width(), srcDev->height ());
1261 SkImageFilter::Context ctx(matrix, clipBounds); 1261 SkImageFilter::Cache* cache = SkImageFilter::Cache::Create();
1262 SkAutoUnref aur(cache);
1263 SkImageFilter::Context ctx(matrix, clipBounds, cache);
1262 if (filter->filterImage(&proxy, src, ctx, &dst, &offset)) { 1264 if (filter->filterImage(&proxy, src, ctx, &dst, &offset)) {
1263 SkPaint tmpUnfiltered(*paint); 1265 SkPaint tmpUnfiltered(*paint);
1264 tmpUnfiltered.setImageFilter(NULL); 1266 tmpUnfiltered.setImageFilter(NULL);
1265 dstDev->drawSprite(iter, dst, pos.x() + offset.x(), pos.y() + of fset.y(), 1267 dstDev->drawSprite(iter, dst, pos.x() + offset.x(), pos.y() + of fset.y(),
1266 tmpUnfiltered); 1268 tmpUnfiltered);
1267 } 1269 }
1268 } else { 1270 } else {
1269 dstDev->drawDevice(iter, srcDev, pos.x(), pos.y(), *paint); 1271 dstDev->drawDevice(iter, srcDev, pos.x(), pos.y(), *paint);
1270 } 1272 }
1271 } 1273 }
(...skipping 19 matching lines...) Expand all
1291 paint = &looper.paint(); 1293 paint = &looper.paint();
1292 SkImageFilter* filter = paint->getImageFilter(); 1294 SkImageFilter* filter = paint->getImageFilter();
1293 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; 1295 SkIPoint pos = { x - iter.getX(), y - iter.getY() };
1294 if (filter && !iter.fDevice->canHandleImageFilter(filter)) { 1296 if (filter && !iter.fDevice->canHandleImageFilter(filter)) {
1295 SkDeviceImageFilterProxy proxy(iter.fDevice); 1297 SkDeviceImageFilterProxy proxy(iter.fDevice);
1296 SkBitmap dst; 1298 SkBitmap dst;
1297 SkIPoint offset = SkIPoint::Make(0, 0); 1299 SkIPoint offset = SkIPoint::Make(0, 0);
1298 SkMatrix matrix = *iter.fMatrix; 1300 SkMatrix matrix = *iter.fMatrix;
1299 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y() )); 1301 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y() ));
1300 SkIRect clipBounds = SkIRect::MakeWH(bitmap.width(), bitmap.height() ); 1302 SkIRect clipBounds = SkIRect::MakeWH(bitmap.width(), bitmap.height() );
1301 SkImageFilter::Context ctx(matrix, clipBounds); 1303 SkImageFilter::Cache* cache = SkImageFilter::Cache::Create();
1304 SkAutoUnref aur(cache);
1305 SkImageFilter::Context ctx(matrix, clipBounds, cache);
1302 if (filter->filterImage(&proxy, bitmap, ctx, &dst, &offset)) { 1306 if (filter->filterImage(&proxy, bitmap, ctx, &dst, &offset)) {
1303 SkPaint tmpUnfiltered(*paint); 1307 SkPaint tmpUnfiltered(*paint);
1304 tmpUnfiltered.setImageFilter(NULL); 1308 tmpUnfiltered.setImageFilter(NULL);
1305 iter.fDevice->drawSprite(iter, dst, pos.x() + offset.x(), pos.y( ) + offset.y(), 1309 iter.fDevice->drawSprite(iter, dst, pos.x() + offset.x(), pos.y( ) + offset.y(),
1306 tmpUnfiltered); 1310 tmpUnfiltered);
1307 } 1311 }
1308 } else { 1312 } else {
1309 iter.fDevice->drawSprite(iter, bitmap, pos.x(), pos.y(), *paint); 1313 iter.fDevice->drawSprite(iter, bitmap, pos.x(), pos.y(), *paint);
1310 } 1314 }
1311 } 1315 }
(...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after
2648 if (!bitmap.installPixels(info, pixels, rowBytes)) { 2652 if (!bitmap.installPixels(info, pixels, rowBytes)) {
2649 return NULL; 2653 return NULL;
2650 } 2654 }
2651 2655
2652 // should this functionality be moved into allocPixels()? 2656 // should this functionality be moved into allocPixels()?
2653 if (!bitmap.info().isOpaque()) { 2657 if (!bitmap.info().isOpaque()) {
2654 bitmap.eraseColor(0); 2658 bitmap.eraseColor(0);
2655 } 2659 }
2656 return SkNEW_ARGS(SkCanvas, (bitmap)); 2660 return SkNEW_ARGS(SkCanvas, (bitmap));
2657 } 2661 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698