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 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 desc.fConfig = kSkia8888_GrPixelConfig; | 489 desc.fConfig = kSkia8888_GrPixelConfig; |
490 SkIRect srcRect = rect; | 490 SkIRect srcRect = rect; |
491 | 491 |
492 SkASSERT(radius.width() > 0 || radius.height() > 0); | 492 SkASSERT(radius.width() > 0 || radius.height() > 0); |
493 | 493 |
494 if (radius.fWidth > 0) { | 494 if (radius.fWidth > 0) { |
495 GrTexture* scratch = context->textureProvider()->createApproxTexture(des
c); | 495 GrTexture* scratch = context->textureProvider()->createApproxTexture(des
c); |
496 if (!scratch) { | 496 if (!scratch) { |
497 return nullptr; | 497 return nullptr; |
498 } | 498 } |
499 SkAutoTUnref<GrDrawContext> dstDrawContext( | 499 sk_sp<GrDrawContext> dstDrawContext( |
500 context->drawContext(scratch->as
RenderTarget())); | 500 context->drawContext(sk_ref_sp(scratch->as
RenderTarget()))); |
501 if (!dstDrawContext) { | 501 if (!dstDrawContext) { |
502 return nullptr; | 502 return nullptr; |
503 } | 503 } |
504 | 504 |
505 apply_morphology_pass(dstDrawContext, clip, srcTexture.get(), | 505 apply_morphology_pass(dstDrawContext.get(), clip, srcTexture.get(), |
506 srcRect, dstRect, radius.fWidth, morphType, | 506 srcRect, dstRect, radius.fWidth, morphType, |
507 Gr1DKernelEffect::kX_Direction); | 507 Gr1DKernelEffect::kX_Direction); |
508 SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom, | 508 SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom, |
509 dstRect.width(), radius.fHeight); | 509 dstRect.width(), radius.fHeight); |
510 GrColor clearColor = GrMorphologyEffect::kErode_MorphologyType == morphT
ype ? | 510 GrColor clearColor = GrMorphologyEffect::kErode_MorphologyType == morphT
ype ? |
511 SK_ColorWHITE : | 511 SK_ColorWHITE : |
512 SK_ColorTRANSPARENT; | 512 SK_ColorTRANSPARENT; |
513 dstDrawContext->clear(&clearRect, clearColor, false); | 513 dstDrawContext->clear(&clearRect, clearColor, false); |
514 | 514 |
515 srcTexture.reset(scratch); | 515 srcTexture.reset(scratch); |
516 srcRect = dstRect; | 516 srcRect = dstRect; |
517 } | 517 } |
518 if (radius.fHeight > 0) { | 518 if (radius.fHeight > 0) { |
519 GrTexture* scratch = context->textureProvider()->createApproxTexture(des
c); | 519 GrTexture* scratch = context->textureProvider()->createApproxTexture(des
c); |
520 if (!scratch) { | 520 if (!scratch) { |
521 return nullptr; | 521 return nullptr; |
522 } | 522 } |
523 SkAutoTUnref<GrDrawContext> dstDrawContext( | 523 sk_sp<GrDrawContext> dstDrawContext( |
524 context->drawContext(scratch->as
RenderTarget())); | 524 context->drawContext(sk_ref_sp(scratch->as
RenderTarget()))); |
525 if (!dstDrawContext) { | 525 if (!dstDrawContext) { |
526 return nullptr; | 526 return nullptr; |
527 } | 527 } |
528 | 528 |
529 apply_morphology_pass(dstDrawContext, clip, srcTexture.get(), | 529 apply_morphology_pass(dstDrawContext.get(), clip, srcTexture.get(), |
530 srcRect, dstRect, radius.fHeight, morphType, | 530 srcRect, dstRect, radius.fHeight, morphType, |
531 Gr1DKernelEffect::kY_Direction); | 531 Gr1DKernelEffect::kY_Direction); |
532 | 532 |
533 srcTexture.reset(scratch); | 533 srcTexture.reset(scratch); |
534 } | 534 } |
535 | 535 |
536 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(rect.width(), rect.height
()), | 536 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(rect.width(), rect.height
()), |
537 kNeedNewImageUniqueID_SpecialImage, | 537 kNeedNewImageUniqueID_SpecialImage, |
538 std::move(srcTexture), &input->props()); | 538 std::move(srcTexture), &input->props()); |
539 } | 539 } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 inputBM.getAddr32(srcBounds.left(), srcBounds.top()), | 639 inputBM.getAddr32(srcBounds.left(), srcBounds.top()), |
640 inputBM.rowBytesAsPixels(), | 640 inputBM.rowBytesAsPixels(), |
641 &dst, height, srcBounds); | 641 &dst, height, srcBounds); |
642 } | 642 } |
643 offset->fX = bounds.left(); | 643 offset->fX = bounds.left(); |
644 offset->fY = bounds.top(); | 644 offset->fY = bounds.top(); |
645 | 645 |
646 return SkSpecialImage::MakeFromRaster(SkIRect::MakeWH(bounds.width(), bounds
.height()), | 646 return SkSpecialImage::MakeFromRaster(SkIRect::MakeWH(bounds.width(), bounds
.height()), |
647 dst, &source->props()); | 647 dst, &source->props()); |
648 } | 648 } |
OLD | NEW |