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

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

Issue 1920733003: share code with drawSpriteWithFilter (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 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 | « no previous file | no next file » | 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 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 paint = &tmp; 1443 paint = &tmp;
1444 } 1444 }
1445 1445
1446 LOOPER_BEGIN_DRAWDEVICE(*paint, SkDrawFilter::kBitmap_Type) 1446 LOOPER_BEGIN_DRAWDEVICE(*paint, SkDrawFilter::kBitmap_Type)
1447 while (iter.next()) { 1447 while (iter.next()) {
1448 SkBaseDevice* dstDev = iter.fDevice; 1448 SkBaseDevice* dstDev = iter.fDevice;
1449 paint = &looper.paint(); 1449 paint = &looper.paint();
1450 SkImageFilter* filter = paint->getImageFilter(); 1450 SkImageFilter* filter = paint->getImageFilter();
1451 SkIPoint pos = { x - iter.getX(), y - iter.getY() }; 1451 SkIPoint pos = { x - iter.getX(), y - iter.getY() };
1452 if (filter) { 1452 if (filter) {
1453 SkIPoint offset = SkIPoint::Make(0, 0);
1454 const SkBitmap& srcBM = srcDev->accessBitmap(false); 1453 const SkBitmap& srcBM = srcDev->accessBitmap(false);
1455 SkMatrix matrix = *iter.fMatrix; 1454 dstDev->drawSpriteWithFilter(iter, srcBM, pos.x(), pos.y(), *paint);
1456 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y() ));
1457 const SkIRect clipBounds = iter.fClip->getBounds().makeOffset(-pos.x (), -pos.y());
1458 SkAutoTUnref<SkImageFilter::Cache> cache(dstDev->getImageFilterCache ());
1459 SkImageFilter::Context ctx(matrix, clipBounds, cache.get());
1460
1461 sk_sp<SkSpecialImage> srcImg(SkSpecialImage::internal_fromBM(srcBM,
1462 &dstDev ->surfaceProps()));
1463 if (!srcImg) {
1464 continue; // something disastrous happened
1465 }
1466
1467 sk_sp<SkSpecialImage> resultImg(filter->filterImage(srcImg.get(), ct x, &offset));
1468 if (resultImg) {
1469 SkPaint tmpUnfiltered(*paint);
1470 tmpUnfiltered.setImageFilter(nullptr);
1471 SkBitmap resultBM;
1472 if (resultImg->internal_getBM(&resultBM)) {
1473 // TODO: add drawSprite(SkSpecialImage) to SkDevice? (see sk bug.com/5073)
1474 dstDev->drawSprite(iter, resultBM, pos.x() + offset.x(), pos .y() + offset.y(),
1475 tmpUnfiltered);
1476 }
1477 }
1478 } else if (deviceIsBitmapDevice) { 1455 } else if (deviceIsBitmapDevice) {
1479 const SkBitmap& src = static_cast<SkBitmapDevice*>(srcDev)->fBitmap; 1456 const SkBitmap& src = static_cast<SkBitmapDevice*>(srcDev)->fBitmap;
1480 dstDev->drawSprite(iter, src, pos.x(), pos.y(), *paint); 1457 dstDev->drawSprite(iter, src, pos.x(), pos.y(), *paint);
1481 } else { 1458 } else {
1482 dstDev->drawDevice(iter, srcDev, pos.x(), pos.y(), *paint); 1459 dstDev->drawDevice(iter, srcDev, pos.x(), pos.y(), *paint);
1483 } 1460 }
1484 } 1461 }
1485 LOOPER_END 1462 LOOPER_END
1486 } 1463 }
1487 1464
(...skipping 1606 matching lines...) Expand 10 before | Expand all | Expand 10 after
3094 3071
3095 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { 3072 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
3096 fCanvas->restoreToCount(fSaveCount); 3073 fCanvas->restoreToCount(fSaveCount);
3097 } 3074 }
3098 3075
3099 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API 3076 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API
3100 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p rops) { 3077 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p rops) {
3101 return this->makeSurface(info, props).release(); 3078 return this->makeSurface(info, props).release();
3102 } 3079 }
3103 #endif 3080 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698