skia2/tools/viewer/sk_app/android
Brian Osman 42bb6acf56 Simplify some Viewer code, and fix a few bugs
The content rect was always identical to the window rect,
so most of the related code did nothing. The translation
limit code is always useful (to avoid dragging the slide
way off-screen with the mouse), so always include it.
The auto-scaling to fit the screen is also still useful,
but just base it on the window rect.

The zoom code has four state variables, only used two of
them, and one was a trivially derived computation. Fold
most of that work into computeMatrix. (The translation
was always zero -- we never changed the zoom center.)

Include fDefaultMatrix in the matrix from computeMatrix,
rather than needing to apply it specially to the canvas.

Don't apply the inverse default matrix to touch or mouse
points. The absolute positions of those touch points is
not important, but because that matrix includes scale
(and sometimes very large or very small scale), it just
had the effect of greatly amplifying or damping the drag
speed. Without it, the slide always pans at the speed of
the touch/mouse drag -- which seems more desirable.

The use of the inverse default matrix was a clever trick,
but it caused the translation (applied to the global mtx)
to be scaled, so the slide was always pinned incorrectly.
Instead, supply the unmodified window rect and the default
matrix, so the trans limit code can do the obvious correct
thing: xform the slide bounds completely, then limit the
translation that will be applied after that. Slides are
now correctly pinned to screen edge regardless of how
much zoom is present in the default matrix.

Note: There are still several bugs related to all of this
code, but given the web of xform state, it's hard to
unravel. The touch gesture still doesn't know about
viewer's zoom, so that's ignored when doing the pinning.
Beyond that, it doesn't even know about window resize -
it only configures the translation limit when setting up
a slide. I had a fix for all of this (doing the
translation limiting in computeMatrix), but then the touch
gesture doesn't know about it, and can accumulate drag
motion that needs to be un-dragged to get back on-screen,
even though the slide is never really translated that far.

SkTouchGesture is in include. No one uses it except viewer:
TBR=bsalomon@google.com

Bug: skia:
Change-Id: I460cc07c3de6d36e63826f57d359faf1facf5ab3
Reviewed-on: https://skia-review.googlesource.com/18524
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Yuqian Li <liyuqian@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2017-06-05 15:21:43 +00:00
..
GLWindowContext_android.cpp Implement an SkImage backed by a Android hardware buffer 2017-06-02 14:51:24 +00:00
main_android.cpp Fix resource and skp paths in Android viewer 2017-05-26 18:29:48 +00:00
RasterWindowContext_android.cpp Add wireframe mode to Viewer. 2017-05-02 20:27:26 +00:00
surface_glue_android.cpp Simplify some Viewer code, and fix a few bugs 2017-06-05 15:21:43 +00:00
surface_glue_android.h Now we can use drawer to view the state information of the native app, and set its state using the spinner. 2016-05-27 08:52:52 -07:00
VulkanWindowContext_android.cpp Fix crash in viewer on certain android devices 2016-08-11 08:15:12 -07:00
Window_android.cpp Add msaa flag and UI to viewer 2017-02-27 16:46:34 +00:00
Window_android.h Simplify some Viewer code, and fix a few bugs 2017-06-05 15:21:43 +00:00
WindowContextFactory_android.h Use Windowing system-specific WindowContext factories. 2016-07-26 12:02:51 -07:00