DescriptionImplement 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 #Messages
Total messages: 49 (18 generated)
|