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

Issue 1034733002: Implement approx-match support in image filter saveLayer() offscreen. (Closed)

Created:
5 years, 9 months ago by Stephen White
Modified:
5 years, 8 months ago
Reviewers:
bsalomon, rmistry, reed2
CC:
reviews_skia.org, joshualitt, reed1
Base URL:
https://skia.googlesource.com/skia.git@master
Target Ref:
refs/heads/master
Project:
skia
Visibility:
Public.

Description

Implement approx-match support in image filter saveLayer() offscreen. Currently, the GPU-side image filter implementation creates exact-match textures for the offscreen backing stores for saveLayer(). This is because several filters have GPU implementations which depend on the texture coordinates being 0..1. The fix is three-fold: 1) Store the actual requested size in the SkGpuDevice, so that when wrapping it in an SkBitmap for passing to filterImage(), we can give it the original size. 2) Fix the filters (SkMagnifierImageFilter, SkLightingImageFilter, SkMatrixConvolutionImageFilter, SkMatrixImageFilter) whose GPU implementation depends on 0..1 texture coordinates. 3) Remove the exception for GPU-side image filters in SkCanvas::internalSaveLayer(). For the lighting filters, there were two bugs which were cancelling each other out: the sobel filter matrix was being computed upside down, but then we'd negate the resulting normal. This worked fine in the exact-match case, but in the approx-match case we'd sample garbage along the edge pixels. Also, we never implemented the edge pixels according to spec in the GPU case. It requires a different fragment shader for each edge of the nine-patch, which meant we couldn't use asFragmentProcessor(), and had to implement the drawing via a filterImageGPU() override. In order to avoid polluting the public API, I inserted a new base class, SkLightingImageFilterInternal above Sk[Diffuse|Specular]LightingImageFilter to handle the implementation. For the SkMatrixConvolutionImageFilter, it seems the GLSL clamp() function occasionally returns values outside the clamped range, resulting in access of garbage texels even in GL_NEAREST. The fix here is to clamp to a rect inset by half a texel. There was also a bug in the unpremultiply step when fConvolveAlpha is false. For SkMatrixImageFilter, the fix was to make the generic draw path be more careful about when to use texture domain. If the bitmap already has a texture, use texture domain if the srcRect is smaller than the entire texture (not the entire bitmap). N.B.: this change will cause some minor pixel diffs in the GPU results of the following GMs (and possibly more): matriximagefilter, matrixconvolution, imagefiltersscaled, lighting, imagemagnifier, filterfastbounds, complexclip_aa_Layer_invert, complexclip_aa_layer, complexclip_bw_layer_invert, complexclip_bw_layer. BUG=skia:3532 Committed: https://skia.googlesource.com/skia/+/b97dafefe63ea0a1bbce8e8b209f4920983fb8b9 Committed: https://skia.googlesource.com/skia/+/f5f8518fe0bbd2703e4ffc1b11ad7b4312ff7641 Committed: https://skia.googlesource.com/skia/+/46112cf2a7c7307f1c9eebb5f881cbda15aa460c Committed: https://skia.googlesource.com/skia/+/d0d37cace08f12abf8d316e6949e947551d418e6

Patch Set 1 #

Patch Set 2 : SkMagnifierImageFilter fixes #

Patch Set 3 : Update SkLightingImageFilter #

Patch Set 4 : Revert SkLightingImageFilter changes. #

Patch Set 5 : Update to ToT #

Total comments: 10

Patch Set 6 : Update to ToT #

Patch Set 7 : Fix 100-col issues #

Patch Set 8 : Fix 100-col issues #

Patch Set 9 : Win64 fix #

Patch Set 10 : Fix SkMagnifierImageFilter; update to ToT #

Patch Set 11 : 100-col fixes #

Patch Set 12 : Fix comment #

Total comments: 1

Patch Set 13 : Add bounds/texture domain to lighting image filter #

Patch Set 14 : #

