aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/views
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2017-06-05 08:46:04 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-06-05 15:21:43 +0000
commit42bb6acf56471e7308926e6b242fbbdd4103f306 (patch)
tree6dd3efd164fd65a58ccdfb009cbe1ea9ad42346f /src/views
parentd3df9ec874b2668111b36ce0993d860b4f88c765 (diff)
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>
Diffstat (limited to 'src/views')
-rw-r--r--src/views/SkTouchGesture.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/views/SkTouchGesture.cpp b/src/views/SkTouchGesture.cpp
index 752828e37f..cd7388b6e1 100644
--- a/src/views/SkTouchGesture.cpp
+++ b/src/views/SkTouchGesture.cpp
@@ -331,10 +331,12 @@ bool SkTouchGesture::handleDblTap(float x, float y) {
return found;
}
-void SkTouchGesture::setTransLimit(const SkRect& contentRect, const SkRect& windowRect) {
+void SkTouchGesture::setTransLimit(const SkRect& contentRect, const SkRect& windowRect,
+ const SkMatrix& preTouchMatrix) {
fIsTransLimited = true;
fContentRect = contentRect;
fWindowRect = windowRect;
+ fPreTouchM = preTouchMatrix;
}
void SkTouchGesture::limitTrans() {
@@ -343,6 +345,7 @@ void SkTouchGesture::limitTrans() {
}
SkRect scaledContent = fContentRect;
+ fPreTouchM.mapRect(&scaledContent);
fGlobalM.mapRect(&scaledContent);
const SkScalar ZERO = 0;