Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Macros | Functions | Variables
TouchGesture.cpp File Reference
#include "tools/viewer/TouchGesture.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkTypes.h"
#include "include/private/base/SkDebug.h"
#include "include/private/base/SkFloatingPoint.h"
#include "src/base/SkTime.h"
#include <algorithm>
#include <cmath>

Go to the source code of this file.

Macros

#define DISCRETIZE_TRANSLATE_TO_AVOID_FLICKER   true
 

Functions

static SkScalar pin_max_fling (SkScalar speed)
 
static double getseconds ()
 
static SkScalar SkScalarSignNonZero (SkScalar x)
 
static void unit_axis_align (SkVector *unit)
 
static bool close_enough_for_jitter (float x0, float y0, float x1, float y1)
 
static SkScalar center (float pos0, float pos1)
 

Variables

static const SkScalar MAX_FLING_SPEED = SkIntToScalar(1500)
 
static const SkMSec MAX_DBL_TAP_INTERVAL = 300
 
static const float MAX_DBL_TAP_DISTANCE = 100
 
static const float MAX_JITTER_RADIUS = 2
 

Macro Definition Documentation

◆ DISCRETIZE_TRANSLATE_TO_AVOID_FLICKER

#define DISCRETIZE_TRANSLATE_TO_AVOID_FLICKER   true

Definition at line 19 of file TouchGesture.cpp.

Function Documentation

◆ center()

static SkScalar center ( float  pos0,
float  pos1 
)
static

Definition at line 193 of file TouchGesture.cpp.

193 {
194 return (pos0 + pos1) * 0.5f;
195}

◆ close_enough_for_jitter()

static bool close_enough_for_jitter ( float  x0,
float  y0,
float  x1,
float  y1 
)
static

Definition at line 102 of file TouchGesture.cpp.

102 {
103 return std::fabs(x0 - x1) <= MAX_JITTER_RADIUS &&
104 std::fabs(y0 - y1) <= MAX_JITTER_RADIUS;
105}
static const float MAX_JITTER_RADIUS

◆ getseconds()

static double getseconds ( )
static

Definition at line 30 of file TouchGesture.cpp.

30 {
31 return SkTime::GetMSecs() * 0.001;
32}
double GetMSecs()
Definition SkTime.h:17

◆ pin_max_fling()

static SkScalar pin_max_fling ( SkScalar  speed)
static

Definition at line 23 of file TouchGesture.cpp.

23 {
24 if (speed > MAX_FLING_SPEED) {
25 speed = MAX_FLING_SPEED;
26 }
27 return speed;
28}
static const SkScalar MAX_FLING_SPEED

◆ SkScalarSignNonZero()

static SkScalar SkScalarSignNonZero ( SkScalar  x)
static

Definition at line 36 of file TouchGesture.cpp.

36 {
38 if (x < 0) {
39 sign = -sign;
40 }
41 return sign;
42}
static int sign(SkScalar x)
Definition SkPath.cpp:2141
#define SK_Scalar1
Definition SkScalar.h:18
float SkScalar
Definition extension.cpp:12
double x

◆ unit_axis_align()

static void unit_axis_align ( SkVector unit)
static

Definition at line 44 of file TouchGesture.cpp.

44 {
45 const SkScalar TOLERANCE = SkDoubleToScalar(0.15);
46 if (SkScalarAbs(unit->fX) < TOLERANCE) {
47 unit->fX = 0;
48 unit->fY = SkScalarSignNonZero(unit->fY);
49 } else if (SkScalarAbs(unit->fY) < TOLERANCE) {
50 unit->fX = SkScalarSignNonZero(unit->fX);
51 unit->fY = 0;
52 }
53}
#define SkDoubleToScalar(x)
Definition SkScalar.h:64
#define SkScalarAbs(x)
Definition SkScalar.h:39
static SkScalar SkScalarSignNonZero(SkScalar x)
float fX
x-axis value
float fY
y-axis value

Variable Documentation

◆ MAX_DBL_TAP_DISTANCE

const float MAX_DBL_TAP_DISTANCE = 100
static

Definition at line 98 of file TouchGesture.cpp.

◆ MAX_DBL_TAP_INTERVAL

const SkMSec MAX_DBL_TAP_INTERVAL = 300
static

Definition at line 97 of file TouchGesture.cpp.

◆ MAX_FLING_SPEED

const SkScalar MAX_FLING_SPEED = SkIntToScalar(1500)
static

Definition at line 21 of file TouchGesture.cpp.

◆ MAX_JITTER_RADIUS

const float MAX_JITTER_RADIUS = 2
static

Definition at line 99 of file TouchGesture.cpp.