| 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 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 // Draw upper and lower margins with bounds; middle without. | 462 // Draw upper and lower margins with bounds; middle without. |
| 463 apply_morphology_rect(drawContext, clip, texture, lowerSrcRect, lowerDst
Rect, radius, | 463 apply_morphology_rect(drawContext, clip, texture, lowerSrcRect, lowerDst
Rect, radius, |
| 464 morphType, bounds, direction); | 464 morphType, bounds, direction); |
| 465 apply_morphology_rect(drawContext, clip, texture, upperSrcRect, upperDst
Rect, radius, | 465 apply_morphology_rect(drawContext, clip, texture, upperSrcRect, upperDst
Rect, radius, |
| 466 morphType, bounds, direction); | 466 morphType, bounds, direction); |
| 467 apply_morphology_rect_no_bounds(drawContext, clip, texture, middleSrcRec
t, middleDstRect, | 467 apply_morphology_rect_no_bounds(drawContext, clip, texture, middleSrcRec
t, middleDstRect, |
| 468 radius, morphType, direction); | 468 radius, morphType, direction); |
| 469 } | 469 } |
| 470 } | 470 } |
| 471 | 471 |
| 472 static sk_sp<SkSpecialImage> apply_morphology(GrContext* context, | 472 static sk_sp<SkSpecialImage> apply_morphology( |
| 473 SkSpecialImage* input, | 473 GrContext* context, |
| 474 const SkIRect& rect, | 474 SkSpecialImage* input, |
| 475 GrMorphologyEffect::MorphologyType
morphType, | 475 const SkIRect& rect, |
| 476 SkISize radius) { | 476 GrMorphologyEffect::MorphologyType mor
phType, |
| 477 SkISize radius, |
| 478 const SkImageFilter::OutputProperties&
outputProperties) { |
| 477 sk_sp<GrTexture> srcTexture(input->asTextureRef(context)); | 479 sk_sp<GrTexture> srcTexture(input->asTextureRef(context)); |
| 478 SkASSERT(srcTexture); | 480 SkASSERT(srcTexture); |
| 479 sk_sp<SkColorSpace> colorSpace = sk_ref_sp(input->getColorSpace()); | 481 sk_sp<SkColorSpace> colorSpace = sk_ref_sp(outputProperties.colorSpace()); |
| 480 GrPixelConfig config = GrRenderableConfigForColorSpace(colorSpace.get()); | 482 GrPixelConfig config = GrRenderableConfigForColorSpace(colorSpace.get()); |
| 481 | 483 |
| 482 // setup new clip | 484 // setup new clip |
| 483 const GrFixedClip clip(SkIRect::MakeWH(srcTexture->width(), srcTexture->heig
ht())); | 485 const GrFixedClip clip(SkIRect::MakeWH(srcTexture->width(), srcTexture->heig
ht())); |
| 484 | 486 |
| 485 const SkIRect dstRect = SkIRect::MakeWH(rect.width(), rect.height()); | 487 const SkIRect dstRect = SkIRect::MakeWH(rect.width(), rect.height()); |
| 486 SkIRect srcRect = rect; | 488 SkIRect srcRect = rect; |
| 487 | 489 |
| 488 SkASSERT(radius.width() > 0 || radius.height() > 0); | 490 SkASSERT(radius.width() > 0 || radius.height() > 0); |
| 489 | 491 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 return input->makeSubset(srcBounds); | 566 return input->makeSubset(srcBounds); |
| 565 } | 567 } |
| 566 | 568 |
| 567 #if SK_SUPPORT_GPU | 569 #if SK_SUPPORT_GPU |
| 568 if (source->isTextureBacked()) { | 570 if (source->isTextureBacked()) { |
| 569 GrContext* context = source->getContext(); | 571 GrContext* context = source->getContext(); |
| 570 | 572 |
| 571 auto type = (kDilate_Op == this->op()) ? GrMorphologyEffect::kDilate_Mor
phologyType | 573 auto type = (kDilate_Op == this->op()) ? GrMorphologyEffect::kDilate_Mor
phologyType |
| 572 : GrMorphologyEffect::kErode_Morp
hologyType; | 574 : GrMorphologyEffect::kErode_Morp
hologyType; |
| 573 sk_sp<SkSpecialImage> result(apply_morphology(context, input.get(), srcB
ounds, type, | 575 sk_sp<SkSpecialImage> result(apply_morphology(context, input.get(), srcB
ounds, type, |
| 574 SkISize::Make(width, heigh
t))); | 576 SkISize::Make(width, heigh
t), |
| 577 ctx.outputProperties())); |
| 575 if (result) { | 578 if (result) { |
| 576 offset->fX = bounds.left(); | 579 offset->fX = bounds.left(); |
| 577 offset->fY = bounds.top(); | 580 offset->fY = bounds.top(); |
| 578 } | 581 } |
| 579 return result; | 582 return result; |
| 580 } | 583 } |
| 581 #endif | 584 #endif |
| 582 | 585 |
| 583 SkBitmap inputBM; | 586 SkBitmap inputBM; |
| 584 | 587 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 inputBM.getAddr32(srcBounds.left(), srcBounds.top()), | 633 inputBM.getAddr32(srcBounds.left(), srcBounds.top()), |
| 631 inputBM.rowBytesAsPixels(), | 634 inputBM.rowBytesAsPixels(), |
| 632 &dst, height, srcBounds); | 635 &dst, height, srcBounds); |
| 633 } | 636 } |
| 634 offset->fX = bounds.left(); | 637 offset->fX = bounds.left(); |
| 635 offset->fY = bounds.top(); | 638 offset->fY = bounds.top(); |
| 636 | 639 |
| 637 return SkSpecialImage::MakeFromRaster(SkIRect::MakeWH(bounds.width(), bounds
.height()), | 640 return SkSpecialImage::MakeFromRaster(SkIRect::MakeWH(bounds.width(), bounds
.height()), |
| 638 dst, &source->props()); | 641 dst, &source->props()); |
| 639 } | 642 } |
| OLD | NEW |