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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkCanvasPriv.h" | 9 #include "SkCanvasPriv.h" |
10 #include "SkBitmapDevice.h" | 10 #include "SkBitmapDevice.h" |
11 #include "SkColorFilter.h" | 11 #include "SkColorFilter.h" |
12 #include "SkDeviceImageFilterProxy.h" | |
13 #include "SkDeviceProperties.h" | 12 #include "SkDeviceProperties.h" |
14 #include "SkDraw.h" | 13 #include "SkDraw.h" |
15 #include "SkDrawable.h" | 14 #include "SkDrawable.h" |
16 #include "SkDrawFilter.h" | 15 #include "SkDrawFilter.h" |
17 #include "SkDrawLooper.h" | 16 #include "SkDrawLooper.h" |
18 #include "SkErrorInternals.h" | 17 #include "SkErrorInternals.h" |
19 #include "SkImage.h" | 18 #include "SkImage.h" |
20 #include "SkMetaData.h" | 19 #include "SkMetaData.h" |
21 #include "SkPathOps.h" | 20 #include "SkPathOps.h" |
22 #include "SkPatchUtils.h" | 21 #include "SkPatchUtils.h" |
(...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1238 paint = &tmp; | 1237 paint = &tmp; |
1239 } | 1238 } |
1240 | 1239 |
1241 LOOPER_BEGIN_DRAWDEVICE(*paint, SkDrawFilter::kBitmap_Type) | 1240 LOOPER_BEGIN_DRAWDEVICE(*paint, SkDrawFilter::kBitmap_Type) |
1242 while (iter.next()) { | 1241 while (iter.next()) { |
1243 SkBaseDevice* dstDev = iter.fDevice; | 1242 SkBaseDevice* dstDev = iter.fDevice; |
1244 paint = &looper.paint(); | 1243 paint = &looper.paint(); |
1245 SkImageFilter* filter = paint->getImageFilter(); | 1244 SkImageFilter* filter = paint->getImageFilter(); |
1246 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; | 1245 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; |
1247 if (filter && !dstDev->canHandleImageFilter(filter)) { | 1246 if (filter && !dstDev->canHandleImageFilter(filter)) { |
1248 SkDeviceImageFilterProxy proxy(dstDev, fProps); | 1247 SkImageFilter::Proxy proxy(dstDev, fProps); |
1249 SkBitmap dst; | 1248 SkBitmap dst; |
1250 SkIPoint offset = SkIPoint::Make(0, 0); | 1249 SkIPoint offset = SkIPoint::Make(0, 0); |
1251 const SkBitmap& src = srcDev->accessBitmap(false); | 1250 const SkBitmap& src = srcDev->accessBitmap(false); |
1252 SkMatrix matrix = *iter.fMatrix; | 1251 SkMatrix matrix = *iter.fMatrix; |
1253 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y()
)); | 1252 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y()
)); |
1254 SkIRect clipBounds = SkIRect::MakeWH(srcDev->width(), srcDev->height
()); | 1253 SkIRect clipBounds = SkIRect::MakeWH(srcDev->width(), srcDev->height
()); |
1255 SkAutoTUnref<SkImageFilter::Cache> cache(dstDev->getImageFilterCache
()); | 1254 SkAutoTUnref<SkImageFilter::Cache> cache(dstDev->getImageFilterCache
()); |
1256 SkImageFilter::Context ctx(matrix, clipBounds, cache.get()); | 1255 SkImageFilter::Context ctx(matrix, clipBounds, cache.get()); |
1257 if (filter->filterImage(&proxy, src, ctx, &dst, &offset)) { | 1256 if (filter->filterImage(&proxy, src, ctx, &dst, &offset)) { |
1258 SkPaint tmpUnfiltered(*paint); | 1257 SkPaint tmpUnfiltered(*paint); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1290 paint = &tmp; | 1289 paint = &tmp; |
1291 } | 1290 } |
1292 | 1291 |
1293 LOOPER_BEGIN_DRAWDEVICE(*paint, SkDrawFilter::kBitmap_Type) | 1292 LOOPER_BEGIN_DRAWDEVICE(*paint, SkDrawFilter::kBitmap_Type) |
1294 | 1293 |
1295 while (iter.next()) { | 1294 while (iter.next()) { |
1296 paint = &looper.paint(); | 1295 paint = &looper.paint(); |
1297 SkImageFilter* filter = paint->getImageFilter(); | 1296 SkImageFilter* filter = paint->getImageFilter(); |
1298 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; | 1297 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; |
1299 if (filter && !iter.fDevice->canHandleImageFilter(filter)) { | 1298 if (filter && !iter.fDevice->canHandleImageFilter(filter)) { |
1300 SkDeviceImageFilterProxy proxy(iter.fDevice, fProps); | 1299 SkImageFilter::Proxy proxy(iter.fDevice, fProps); |
1301 SkBitmap dst; | 1300 SkBitmap dst; |
1302 SkIPoint offset = SkIPoint::Make(0, 0); | 1301 SkIPoint offset = SkIPoint::Make(0, 0); |
1303 SkMatrix matrix = *iter.fMatrix; | 1302 SkMatrix matrix = *iter.fMatrix; |
1304 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y()
)); | 1303 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y()
)); |
1305 const SkIRect clipBounds = bitmap.bounds(); | 1304 const SkIRect clipBounds = bitmap.bounds(); |
1306 SkAutoTUnref<SkImageFilter::Cache> cache(iter.fDevice->getImageFilte
rCache()); | 1305 SkAutoTUnref<SkImageFilter::Cache> cache(iter.fDevice->getImageFilte
rCache()); |
1307 SkImageFilter::Context ctx(matrix, clipBounds, cache.get()); | 1306 SkImageFilter::Context ctx(matrix, clipBounds, cache.get()); |
1308 if (filter->filterImage(&proxy, bitmap, ctx, &dst, &offset)) { | 1307 if (filter->filterImage(&proxy, bitmap, ctx, &dst, &offset)) { |
1309 SkPaint tmpUnfiltered(*paint); | 1308 SkPaint tmpUnfiltered(*paint); |
1310 tmpUnfiltered.setImageFilter(NULL); | 1309 tmpUnfiltered.setImageFilter(NULL); |
(...skipping 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2711 } | 2710 } |
2712 | 2711 |
2713 if (matrix) { | 2712 if (matrix) { |
2714 canvas->concat(*matrix); | 2713 canvas->concat(*matrix); |
2715 } | 2714 } |
2716 } | 2715 } |
2717 | 2716 |
2718 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 2717 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
2719 fCanvas->restoreToCount(fSaveCount); | 2718 fCanvas->restoreToCount(fSaveCount); |
2720 } | 2719 } |
OLD | NEW |