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

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

Issue 1388823002: add LocalMatrixImageFilter Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add gm Created 5 years, 2 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 | « include/core/SkImageFilter.h ('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 #include "SkBitmapDevice.h" 8 #include "SkBitmapDevice.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkCanvasPriv.h" 10 #include "SkCanvasPriv.h"
(...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 SkPaint tmp; 1291 SkPaint tmp;
1292 if (nullptr == paint) { 1292 if (nullptr == paint) {
1293 paint = &tmp; 1293 paint = &tmp;
1294 } 1294 }
1295 1295
1296 LOOPER_BEGIN_DRAWDEVICE(*paint, SkDrawFilter::kBitmap_Type) 1296 LOOPER_BEGIN_DRAWDEVICE(*paint, SkDrawFilter::kBitmap_Type)
1297 while (iter.next()) { 1297 while (iter.next()) {
1298 SkBaseDevice* dstDev = iter.fDevice; 1298 SkBaseDevice* dstDev = iter.fDevice;
1299 paint = &looper.paint(); 1299 paint = &looper.paint();
1300 SkImageFilter* filter = paint->getImageFilter(); 1300 SkImageFilter* filter = paint->getImageFilter();
1301
1302 SkAutoTUnref<SkImageFilter> localFilter;
1303 if (filter) {
1304 localFilter.reset(filter->newWithLocalMatrix(SkMatrix::I()));
1305 filter = localFilter;
1306 }
1307
1301 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; 1308 SkIPoint pos = { x - iter.getX(), y - iter.getY() };
1302 if (filter && !dstDev->canHandleImageFilter(filter)) { 1309 if (filter && !dstDev->canHandleImageFilter(filter)) {
1303 SkImageFilter::DeviceProxy proxy(dstDev); 1310 SkImageFilter::DeviceProxy proxy(dstDev);
1304 SkBitmap dst; 1311 SkBitmap dst;
1305 SkIPoint offset = SkIPoint::Make(0, 0); 1312 SkIPoint offset = SkIPoint::Make(0, 0);
1306 const SkBitmap& src = srcDev->accessBitmap(false); 1313 const SkBitmap& src = srcDev->accessBitmap(false);
1307 SkMatrix matrix = *iter.fMatrix; 1314 SkMatrix matrix = *iter.fMatrix;
1308 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y() )); 1315 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y() ));
1309 SkIRect clipBounds = SkIRect::MakeWH(srcDev->width(), srcDev->height ()); 1316 SkIRect clipBounds = SkIRect::MakeWH(srcDev->width(), srcDev->height ());
1310 SkAutoTUnref<SkImageFilter::Cache> cache(dstDev->getImageFilterCache ()); 1317 SkAutoTUnref<SkImageFilter::Cache> cache(dstDev->getImageFilterCache ());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1343 SkPaint tmp; 1350 SkPaint tmp;
1344 if (nullptr == paint) { 1351 if (nullptr == paint) {
1345 paint = &tmp; 1352 paint = &tmp;
1346 } 1353 }
1347 1354
1348 LOOPER_BEGIN_DRAWDEVICE(*paint, SkDrawFilter::kBitmap_Type) 1355 LOOPER_BEGIN_DRAWDEVICE(*paint, SkDrawFilter::kBitmap_Type)
1349 1356
1350 while (iter.next()) { 1357 while (iter.next()) {
1351 paint = &looper.paint(); 1358 paint = &looper.paint();
1352 SkImageFilter* filter = paint->getImageFilter(); 1359 SkImageFilter* filter = paint->getImageFilter();
1360
1361 SkAutoTUnref<SkImageFilter> localFilter;
1362 if (filter) {
1363 localFilter.reset(filter->newWithLocalMatrix(SkMatrix::I()));
1364 filter = localFilter;
1365 }
1366
1353 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; 1367 SkIPoint pos = { x - iter.getX(), y - iter.getY() };
1354 if (filter && !iter.fDevice->canHandleImageFilter(filter)) { 1368 if (filter && !iter.fDevice->canHandleImageFilter(filter)) {
1355 SkImageFilter::DeviceProxy proxy(iter.fDevice); 1369 SkImageFilter::DeviceProxy proxy(iter.fDevice);
1356 SkBitmap dst; 1370 SkBitmap dst;
1357 SkIPoint offset = SkIPoint::Make(0, 0); 1371 SkIPoint offset = SkIPoint::Make(0, 0);
1358 SkMatrix matrix = *iter.fMatrix; 1372 SkMatrix matrix = *iter.fMatrix;
1359 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y() )); 1373 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y() ));
1360 const SkIRect clipBounds = bitmap.bounds(); 1374 const SkIRect clipBounds = bitmap.bounds();
1361 SkAutoTUnref<SkImageFilter::Cache> cache(iter.fDevice->getImageFilte rCache()); 1375 SkAutoTUnref<SkImageFilter::Cache> cache(iter.fDevice->getImageFilte rCache());
1362 SkImageFilter::Context ctx(matrix, clipBounds, cache.get()); 1376 SkImageFilter::Context ctx(matrix, clipBounds, cache.get());
(...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after
2880 } 2894 }
2881 2895
2882 if (matrix) { 2896 if (matrix) {
2883 canvas->concat(*matrix); 2897 canvas->concat(*matrix);
2884 } 2898 }
2885 } 2899 }
2886 2900
2887 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { 2901 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
2888 fCanvas->restoreToCount(fSaveCount); 2902 fCanvas->restoreToCount(fSaveCount);
2889 } 2903 }
OLDNEW
« no previous file with comments | « include/core/SkImageFilter.h ('k') | src/core/SkImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698