Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(308)

Unified Diff: src/effects/SkMorphologyImageFilter.cpp

Issue 1861643003: Upgrade SkSpecialImage to have getTextureRef & getROPixels entry points (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Really fix no-GPU build Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/effects/SkBlurImageFilter.cpp ('k') | tests/ImageFilterTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « src/effects/SkBlurImageFilter.cpp ('k') | tests/ImageFilterTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698