skia2/tools/viewer/sk_app
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
..
android Simplify some Viewer code, and fix a few bugs 2017-06-05 15:21:43 +00:00
mac Add msaa flag and UI to viewer 2017-02-27 16:46:34 +00:00
unix Add wireframe mode to Viewer. 2017-05-02 20:27:26 +00:00
win Add wireframe mode to Viewer. 2017-05-02 20:27:26 +00:00
Application.h More accurate render time and continuous fresh 2016-07-06 14:11:32 -07:00
CommandSet.cpp add drawString helper to canvas 2017-04-28 20:41:04 +00:00
CommandSet.h Integrate the ImGui library with viewer 2017-02-10 19:17:03 +00:00
DisplayParams.h viewer: Add a "Path renderer" dropdown menu 2017-02-28 18:21:34 +00:00
GLWindowContext.cpp Add wireframe mode to Viewer. 2017-05-02 20:27:26 +00:00
GLWindowContext.h Add msaa flag and UI to viewer 2017-02-27 16:46:34 +00:00
RasterWindowContext.h Add wireframe mode to Viewer. 2017-05-02 20:27:26 +00:00
VulkanWindowContext.cpp Add wireframe mode to Viewer. 2017-05-02 20:27:26 +00:00
VulkanWindowContext.h Add wireframe mode to Viewer. 2017-05-02 20:27:26 +00:00
Window.cpp Fix crash switching to Vulkan in viewer on Windows 2017-02-28 20:15:43 +00:00
Window.h Simplify some Viewer code, and fix a few bugs 2017-06-05 15:21:43 +00:00
WindowContext.h Add wireframe mode to Viewer. 2017-05-02 20:27:26 +00:00