Chromium Code Reviews| Index: src/effects/SkMorphologyImageFilter.cpp |
| diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp |
| index ea714e59f69b1579bc26d2e87c95c8c58915a6f5..c4ee224e575e5b0e78f0bf43116cc2eea06c7afa 100644 |
| --- a/src/effects/SkMorphologyImageFilter.cpp |
| +++ b/src/effects/SkMorphologyImageFilter.cpp |
| @@ -43,9 +43,9 @@ void SkMorphologyImageFilter::flatten(SkWriteBuffer& buffer) const { |
| } |
| static void call_proc_X(SkMorphologyImageFilter::Proc procX, |
| - const SkPixmap& src, SkBitmap* dst, |
| + const SkBitmap& src, SkBitmap* dst, |
| int radiusX, const SkIRect& bounds) { |
| - procX(src.addr32(bounds.left(), bounds.top()), dst->getAddr32(0, 0), |
| + procX(src.getAddr32(bounds.left(), bounds.top()), dst->getAddr32(0, 0), |
| radiusX, bounds.width(), bounds.height(), |
| src.rowBytesAsPixels(), dst->rowBytesAsPixels()); |
| } |
| @@ -550,7 +550,12 @@ sk_sp<SkSpecialImage> SkMorphologyImageFilter::onFilterImage(SkSpecialImage* sou |
| } |
| #if SK_SUPPORT_GPU |
| - if (input->peekTexture() && input->peekTexture()->getContext()) { |
| + if (source->peekTexture() && source->peekTexture()->getContext()) { |
| + GrTexture* inputTexture = input->asTextureRef(source->peekTexture()->getContext()); |
| + if (!inputTexture) { |
|
Stephen White
2016/04/06 16:21:23
I find this API somewhat error-prone, in that it's
robertphillips
2016/04/06 17:19:53
I have updated the SkSpecialImage API to cleave mo
|
| + return nullptr; |
| + } |
| + |
| auto type = (kDilate_Op == this->op()) ? GrMorphologyEffect::kDilate_MorphologyType |
| : GrMorphologyEffect::kErode_MorphologyType; |
| sk_sp<SkSpecialImage> result(apply_morphology(input.get(), srcBounds, type, |
| @@ -563,25 +568,25 @@ sk_sp<SkSpecialImage> SkMorphologyImageFilter::onFilterImage(SkSpecialImage* sou |
| } |
| #endif |
| - SkPixmap inputPixmap; |
| + SkBitmap inputBM; |
| - if (!input->peekPixels(&inputPixmap)) { |
| + if (!input->getROPixels(&inputBM)) { |
| return nullptr; |
| } |
| - if (inputPixmap.colorType() != kN32_SkColorType) { |
| + if (inputBM.colorType() != kN32_SkColorType) { |
| return nullptr; |
| } |
| SkImageInfo info = SkImageInfo::Make(bounds.width(), bounds.height(), |
| - inputPixmap.colorType(), inputPixmap.alphaType()); |
| + inputBM.colorType(), inputBM.alphaType()); |
| SkBitmap dst; |
| if (!dst.tryAllocPixels(info)) { |
| return nullptr; |
| } |
| - SkAutoLockPixels dstLock(dst); |
| + SkAutoLockPixels inputLock(inputBM), dstLock(dst); |
| SkMorphologyImageFilter::Proc procX, procY; |
| @@ -601,17 +606,17 @@ sk_sp<SkSpecialImage> SkMorphologyImageFilter::onFilterImage(SkSpecialImage* sou |
| SkAutoLockPixels tmpLock(tmp); |
| - call_proc_X(procX, inputPixmap, &tmp, width, srcBounds); |
| + call_proc_X(procX, inputBM, &tmp, width, srcBounds); |
| SkIRect tmpBounds = SkIRect::MakeWH(srcBounds.width(), srcBounds.height()); |
| call_proc_Y(procY, |
| tmp.getAddr32(tmpBounds.left(), tmpBounds.top()), tmp.rowBytesAsPixels(), |
| &dst, height, tmpBounds); |
| } else if (width > 0) { |
| - call_proc_X(procX, inputPixmap, &dst, width, srcBounds); |
| + call_proc_X(procX, inputBM, &dst, width, srcBounds); |
| } else if (height > 0) { |
| call_proc_Y(procY, |
| - inputPixmap.addr32(srcBounds.left(), srcBounds.top()), |
| - inputPixmap.rowBytesAsPixels(), |
| + inputBM.getAddr32(srcBounds.left(), srcBounds.top()), |
| + inputBM.rowBytesAsPixels(), |
| &dst, height, srcBounds); |
| } |
| offset->fX = bounds.left(); |