| 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 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 desc.fWidth = rect.width(); | 566 desc.fWidth = rect.width(); |
| 567 desc.fHeight = rect.height(); | 567 desc.fHeight = rect.height(); |
| 568 desc.fConfig = kSkia8888_GrPixelConfig; | 568 desc.fConfig = kSkia8888_GrPixelConfig; |
| 569 SkIRect srcRect = rect; | 569 SkIRect srcRect = rect; |
| 570 | 570 |
| 571 if (radius.fWidth > 0) { | 571 if (radius.fWidth > 0) { |
| 572 GrTexture* scratch = context->textureProvider()->createApproxTexture(des
c); | 572 GrTexture* scratch = context->textureProvider()->createApproxTexture(des
c); |
| 573 if (nullptr == scratch) { | 573 if (nullptr == scratch) { |
| 574 return false; | 574 return false; |
| 575 } | 575 } |
| 576 GrDrawContext* dstDrawContext = context->drawContext(); | 576 SkAutoTUnref<GrDrawContext> dstDrawContext(context->drawContext()); |
| 577 if (!dstDrawContext) { | 577 if (!dstDrawContext) { |
| 578 return false; | 578 return false; |
| 579 } | 579 } |
| 580 | 580 |
| 581 apply_morphology_pass(dstDrawContext, scratch->asRenderTarget(), clip, s
rcTexture, | 581 apply_morphology_pass(dstDrawContext, scratch->asRenderTarget(), clip, s
rcTexture, |
| 582 srcRect, dstRect, radius.fWidth, morphType, | 582 srcRect, dstRect, radius.fWidth, morphType, |
| 583 Gr1DKernelEffect::kX_Direction); | 583 Gr1DKernelEffect::kX_Direction); |
| 584 SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom, | 584 SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom, |
| 585 dstRect.width(), radius.fHeight); | 585 dstRect.width(), radius.fHeight); |
| 586 GrColor clearColor = GrMorphologyEffect::kErode_MorphologyType == morphT
ype ? | 586 GrColor clearColor = GrMorphologyEffect::kErode_MorphologyType == morphT
ype ? |
| 587 SK_ColorWHITE : | 587 SK_ColorWHITE : |
| 588 SK_ColorTRANSPARENT; | 588 SK_ColorTRANSPARENT; |
| 589 dstDrawContext->clear(scratch->asRenderTarget(), &clearRect, clearColor,
false); | 589 dstDrawContext->clear(scratch->asRenderTarget(), &clearRect, clearColor,
false); |
| 590 | 590 |
| 591 srcTexture.reset(scratch); | 591 srcTexture.reset(scratch); |
| 592 srcRect = dstRect; | 592 srcRect = dstRect; |
| 593 } | 593 } |
| 594 if (radius.fHeight > 0) { | 594 if (radius.fHeight > 0) { |
| 595 GrTexture* scratch = context->textureProvider()->createApproxTexture(des
c); | 595 GrTexture* scratch = context->textureProvider()->createApproxTexture(des
c); |
| 596 if (nullptr == scratch) { | 596 if (nullptr == scratch) { |
| 597 return false; | 597 return false; |
| 598 } | 598 } |
| 599 GrDrawContext* dstDrawContext = context->drawContext(); | 599 SkAutoTUnref<GrDrawContext> dstDrawContext(context->drawContext()); |
| 600 if (!dstDrawContext) { | 600 if (!dstDrawContext) { |
| 601 return false; | 601 return false; |
| 602 } | 602 } |
| 603 | 603 |
| 604 apply_morphology_pass(dstDrawContext, scratch->asRenderTarget(), clip, s
rcTexture, | 604 apply_morphology_pass(dstDrawContext, scratch->asRenderTarget(), clip, s
rcTexture, |
| 605 srcRect, dstRect, radius.fHeight, morphType, | 605 srcRect, dstRect, radius.fHeight, morphType, |
| 606 Gr1DKernelEffect::kY_Direction); | 606 Gr1DKernelEffect::kY_Direction); |
| 607 | 607 |
| 608 srcTexture.reset(scratch); | 608 srcTexture.reset(scratch); |
| 609 } | 609 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 SkBitmap* result, SkIPoint* offset) con
st { | 662 SkBitmap* result, SkIPoint* offset) con
st { |
| 663 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset); | 663 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset); |
| 664 } | 664 } |
| 665 | 665 |
| 666 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
Context& ctx, | 666 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
Context& ctx, |
| 667 SkBitmap* result, SkIPoint* offset) cons
t { | 667 SkBitmap* result, SkIPoint* offset) cons
t { |
| 668 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset); | 668 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset); |
| 669 } | 669 } |
| 670 | 670 |
| 671 #endif | 671 #endif |
| OLD | NEW |