Accept displacement with no displacement input

BUG=
R=senorblanco@google.com, senorblanco@chromium.org, sugoi@google.com, bsalomon@google.com, bsalomon@chromium.org

Author: sugoi@chromium.org

Review URL: https://codereview.chromium.org/104853005

git-svn-id: http://skia.googlecode.com/svn/trunk@12773 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
commit-bot@chromium.org 2013-12-19 17:00:46 +00:00
parent 5f6c2c0477
commit 6d7296aaa0
3 changed files with 15 additions and 3 deletions

View File

@ -66,3 +66,6 @@ clipped-bitmap-shaders-tile-hq_gpu
clipped-bitmap-shaders-clamp-hq_angle
clipped-bitmap-shaders-mirror-hq_angle
clipped-bitmap-shaders-tile-hq_angle
# Added by sugoi for added test in https://codereview.chromium.org/104853005
displacement

View File

@ -183,6 +183,7 @@ protected:
40.0f, displ, NULL, &cropRect)))->unref();
drawClippedBitmap(canvas, 400, 300, paint);
// Tests for images of different sizes
displ.reset(SkNEW_ARGS(SkBitmapSource, (fSmall)));
paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
(SkDisplacementMapEffect::kR_ChannelSelectorType,
@ -207,6 +208,15 @@ protected:
SkDisplacementMapEffect::kA_ChannelSelectorType,
40.0f, displ)))->unref();
drawClippedBitmap(canvas, 300, 400, paint);
// Test for no given displacement input. In this case, both displacement
// and color should use the same bitmap, given to SkCanvas::drawBitmap()
// as an input argument.
paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
(SkDisplacementMapEffect::kG_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType,
40.0f, NULL)))->unref();
drawClippedBitmap(canvas, 400, 400, paint);
}
private:

View File

@ -183,12 +183,11 @@ bool SkDisplacementMapEffect::onFilterImage(Proxy* proxy,
const SkMatrix& ctm,
SkBitmap* dst,
SkIPoint* offset) {
SkBitmap displ, color = src;
SkBitmap displ = src, color = src;
SkImageFilter* colorInput = getColorInput();
SkImageFilter* displacementInput = getDisplacementInput();
SkASSERT(NULL != displacementInput);
if ((colorInput && !colorInput->filterImage(proxy, src, ctm, &color, offset)) ||
!displacementInput || !displacementInput->filterImage(proxy, src, ctm, &displ, offset)) {
(displacementInput && !displacementInput->filterImage(proxy, src, ctm, &displ, offset))) {
return false;
}
if ((displ.config() != SkBitmap::kARGB_8888_Config) ||