Chromium Code Reviews| Index: src/views/SkTouchGesture.cpp |
| diff --git a/src/views/SkTouchGesture.cpp b/src/views/SkTouchGesture.cpp |
| index 5fc8d7ee90b1e5c3fb371576e9cffbcfa6659115..e8a0506c088be206a20946eb4c3776aee76e68d5 100644 |
| --- a/src/views/SkTouchGesture.cpp |
| +++ b/src/views/SkTouchGesture.cpp |
| @@ -5,7 +5,7 @@ |
| * found in the LICENSE file. |
| */ |
| - |
| +#include <algorithm> |
| #include "SkTouchGesture.h" |
| #include "SkMatrix.h" |
| @@ -109,6 +109,7 @@ SkTouchGesture::~SkTouchGesture() { |
| } |
| void SkTouchGesture::reset() { |
| + fIsTransLimited = false; |
| fTouches.reset(); |
| fState = kEmpty_State; |
| fLocalM.reset(); |
| @@ -293,6 +294,8 @@ void SkTouchGesture::touchEnd(void* owner) { |
| } |
| fTouches.removeShuffle(index); |
| + |
| + limitTrans(); |
| } |
| float SkTouchGesture::computePinch(const Rec& rec0, const Rec& rec1) { |
| @@ -327,3 +330,24 @@ bool SkTouchGesture::handleDblTap(float x, float y) { |
| fLastUpP.set(x, y); |
| return found; |
| } |
| + |
| +void SkTouchGesture::setTransLimit(const SkRect& contentRect, const SkRect& windowRect) { |
| + fIsTransLimited = true; |
| + fContentRect = contentRect; |
| + fWindowRect = windowRect; |
| +} |
| + |
| +void SkTouchGesture::limitTrans() { |
| + if (!fIsTransLimited) { |
| + return; |
| + } |
| + |
| + SkPoint topLeft = fGlobalM.mapXY(fContentRect.fLeft, fContentRect.fTop); |
| + SkPoint botRight = fGlobalM.mapXY(fContentRect.fRight, fContentRect.fBottom); |
|
djsollen
2016/05/20 13:36:57
SkRect scaledContent;
fGlobalM.mapRect(&scaledCont
|
| + const SkScalar ZERO = 0; |
| + |
| + fGlobalM.postTranslate(ZERO, std::min(ZERO, fWindowRect.fBottom - topLeft.fY)); |
| + fGlobalM.postTranslate(ZERO, std::max(ZERO, fWindowRect.fTop - botRight.fY)); |
| + fGlobalM.postTranslate(std::min(ZERO, fWindowRect.fRight - topLeft.fX), ZERO); |
| + fGlobalM.postTranslate(std::max(ZERO, fWindowRect.fLeft - botRight.fX), ZERO); |
| +} |