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

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

Issue 1308703007: Fix filter primitive bounds computations. (Closed) Base URL: https://skia.googlesource.com/skia.git@saveLayer-bounds-not-transformed
Patch Set: Update to ToT Created 5 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
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 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 1063
1064 bool SkCanvas::clipRectBounds(const SkRect* bounds, SaveFlags flags, 1064 bool SkCanvas::clipRectBounds(const SkRect* bounds, SaveFlags flags,
1065 SkIRect* intersection, const SkImageFilter* imageF ilter) { 1065 SkIRect* intersection, const SkImageFilter* imageF ilter) {
1066 SkIRect clipBounds; 1066 SkIRect clipBounds;
1067 if (!this->getClipDeviceBounds(&clipBounds)) { 1067 if (!this->getClipDeviceBounds(&clipBounds)) {
1068 return false; 1068 return false;
1069 } 1069 }
1070 1070
1071 const SkMatrix& ctm = fMCRec->fMatrix; // this->getTotalMatrix() 1071 const SkMatrix& ctm = fMCRec->fMatrix; // this->getTotalMatrix()
1072 1072
1073 // This is a temporary hack, until individual filters can do their own
1074 // bloating, when this will be removed.
1075 #ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS
1076 SkRect storage;
1077 #endif
1078 if (imageFilter) { 1073 if (imageFilter) {
1079 imageFilter->filterBounds(clipBounds, ctm, &clipBounds); 1074 imageFilter->filterBounds(clipBounds, ctm, &clipBounds);
1080 #ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS 1075 if (bounds && !imageFilter->canComputeFastBounds()) {
1081 if (bounds && imageFilter->canComputeFastBounds()) {
1082 imageFilter->computeFastBounds(*bounds, &storage);
1083 bounds = &storage;
1084 } else {
1085 bounds = nullptr; 1076 bounds = nullptr;
1086 } 1077 }
1087 #endif
1088 } 1078 }
1089 SkIRect ir; 1079 SkIRect ir;
1090 if (bounds) { 1080 if (bounds) {
1091 SkRect r; 1081 SkRect r;
1092 1082
1093 ctm.mapRect(&r, *bounds); 1083 ctm.mapRect(&r, *bounds);
1094 r.roundOut(&ir); 1084 r.roundOut(&ir);
1095 // early exit if the layer's bounds are clipped out 1085 // early exit if the layer's bounds are clipped out
1096 if (!ir.intersect(clipBounds)) { 1086 if (!ir.intersect(clipBounds)) {
1097 if (bounds_affects_clip(flags)) { 1087 if (bounds_affects_clip(flags)) {
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 paint = &looper.paint(); 1353 paint = &looper.paint();
1364 SkImageFilter* filter = paint->getImageFilter(); 1354 SkImageFilter* filter = paint->getImageFilter();
1365 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; 1355 SkIPoint pos = { x - iter.getX(), y - iter.getY() };
1366 if (filter && !dstDev->canHandleImageFilter(filter)) { 1356 if (filter && !dstDev->canHandleImageFilter(filter)) {
1367 SkImageFilter::DeviceProxy proxy(dstDev); 1357 SkImageFilter::DeviceProxy proxy(dstDev);
1368 SkBitmap dst; 1358 SkBitmap dst;
1369 SkIPoint offset = SkIPoint::Make(0, 0); 1359 SkIPoint offset = SkIPoint::Make(0, 0);
1370 const SkBitmap& src = srcDev->accessBitmap(false); 1360 const SkBitmap& src = srcDev->accessBitmap(false);
1371 SkMatrix matrix = *iter.fMatrix; 1361 SkMatrix matrix = *iter.fMatrix;
1372 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y() )); 1362 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y() ));
1373 SkIRect clipBounds = SkIRect::MakeWH(srcDev->width(), srcDev->height ()); 1363 SkIRect clipBounds = iter.fClip->getBounds();
1364 clipBounds.offset(-pos.x(), -pos.y());
1374 SkAutoTUnref<SkImageFilter::Cache> cache(dstDev->getImageFilterCache ()); 1365 SkAutoTUnref<SkImageFilter::Cache> cache(dstDev->getImageFilterCache ());
1375 SkImageFilter::Context ctx(matrix, clipBounds, cache.get(), 1366 SkImageFilter::Context ctx(matrix, clipBounds, cache.get(),
1376 SkImageFilter::kApprox_SizeConstraint); 1367 SkImageFilter::kApprox_SizeConstraint);
1377 if (filter->filterImage(&proxy, src, ctx, &dst, &offset)) { 1368 if (filter->filterImage(&proxy, src, ctx, &dst, &offset)) {
1378 SkPaint tmpUnfiltered(*paint); 1369 SkPaint tmpUnfiltered(*paint);
1379 tmpUnfiltered.setImageFilter(nullptr); 1370 tmpUnfiltered.setImageFilter(nullptr);
1380 dstDev->drawSprite(iter, dst, pos.x() + offset.x(), pos.y() + of fset.y(), 1371 dstDev->drawSprite(iter, dst, pos.x() + offset.x(), pos.y() + of fset.y(),
1381 tmpUnfiltered); 1372 tmpUnfiltered);
1382 } 1373 }
1383 } else if (deviceIsBitmapDevice) { 1374 } else if (deviceIsBitmapDevice) {
(...skipping 1619 matching lines...) Expand 10 before | Expand all | Expand 10 after
3003 } 2994 }
3004 2995
3005 if (matrix) { 2996 if (matrix) {
3006 canvas->concat(*matrix); 2997 canvas->concat(*matrix);
3007 } 2998 }
3008 } 2999 }
3009 3000
3010 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { 3001 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
3011 fCanvas->restoreToCount(fSaveCount); 3002 fCanvas->restoreToCount(fSaveCount);
3012 } 3003 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698