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 10 matching lines...) Expand all Loading... |
21 #include "SkMatrixUtils.h" | 21 #include "SkMatrixUtils.h" |
22 #include "SkMetaData.h" | 22 #include "SkMetaData.h" |
23 #include "SkNinePatchIter.h" | 23 #include "SkNinePatchIter.h" |
24 #include "SkPaintPriv.h" | 24 #include "SkPaintPriv.h" |
25 #include "SkPatchUtils.h" | 25 #include "SkPatchUtils.h" |
26 #include "SkPicture.h" | 26 #include "SkPicture.h" |
27 #include "SkRasterClip.h" | 27 #include "SkRasterClip.h" |
28 #include "SkReadPixelsRec.h" | 28 #include "SkReadPixelsRec.h" |
29 #include "SkRRect.h" | 29 #include "SkRRect.h" |
30 #include "SkSmallAllocator.h" | 30 #include "SkSmallAllocator.h" |
| 31 #include "SkSpecialImage.h" |
31 #include "SkSurface_Base.h" | 32 #include "SkSurface_Base.h" |
32 #include "SkTextBlob.h" | 33 #include "SkTextBlob.h" |
33 #include "SkTextFormatParams.h" | 34 #include "SkTextFormatParams.h" |
34 #include "SkTLazy.h" | 35 #include "SkTLazy.h" |
35 #include "SkTraceEvent.h" | 36 #include "SkTraceEvent.h" |
36 | 37 |
37 #include <new> | 38 #include <new> |
38 | 39 |
39 #if SK_SUPPORT_GPU | 40 #if SK_SUPPORT_GPU |
40 #include "GrContext.h" | 41 #include "GrContext.h" |
(...skipping 1344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1385 } | 1386 } |
1386 | 1387 |
1387 LOOPER_BEGIN_DRAWDEVICE(*paint, SkDrawFilter::kBitmap_Type) | 1388 LOOPER_BEGIN_DRAWDEVICE(*paint, SkDrawFilter::kBitmap_Type) |
1388 while (iter.next()) { | 1389 while (iter.next()) { |
1389 SkBaseDevice* dstDev = iter.fDevice; | 1390 SkBaseDevice* dstDev = iter.fDevice; |
1390 paint = &looper.paint(); | 1391 paint = &looper.paint(); |
1391 SkImageFilter* filter = paint->getImageFilter(); | 1392 SkImageFilter* filter = paint->getImageFilter(); |
1392 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; | 1393 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; |
1393 if (filter && !dstDev->canHandleImageFilter(filter)) { | 1394 if (filter && !dstDev->canHandleImageFilter(filter)) { |
1394 SkImageFilter::DeviceProxy proxy(dstDev); | 1395 SkImageFilter::DeviceProxy proxy(dstDev); |
1395 SkBitmap dst; | |
1396 SkIPoint offset = SkIPoint::Make(0, 0); | 1396 SkIPoint offset = SkIPoint::Make(0, 0); |
1397 const SkBitmap& src = srcDev->accessBitmap(false); | 1397 const SkBitmap& srcBM = srcDev->accessBitmap(false); |
1398 SkMatrix matrix = *iter.fMatrix; | 1398 SkMatrix matrix = *iter.fMatrix; |
1399 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y()
)); | 1399 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y()
)); |
1400 SkIRect clipBounds = iter.fClip->getBounds().makeOffset(-pos.x(), -p
os.y()); | 1400 const SkIRect clipBounds = iter.fClip->getBounds().makeOffset(-pos.x
(), -pos.y()); |
1401 SkAutoTUnref<SkImageFilter::Cache> cache(dstDev->getImageFilterCache
()); | 1401 SkAutoTUnref<SkImageFilter::Cache> cache(dstDev->getImageFilterCache
()); |
1402 SkImageFilter::Context ctx(matrix, clipBounds, cache.get()); | 1402 SkImageFilter::Context ctx(matrix, clipBounds, cache.get()); |
1403 if (filter->filterImageDeprecated(&proxy, src, ctx, &dst, &offset))
{ | 1403 |
| 1404 SkAutoTUnref<SkSpecialImage> srcImg(SkSpecialImage::internal_fromBM(
&proxy, srcBM)); |
| 1405 if (!srcImg) { |
| 1406 continue; // something disastrous happened |
| 1407 } |
| 1408 |
| 1409 SkAutoTUnref<SkSpecialImage> resultImg(filter->filterImage(srcImg, c
tx, &offset)); |
| 1410 if (resultImg) { |
1404 SkPaint tmpUnfiltered(*paint); | 1411 SkPaint tmpUnfiltered(*paint); |
1405 tmpUnfiltered.setImageFilter(nullptr); | 1412 tmpUnfiltered.setImageFilter(nullptr); |
1406 dstDev->drawSprite(iter, dst, pos.x() + offset.x(), pos.y() + of
fset.y(), | 1413 SkBitmap resultBM; |
1407 tmpUnfiltered); | 1414 if (resultImg->internal_getBM(&resultBM)) { |
| 1415 // TODO: add drawSprite(SkSpecialImage) to SkDevice? |
| 1416 dstDev->drawSprite(iter, resultBM, pos.x() + offset.x(), pos
.y() + offset.y(), |
| 1417 tmpUnfiltered); |
| 1418 } |
1408 } | 1419 } |
1409 } else if (deviceIsBitmapDevice) { | 1420 } else if (deviceIsBitmapDevice) { |
1410 const SkBitmap& src = static_cast<SkBitmapDevice*>(srcDev)->fBitmap; | 1421 const SkBitmap& src = static_cast<SkBitmapDevice*>(srcDev)->fBitmap; |
1411 dstDev->drawSprite(iter, src, pos.x(), pos.y(), *paint); | 1422 dstDev->drawSprite(iter, src, pos.x(), pos.y(), *paint); |
1412 } else { | 1423 } else { |
1413 dstDev->drawDevice(iter, srcDev, pos.x(), pos.y(), *paint); | 1424 dstDev->drawDevice(iter, srcDev, pos.x(), pos.y(), *paint); |
1414 } | 1425 } |
1415 } | 1426 } |
1416 LOOPER_END | 1427 LOOPER_END |
1417 } | 1428 } |
(...skipping 1583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3001 } | 3012 } |
3002 | 3013 |
3003 if (matrix) { | 3014 if (matrix) { |
3004 canvas->concat(*matrix); | 3015 canvas->concat(*matrix); |
3005 } | 3016 } |
3006 } | 3017 } |
3007 | 3018 |
3008 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 3019 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
3009 fCanvas->restoreToCount(fSaveCount); | 3020 fCanvas->restoreToCount(fSaveCount); |
3010 } | 3021 } |
OLD | NEW |