Patch Set 15 : Implement proper boundary handling in SkLightingImageFilter #

Patch Set 16 : Fixes to light computation #

Patch Set 17 : Add all boundary modes to unit tests. #

Patch Set 18 : Don't offset bounds by srcOffset #

Patch Set 19 : Fix expanding crop rects for lighting; add new GM test case #

Patch Set 20 : Update to ToT #

Patch Set 21 : Fix 100-col issues #

Patch Set 22 : Fix more 100-col issues #

Total comments: 2

Patch Set 23 : Fix trailing whitespace #

Patch Set 24 : Fix this->, resulting 100-col issues, extraneous "virtual" #

Patch Set 25 : Fix more formatting issues #

Patch Set 26 : Win64 fixes #

Patch Set 27 : Offset the bounds by srcOffset (as the CPU path does). #

Patch Set 28 : Fix SkMatrixConvolutionImagefilter #

Patch Set 29 : Cleanup. #

Patch Set 30 : Fix for SkMatrixImageFilter (actually the generic draw path) #

Patch Set 31 : Fix #

Patch Set 32 : Fix empty/out-of-range rects in GrTextureDomain Clamp mode #

Unified diffs Side-by-side diffs Delta from patch set Stats (+514 lines, -140 lines) Patch
M gm/lighting.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 2 chunks +52 lines, -9 lines 0 comments Download
M src/core/SkCanvas.cpp View 1 1 chunk +0 lines, -8 lines 0 comments Download
M src/effects/SkLightingImageFilter.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 35 chunks +359 lines, -85 lines 0 comments Download
M src/effects/SkMagnifierImageFilter.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 12 chunks +40 lines, -11 lines 0 comments Download
M src/gpu/SkGpuDevice.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 4 chunks +10 lines, -3 lines 0 comments Download
M src/gpu/SkGpuDevice.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 13 chunks +34 lines, -19 lines 0 comments Download
M src/gpu/effects/GrMatrixConvolutionEffect.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 2 chunks +2 lines, -1 line 0 comments Download
M src/gpu/effects/GrTextureDomain.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 1 chunk +13 lines, -0 lines 0 comments Download
M src/gpu/effects/GrTextureDomain.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 1 chunk +4 lines, -4 lines 0 comments Download

Messages

