OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |