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

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

Issue 414483003: Implement a persistent uniqueID-based cache for SkImageFilter. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix cross-process issue (revert those changes to HEAD^^) Created 6 years, 4 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
« no previous file with comments | « src/core/SkBitmapDevice.cpp ('k') | src/core/SkImageFilter.cpp » ('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 * Copyright 2008 The Android Open Source Project 2 * Copyright 2008 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 8
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkBitmapDevice.h" 10 #include "SkBitmapDevice.h"
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 SkImageFilter* filter = paint->getImageFilter(); 1127 SkImageFilter* filter = paint->getImageFilter();
1128 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; 1128 SkIPoint pos = { x - iter.getX(), y - iter.getY() };
1129 if (filter && !dstDev->canHandleImageFilter(filter)) { 1129 if (filter && !dstDev->canHandleImageFilter(filter)) {
1130 SkDeviceImageFilterProxy proxy(dstDev); 1130 SkDeviceImageFilterProxy proxy(dstDev);
1131 SkBitmap dst; 1131 SkBitmap dst;
1132 SkIPoint offset = SkIPoint::Make(0, 0); 1132 SkIPoint offset = SkIPoint::Make(0, 0);
1133 const SkBitmap& src = srcDev->accessBitmap(false); 1133 const SkBitmap& src = srcDev->accessBitmap(false);
1134 SkMatrix matrix = *iter.fMatrix; 1134 SkMatrix matrix = *iter.fMatrix;
1135 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y() )); 1135 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y() ));
1136 SkIRect clipBounds = SkIRect::MakeWH(srcDev->width(), srcDev->height ()); 1136 SkIRect clipBounds = SkIRect::MakeWH(srcDev->width(), srcDev->height ());
1137 SkImageFilter::Cache* cache = SkImageFilter::GetExternalCache(); 1137 SkAutoTUnref<SkImageFilter::UniqueIDCache> cache(dstDev->getImageFil terCache());
1138 SkAutoUnref aur(NULL); 1138 SkImageFilter::Context ctx(matrix, clipBounds, cache.get());
1139 if (!cache) {
1140 cache = SkImageFilter::Cache::Create();
1141 aur.reset(cache);
1142 }
1143 SkImageFilter::Context ctx(matrix, clipBounds, cache);
1144 if (filter->filterImage(&proxy, src, ctx, &dst, &offset)) { 1139 if (filter->filterImage(&proxy, src, ctx, &dst, &offset)) {
1145 SkPaint tmpUnfiltered(*paint); 1140 SkPaint tmpUnfiltered(*paint);
1146 tmpUnfiltered.setImageFilter(NULL); 1141 tmpUnfiltered.setImageFilter(NULL);
1147 dstDev->drawSprite(iter, dst, pos.x() + offset.x(), pos.y() + of fset.y(), 1142 dstDev->drawSprite(iter, dst, pos.x() + offset.x(), pos.y() + of fset.y(),
1148 tmpUnfiltered); 1143 tmpUnfiltered);
1149 } 1144 }
1150 } else { 1145 } else {
1151 dstDev->drawDevice(iter, srcDev, pos.x(), pos.y(), *paint); 1146 dstDev->drawDevice(iter, srcDev, pos.x(), pos.y(), *paint);
1152 } 1147 }
1153 } 1148 }
(...skipping 18 matching lines...) Expand all
1172 paint = &looper.paint(); 1167 paint = &looper.paint();
1173 SkImageFilter* filter = paint->getImageFilter(); 1168 SkImageFilter* filter = paint->getImageFilter();
1174 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; 1169 SkIPoint pos = { x - iter.getX(), y - iter.getY() };
1175 if (filter && !iter.fDevice->canHandleImageFilter(filter)) { 1170 if (filter && !iter.fDevice->canHandleImageFilter(filter)) {
1176 SkDeviceImageFilterProxy proxy(iter.fDevice); 1171 SkDeviceImageFilterProxy proxy(iter.fDevice);
1177 SkBitmap dst; 1172 SkBitmap dst;
1178 SkIPoint offset = SkIPoint::Make(0, 0); 1173 SkIPoint offset = SkIPoint::Make(0, 0);
1179 SkMatrix matrix = *iter.fMatrix; 1174 SkMatrix matrix = *iter.fMatrix;
1180 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y() )); 1175 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y() ));
1181 SkIRect clipBounds = SkIRect::MakeWH(bitmap.width(), bitmap.height() ); 1176 SkIRect clipBounds = SkIRect::MakeWH(bitmap.width(), bitmap.height() );
1182 SkImageFilter::Cache* cache = SkImageFilter::GetExternalCache(); 1177 SkAutoTUnref<SkImageFilter::UniqueIDCache> cache(iter.fDevice->getIm ageFilterCache());
1183 SkAutoUnref aur(NULL); 1178 SkImageFilter::Context ctx(matrix, clipBounds, cache.get());
1184 if (!cache) {
1185 cache = SkImageFilter::Cache::Create();
1186 aur.reset(cache);
1187 }
1188 SkImageFilter::Context ctx(matrix, clipBounds, cache);
1189 if (filter->filterImage(&proxy, bitmap, ctx, &dst, &offset)) { 1179 if (filter->filterImage(&proxy, bitmap, ctx, &dst, &offset)) {
1190 SkPaint tmpUnfiltered(*paint); 1180 SkPaint tmpUnfiltered(*paint);
1191 tmpUnfiltered.setImageFilter(NULL); 1181 tmpUnfiltered.setImageFilter(NULL);
1192 iter.fDevice->drawSprite(iter, dst, pos.x() + offset.x(), pos.y( ) + offset.y(), 1182 iter.fDevice->drawSprite(iter, dst, pos.x() + offset.x(), pos.y( ) + offset.y(),
1193 tmpUnfiltered); 1183 tmpUnfiltered);
1194 } 1184 }
1195 } else { 1185 } else {
1196 iter.fDevice->drawSprite(iter, bitmap, pos.x(), pos.y(), *paint); 1186 iter.fDevice->drawSprite(iter, bitmap, pos.x(), pos.y(), *paint);
1197 } 1187 }
1198 } 1188 }
(...skipping 1296 matching lines...) Expand 10 before | Expand all | Expand 10 after
2495 if (!supported_for_raster_canvas(info)) { 2485 if (!supported_for_raster_canvas(info)) {
2496 return NULL; 2486 return NULL;
2497 } 2487 }
2498 2488
2499 SkBitmap bitmap; 2489 SkBitmap bitmap;
2500 if (!bitmap.installPixels(info, pixels, rowBytes)) { 2490 if (!bitmap.installPixels(info, pixels, rowBytes)) {
2501 return NULL; 2491 return NULL;
2502 } 2492 }
2503 return SkNEW_ARGS(SkCanvas, (bitmap)); 2493 return SkNEW_ARGS(SkCanvas, (bitmap));
2504 } 2494 }
OLDNEW
« no previous file with comments | « src/core/SkBitmapDevice.cpp ('k') | src/core/SkImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698