Total messages: 49 (18 generated)
Stephen White
Brian: PTAL. Thanks! Note that I have another version of this patch which removes the ...
5 years, 9 months ago (2015-03-25 21:45:22 UTC) #3
bsalomon
great to see this! lgtm https://codereview.chromium.org/1034733002/diff/80001/src/gpu/SkGpuDevice.cpp File src/gpu/SkGpuDevice.cpp (right): https://codereview.chromium.org/1034733002/diff/80001/src/gpu/SkGpuDevice.cpp#newcode127 src/gpu/SkGpuDevice.cpp:127: SkGpuDevice* SkGpuDevice::Create(GrRenderTarget* rt, int ...
5 years, 9 months ago (2015-03-26 19:04:00 UTC) #4
Stephen White
https://codereview.chromium.org/1034733002/diff/80001/src/gpu/SkGpuDevice.cpp File src/gpu/SkGpuDevice.cpp (right): https://codereview.chromium.org/1034733002/diff/80001/src/gpu/SkGpuDevice.cpp#newcode127 src/gpu/SkGpuDevice.cpp:127: SkGpuDevice* SkGpuDevice::Create(GrRenderTarget* rt, int width, int height, const SkSurfaceProps* ...
5 years, 9 months ago (2015-03-26 19:34:16 UTC) #5
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1034733002/140001
5 years, 9 months ago (2015-03-26 19:42:43 UTC) #8
commit-bot: I haz the power
Try jobs failed on following builders: Build-Win-MSVC-x86_64-Debug-Trybot on client.skia.compile (JOB_FAILED, http://build.chromium.org/p/client.skia.compile/builders/Build-Win-MSVC-x86_64-Debug-Trybot/builds/166)
5 years, 9 months ago (2015-03-26 19:51:25 UTC) #10
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1034733002/220001
5 years, 9 months ago (2015-03-28 20:37:52 UTC) #13
commit-bot: I haz the power
Committed patchset #12 (id:220001) as https://skia.googlesource.com/skia/+/b97dafefe63ea0a1bbce8e8b209f4920983fb8b9
5 years, 9 months ago (2015-03-28 20:43:19 UTC) #14
reed2
https://codereview.chromium.org/1034733002/diff/220001/src/effects/SkMagnifierImageFilter.cpp File src/effects/SkMagnifierImageFilter.cpp (right): https://codereview.chromium.org/1034733002/diff/220001/src/effects/SkMagnifierImageFilter.cpp#newcode28 src/effects/SkMagnifierImageFilter.cpp:28: const SkRect& bounds, If we try to re-land this, ...
5 years, 9 months ago (2015-03-28 21:55:27 UTC) #16
reed2
5 years, 9 months ago (2015-03-28 21:55:28 UTC) #17
Stephen White
On 2015/03/28 21:55:27, reed2 wrote: > https://codereview.chromium.org/1034733002/diff/220001/src/effects/SkMagnifierImageFilter.cpp > File src/effects/SkMagnifierImageFilter.cpp (right): > > https://codereview.chromium.org/1034733002/diff/220001/src/effects/SkMagnifierImageFilter.cpp#newcode28 > ...
5 years, 8 months ago (2015-03-30 15:22:54 UTC) #18
Stephen White
New patch up: implemented fixes for SkLightingImageFilter. Dirty little secret about the GPU path: it ...
5 years, 8 months ago (2015-03-30 22:12:35 UTC) #19
bsalomon
lgtm https://codereview.chromium.org/1034733002/diff/410001/src/effects/SkLightingImageFilter.cpp File src/effects/SkLightingImageFilter.cpp (right): https://codereview.chromium.org/1034733002/diff/410001/src/effects/SkLightingImageFilter.cpp#newcode387 src/effects/SkLightingImageFilter.cpp:387: drawRect(context, srcTexture, dst, matrix, clip, topLeft, kTopLeft_BoundaryMode, bounds); ...
5 years, 8 months ago (2015-03-31 14:50:24 UTC) #20
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1034733002/450001
5 years, 8 months ago (2015-03-31 15:00:30 UTC) #23
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1034733002/510001
5 years, 8 months ago (2015-03-31 15:17:10 UTC) #26
commit-bot: I haz the power
Committed patchset #27 (id:510001) as https://skia.googlesource.com/skia/+/f5f8518fe0bbd2703e4ffc1b11ad7b4312ff7641
5 years, 8 months ago (2015-03-31 15:35:20 UTC) #27
rmistry
A revert of this CL (patchset #27 id:510001) has been created in https://codereview.chromium.org/1057443003/ by rmistry@google.com. ...
5 years, 8 months ago (2015-04-01 11:19:23 UTC) #28
Stephen White
I've added fixes for SkMatrixConvolutionImageFilter. PTAL. Thanks!
5 years, 8 months ago (2015-04-01 19:41:05 UTC) #29
bsalomon
lgtm
5 years, 8 months ago (2015-04-01 21:04:29 UTC) #30
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1034733002/590001
5 years, 8 months ago (2015-04-01 21:12:00 UTC) #32
commit-bot: I haz the power
Committed patchset #31 (id:590001) as https://skia.googlesource.com/skia/+/46112cf2a7c7307f1c9eebb5f881cbda15aa460c
5 years, 8 months ago (2015-04-01 21:17:18 UTC) #33
rmistry
Looks like this is causing failed assertions in some debug builds: https://build.chromium.org/p/client.skia.android/builders/Test-Android-GCC-Nexus7-GPU-Tegra3-Arm7-Debug/builds/49 https://build.chromium.org/p/client.skia/builders/Test-Mac10.9-Clang-MacMini6.2-GPU-HD4000-x86_64-Debug/builds/48 https://build.chromium.org/p/client.skia/builders/Test-Ubuntu-GCC-ShuttleA-GPU-GTX660-x86_64-Debug/builds/51 https://build.chromium.org/p/client.skia/builders/Test-Win7-MSVC-ShuttleA-GPU-HD2000-x86-Debug-GDI/builds/20 ...
5 years, 8 months ago (2015-04-01 22:00:29 UTC) #35
Stephen White
On 2015/04/01 22:00:29, rmistry wrote: > Looks like this is causing failed assertions in some ...
5 years, 8 months ago (2015-04-01 22:04:30 UTC) #36
rmistry
A revert of this CL (patchset #31 id:590001) has been created in https://codereview.chromium.org/1057693002/ by rmistry@google.com. ...
5 years, 8 months ago (2015-04-01 22:52:49 UTC) #37
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1034733002/610001
5 years, 8 months ago (2015-04-02 10:52:42 UTC) #40
rmistry
On 2015/04/02 10:52:42, I haz the power (commit-bot) wrote: > CQ is trying da patch. ...
5 years, 8 months ago (2015-04-02 10:56:50 UTC) #42
Stephen White
On 2015/04/02 10:56:50, rmistry wrote: > On 2015/04/02 10:52:42, I haz the power (commit-bot) wrote: ...
5 years, 8 months ago (2015-04-02 11:25:57 UTC) #43
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1034733002/610001
5 years, 8 months ago (2015-04-02 11:54:45 UTC) #45
commit-bot: I haz the power
Committed patchset #32 (id:610001) as https://skia.googlesource.com/skia/+/d0d37cace08f12abf8d316e6949e947551d418e6
5 years, 8 months ago (2015-04-02 11:55:02 UTC) #46
rmistry
On 2015/04/02 11:55:02, I haz the power (commit-bot) wrote: > Committed patchset #32 (id:610001) as ...
5 years, 8 months ago (2015-04-02 12:49:58 UTC) #47
Stephen White
On 2015/04/02 12:49:58, rmistry wrote: > On 2015/04/02 11:55:02, I haz the power (commit-bot) wrote: ...
5 years, 8 months ago (2015-04-02 15:30:45 UTC) #48
rmistry
5 years, 8 months ago (2015-04-02 17:49:01 UTC) #49
Message was sent while issue was closed.
On 2015/04/02 15:30:45, Stephen White wrote:
> On 2015/04/02 12:49:58, rmistry wrote:
> > On 2015/04/02 11:55:02, I haz the power (commit-bot) wrote:
> > > Committed patchset #32 (id:610001) as
> > >
> https://skia.googlesource.com/skia/+/d0d37cace08f12abf8d316e6949e947551d418e6
> > 
> > Looks like this caused a failed assertion in the
> > Test-Win8-MSVC-ShuttleA-GPU-GTX660-x86_64-Debug build:
> >
>
https://uberchromegw.corp.google.com/i/client.skia/builders/Test-Win8-MSVC-Sh...
> > 
> > Snippet:
> > ( 347MB     7) 56.3ms	unit test
> >
>
GpuColorFilterc:\0\build\slave\test-win8-msvc-shuttlea-gpu-gtx660-x86_64-debug\build\skia\src\gpu\grinvariantoutput.cpp:16:
> > failed assertion "this->colorComponentsAllEqual()"
> 
> Note that that test seems to be failing on other builders, even without my
> change:
>
http://build.chromium.org/p/client.skia/builders/Test-Ubuntu-GCC-ShuttleA-GPU...
> 
> (occurred between the revert and my re-land).
> 
> Something in my change is tickling it, but I don't think it's the cause.

Looks like Brian's revert ( https://codereview.chromium.org/1032593003 ) made
this go away.

Powered by Google App Engine
This is Rietveld 408576698