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

Side by Side Diff: tools/viewer/Viewer.cpp

Issue 1982643004: Implement touch control (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 months 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
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "Viewer.h" 8 #include "Viewer.h"
9 9
10 #include "GMSlide.h" 10 #include "GMSlide.h"
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 //m = this->getLocalMatrix();//.invert(&m); 217 //m = this->getLocalMatrix();//.invert(&m);
218 m.mapXY(fZoomCenterX, fZoomCenterY, &center); 218 m.mapXY(fZoomCenterX, fZoomCenterY, &center);
219 SkScalar cx = center.fX; 219 SkScalar cx = center.fX;
220 SkScalar cy = center.fY; 220 SkScalar cy = center.fY;
221 221
222 m.setTranslate(-cx, -cy); 222 m.setTranslate(-cx, -cy);
223 m.postScale(fZoomScale, fZoomScale); 223 m.postScale(fZoomScale, fZoomScale);
224 m.postTranslate(cx, cy); 224 m.postTranslate(cx, cy);
225 } 225 }
226 226
227 // TODO: add gesture support 227 m.preConcat(fWindow->getGestureLocalM());
228 // Apply any gesture matrix 228 m.preConcat(fWindow->getGestureGlobalM());
229 //m.preConcat(fGesture.localM());
230 //m.preConcat(fGesture.globalM());
231 229
232 fLocalMatrix = m; 230 fLocalMatrix = m;
233 } 231 }
234 232
235 void Viewer::onPaint(SkCanvas* canvas) { 233 void Viewer::onPaint(SkCanvas* canvas) {
236 234
237 int count = canvas->save(); 235 int count = canvas->save();
238 236
239 if (fWindow->supportsContentRect()) { 237 if (fWindow->supportsContentRect()) {
240 SkRect contentRect = fWindow->getContentRect(); 238 SkRect contentRect = fWindow->getContentRect();
(...skipping 12 matching lines...) Expand all
253 } 251 }
254 canvas->concat(fLocalMatrix); 252 canvas->concat(fLocalMatrix);
255 253
256 fSlides[fCurrentSlide]->draw(canvas); 254 fSlides[fCurrentSlide]->draw(canvas);
257 canvas->restoreToCount(count); 255 canvas->restoreToCount(count);
258 256
259 if (fDisplayStats) { 257 if (fDisplayStats) {
260 drawStats(canvas); 258 drawStats(canvas);
261 } 259 }
262 fCommands.drawHelp(canvas); 260 fCommands.drawHelp(canvas);
261
262 updateMatrix();
djsollen 2016/05/16 18:16:00 comment why we need to update the matrix after we
liyuqian 2016/05/16 18:32:37 Done.
263 } 263 }
264 264
265 void Viewer::drawStats(SkCanvas* canvas) { 265 void Viewer::drawStats(SkCanvas* canvas) {
266 static const float kPixelPerMS = 2.0f; 266 static const float kPixelPerMS = 2.0f;
267 static const int kDisplayWidth = 130; 267 static const int kDisplayWidth = 130;
268 static const int kDisplayHeight = 100; 268 static const int kDisplayHeight = 100;
269 static const int kDisplayPadding = 10; 269 static const int kDisplayPadding = 10;
270 static const int kGraphPadding = 3; 270 static const int kGraphPadding = 3;
271 static const SkScalar kBaseMS = 1000.f / 60.f; // ms/frame to hit 60 fps 271 static const SkScalar kBaseMS = 1000.f / 60.f; // ms/frame to hit 60 fps
272 272
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 // Record measurements 314 // Record measurements
315 fMeasurements[fCurrentMeasurement++] = ms; 315 fMeasurements[fCurrentMeasurement++] = ms;
316 fCurrentMeasurement &= (kMeasurementCount - 1); // fast mod 316 fCurrentMeasurement &= (kMeasurementCount - 1); // fast mod
317 SkASSERT(fCurrentMeasurement < kMeasurementCount); 317 SkASSERT(fCurrentMeasurement < kMeasurementCount);
318 318
319 fAnimTimer.updateTime(); 319 fAnimTimer.updateTime();
320 if (fSlides[fCurrentSlide]->animate(fAnimTimer) || fDisplayStats) { 320 if (fSlides[fCurrentSlide]->animate(fAnimTimer) || fDisplayStats) {
321 fWindow->inval(); 321 fWindow->inval();
322 } 322 }
323 } 323 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698