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 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 // setup new clip | 480 // setup new clip |
481 const GrClip clip(SkRect::MakeWH(SkIntToScalar(srcTexture->width()), | 481 const GrClip clip(SkRect::MakeWH(SkIntToScalar(srcTexture->width()), |
482 SkIntToScalar(srcTexture->height()))); | 482 SkIntToScalar(srcTexture->height()))); |
483 | 483 |
484 const SkIRect dstRect = SkIRect::MakeWH(rect.width(), rect.height()); | 484 const SkIRect dstRect = SkIRect::MakeWH(rect.width(), rect.height()); |
485 SkIRect srcRect = rect; | 485 SkIRect srcRect = rect; |
486 | 486 |
487 SkASSERT(radius.width() > 0 || radius.height() > 0); | 487 SkASSERT(radius.width() > 0 || radius.height() > 0); |
488 | 488 |
489 if (radius.fWidth > 0) { | 489 if (radius.fWidth > 0) { |
490 sk_sp<GrDrawContext> dstDrawContext(context->newDrawContext(GrContext::k
Loose_BackingFit, | 490 sk_sp<GrDrawContext> dstDrawContext(context->newDrawContext(SkBackingFit
::kApprox, |
491 rect.width()
, rect.height(), | 491 rect.width()
, rect.height(), |
492 kSkia8888_Gr
PixelConfig)); | 492 kSkia8888_Gr
PixelConfig)); |
493 if (!dstDrawContext) { | 493 if (!dstDrawContext) { |
494 return nullptr; | 494 return nullptr; |
495 } | 495 } |
496 | 496 |
497 apply_morphology_pass(dstDrawContext.get(), clip, srcTexture.get(), | 497 apply_morphology_pass(dstDrawContext.get(), clip, srcTexture.get(), |
498 srcRect, dstRect, radius.fWidth, morphType, | 498 srcRect, dstRect, radius.fWidth, morphType, |
499 Gr1DKernelEffect::kX_Direction); | 499 Gr1DKernelEffect::kX_Direction); |
500 SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom, | 500 SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom, |
501 dstRect.width(), radius.fHeight); | 501 dstRect.width(), radius.fHeight); |
502 GrColor clearColor = GrMorphologyEffect::kErode_MorphologyType == morphT
ype | 502 GrColor clearColor = GrMorphologyEffect::kErode_MorphologyType == morphT
ype |
503 ? SK_ColorWHITE | 503 ? SK_ColorWHITE |
504 : SK_ColorTRANSPARENT; | 504 : SK_ColorTRANSPARENT; |
505 dstDrawContext->clear(&clearRect, clearColor, false); | 505 dstDrawContext->clear(&clearRect, clearColor, false); |
506 | 506 |
507 srcTexture = dstDrawContext->asTexture(); | 507 srcTexture = dstDrawContext->asTexture(); |
508 srcRect = dstRect; | 508 srcRect = dstRect; |
509 } | 509 } |
510 if (radius.fHeight > 0) { | 510 if (radius.fHeight > 0) { |
511 sk_sp<GrDrawContext> dstDrawContext(context->newDrawContext(GrContext::k
Loose_BackingFit, | 511 sk_sp<GrDrawContext> dstDrawContext(context->newDrawContext(SkBackingFit
::kApprox, |
512 rect.width()
, rect.height(), | 512 rect.width()
, rect.height(), |
513 kSkia8888_Gr
PixelConfig)); | 513 kSkia8888_Gr
PixelConfig)); |
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 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 inputBM.getAddr32(srcBounds.left(), srcBounds.top()), | 628 inputBM.getAddr32(srcBounds.left(), srcBounds.top()), |
629 inputBM.rowBytesAsPixels(), | 629 inputBM.rowBytesAsPixels(), |
630 &dst, height, srcBounds); | 630 &dst, height, srcBounds); |
631 } | 631 } |
632 offset->fX = bounds.left(); | 632 offset->fX = bounds.left(); |
633 offset->fY = bounds.top(); | 633 offset->fY = bounds.top(); |
634 | 634 |
635 return SkSpecialImage::MakeFromRaster(SkIRect::MakeWH(bounds.width(), bounds
.height()), | 635 return SkSpecialImage::MakeFromRaster(SkIRect::MakeWH(bounds.width(), bounds
.height()), |
636 dst, &source->props()); | 636 dst, &source->props()); |
637 } | 637 } |
OLD | NEW |