| OLD | NEW |
| 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 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1064 | 1064 |
| 1065 bool SkCanvas::clipRectBounds(const SkRect* bounds, SaveLayerFlags saveLayerFlag
s, | 1065 bool SkCanvas::clipRectBounds(const SkRect* bounds, SaveLayerFlags saveLayerFlag
s, |
| 1066 SkIRect* intersection, const SkImageFilter* imageF
ilter) { | 1066 SkIRect* intersection, const SkImageFilter* imageF
ilter) { |
| 1067 SkIRect clipBounds; | 1067 SkIRect clipBounds; |
| 1068 if (!this->getClipDeviceBounds(&clipBounds)) { | 1068 if (!this->getClipDeviceBounds(&clipBounds)) { |
| 1069 return false; | 1069 return false; |
| 1070 } | 1070 } |
| 1071 | 1071 |
| 1072 const SkMatrix& ctm = fMCRec->fMatrix; // this->getTotalMatrix() | 1072 const SkMatrix& ctm = fMCRec->fMatrix; // this->getTotalMatrix() |
| 1073 | 1073 |
| 1074 // This is a temporary hack, until individual filters can do their own | |
| 1075 // bloating, when this will be removed. | |
| 1076 #ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS | |
| 1077 SkRect storage; | |
| 1078 #endif | |
| 1079 if (imageFilter) { | 1074 if (imageFilter) { |
| 1080 imageFilter->filterBounds(clipBounds, ctm, &clipBounds); | 1075 imageFilter->filterBounds(clipBounds, ctm, &clipBounds); |
| 1081 #ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS | |
| 1082 if (bounds && imageFilter->canComputeFastBounds()) { | |
| 1083 imageFilter->computeFastBounds(*bounds, &storage); | |
| 1084 bounds = &storage; | |
| 1085 } else { | |
| 1086 bounds = nullptr; | |
| 1087 } | |
| 1088 #else | |
| 1089 if (bounds && !imageFilter->canComputeFastBounds()) { | 1076 if (bounds && !imageFilter->canComputeFastBounds()) { |
| 1090 bounds = nullptr; | 1077 bounds = nullptr; |
| 1091 } | 1078 } |
| 1092 #endif | |
| 1093 } | 1079 } |
| 1094 SkIRect ir; | 1080 SkIRect ir; |
| 1095 if (bounds) { | 1081 if (bounds) { |
| 1096 SkRect r; | 1082 SkRect r; |
| 1097 | 1083 |
| 1098 ctm.mapRect(&r, *bounds); | 1084 ctm.mapRect(&r, *bounds); |
| 1099 r.roundOut(&ir); | 1085 r.roundOut(&ir); |
| 1100 // early exit if the layer's bounds are clipped out | 1086 // early exit if the layer's bounds are clipped out |
| 1101 if (!ir.intersect(clipBounds)) { | 1087 if (!ir.intersect(clipBounds)) { |
| 1102 if (BoundsAffectsClip(saveLayerFlags)) { | 1088 if (BoundsAffectsClip(saveLayerFlags)) { |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1426 paint = &looper.paint(); | 1412 paint = &looper.paint(); |
| 1427 SkImageFilter* filter = paint->getImageFilter(); | 1413 SkImageFilter* filter = paint->getImageFilter(); |
| 1428 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; | 1414 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; |
| 1429 if (filter && !dstDev->canHandleImageFilter(filter)) { | 1415 if (filter && !dstDev->canHandleImageFilter(filter)) { |
| 1430 SkImageFilter::DeviceProxy proxy(dstDev); | 1416 SkImageFilter::DeviceProxy proxy(dstDev); |
| 1431 SkBitmap dst; | 1417 SkBitmap dst; |
| 1432 SkIPoint offset = SkIPoint::Make(0, 0); | 1418 SkIPoint offset = SkIPoint::Make(0, 0); |
| 1433 const SkBitmap& src = srcDev->accessBitmap(false); | 1419 const SkBitmap& src = srcDev->accessBitmap(false); |
| 1434 SkMatrix matrix = *iter.fMatrix; | 1420 SkMatrix matrix = *iter.fMatrix; |
| 1435 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y()
)); | 1421 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y()
)); |
| 1436 #ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS | |
| 1437 SkIRect clipBounds = SkIRect::MakeWH(srcDev->width(), srcDev->height
()); | |
| 1438 #else | |
| 1439 SkIRect clipBounds = iter.fClip->getBounds().makeOffset(-pos.x(), -p
os.y()); | 1422 SkIRect clipBounds = iter.fClip->getBounds().makeOffset(-pos.x(), -p
os.y()); |
| 1440 #endif | |
| 1441 SkAutoTUnref<SkImageFilter::Cache> cache(dstDev->getImageFilterCache
()); | 1423 SkAutoTUnref<SkImageFilter::Cache> cache(dstDev->getImageFilterCache
()); |
| 1442 SkImageFilter::Context ctx(matrix, clipBounds, cache.get()); | 1424 SkImageFilter::Context ctx(matrix, clipBounds, cache.get()); |
| 1443 if (filter->filterImage(&proxy, src, ctx, &dst, &offset)) { | 1425 if (filter->filterImage(&proxy, src, ctx, &dst, &offset)) { |
| 1444 SkPaint tmpUnfiltered(*paint); | 1426 SkPaint tmpUnfiltered(*paint); |
| 1445 tmpUnfiltered.setImageFilter(nullptr); | 1427 tmpUnfiltered.setImageFilter(nullptr); |
| 1446 dstDev->drawSprite(iter, dst, pos.x() + offset.x(), pos.y() + of
fset.y(), | 1428 dstDev->drawSprite(iter, dst, pos.x() + offset.x(), pos.y() + of
fset.y(), |
| 1447 tmpUnfiltered); | 1429 tmpUnfiltered); |
| 1448 } | 1430 } |
| 1449 } else if (deviceIsBitmapDevice) { | 1431 } else if (deviceIsBitmapDevice) { |
| 1450 const SkBitmap& src = static_cast<SkBitmapDevice*>(srcDev)->fBitmap; | 1432 const SkBitmap& src = static_cast<SkBitmapDevice*>(srcDev)->fBitmap; |
| (...skipping 1576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3027 } | 3009 } |
| 3028 | 3010 |
| 3029 if (matrix) { | 3011 if (matrix) { |
| 3030 canvas->concat(*matrix); | 3012 canvas->concat(*matrix); |
| 3031 } | 3013 } |
| 3032 } | 3014 } |
| 3033 | 3015 |
| 3034 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 3016 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
| 3035 fCanvas->restoreToCount(fSaveCount); | 3017 fCanvas->restoreToCount(fSaveCount); |
| 3036 } | 3018 } |
| OLD | NEW |