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

Side by Side Diff: samplecode/SampleApp.cpp

Issue 2142033002: Factor code to rotate a canvas about a point. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Move to canvas. Created 4 years, 5 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 2011 Google Inc. 2 * Copyright 2011 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 "SampleApp.h" 8 #include "SampleApp.h"
9 9
10 #include "OverView.h" 10 #include "OverView.h"
(...skipping 1354 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 orig->flush(); 1365 orig->flush();
1366 fTimer.end(); 1366 fTimer.end();
1367 fMeasureFPS_Time += fTimer.fWall; 1367 fMeasureFPS_Time += fTimer.fWall;
1368 } 1368 }
1369 } 1369 }
1370 1370
1371 void SampleWindow::beforeChild(SkView* child, SkCanvas* canvas) { 1371 void SampleWindow::beforeChild(SkView* child, SkCanvas* canvas) {
1372 if (fRotate) { 1372 if (fRotate) {
1373 SkScalar cx = this->width() / 2; 1373 SkScalar cx = this->width() / 2;
1374 SkScalar cy = this->height() / 2; 1374 SkScalar cy = this->height() / 2;
1375 canvas->translate(cx, cy); 1375 canvas->rotate(gAnimTimer.scaled(10), cx, cy);
1376 canvas->rotate(gAnimTimer.scaled(10));
1377 canvas->translate(-cx, -cy);
1378 } 1376 }
1379 1377
1380 if (fPerspAnim) { 1378 if (fPerspAnim) {
1381 SkScalar secs = gAnimTimer.scaled(1); 1379 SkScalar secs = gAnimTimer.scaled(1);
1382 1380
1383 static const SkScalar gAnimPeriod = 10 * SK_Scalar1; 1381 static const SkScalar gAnimPeriod = 10 * SK_Scalar1;
1384 static const SkScalar gAnimMag = SK_Scalar1 / 1000; 1382 static const SkScalar gAnimMag = SK_Scalar1 / 1000;
1385 SkScalar t = SkScalarMod(secs, gAnimPeriod); 1383 SkScalar t = SkScalarMod(secs, gAnimPeriod);
1386 if (SkScalarFloorToInt(secs / gAnimPeriod) & 0x1) { 1384 if (SkScalarFloorToInt(secs / gAnimPeriod) & 0x1) {
1387 t = gAnimPeriod - t; 1385 t = gAnimPeriod - t;
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after
2253 #ifdef SK_BUILD_FOR_MAC 2251 #ifdef SK_BUILD_FOR_MAC
2254 setenv("ANDROID_ROOT", "/android/device/data", 0); 2252 setenv("ANDROID_ROOT", "/android/device/data", 0);
2255 #endif 2253 #endif
2256 SkGraphics::Init(); 2254 SkGraphics::Init();
2257 SkEvent::Init(); 2255 SkEvent::Init();
2258 } 2256 }
2259 2257
2260 void application_term() { 2258 void application_term() {
2261 SkEvent::Term(); 2259 SkEvent::Term();
2262 } 2260 }
OLDNEW
« no previous file with comments | « include/core/SkCanvas.h ('k') | samplecode/SampleCircle.cpp » ('j') | src/core/SkCanvas.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698