aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar senorblanco <senorblanco@chromium.org>2015-10-16 11:35:14 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-10-16 11:35:14 -0700
commit9a70b6ef59c38f3cbe6646aed624f22155326d05 (patch)
treef39124286f94a4a93729474a70c575e0e9088d7c /src
parent80803ff615e4293e8af2dc5d094a1f4fa81ec396 (diff)
Image filters: refactor input GPU processing into filterInputGPU().
(analog of CPU version here: https://codereview.chromium.org/1404743005/) No change in behaviour; this is a straight refactoring. BUG=skia:3194 Review URL: https://codereview.chromium.org/1393283008
Diffstat (limited to 'src')
-rw-r--r--src/core/SkImageFilter.cpp19
-rw-r--r--src/effects/SkBlurImageFilter.cpp3
-rw-r--r--src/effects/SkDisplacementMapEffect.cpp7
-rw-r--r--src/effects/SkLightingImageFilter.cpp3
-rw-r--r--src/effects/SkMorphologyImageFilter.cpp3
-rw-r--r--src/effects/SkXfermodeImageFilter.cpp6
6 files changed, 18 insertions, 23 deletions
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index 9cadc3f920..d7af4e65d0 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -329,8 +329,7 @@ bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Cont
SkBitmap input = src;
SkASSERT(fInputCount == 1);
SkIPoint srcOffset = SkIPoint::Make(0, 0);
- if (this->getInput(0) &&
- !this->getInput(0)->getInputResultGPU(proxy, src, ctx, &input, &srcOffset)) {
+ if (!this->filterInputGPU(0, proxy, src, ctx, &input, &srcOffset)) {
return false;
}
GrTexture* srcTexture = input.getTexture();
@@ -466,18 +465,22 @@ void SkImageFilter::WrapTexture(GrTexture* texture, int width, int height, SkBit
result->setPixelRef(new SkGrPixelRef(info, texture))->unref();
}
-bool SkImageFilter::getInputResultGPU(SkImageFilter::Proxy* proxy,
- const SkBitmap& src, const Context& ctx,
- SkBitmap* result, SkIPoint* offset) const {
+bool SkImageFilter::filterInputGPU(int index, SkImageFilter::Proxy* proxy,
+ const SkBitmap& src, const Context& ctx,
+ SkBitmap* result, SkIPoint* offset) const {
+ SkImageFilter* input = this->getInput(index);
+ if (!input) {
+ return true;
+ }
// Ensure that GrContext calls under filterImage and filterImageGPU below will see an identity
// matrix with no clip and that the matrix, clip, and render target set before this function was
// called are restored before we return to the caller.
GrContext* context = src.getTexture()->getContext();
- if (this->canFilterImageGPU()) {
- return this->filterImageGPU(proxy, src, ctx, result, offset);
+ if (input->canFilterImageGPU()) {
+ return input->filterImageGPU(proxy, src, ctx, result, offset);
} else {
- if (this->filterImage(proxy, src, ctx, result, offset)) {
+ if (input->filterImage(proxy, src, ctx, result, offset)) {
if (!result->getTexture()) {
const SkImageInfo info = result->info();
if (kUnknown_SkColorType == info.colorType()) {
diff --git a/src/effects/SkBlurImageFilter.cpp b/src/effects/SkBlurImageFilter.cpp
index ddc034d73c..20976968fe 100644
--- a/src/effects/SkBlurImageFilter.cpp
+++ b/src/effects/SkBlurImageFilter.cpp
@@ -194,8 +194,7 @@ bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
#if SK_SUPPORT_GPU
SkBitmap input = src;
SkIPoint srcOffset = SkIPoint::Make(0, 0);
- if (this->getInput(0) &&
- !this->getInput(0)->getInputResultGPU(proxy, src, ctx, &input, &srcOffset)) {
+ if (!this->filterInputGPU(0, proxy, src, ctx, &input, &srcOffset)) {
return false;
}
SkIRect rect;
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index 5de945ff07..4be8d77351 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -384,15 +384,12 @@ bool SkDisplacementMapEffect::filterImageGPU(Proxy* proxy, const SkBitmap& src,
SkBitmap* result, SkIPoint* offset) const {
SkBitmap colorBM = src;
SkIPoint colorOffset = SkIPoint::Make(0, 0);
- if (this->getColorInput() &&
- !this->getColorInput()->getInputResultGPU(proxy, src, ctx, &colorBM, &colorOffset)) {
+ if (!this->filterInputGPU(1, proxy, src, ctx, &colorBM, &colorOffset)) {
return false;
}
SkBitmap displacementBM = src;
SkIPoint displacementOffset = SkIPoint::Make(0, 0);
- if (this->getDisplacementInput() &&
- !this->getDisplacementInput()->getInputResultGPU(proxy, src, ctx, &displacementBM,
- &displacementOffset)) {
+ if (!this->filterInputGPU(0, proxy, src, ctx, &displacementBM, &displacementOffset)) {
return false;
}
SkIRect bounds;
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp
index 270c10f86b..199bb4d684 100644
--- a/src/effects/SkLightingImageFilter.cpp
+++ b/src/effects/SkLightingImageFilter.cpp
@@ -361,8 +361,7 @@ bool SkLightingImageFilterInternal::filterImageGPU(Proxy* proxy,
SkIPoint* offset) const {
SkBitmap input = src;
SkIPoint srcOffset = SkIPoint::Make(0, 0);
- if (this->getInput(0) &&
- !this->getInput(0)->getInputResultGPU(proxy, src, ctx, &input, &srcOffset)) {
+ if (!this->filterInputGPU(0, proxy, src, ctx, &input, &srcOffset)) {
return false;
}
SkIRect bounds;
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index f3ae6accd9..6f6a1e15f7 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -612,8 +612,7 @@ bool SkMorphologyImageFilter::filterImageGPUGeneric(bool dilate,
SkIPoint* offset) const {
SkBitmap input = src;
SkIPoint srcOffset = SkIPoint::Make(0, 0);
- if (this->getInput(0) &&
- !this->getInput(0)->getInputResultGPU(proxy, src, ctx, &input, &srcOffset)) {
+ if (!this->filterInputGPU(0, proxy, src, ctx, &input, &srcOffset)) {
return false;
}
SkIRect bounds;
diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp
index 9692a2dd48..6cedf840ed 100644
--- a/src/effects/SkXfermodeImageFilter.cpp
+++ b/src/effects/SkXfermodeImageFilter.cpp
@@ -130,8 +130,7 @@ bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy,
SkIPoint* offset) const {
SkBitmap background = src;
SkIPoint backgroundOffset = SkIPoint::Make(0, 0);
- if (this->getInput(0) &&
- !this->getInput(0)->getInputResultGPU(proxy, src, ctx, &background, &backgroundOffset)) {
+ if (!this->filterInputGPU(0, proxy, src, ctx, &background, &backgroundOffset)) {
return false;
}
@@ -143,8 +142,7 @@ bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy,
SkBitmap foreground = src;
SkIPoint foregroundOffset = SkIPoint::Make(0, 0);
- if (this->getInput(1) &&
- !this->getInput(1)->getInputResultGPU(proxy, src, ctx, &foreground, &foregroundOffset)) {
+ if (!this->filterInputGPU(1, proxy, src, ctx, &foreground, &foregroundOffset)) {
return false;
}
GrTexture* foregroundTex = foreground.getTexture();