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 22 matching lines...) Expand all Loading... |
33 #include "SkTextFormatParams.h" | 33 #include "SkTextFormatParams.h" |
34 #include "SkTLazy.h" | 34 #include "SkTLazy.h" |
35 #include "SkTraceEvent.h" | 35 #include "SkTraceEvent.h" |
36 | 36 |
37 #include <new> | 37 #include <new> |
38 | 38 |
39 #if SK_SUPPORT_GPU | 39 #if SK_SUPPORT_GPU |
40 #include "GrRenderTarget.h" | 40 #include "GrRenderTarget.h" |
41 #endif | 41 #endif |
42 | 42 |
43 #define SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS | |
44 | |
45 /* | 43 /* |
46 * Return true if the drawing this rect would hit every pixels in the canvas. | 44 * Return true if the drawing this rect would hit every pixels in the canvas. |
47 * | 45 * |
48 * Returns false if | 46 * Returns false if |
49 * - rect does not contain the canvas' bounds | 47 * - rect does not contain the canvas' bounds |
50 * - paint is not fill | 48 * - paint is not fill |
51 * - paint would blur or otherwise change the coverage of the rect | 49 * - paint would blur or otherwise change the coverage of the rect |
52 */ | 50 */ |
53 bool SkCanvas::wouldOverwriteEntireSurface(const SkRect* rect, const SkPaint* pa
int, | 51 bool SkCanvas::wouldOverwriteEntireSurface(const SkRect* rect, const SkPaint* pa
int, |
54 ShaderOverrideOpacity overrideOpacity
) const { | 52 ShaderOverrideOpacity overrideOpacity
) const { |
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1077 #endif | 1075 #endif |
1078 if (imageFilter) { | 1076 if (imageFilter) { |
1079 imageFilter->filterBounds(clipBounds, ctm, &clipBounds); | 1077 imageFilter->filterBounds(clipBounds, ctm, &clipBounds); |
1080 #ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS | 1078 #ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS |
1081 if (bounds && imageFilter->canComputeFastBounds()) { | 1079 if (bounds && imageFilter->canComputeFastBounds()) { |
1082 imageFilter->computeFastBounds(*bounds, &storage); | 1080 imageFilter->computeFastBounds(*bounds, &storage); |
1083 bounds = &storage; | 1081 bounds = &storage; |
1084 } else { | 1082 } else { |
1085 bounds = nullptr; | 1083 bounds = nullptr; |
1086 } | 1084 } |
| 1085 #else |
| 1086 if (bounds && !imageFilter->canComputeFastBounds()) { |
| 1087 bounds = nullptr; |
| 1088 } |
1087 #endif | 1089 #endif |
1088 } | 1090 } |
1089 SkIRect ir; | 1091 SkIRect ir; |
1090 if (bounds) { | 1092 if (bounds) { |
1091 SkRect r; | 1093 SkRect r; |
1092 | 1094 |
1093 ctm.mapRect(&r, *bounds); | 1095 ctm.mapRect(&r, *bounds); |
1094 r.roundOut(&ir); | 1096 r.roundOut(&ir); |
1095 // early exit if the layer's bounds are clipped out | 1097 // early exit if the layer's bounds are clipped out |
1096 if (!ir.intersect(clipBounds)) { | 1098 if (!ir.intersect(clipBounds)) { |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1363 paint = &looper.paint(); | 1365 paint = &looper.paint(); |
1364 SkImageFilter* filter = paint->getImageFilter(); | 1366 SkImageFilter* filter = paint->getImageFilter(); |
1365 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; | 1367 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; |
1366 if (filter && !dstDev->canHandleImageFilter(filter)) { | 1368 if (filter && !dstDev->canHandleImageFilter(filter)) { |
1367 SkImageFilter::DeviceProxy proxy(dstDev); | 1369 SkImageFilter::DeviceProxy proxy(dstDev); |
1368 SkBitmap dst; | 1370 SkBitmap dst; |
1369 SkIPoint offset = SkIPoint::Make(0, 0); | 1371 SkIPoint offset = SkIPoint::Make(0, 0); |
1370 const SkBitmap& src = srcDev->accessBitmap(false); | 1372 const SkBitmap& src = srcDev->accessBitmap(false); |
1371 SkMatrix matrix = *iter.fMatrix; | 1373 SkMatrix matrix = *iter.fMatrix; |
1372 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y()
)); | 1374 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y()
)); |
| 1375 #ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS |
1373 SkIRect clipBounds = SkIRect::MakeWH(srcDev->width(), srcDev->height
()); | 1376 SkIRect clipBounds = SkIRect::MakeWH(srcDev->width(), srcDev->height
()); |
| 1377 #else |
| 1378 SkIRect clipBounds = iter.fClip->getBounds().makeOffset(-pos.x(), -p
os.y()); |
| 1379 #endif |
1374 SkAutoTUnref<SkImageFilter::Cache> cache(dstDev->getImageFilterCache
()); | 1380 SkAutoTUnref<SkImageFilter::Cache> cache(dstDev->getImageFilterCache
()); |
1375 SkImageFilter::Context ctx(matrix, clipBounds, cache.get(), | 1381 SkImageFilter::Context ctx(matrix, clipBounds, cache.get(), |
1376 SkImageFilter::kApprox_SizeConstraint); | 1382 SkImageFilter::kApprox_SizeConstraint); |
1377 if (filter->filterImage(&proxy, src, ctx, &dst, &offset)) { | 1383 if (filter->filterImage(&proxy, src, ctx, &dst, &offset)) { |
1378 SkPaint tmpUnfiltered(*paint); | 1384 SkPaint tmpUnfiltered(*paint); |
1379 tmpUnfiltered.setImageFilter(nullptr); | 1385 tmpUnfiltered.setImageFilter(nullptr); |
1380 dstDev->drawSprite(iter, dst, pos.x() + offset.x(), pos.y() + of
fset.y(), | 1386 dstDev->drawSprite(iter, dst, pos.x() + offset.x(), pos.y() + of
fset.y(), |
1381 tmpUnfiltered); | 1387 tmpUnfiltered); |
1382 } | 1388 } |
1383 } else if (deviceIsBitmapDevice) { | 1389 } else if (deviceIsBitmapDevice) { |
(...skipping 1614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2998 } | 3004 } |
2999 | 3005 |
3000 if (matrix) { | 3006 if (matrix) { |
3001 canvas->concat(*matrix); | 3007 canvas->concat(*matrix); |
3002 } | 3008 } |
3003 } | 3009 } |
3004 | 3010 |
3005 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 3011 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
3006 fCanvas->restoreToCount(fSaveCount); | 3012 fCanvas->restoreToCount(fSaveCount); |
3007 } | 3013 } |
OLD | NEW |