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

Side by Side Diff: samplecode/SampleApp.cpp

Issue 1288473002: Add high resolution WallTimer to SampleApp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « samplecode/SampleApp.h ('k') | no next file » | 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 * 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 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 } else if (kDeferred_DeviceType == fDeviceType) { 1304 } else if (kDeferred_DeviceType == fDeviceType) {
1305 SkAutoTUnref<SkImage> image(fDeferredCanvas->newImageSnapshot()); 1305 SkAutoTUnref<SkImage> image(fDeferredCanvas->newImageSnapshot());
1306 if (image) { 1306 if (image) {
1307 orig->drawImage(image, 0, 0, NULL); 1307 orig->drawImage(image, 0, 0, NULL);
1308 } 1308 }
1309 fDeferredCanvas.reset(NULL); 1309 fDeferredCanvas.reset(NULL);
1310 fDeferredSurface.reset(NULL); 1310 fDeferredSurface.reset(NULL);
1311 } 1311 }
1312 1312
1313 // Do this after presentGL and other finishing, rather than in afterChild 1313 // Do this after presentGL and other finishing, rather than in afterChild
1314 if (fMeasureFPS && fMeasureFPS_StartTime) { 1314 if (fMeasureFPS) {
1315 fMeasureFPS_Time += SkTime::GetMSecs() - fMeasureFPS_StartTime; 1315 fTimer.end();
1316 fMeasureFPS_Time += fTimer.fWall;
1316 } 1317 }
1317 } 1318 }
1318 1319
1319 void SampleWindow::beforeChild(SkView* child, SkCanvas* canvas) { 1320 void SampleWindow::beforeChild(SkView* child, SkCanvas* canvas) {
1320 if (fRotate) { 1321 if (fRotate) {
1321 SkScalar cx = this->width() / 2; 1322 SkScalar cx = this->width() / 2;
1322 SkScalar cy = this->height() / 2; 1323 SkScalar cy = this->height() / 2;
1323 canvas->translate(cx, cy); 1324 canvas->translate(cx, cy);
1324 canvas->rotate(gAnimTimer.scaled(10)); 1325 canvas->rotate(gAnimTimer.scaled(10));
1325 canvas->translate(-cx, -cy); 1326 canvas->translate(-cx, -cy);
(...skipping 16 matching lines...) Expand all
1342 m.setPerspY(t); 1343 m.setPerspY(t);
1343 #else 1344 #else
1344 m.setPerspY(SK_Scalar1 / 1000); 1345 m.setPerspY(SK_Scalar1 / 1000);
1345 m.setSkewX(8.0f / 25); 1346 m.setSkewX(8.0f / 25);
1346 m.dump(); 1347 m.dump();
1347 #endif 1348 #endif
1348 canvas->concat(m); 1349 canvas->concat(m);
1349 } 1350 }
1350 1351
1351 if (fMeasureFPS) { 1352 if (fMeasureFPS) {
1352 if (SampleView::SetRepeatDraw(child, FPS_REPEAT_COUNT)) { 1353 (void)SampleView::SetRepeatDraw(child, FPS_REPEAT_COUNT);
1353 fMeasureFPS_StartTime = SkTime::GetMSecs(); 1354 fTimer.start();
1354 }
1355 } else { 1355 } else {
1356 (void)SampleView::SetRepeatDraw(child, 1); 1356 (void)SampleView::SetRepeatDraw(child, 1);
1357 } 1357 }
1358 if (fPerspAnim || fRotate) { 1358 if (fPerspAnim || fRotate) {
1359 this->inval(NULL); 1359 this->inval(NULL);
1360 } 1360 }
1361 } 1361 }
1362 1362
1363 void SampleWindow::changeZoomLevel(float delta) { 1363 void SampleWindow::changeZoomLevel(float delta) {
1364 fZoomLevel += delta; 1364 fZoomLevel += delta;
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
1926 title.prepend(trystate_str(fSubpixelState, "S ", "s ")); 1926 title.prepend(trystate_str(fSubpixelState, "S ", "s "));
1927 title.prepend(fFlipAxis & kFlipAxis_X ? "X " : NULL); 1927 title.prepend(fFlipAxis & kFlipAxis_X ? "X " : NULL);
1928 title.prepend(fFlipAxis & kFlipAxis_Y ? "Y " : NULL); 1928 title.prepend(fFlipAxis & kFlipAxis_Y ? "Y " : NULL);
1929 title.prepend(gHintingStates[fHintingState].label); 1929 title.prepend(gHintingStates[fHintingState].label);
1930 1930
1931 if (fZoomLevel) { 1931 if (fZoomLevel) {
1932 title.prependf("{%.2f} ", SkScalarToFloat(fZoomLevel)); 1932 title.prependf("{%.2f} ", SkScalarToFloat(fZoomLevel));
1933 } 1933 }
1934 1934
1935 if (fMeasureFPS) { 1935 if (fMeasureFPS) {
1936 title.appendf(" %8.3f ms", fMeasureFPS_Time / (float)FPS_REPEAT_COUNT); 1936 title.appendf(" %8.4f ms", fMeasureFPS_Time / (float)FPS_REPEAT_COUNT);
1937 } 1937 }
1938 1938
1939 SkView* view = curr_view(this); 1939 SkView* view = curr_view(this);
1940 if (SampleView::IsSampleView(view)) { 1940 if (SampleView::IsSampleView(view)) {
1941 switch (fPipeState) { 1941 switch (fPipeState) {
1942 case SkOSMenu::kOnState: 1942 case SkOSMenu::kOnState:
1943 title.prepend("<Pipe> "); 1943 title.prepend("<Pipe> ");
1944 break; 1944 break;
1945 case SkOSMenu::kMixedState: 1945 case SkOSMenu::kMixedState:
1946 title.prepend("<Tiled Pipe> "); 1946 title.prepend("<Tiled Pipe> ");
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
2302 setenv("ANDROID_ROOT", "/android/device/data", 0); 2302 setenv("ANDROID_ROOT", "/android/device/data", 0);
2303 #endif 2303 #endif
2304 SkGraphics::Init(); 2304 SkGraphics::Init();
2305 SkEvent::Init(); 2305 SkEvent::Init();
2306 } 2306 }
2307 2307
2308 void application_term() { 2308 void application_term() {
2309 SkEvent::Term(); 2309 SkEvent::Term();
2310 SkGraphics::Term(); 2310 SkGraphics::Term();
2311 } 2311 }
OLDNEW
« no previous file with comments | « samplecode/SampleApp.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698