gfx/skia/trunk/include/views/SkTouchGesture.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1
michael@0 2 /*
michael@0 3 * Copyright 2011 Google Inc.
michael@0 4 *
michael@0 5 * Use of this source code is governed by a BSD-style license that can be
michael@0 6 * found in the LICENSE file.
michael@0 7 */
michael@0 8 #ifndef SkTouchGesture_DEFINED
michael@0 9 #define SkTouchGesture_DEFINED
michael@0 10
michael@0 11 #include "SkTDArray.h"
michael@0 12 #include "SkMatrix.h"
michael@0 13
michael@0 14 struct SkFlingState {
michael@0 15 SkFlingState() : fActive(false) {}
michael@0 16
michael@0 17 bool isActive() const { return fActive; }
michael@0 18 void stop() { fActive = false; }
michael@0 19
michael@0 20 void reset(float sx, float sy);
michael@0 21 bool evaluateMatrix(SkMatrix* matrix);
michael@0 22
michael@0 23 private:
michael@0 24 SkPoint fDirection;
michael@0 25 SkScalar fSpeed0;
michael@0 26 double fTime0;
michael@0 27 bool fActive;
michael@0 28 };
michael@0 29
michael@0 30 class SkTouchGesture {
michael@0 31 public:
michael@0 32 SkTouchGesture();
michael@0 33 ~SkTouchGesture();
michael@0 34
michael@0 35 void touchBegin(void* owner, float x, float y);
michael@0 36 void touchMoved(void* owner, float x, float y);
michael@0 37 void touchEnd(void* owner);
michael@0 38 void reset();
michael@0 39
michael@0 40 bool isActive() { return fFlinger.isActive(); }
michael@0 41 void stop() { fFlinger.stop(); }
michael@0 42
michael@0 43 const SkMatrix& localM();
michael@0 44 const SkMatrix& globalM() const { return fGlobalM; }
michael@0 45
michael@0 46 private:
michael@0 47 enum State {
michael@0 48 kEmpty_State,
michael@0 49 kTranslate_State,
michael@0 50 kZoom_State,
michael@0 51 };
michael@0 52
michael@0 53 struct Rec {
michael@0 54 void* fOwner;
michael@0 55 float fStartX, fStartY;
michael@0 56 float fPrevX, fPrevY;
michael@0 57 float fLastX, fLastY;
michael@0 58 SkMSec fPrevT, fLastT;
michael@0 59 };
michael@0 60 SkTDArray<Rec> fTouches;
michael@0 61
michael@0 62 State fState;
michael@0 63 SkMatrix fLocalM, fGlobalM;
michael@0 64 SkFlingState fFlinger;
michael@0 65 SkMSec fLastUpT;
michael@0 66 SkPoint fLastUpP;
michael@0 67
michael@0 68
michael@0 69 void flushLocalM();
michael@0 70 int findRec(void* owner) const;
michael@0 71 void appendNewRec(void* owner, float x, float y);
michael@0 72 float computePinch(const Rec&, const Rec&);
michael@0 73 float limitTotalZoom(float scale) const;
michael@0 74 bool handleDblTap(float, float);
michael@0 75 };
michael@0 76
michael@0 77 #endif

mercurial