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

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

Issue 1826893002: Switch new SkImageFilter internal methods over to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Change method name to drawSpriteWithFilter 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/effects/SkPaintImageFilter.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 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after
1405 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y() )); 1405 matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y() ));
1406 const SkIRect clipBounds = iter.fClip->getBounds().makeOffset(-pos.x (), -pos.y()); 1406 const SkIRect clipBounds = iter.fClip->getBounds().makeOffset(-pos.x (), -pos.y());
1407 SkAutoTUnref<SkImageFilter::Cache> cache(dstDev->getImageFilterCache ()); 1407 SkAutoTUnref<SkImageFilter::Cache> cache(dstDev->getImageFilterCache ());
1408 SkImageFilter::Context ctx(matrix, clipBounds, cache.get()); 1408 SkImageFilter::Context ctx(matrix, clipBounds, cache.get());
1409 1409
1410 sk_sp<SkSpecialImage> srcImg(SkSpecialImage::internal_fromBM(&proxy, srcBM)); 1410 sk_sp<SkSpecialImage> srcImg(SkSpecialImage::internal_fromBM(&proxy, srcBM));
1411 if (!srcImg) { 1411 if (!srcImg) {
1412 continue; // something disastrous happened 1412 continue; // something disastrous happened
1413 } 1413 }
1414 1414
1415 SkAutoTUnref<SkSpecialImage> resultImg(filter->filterImage(srcImg.ge t(), ctx, 1415 sk_sp<SkSpecialImage> resultImg(filter->filterImage(srcImg.get(), ct x, &offset));
1416 &offset)) ;
1417 if (resultImg) { 1416 if (resultImg) {
1418 SkPaint tmpUnfiltered(*paint); 1417 SkPaint tmpUnfiltered(*paint);
1419 tmpUnfiltered.setImageFilter(nullptr); 1418 tmpUnfiltered.setImageFilter(nullptr);
1420 SkBitmap resultBM; 1419 SkBitmap resultBM;
1421 if (resultImg->internal_getBM(&resultBM)) { 1420 if (resultImg->internal_getBM(&resultBM)) {
1422 // TODO: add drawSprite(SkSpecialImage) to SkDevice? (see sk bug.com/5073) 1421 // TODO: add drawSprite(SkSpecialImage) to SkDevice? (see sk bug.com/5073)
1423 dstDev->drawSprite(iter, resultBM, pos.x() + offset.x(), pos .y() + offset.y(), 1422 dstDev->drawSprite(iter, resultBM, pos.x() + offset.x(), pos .y() + offset.y(),
1424 tmpUnfiltered); 1423 tmpUnfiltered);
1425 } 1424 }
1426 } 1425 }
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after
2258 2257
2259 LOOPER_BEGIN_DRAWBITMAP(*paint, drawAsSprite, &bounds) 2258 LOOPER_BEGIN_DRAWBITMAP(*paint, drawAsSprite, &bounds)
2260 2259
2261 while (iter.next()) { 2260 while (iter.next()) {
2262 const SkPaint& pnt = looper.paint(); 2261 const SkPaint& pnt = looper.paint();
2263 if (drawAsSprite && pnt.getImageFilter()) { 2262 if (drawAsSprite && pnt.getImageFilter()) {
2264 SkBitmap bitmap; 2263 SkBitmap bitmap;
2265 if (as_IB(image)->asBitmapForImageFilters(&bitmap)) { 2264 if (as_IB(image)->asBitmapForImageFilters(&bitmap)) {
2266 SkPoint pt; 2265 SkPoint pt;
2267 iter.fMatrix->mapXY(x, y, &pt); 2266 iter.fMatrix->mapXY(x, y, &pt);
2268 iter.fDevice->drawBitmapAsSpriteWithImageFilter(iter, bitmap, 2267 iter.fDevice->drawSpriteWithFilter(iter, bitmap,
2269 SkScalarRoundToI nt(pt.fX), 2268 SkScalarRoundToInt(pt.fX),
2270 SkScalarRoundToI nt(pt.fY), pnt); 2269 SkScalarRoundToInt(pt.fY), pn t);
2271 } 2270 }
2272 } else { 2271 } else {
2273 iter.fDevice->drawImage(iter, image, x, y, pnt); 2272 iter.fDevice->drawImage(iter, image, x, y, pnt);
2274 } 2273 }
2275 } 2274 }
2276 2275
2277 LOOPER_END 2276 LOOPER_END
2278 } 2277 }
2279 2278
2280 void SkCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const Sk Rect& dst, 2279 void SkCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const Sk Rect& dst,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2340 } 2339 }
2341 } 2340 }
2342 2341
2343 LOOPER_BEGIN_DRAWBITMAP(*paint, drawAsSprite, bounds) 2342 LOOPER_BEGIN_DRAWBITMAP(*paint, drawAsSprite, bounds)
2344 2343
2345 while (iter.next()) { 2344 while (iter.next()) {
2346 const SkPaint& pnt = looper.paint(); 2345 const SkPaint& pnt = looper.paint();
2347 if (drawAsSprite && pnt.getImageFilter()) { 2346 if (drawAsSprite && pnt.getImageFilter()) {
2348 SkPoint pt; 2347 SkPoint pt;
2349 iter.fMatrix->mapXY(x, y, &pt); 2348 iter.fMatrix->mapXY(x, y, &pt);
2350 iter.fDevice->drawBitmapAsSpriteWithImageFilter(iter, bitmap, 2349 iter.fDevice->drawSpriteWithFilter(iter, bitmap,
2351 SkScalarRoundToInt(p t.fX), 2350 SkScalarRoundToInt(pt.fX),
2352 SkScalarRoundToInt(p t.fY), pnt); 2351 SkScalarRoundToInt(pt.fY), pnt);
2353 } else { 2352 } else {
2354 iter.fDevice->drawBitmap(iter, bitmap, matrix, looper.paint()); 2353 iter.fDevice->drawBitmap(iter, bitmap, matrix, looper.paint());
2355 } 2354 }
2356 } 2355 }
2357 2356
2358 LOOPER_END 2357 LOOPER_END
2359 } 2358 }
2360 2359
2361 // this one is non-virtual, so it can be called safely by other canvas apis 2360 // this one is non-virtual, so it can be called safely by other canvas apis
2362 void SkCanvas::internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, 2361 void SkCanvas::internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
3042 3041
3043 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { 3042 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
3044 fCanvas->restoreToCount(fSaveCount); 3043 fCanvas->restoreToCount(fSaveCount);
3045 } 3044 }
3046 3045
3047 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API 3046 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API
3048 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p rops) { 3047 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p rops) {
3049 return this->makeSurface(info, props).release(); 3048 return this->makeSurface(info, props).release();
3050 } 3049 }
3051 #endif 3050 #endif
OLDNEW
« no previous file with comments | « include/effects/SkPaintImageFilter.h ('k') | src/core/SkDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698