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

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

Issue 1762013002: Swap over to using SkImageFilter::filterImage instead of filterImageDeprecated (Closed) Base URL: https://skia.googlesource.com/skia.git@if-fragment
Patch Set: Fix no-GPU build Created 4 years, 9 months 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
« no previous file with comments | « include/core/SkImageFilter.h ('k') | src/core/SkDevice.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 10 matching lines...) Expand all
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
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? (see sk bug.com/5073)
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 1600 matching lines...) Expand 10 before | Expand all | Expand 10 after
3018 } 3029 }
3019 3030
3020 if (matrix) { 3031 if (matrix) {
3021 canvas->concat(*matrix); 3032 canvas->concat(*matrix);
3022 } 3033 }
3023 } 3034 }
3024 3035
3025 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { 3036 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
3026 fCanvas->restoreToCount(fSaveCount); 3037 fCanvas->restoreToCount(fSaveCount);
3027 } 3038 }
OLDNEW
« no previous file with comments | « include/core/SkImageFilter.h ('k') | src/core/SkDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698