| 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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 SkIRect dstRect = SkIRect::MakeWH(rect.width(), rect.height()); | 499 SkIRect dstRect = SkIRect::MakeWH(rect.width(), rect.height()); |
| 500 GrTextureDesc desc; | 500 GrTextureDesc desc; |
| 501 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit; | 501 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit; |
| 502 desc.fWidth = rect.width(); | 502 desc.fWidth = rect.width(); |
| 503 desc.fHeight = rect.height(); | 503 desc.fHeight = rect.height(); |
| 504 desc.fConfig = kSkia8888_GrPixelConfig; | 504 desc.fConfig = kSkia8888_GrPixelConfig; |
| 505 SkIRect srcRect = rect; | 505 SkIRect srcRect = rect; |
| 506 | 506 |
| 507 if (radius.fWidth > 0) { | 507 if (radius.fWidth > 0) { |
| 508 GrAutoScratchTexture ast(context, desc); | 508 GrAutoScratchTexture ast(context, desc); |
| 509 if (NULL == ast.texture()) { |
| 510 return false; |
| 511 } |
| 509 GrContext::AutoRenderTarget art(context, ast.texture()->asRenderTarget()
); | 512 GrContext::AutoRenderTarget art(context, ast.texture()->asRenderTarget()
); |
| 510 apply_morphology_pass(context, src, srcRect, dstRect, radius.fWidth, | 513 apply_morphology_pass(context, src, srcRect, dstRect, radius.fWidth, |
| 511 morphType, Gr1DKernelEffect::kX_Direction); | 514 morphType, Gr1DKernelEffect::kX_Direction); |
| 512 SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom, | 515 SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom, |
| 513 dstRect.width(), radius.fHeight); | 516 dstRect.width(), radius.fHeight); |
| 514 context->clear(&clearRect, GrMorphologyEffect::kErode_MorphologyType ==
morphType ? | 517 context->clear(&clearRect, GrMorphologyEffect::kErode_MorphologyType ==
morphType ? |
| 515 SK_ColorWHITE : | 518 SK_ColorWHITE : |
| 516 SK_ColorTRANSPARENT, false); | 519 SK_ColorTRANSPARENT, false); |
| 517 src.reset(ast.detach()); | 520 src.reset(ast.detach()); |
| 518 srcRect = dstRect; | 521 srcRect = dstRect; |
| 519 } | 522 } |
| 520 if (radius.fHeight > 0) { | 523 if (radius.fHeight > 0) { |
| 521 GrAutoScratchTexture ast(context, desc); | 524 GrAutoScratchTexture ast(context, desc); |
| 525 if (NULL == ast.texture()) { |
| 526 return false; |
| 527 } |
| 522 GrContext::AutoRenderTarget art(context, ast.texture()->asRenderTarget()
); | 528 GrContext::AutoRenderTarget art(context, ast.texture()->asRenderTarget()
); |
| 523 apply_morphology_pass(context, src, srcRect, dstRect, radius.fHeight, | 529 apply_morphology_pass(context, src, srcRect, dstRect, radius.fHeight, |
| 524 morphType, Gr1DKernelEffect::kY_Direction); | 530 morphType, Gr1DKernelEffect::kY_Direction); |
| 525 src.reset(ast.detach()); | 531 src.reset(ast.detach()); |
| 526 } | 532 } |
| 527 SkImageFilter::WrapTexture(src, rect.width(), rect.height(), dst); | 533 SkImageFilter::WrapTexture(src, rect.width(), rect.height(), dst); |
| 528 return true; | 534 return true; |
| 529 } | 535 } |
| 530 | 536 |
| 531 }; | 537 }; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 SkBitmap* result, SkIPoint* offset) con
st { | 584 SkBitmap* result, SkIPoint* offset) con
st { |
| 579 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset); | 585 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset); |
| 580 } | 586 } |
| 581 | 587 |
| 582 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
Context& ctx, | 588 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
Context& ctx, |
| 583 SkBitmap* result, SkIPoint* offset) cons
t { | 589 SkBitmap* result, SkIPoint* offset) cons
t { |
| 584 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset); | 590 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset); |
| 585 } | 591 } |
| 586 | 592 |
| 587 #endif | 593 #endif |
| OLD | NEW |