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

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

Issue 1411013004: Image filters: simplify filterInputGPU(). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month 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 | « bench/ImageFilterDAGBench.cpp ('k') | 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 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 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 // matrix with no clip and that the matrix, clip, and render target set befo re this function was 489 // matrix with no clip and that the matrix, clip, and render target set befo re this function was
490 // called are restored before we return to the caller. 490 // called are restored before we return to the caller.
491 GrContext* context = src.getTexture()->getContext(); 491 GrContext* context = src.getTexture()->getContext();
492 492
493 SizeConstraint constraint = origCtx.sizeConstraint(); 493 SizeConstraint constraint = origCtx.sizeConstraint();
494 if (relaxSizeConstraint && (kExact_SizeConstraint == constraint)) { 494 if (relaxSizeConstraint && (kExact_SizeConstraint == constraint)) {
495 constraint = kApprox_SizeConstraint; 495 constraint = kApprox_SizeConstraint;
496 } 496 }
497 Context ctx(origCtx.ctm(), origCtx.clipBounds(), origCtx.cache(), constraint ); 497 Context ctx(origCtx.ctm(), origCtx.clipBounds(), origCtx.cache(), constraint );
498 498
499 if (input->canFilterImageGPU()) { 499 if (input->filterImage(proxy, src, ctx, result, offset)) {
500 return input->filterImageGPU(proxy, src, ctx, result, offset); 500 if (!result->getTexture()) {
501 const SkImageInfo info = result->info();
502 if (kUnknown_SkColorType == info.colorType()) {
503 return false;
504 }
505 SkAutoTUnref<GrTexture> resultTex(
506 GrRefCachedBitmapTexture(context, *result,GrTextureParams::Clamp NoFilter()));
507 result->setPixelRef(new SkGrPixelRef(info, resultTex))->unref();
508 }
509 return true;
501 } else { 510 } else {
502 if (input->filterImage(proxy, src, ctx, result, offset)) { 511 return false;
503 if (!result->getTexture()) {
504 const SkImageInfo info = result->info();
505 if (kUnknown_SkColorType == info.colorType()) {
506 return false;
507 }
508 SkAutoTUnref<GrTexture> resultTex(
509 GrRefCachedBitmapTexture(context, *result,GrTextureParams::C lampNoFilter()));
510 result->setPixelRef(new SkGrPixelRef(info, resultTex))->unref();
511 }
512 return true;
513 } else {
514 return false;
515 }
516 } 512 }
517 } 513 }
518 #endif 514 #endif
519 515
520 namespace { 516 namespace {
521 517
522 class CacheImpl : public SkImageFilter::Cache { 518 class CacheImpl : public SkImageFilter::Cache {
523 public: 519 public:
524 CacheImpl(size_t maxBytes) : fMaxBytes(maxBytes), fCurrentBytes(0) { 520 CacheImpl(size_t maxBytes) : fMaxBytes(maxBytes), fCurrentBytes(0) {
525 } 521 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 } 628 }
633 return dev; 629 return dev;
634 } 630 }
635 631
636 bool SkImageFilter::DeviceProxy::filterImage(const SkImageFilter* filter, const SkBitmap& src, 632 bool SkImageFilter::DeviceProxy::filterImage(const SkImageFilter* filter, const SkBitmap& src,
637 const SkImageFilter::Context& ctx, 633 const SkImageFilter::Context& ctx,
638 SkBitmap* result, SkIPoint* offset) { 634 SkBitmap* result, SkIPoint* offset) {
639 return fDevice->filterImage(filter, src, ctx, result, offset); 635 return fDevice->filterImage(filter, src, ctx, result, offset);
640 } 636 }
641 637
OLDNEW
« no previous file with comments | « bench/ImageFilterDAGBench.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698