| 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 "SkMorphologyImageFilter.h" | 8 #include "SkMorphologyImageFilter.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 | 655 |
| 656 SkIRect dstRect = SkIRect::MakeWH(rect.width(), rect.height()); | 656 SkIRect dstRect = SkIRect::MakeWH(rect.width(), rect.height()); |
| 657 GrSurfaceDesc desc; | 657 GrSurfaceDesc desc; |
| 658 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 658 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
| 659 desc.fWidth = rect.width(); | 659 desc.fWidth = rect.width(); |
| 660 desc.fHeight = rect.height(); | 660 desc.fHeight = rect.height(); |
| 661 desc.fConfig = kSkia8888_GrPixelConfig; | 661 desc.fConfig = kSkia8888_GrPixelConfig; |
| 662 SkIRect srcRect = rect; | 662 SkIRect srcRect = rect; |
| 663 | 663 |
| 664 if (radius.fWidth > 0) { | 664 if (radius.fWidth > 0) { |
| 665 GrTexture* scratch = context->textureProvider()->refScratchTexture( | 665 GrTexture* scratch = context->textureProvider()->createApproxTexture(des
c); |
| 666 desc, GrTextureProvider::kApprox_ScratchTexMatch); | |
| 667 if (NULL == scratch) { | 666 if (NULL == scratch) { |
| 668 return false; | 667 return false; |
| 669 } | 668 } |
| 670 GrDrawContext* dstDrawContext = context->drawContext(); | 669 GrDrawContext* dstDrawContext = context->drawContext(); |
| 671 if (!dstDrawContext) { | 670 if (!dstDrawContext) { |
| 672 return false; | 671 return false; |
| 673 } | 672 } |
| 674 | 673 |
| 675 apply_morphology_pass(dstDrawContext, scratch->asRenderTarget(), clip, s
rcTexture, | 674 apply_morphology_pass(dstDrawContext, scratch->asRenderTarget(), clip, s
rcTexture, |
| 676 srcRect, dstRect, radius.fWidth, morphType, | 675 srcRect, dstRect, radius.fWidth, morphType, |
| 677 Gr1DKernelEffect::kX_Direction); | 676 Gr1DKernelEffect::kX_Direction); |
| 678 SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom, | 677 SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom, |
| 679 dstRect.width(), radius.fHeight); | 678 dstRect.width(), radius.fHeight); |
| 680 GrColor clearColor = GrMorphologyEffect::kErode_MorphologyType == morphT
ype ? | 679 GrColor clearColor = GrMorphologyEffect::kErode_MorphologyType == morphT
ype ? |
| 681 SK_ColorWHITE : | 680 SK_ColorWHITE : |
| 682 SK_ColorTRANSPARENT; | 681 SK_ColorTRANSPARENT; |
| 683 dstDrawContext->clear(scratch->asRenderTarget(), &clearRect, clearColor,
false); | 682 dstDrawContext->clear(scratch->asRenderTarget(), &clearRect, clearColor,
false); |
| 684 | 683 |
| 685 srcTexture.reset(scratch); | 684 srcTexture.reset(scratch); |
| 686 srcRect = dstRect; | 685 srcRect = dstRect; |
| 687 } | 686 } |
| 688 if (radius.fHeight > 0) { | 687 if (radius.fHeight > 0) { |
| 689 GrTexture* scratch = context->textureProvider()->refScratchTexture(desc, | 688 GrTexture* scratch = context->textureProvider()->createApproxTexture(des
c); |
| 690 GrTextureProvider::kApprox_ScratchTexMatch); | |
| 691 if (NULL == scratch) { | 689 if (NULL == scratch) { |
| 692 return false; | 690 return false; |
| 693 } | 691 } |
| 694 GrDrawContext* dstDrawContext = context->drawContext(); | 692 GrDrawContext* dstDrawContext = context->drawContext(); |
| 695 if (!dstDrawContext) { | 693 if (!dstDrawContext) { |
| 696 return false; | 694 return false; |
| 697 } | 695 } |
| 698 | 696 |
| 699 apply_morphology_pass(dstDrawContext, scratch->asRenderTarget(), clip, s
rcTexture, | 697 apply_morphology_pass(dstDrawContext, scratch->asRenderTarget(), clip, s
rcTexture, |
| 700 srcRect, dstRect, radius.fHeight, morphType, | 698 srcRect, dstRect, radius.fHeight, morphType, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 SkBitmap* result, SkIPoint* offset) con
st { | 755 SkBitmap* result, SkIPoint* offset) con
st { |
| 758 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset); | 756 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset); |
| 759 } | 757 } |
| 760 | 758 |
| 761 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
Context& ctx, | 759 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
Context& ctx, |
| 762 SkBitmap* result, SkIPoint* offset) cons
t { | 760 SkBitmap* result, SkIPoint* offset) cons
t { |
| 763 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset); | 761 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset); |
| 764 } | 762 } |
| 765 | 763 |
| 766 #endif | 764 #endif |
| OLD | NEW |