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 | 9 |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 | 478 |
479 // setup new clip | 479 // setup new clip |
480 const GrFixedClip clip(SkIRect::MakeWH(srcTexture->width(), srcTexture->heig
ht())); | 480 const GrFixedClip clip(SkIRect::MakeWH(srcTexture->width(), srcTexture->heig
ht())); |
481 | 481 |
482 const SkIRect dstRect = SkIRect::MakeWH(rect.width(), rect.height()); | 482 const SkIRect dstRect = SkIRect::MakeWH(rect.width(), rect.height()); |
483 SkIRect srcRect = rect; | 483 SkIRect srcRect = rect; |
484 | 484 |
485 SkASSERT(radius.width() > 0 || radius.height() > 0); | 485 SkASSERT(radius.width() > 0 || radius.height() > 0); |
486 | 486 |
487 if (radius.fWidth > 0) { | 487 if (radius.fWidth > 0) { |
488 sk_sp<GrDrawContext> dstDrawContext(context->newDrawContext(SkBackingFit
::kApprox, | 488 sk_sp<GrDrawContext> dstDrawContext(context->makeDrawContext(SkBackingFi
t::kApprox, |
489 rect.width()
, rect.height(), | 489 rect.width(
), rect.height(), |
490 kSkia8888_Gr
PixelConfig, | 490 kSkia8888_G
rPixelConfig, |
491 colorSpace))
; | 491 colorSpace)
); |
492 if (!dstDrawContext) { | 492 if (!dstDrawContext) { |
493 return nullptr; | 493 return nullptr; |
494 } | 494 } |
495 | 495 |
496 apply_morphology_pass(dstDrawContext.get(), clip, srcTexture.get(), | 496 apply_morphology_pass(dstDrawContext.get(), clip, srcTexture.get(), |
497 srcRect, dstRect, radius.fWidth, morphType, | 497 srcRect, dstRect, radius.fWidth, morphType, |
498 Gr1DKernelEffect::kX_Direction); | 498 Gr1DKernelEffect::kX_Direction); |
499 SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom, | 499 SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom, |
500 dstRect.width(), radius.fHeight); | 500 dstRect.width(), radius.fHeight); |
501 GrColor clearColor = GrMorphologyEffect::kErode_MorphologyType == morphT
ype | 501 GrColor clearColor = GrMorphologyEffect::kErode_MorphologyType == morphT
ype |
502 ? SK_ColorWHITE | 502 ? SK_ColorWHITE |
503 : SK_ColorTRANSPARENT; | 503 : SK_ColorTRANSPARENT; |
504 dstDrawContext->clear(&clearRect, clearColor, false); | 504 dstDrawContext->clear(&clearRect, clearColor, false); |
505 | 505 |
506 srcTexture = dstDrawContext->asTexture(); | 506 srcTexture = dstDrawContext->asTexture(); |
507 srcRect = dstRect; | 507 srcRect = dstRect; |
508 } | 508 } |
509 if (radius.fHeight > 0) { | 509 if (radius.fHeight > 0) { |
510 sk_sp<GrDrawContext> dstDrawContext(context->newDrawContext(SkBackingFit
::kApprox, | 510 sk_sp<GrDrawContext> dstDrawContext(context->makeDrawContext(SkBackingFi
t::kApprox, |
511 rect.width()
, rect.height(), | 511 rect.width(
), rect.height(), |
512 kSkia8888_Gr
PixelConfig, | 512 kSkia8888_G
rPixelConfig, |
513 colorSpace))
; | 513 colorSpace)
); |
514 if (!dstDrawContext) { | 514 if (!dstDrawContext) { |
515 return nullptr; | 515 return nullptr; |
516 } | 516 } |
517 | 517 |
518 apply_morphology_pass(dstDrawContext.get(), clip, srcTexture.get(), | 518 apply_morphology_pass(dstDrawContext.get(), clip, srcTexture.get(), |
519 srcRect, dstRect, radius.fHeight, morphType, | 519 srcRect, dstRect, radius.fHeight, morphType, |
520 Gr1DKernelEffect::kY_Direction); | 520 Gr1DKernelEffect::kY_Direction); |
521 | 521 |
522 srcTexture = dstDrawContext->asTexture(); | 522 srcTexture = dstDrawContext->asTexture(); |
523 } | 523 } |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 inputBM.getAddr32(srcBounds.left(), srcBounds.top()), | 629 inputBM.getAddr32(srcBounds.left(), srcBounds.top()), |
630 inputBM.rowBytesAsPixels(), | 630 inputBM.rowBytesAsPixels(), |
631 &dst, height, srcBounds); | 631 &dst, height, srcBounds); |
632 } | 632 } |
633 offset->fX = bounds.left(); | 633 offset->fX = bounds.left(); |
634 offset->fY = bounds.top(); | 634 offset->fY = bounds.top(); |
635 | 635 |
636 return SkSpecialImage::MakeFromRaster(SkIRect::MakeWH(bounds.width(), bounds
.height()), | 636 return SkSpecialImage::MakeFromRaster(SkIRect::MakeWH(bounds.width(), bounds
.height()), |
637 dst, &source->props()); | 637 dst, &source->props()); |
638 } | 638 } |
OLD | NEW |