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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 | 445 |
446 namespace { | 446 namespace { |
447 | 447 |
448 void apply_morphology_pass(GrContext* context, | 448 void apply_morphology_pass(GrContext* context, |
449 GrTexture* texture, | 449 GrTexture* texture, |
450 const SkIRect& rect, | 450 const SkIRect& rect, |
451 int radius, | 451 int radius, |
452 GrMorphologyEffect::MorphologyType morphType, | 452 GrMorphologyEffect::MorphologyType morphType, |
453 Gr1DKernelEffect::Direction direction) { | 453 Gr1DKernelEffect::Direction direction) { |
454 GrPaint paint; | 454 GrPaint paint; |
455 paint.colorStage(0)->setEffect(GrMorphologyEffect::Create(texture, | 455 paint.addColorEffect(GrMorphologyEffect::Create(texture, |
456 direction, | 456 direction, |
457 radius, | 457 radius, |
458 morphType))->unref
(); | 458 morphType))->unref(); |
459 context->drawRect(paint, SkRect::MakeFromIRect(rect)); | 459 context->drawRect(paint, SkRect::MakeFromIRect(rect)); |
460 } | 460 } |
461 | 461 |
462 GrTexture* apply_morphology(GrTexture* srcTexture, | 462 GrTexture* apply_morphology(GrTexture* srcTexture, |
463 const SkIRect& rect, | 463 const SkIRect& rect, |
464 GrMorphologyEffect::MorphologyType morphType, | 464 GrMorphologyEffect::MorphologyType morphType, |
465 SkISize radius) { | 465 SkISize radius) { |
466 GrContext* context = srcTexture->getContext(); | 466 GrContext* context = srcTexture->getContext(); |
467 srcTexture->ref(); | 467 srcTexture->ref(); |
468 | 468 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 } | 524 } |
525 GrTexture* input = inputBM.getTexture(); | 525 GrTexture* input = inputBM.getTexture(); |
526 SkIRect bounds; | 526 SkIRect bounds; |
527 src.getBounds(&bounds); | 527 src.getBounds(&bounds); |
528 SkAutoTUnref<GrTexture> resultTex(apply_morphology(input, bounds, | 528 SkAutoTUnref<GrTexture> resultTex(apply_morphology(input, bounds, |
529 GrMorphologyEffect::kErode_MorphologyType, radius())); | 529 GrMorphologyEffect::kErode_MorphologyType, radius())); |
530 return SkImageFilterUtils::WrapTexture(resultTex, src.width(), src.height(),
result); | 530 return SkImageFilterUtils::WrapTexture(resultTex, src.width(), src.height(),
result); |
531 } | 531 } |
532 | 532 |
533 #endif | 533 #endif |
OLD | NEW |