Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: src/views/SkTouchGesture.cpp

Issue 85463005: remove SkFloatToScalar macro (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: add flag to expose SkFloatToScalar to chromium Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/utils/win/SkDWriteGeometrySink.cpp ('k') | tests/AAClipTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2010 Google Inc. 3 * Copyright 2010 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 unit->fX = 0; 43 unit->fX = 0;
44 unit->fY = SkScalarSignNonZero(unit->fY); 44 unit->fY = SkScalarSignNonZero(unit->fY);
45 } else if (SkScalarAbs(unit->fY) < TOLERANCE) { 45 } else if (SkScalarAbs(unit->fY) < TOLERANCE) {
46 unit->fX = SkScalarSignNonZero(unit->fX); 46 unit->fX = SkScalarSignNonZero(unit->fX);
47 unit->fY = 0; 47 unit->fY = 0;
48 } 48 }
49 } 49 }
50 50
51 void SkFlingState::reset(float sx, float sy) { 51 void SkFlingState::reset(float sx, float sy) {
52 fActive = true; 52 fActive = true;
53 fDirection.set(SkFloatToScalar(sx), SkFloatToScalar(sy)); 53 fDirection.set(sx, sy);
54 fSpeed0 = SkPoint::Normalize(&fDirection); 54 fSpeed0 = SkPoint::Normalize(&fDirection);
55 fSpeed0 = pin_max_fling(fSpeed0); 55 fSpeed0 = pin_max_fling(fSpeed0);
56 fTime0 = getseconds(); 56 fTime0 = getseconds();
57 57
58 unit_axis_align(&fDirection); 58 unit_axis_align(&fDirection);
59 // printf("---- speed %g dir %g %g\n", fSpeed0, fDirection.fX, fDirection.fY) ; 59 // printf("---- speed %g dir %g %g\n", fSpeed0, fDirection.fX, fDirection.fY) ;
60 } 60 }
61 61
62 bool SkFlingState::evaluateMatrix(SkMatrix* matrix) { 62 bool SkFlingState::evaluateMatrix(SkMatrix* matrix) {
63 if (!fActive) { 63 if (!fActive) {
(...skipping 11 matching lines...) Expand all
75 } 75 }
76 float dist = (fSpeed0 - speed) / K0; 76 float dist = (fSpeed0 - speed) / K0;
77 77
78 // printf("---- time %g speed %g dist %g\n", t, speed, dist); 78 // printf("---- time %g speed %g dist %g\n", t, speed, dist);
79 float tx = fDirection.fX * dist; 79 float tx = fDirection.fX * dist;
80 float ty = fDirection.fY * dist; 80 float ty = fDirection.fY * dist;
81 if (DISCRETIZE_TRANSLATE_TO_AVOID_FLICKER) { 81 if (DISCRETIZE_TRANSLATE_TO_AVOID_FLICKER) {
82 tx = (float)sk_float_round2int(tx); 82 tx = (float)sk_float_round2int(tx);
83 ty = (float)sk_float_round2int(ty); 83 ty = (float)sk_float_round2int(ty);
84 } 84 }
85 matrix->setTranslate(SkFloatToScalar(tx), SkFloatToScalar(ty)); 85 matrix->setTranslate(tx, ty);
86 // printf("---- evaluate (%g %g)\n", tx, ty); 86 // printf("---- evaluate (%g %g)\n", tx, ty);
87 87
88 return true; 88 return true;
89 } 89 }
90 90
91 /////////////////////////////////////////////////////////////////////////////// 91 ///////////////////////////////////////////////////////////////////////////////
92 92
93 static const SkMSec MAX_DBL_TAP_INTERVAL = 300; 93 static const SkMSec MAX_DBL_TAP_INTERVAL = 300;
94 static const float MAX_DBL_TAP_DISTANCE = 100; 94 static const float MAX_DBL_TAP_DISTANCE = 100;
95 static const float MAX_JITTER_RADIUS = 2; 95 static const float MAX_JITTER_RADIUS = 2;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 int SkTouchGesture::findRec(void* owner) const { 175 int SkTouchGesture::findRec(void* owner) const {
176 for (int i = 0; i < fTouches.count(); i++) { 176 for (int i = 0; i < fTouches.count(); i++) {
177 if (owner == fTouches[i].fOwner) { 177 if (owner == fTouches[i].fOwner) {
178 return i; 178 return i;
179 } 179 }
180 } 180 }
181 return -1; 181 return -1;
182 } 182 }
183 183
184 static SkScalar center(float pos0, float pos1) { 184 static SkScalar center(float pos0, float pos1) {
185 return SkFloatToScalar((pos0 + pos1) * 0.5f); 185 return (pos0 + pos1) * 0.5f;
186 } 186 }
187 187
188 static const float MAX_ZOOM_SCALE = 4; 188 static const float MAX_ZOOM_SCALE = 4;
189 static const float MIN_ZOOM_SCALE = 0.25f; 189 static const float MIN_ZOOM_SCALE = 0.25f;
190 190
191 float SkTouchGesture::limitTotalZoom(float scale) const { 191 float SkTouchGesture::limitTotalZoom(float scale) const {
192 // this query works 'cause we know that we're square-scale w/ no skew/rotati on 192 // this query works 'cause we know that we're square-scale w/ no skew/rotati on
193 const float curr = SkScalarToFloat(fGlobalM[0]); 193 const float curr = SkScalarToFloat(fGlobalM[0]);
194 194
195 if (scale > 1 && curr * scale > MAX_ZOOM_SCALE) { 195 if (scale > 1 && curr * scale > MAX_ZOOM_SCALE) {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 fTouches.reset(); 318 fTouches.reset();
319 fState = kEmpty_State; 319 fState = kEmpty_State;
320 found = true; 320 found = true;
321 } 321 }
322 } 322 }
323 323
324 fLastUpT = now; 324 fLastUpT = now;
325 fLastUpP.set(x, y); 325 fLastUpP.set(x, y);
326 return found; 326 return found;
327 } 327 }
OLDNEW
« no previous file with comments | « src/utils/win/SkDWriteGeometrySink.cpp ('k') | tests/AAClipTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698