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

Side by Side Diff: src/core/SkDevice.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 | « src/core/SkCanvas.cpp ('k') | src/core/SkImageFilter.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 2011 Google Inc. 2 * Copyright 2011 Google Inc.
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 "SkColorFilter.h" 8 #include "SkColorFilter.h"
9 #include "SkDevice.h" 9 #include "SkDevice.h"
10 #include "SkDraw.h" 10 #include "SkDraw.h"
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 m.postConcat(*matrix); 396 m.postConcat(*matrix);
397 } 397 }
398 morphpath(&tmp, *iterPath, meas, m); 398 morphpath(&tmp, *iterPath, meas, m);
399 this->drawPath(draw, tmp, iter.getPaint(), nullptr, true); 399 this->drawPath(draw, tmp, iter.getPaint(), nullptr, true);
400 } 400 }
401 } 401 }
402 } 402 }
403 403
404 //////////////////////////////////////////////////////////////////////////////// ////////// 404 //////////////////////////////////////////////////////////////////////////////// //////////
405 405
406 void SkBaseDevice::drawBitmapAsSpriteWithImageFilter(const SkDraw& draw, const S kBitmap& bitmap, 406 void SkBaseDevice::drawSpriteWithFilter(const SkDraw& draw, const SkBitmap& bitm ap,
407 int x, int y, 407 int x, int y,
408 const SkPaint& paint) { 408 const SkPaint& paint) {
409 SkImageFilter* filter = paint.getImageFilter(); 409 SkImageFilter* filter = paint.getImageFilter();
410 SkASSERT(filter); 410 SkASSERT(filter);
411 411
412 if (!this->canHandleImageFilter(filter)) { 412 if (!this->canHandleImageFilter(filter)) {
413 SkImageFilter::DeviceProxy proxy(this); 413 SkImageFilter::DeviceProxy proxy(this);
414 SkIPoint offset = SkIPoint::Make(0, 0); 414 SkIPoint offset = SkIPoint::Make(0, 0);
415 SkMatrix matrix = *draw.fMatrix; 415 SkMatrix matrix = *draw.fMatrix;
416 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); 416 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y));
417 const SkIRect clipBounds = draw.fClip->getBounds().makeOffset(-x, -y); 417 const SkIRect clipBounds = draw.fClip->getBounds().makeOffset(-x, -y);
418 SkAutoTUnref<SkImageFilter::Cache> cache(this->getImageFilterCache()); 418 SkAutoTUnref<SkImageFilter::Cache> cache(this->getImageFilterCache());
419 SkImageFilter::Context ctx(matrix, clipBounds, cache.get()); 419 SkImageFilter::Context ctx(matrix, clipBounds, cache.get());
420 420
421 sk_sp<SkSpecialImage> srcImg(SkSpecialImage::internal_fromBM(&proxy, bit map)); 421 sk_sp<SkSpecialImage> srcImg(SkSpecialImage::internal_fromBM(&proxy, bit map));
422 if (!srcImg) { 422 if (!srcImg) {
423 return; // something disastrous happened 423 return; // something disastrous happened
424 } 424 }
425 425
426 SkAutoTUnref<SkSpecialImage> resultImg(filter->filterImage(srcImg.get(), ctx, &offset)); 426 sk_sp<SkSpecialImage> resultImg(filter->filterImage(srcImg.get(), ctx, & offset));
427 if (resultImg) { 427 if (resultImg) {
428 SkPaint tmpUnfiltered(paint); 428 SkPaint tmpUnfiltered(paint);
429 tmpUnfiltered.setImageFilter(nullptr); 429 tmpUnfiltered.setImageFilter(nullptr);
430 SkBitmap resultBM; 430 SkBitmap resultBM;
431 if (resultImg->internal_getBM(&resultBM)) { 431 if (resultImg->internal_getBM(&resultBM)) {
432 // TODO: add drawSprite(SkSpecialImage) to SkDevice? (see skbug. com/5073) 432 // TODO: add drawSprite(SkSpecialImage) to SkDevice? (see skbug. com/5073)
433 this->drawSprite(draw, resultBM, x + offset.x(), y + offset.y(), tmpUnfiltered); 433 this->drawSprite(draw, resultBM, x + offset.x(), y + offset.y(), tmpUnfiltered);
434 } 434 }
435 } 435 }
436 } else { 436 } else {
(...skipping 14 matching lines...) Expand all
451 flags &= ~SkPaint::kLCDRenderText_Flag; 451 flags &= ~SkPaint::kLCDRenderText_Flag;
452 flags |= SkPaint::kGenA8FromLCD_Flag; 452 flags |= SkPaint::kGenA8FromLCD_Flag;
453 } 453 }
454 454
455 return flags; 455 return flags;
456 } 456 }
457 457
458 sk_sp<SkSurface> SkBaseDevice::makeSurface(SkImageInfo const&, SkSurfaceProps co nst&) { 458 sk_sp<SkSurface> SkBaseDevice::makeSurface(SkImageInfo const&, SkSurfaceProps co nst&) {
459 return nullptr; 459 return nullptr;
460 } 460 }
OLDNEW
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/core/SkImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698