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 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 desc.fWidth = rect.width(); | 557 desc.fWidth = rect.width(); |
558 desc.fHeight = rect.height(); | 558 desc.fHeight = rect.height(); |
559 desc.fConfig = kSkia8888_GrPixelConfig; | 559 desc.fConfig = kSkia8888_GrPixelConfig; |
560 SkIRect srcRect = rect; | 560 SkIRect srcRect = rect; |
561 | 561 |
562 if (radius.fWidth > 0) { | 562 if (radius.fWidth > 0) { |
563 GrTexture* scratch = context->textureProvider()->createApproxTexture(des
c); | 563 GrTexture* scratch = context->textureProvider()->createApproxTexture(des
c); |
564 if (nullptr == scratch) { | 564 if (nullptr == scratch) { |
565 return false; | 565 return false; |
566 } | 566 } |
567 SkAutoTUnref<GrDrawContext> dstDrawContext(context->drawContext(scratch-
>asRenderTarget())); | 567 SkAutoTUnref<GrDrawContext> dstDrawContext( |
| 568 context->drawContext(scratch->as
RenderTarget())); |
568 if (!dstDrawContext) { | 569 if (!dstDrawContext) { |
569 return false; | 570 return false; |
570 } | 571 } |
571 | 572 |
572 apply_morphology_pass(dstDrawContext, clip, srcTexture, | 573 apply_morphology_pass(dstDrawContext, clip, srcTexture, |
573 srcRect, dstRect, radius.fWidth, morphType, | 574 srcRect, dstRect, radius.fWidth, morphType, |
574 Gr1DKernelEffect::kX_Direction); | 575 Gr1DKernelEffect::kX_Direction); |
575 SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom, | 576 SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom, |
576 dstRect.width(), radius.fHeight); | 577 dstRect.width(), radius.fHeight); |
577 GrColor clearColor = GrMorphologyEffect::kErode_MorphologyType == morphT
ype ? | 578 GrColor clearColor = GrMorphologyEffect::kErode_MorphologyType == morphT
ype ? |
578 SK_ColorWHITE : | 579 SK_ColorWHITE : |
579 SK_ColorTRANSPARENT; | 580 SK_ColorTRANSPARENT; |
580 dstDrawContext->clear(&clearRect, clearColor, false); | 581 dstDrawContext->clear(&clearRect, clearColor, false); |
581 | 582 |
582 srcTexture.reset(scratch); | 583 srcTexture.reset(scratch); |
583 srcRect = dstRect; | 584 srcRect = dstRect; |
584 } | 585 } |
585 if (radius.fHeight > 0) { | 586 if (radius.fHeight > 0) { |
586 GrTexture* scratch = context->textureProvider()->createApproxTexture(des
c); | 587 GrTexture* scratch = context->textureProvider()->createApproxTexture(des
c); |
587 if (nullptr == scratch) { | 588 if (nullptr == scratch) { |
588 return false; | 589 return false; |
589 } | 590 } |
590 SkAutoTUnref<GrDrawContext> dstDrawContext(context->drawContext(scratch-
>asRenderTarget())); | 591 SkAutoTUnref<GrDrawContext> dstDrawContext( |
| 592 context->drawContext(scratch->as
RenderTarget())); |
591 if (!dstDrawContext) { | 593 if (!dstDrawContext) { |
592 return false; | 594 return false; |
593 } | 595 } |
594 | 596 |
595 apply_morphology_pass(dstDrawContext, clip, srcTexture, | 597 apply_morphology_pass(dstDrawContext, clip, srcTexture, |
596 srcRect, dstRect, radius.fHeight, morphType, | 598 srcRect, dstRect, radius.fHeight, morphType, |
597 Gr1DKernelEffect::kY_Direction); | 599 Gr1DKernelEffect::kY_Direction); |
598 | 600 |
599 srcTexture.reset(scratch); | 601 srcTexture.reset(scratch); |
600 } | 602 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 SkBitmap* result, SkIPoint* offset) con
st { | 655 SkBitmap* result, SkIPoint* offset) con
st { |
654 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset); | 656 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset); |
655 } | 657 } |
656 | 658 |
657 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
Context& ctx, | 659 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
Context& ctx, |
658 SkBitmap* result, SkIPoint* offset) cons
t { | 660 SkBitmap* result, SkIPoint* offset) cons
t { |
659 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset); | 661 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset); |
660 } | 662 } |
661 | 663 |
662 #endif | 664 #endif |
OLD | NEW |