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

Side by Side Diff: src/core/SkImageFilter.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 | « src/core/SkDevice.cpp ('k') | src/core/SkSpecialImage.h » ('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 2012 The Android Open Source Project 2 * Copyright 2012 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 "SkImageFilter.h" 8 #include "SkImageFilter.h"
9 #include "SkImageFilterCacheKey.h" 9 #include "SkImageFilterCacheKey.h"
10 10
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 return false; 265 return false;
266 } 266 }
267 267
268 bool SkImageFilter::filterInputDeprecated(int index, Proxy* proxy, const SkBitma p& src, 268 bool SkImageFilter::filterInputDeprecated(int index, Proxy* proxy, const SkBitma p& src,
269 const Context& ctx, 269 const Context& ctx,
270 SkBitmap* result, SkIPoint* offset) co nst { 270 SkBitmap* result, SkIPoint* offset) co nst {
271 SkImageFilter* input = this->getInput(index); 271 SkImageFilter* input = this->getInput(index);
272 if (!input) { 272 if (!input) {
273 return true; 273 return true;
274 } 274 }
275 return input->filterImageDeprecated(proxy, src, this->mapContext(ctx), resul t, offset); 275
276 SkAutoTUnref<SkSpecialImage> specialSrc(SkSpecialImage::internal_fromBM(prox y, src));
277 if (!specialSrc) {
278 return false;
279 }
280
281 SkAutoTUnref<SkSpecialImage> tmp(input->onFilterImage(specialSrc,
282 this->mapContext(ctx),
283 offset));
284 if (!tmp) {
285 return false;
286 }
287
288 return tmp->internal_getBM(result);
276 } 289 }
277 290
278 bool SkImageFilter::filterBounds(const SkIRect& src, const SkMatrix& ctm, SkIRec t* dst, 291 bool SkImageFilter::filterBounds(const SkIRect& src, const SkMatrix& ctm, SkIRec t* dst,
279 MapDirection direction) const { 292 MapDirection direction) const {
280 SkASSERT(dst); 293 SkASSERT(dst);
281 SkIRect bounds; 294 SkIRect bounds;
282 if (kReverse_MapDirection == direction) { 295 if (kReverse_MapDirection == direction) {
283 this->onFilterNodeBounds(src, ctm, &bounds, direction); 296 this->onFilterNodeBounds(src, ctm, &bounds, direction);
284 return this->onFilterBounds(bounds, ctm, dst, direction); 297 return this->onFilterBounds(bounds, ctm, dst, direction);
285 } else { 298 } else {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 SkImageFilter* input = this->getInput(i); 333 SkImageFilter* input = this->getInput(i);
321 if (input && !input->canComputeFastBounds()) { 334 if (input && !input->canComputeFastBounds()) {
322 return false; 335 return false;
323 } 336 }
324 } 337 }
325 return true; 338 return true;
326 } 339 }
327 340
328 bool SkImageFilter::onFilterImageDeprecated(Proxy*, const SkBitmap&, const Conte xt&, 341 bool SkImageFilter::onFilterImageDeprecated(Proxy*, const SkBitmap&, const Conte xt&,
329 SkBitmap*, SkIPoint*) const { 342 SkBitmap*, SkIPoint*) const {
343 // Only classes that now use the new SkSpecialImage-based path will not have
344 // onFilterImageDeprecated methods. For those classes we should never be
345 // calling this method.
346 SkASSERT(0);
330 return false; 347 return false;
331 } 348 }
332 349
350 // SkImageFilter-derived classes that do not yet have their own onFilterImage
351 // implementation convert back to calling the deprecated filterImage method
333 SkSpecialImage* SkImageFilter::onFilterImage(SkSpecialImage* src, const Context& ctx, 352 SkSpecialImage* SkImageFilter::onFilterImage(SkSpecialImage* src, const Context& ctx,
334 SkIPoint* offset) const { 353 SkIPoint* offset) const {
335 SkBitmap srcBM, resultBM; 354 SkBitmap srcBM, resultBM;
336 355
337 if (!src->internal_getBM(&srcBM)) { 356 if (!src->internal_getBM(&srcBM)) {
338 return nullptr; 357 return nullptr;
339 } 358 }
340 359
360 // This is the only valid call to the old filterImage path
341 if (!this->filterImageDeprecated(src->internal_getProxy(), srcBM, ctx, &resu ltBM, offset)) { 361 if (!this->filterImageDeprecated(src->internal_getProxy(), srcBM, ctx, &resu ltBM, offset)) {
342 return nullptr; 362 return nullptr;
343 } 363 }
344 364
345 return SkSpecialImage::internal_fromBM(src->internal_getProxy(), resultBM); 365 return SkSpecialImage::internal_fromBM(src->internal_getProxy(), resultBM);
346 } 366 }
347 367
348 bool SkImageFilter::canFilterImageGPU() const { 368 bool SkImageFilter::canFilterImageGPU() const {
349 return this->asFragmentProcessor(nullptr, nullptr, SkMatrix::I(), SkIRect()) ; 369 return this->asFragmentProcessor(nullptr, nullptr, SkMatrix::I(), SkIRect()) ;
350 } 370 }
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 596
577 #if SK_SUPPORT_GPU 597 #if SK_SUPPORT_GPU
578 598
579 bool SkImageFilter::filterInputGPUDeprecated(int index, SkImageFilter::Proxy* pr oxy, 599 bool SkImageFilter::filterInputGPUDeprecated(int index, SkImageFilter::Proxy* pr oxy,
580 const SkBitmap& src, const Context& ctx, 600 const SkBitmap& src, const Context& ctx,
581 SkBitmap* result, SkIPoint* offset) const { 601 SkBitmap* result, SkIPoint* offset) const {
582 SkImageFilter* input = this->getInput(index); 602 SkImageFilter* input = this->getInput(index);
583 if (!input) { 603 if (!input) {
584 return true; 604 return true;
585 } 605 }
586 // Ensure that GrContext calls under filterImage and filterImageGPU below wi ll see an identity 606
587 // matrix with no clip and that the matrix, clip, and render target set befo re this function was 607 SkAutoTUnref<SkSpecialImage> specialSrc(SkSpecialImage::internal_fromBM(prox y, src));
588 // called are restored before we return to the caller. 608 if (!specialSrc) {
589 GrContext* context = src.getTexture()->getContext();
590 if (input->filterImageDeprecated(proxy, src, this->mapContext(ctx), result, offset)) {
591 if (!result->getTexture()) {
592 const SkImageInfo info = result->info();
593 if (kUnknown_SkColorType == info.colorType()) {
594 return false;
595 }
596 SkAutoTUnref<GrTexture> resultTex(
597 GrRefCachedBitmapTexture(context, *result, GrTextureParams::Clam pNoFilter()));
598 if (!resultTex) {
599 return false;
600 }
601 result->setPixelRef(new SkGrPixelRef(info, resultTex))->unref();
602 }
603 return true;
604 } else {
605 return false; 609 return false;
606 } 610 }
611
612 SkAutoTUnref<SkSpecialImage> tmp(input->onFilterImage(specialSrc,
613 this->mapContext(ctx),
614 offset));
615 if (!tmp) {
616 return false;
617 }
618
619 if (!tmp->internal_getBM(result)) {
620 return false;
621 }
622
623 if (!result->getTexture()) {
624 GrContext* context = src.getTexture()->getContext();
625
626 const SkImageInfo info = result->info();
627 if (kUnknown_SkColorType == info.colorType()) {
628 return false;
629 }
630 SkAutoTUnref<GrTexture> resultTex(
631 GrRefCachedBitmapTexture(context, *result, GrTextureParams::ClampNoF ilter()));
632 if (!resultTex) {
633 return false;
634 }
635 result->setPixelRef(new SkGrPixelRef(info, resultTex))->unref();
636 }
637
638 return true;
607 } 639 }
608 #endif 640 #endif
609 641
610 namespace { 642 namespace {
611 643
612 class CacheImpl : public SkImageFilter::Cache { 644 class CacheImpl : public SkImageFilter::Cache {
613 public: 645 public:
614 CacheImpl(size_t maxBytes) : fMaxBytes(maxBytes), fCurrentBytes(0) { } 646 CacheImpl(size_t maxBytes) : fMaxBytes(maxBytes), fCurrentBytes(0) { }
615 ~CacheImpl() override { 647 ~CacheImpl() override {
616 SkTDynamicHash<Value, Key>::Iter iter(&fLookup); 648 SkTDynamicHash<Value, Key>::Iter iter(&fLookup);
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 } 806 }
775 return dev; 807 return dev;
776 } 808 }
777 809
778 bool SkImageFilter::DeviceProxy::filterImage(const SkImageFilter* filter, const SkBitmap& src, 810 bool SkImageFilter::DeviceProxy::filterImage(const SkImageFilter* filter, const SkBitmap& src,
779 const SkImageFilter::Context& ctx, 811 const SkImageFilter::Context& ctx,
780 SkBitmap* result, SkIPoint* offset) { 812 SkBitmap* result, SkIPoint* offset) {
781 return fDevice->filterImage(filter, src, ctx, result, offset); 813 return fDevice->filterImage(filter, src, ctx, result, offset);
782 } 814 }
783 815
OLDNEW
« no previous file with comments | « src/core/SkDevice.cpp ('k') | src/core/SkSpecialImage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698