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

Side by Side Diff: samplecode/SampleApp.cpp

Issue 888283002: allow GMs to animate (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: use SPACE to toggle animations Created 5 years, 10 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 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 if (view) { 655 if (view) {
656 SkEvent evt(gTitleEvtName); 656 SkEvent evt(gTitleEvtName);
657 if (view->doQuery(&evt)) { 657 if (view->doQuery(&evt)) {
658 title->set(evt.findString(gTitleEvtName)); 658 title->set(evt.findString(gTitleEvtName));
659 return true; 659 return true;
660 } 660 }
661 } 661 }
662 return false; 662 return false;
663 } 663 }
664 664
665 bool SampleWindow::sendAnimatePulse() {
666 SkView* view = curr_view(this);
667 if (SampleView::IsSampleView(view)) {
668 if (fDoAnimate) {
669 SkMSec now = SkTime::GetMSecs();
670 return ((SampleView*)view)->animatePulse(now);
671 } else {
672 // 0 signals the view that we are no longer animating
673 ((SampleView*)view)->animatePulse(0);
674 }
675 }
676 return false;
677 }
678
665 void SampleWindow::setZoomCenter(float x, float y) 679 void SampleWindow::setZoomCenter(float x, float y)
666 { 680 {
667 fZoomCenterX = x; 681 fZoomCenterX = x;
668 fZoomCenterY = y; 682 fZoomCenterY = y;
669 } 683 }
670 684
671 bool SampleWindow::zoomIn() 685 bool SampleWindow::zoomIn()
672 { 686 {
673 // Arbitrarily decided 687 // Arbitrarily decided
674 if (fFatBitsScale == 25) return false; 688 if (fFatBitsScale == 25) return false;
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 830
817 fDeviceType = kRaster_DeviceType; 831 fDeviceType = kRaster_DeviceType;
818 832
819 #if DEFAULT_TO_GPU 833 #if DEFAULT_TO_GPU
820 fDeviceType = kGPU_DeviceType; 834 fDeviceType = kGPU_DeviceType;
821 #endif 835 #endif
822 #if SK_ANGLE && DEFAULT_TO_ANGLE 836 #if SK_ANGLE && DEFAULT_TO_ANGLE
823 fDeviceType = kANGLE_DeviceType; 837 fDeviceType = kANGLE_DeviceType;
824 #endif 838 #endif
825 839
840 fDoAnimate = false;
826 fUseClip = false; 841 fUseClip = false;
827 fNClip = false; 842 fNClip = false;
828 fAnimating = false; 843 fAnimating = false;
829 fRotate = false; 844 fRotate = false;
830 fRotateAnimTime = 0; 845 fRotateAnimTime = 0;
831 fPerspAnim = false; 846 fPerspAnim = false;
832 fPerspAnimTime = 0; 847 fPerspAnimTime = 0;
833 fRequestGrabImage = false; 848 fRequestGrabImage = false;
834 fPipeState = SkOSMenu::kOffState; 849 fPipeState = SkOSMenu::kOffState;
835 fTilingMode = kNo_Tiling; 850 fTilingMode = kNo_Tiling;
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 } 1138 }
1124 if (fMagnify && !fSaveToPdf) { 1139 if (fMagnify && !fSaveToPdf) {
1125 magnify(canvas); 1140 magnify(canvas);
1126 } 1141 }
1127 1142
1128 if (fMeasureFPS && fMeasureFPS_Time) { 1143 if (fMeasureFPS && fMeasureFPS_Time) {
1129 this->updateTitle(); 1144 this->updateTitle();
1130 this->postInvalDelay(); 1145 this->postInvalDelay();
1131 } 1146 }
1132 1147
1148 if (this->sendAnimatePulse()) {
1149 this->inval(NULL);
1150 }
1151
1133 // do this last 1152 // do this last
1134 fDevManager->publishCanvas(fDeviceType, canvas, this); 1153 fDevManager->publishCanvas(fDeviceType, canvas, this);
1135 } 1154 }
1136 1155
1137 static float clipW = 200; 1156 static float clipW = 200;
1138 static float clipH = 200; 1157 static float clipH = 200;
1139 void SampleWindow::magnify(SkCanvas* canvas) { 1158 void SampleWindow::magnify(SkCanvas* canvas) {
1140 SkRect r; 1159 SkRect r;
1141 int count = canvas->save(); 1160 int count = canvas->save();
1142 1161
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
1702 fScrollTestX = fScrollTestY = 0; 1721 fScrollTestX = fScrollTestY = 0;
1703 } else { 1722 } else {
1704 fScrollTestX += dx; 1723 fScrollTestX += dx;
1705 fScrollTestY += dy; 1724 fScrollTestY += dy;
1706 } 1725 }
1707 this->inval(NULL); 1726 this->inval(NULL);
1708 return true; 1727 return true;
1709 } 1728 }
1710 1729
1711 switch (uni) { 1730 switch (uni) {
1731 case ' ':
1732 fDoAnimate = !fDoAnimate;
1733 if (this->sendAnimatePulse()) {
1734 this->inval(NULL);
1735 }
1736 break;
1712 case 'B': 1737 case 'B':
1713 post_event_to_sink(SkNEW_ARGS(SkEvent, ("PictFileView::toggleBBox")) , curr_view(this)); 1738 post_event_to_sink(SkNEW_ARGS(SkEvent, ("PictFileView::toggleBBox")) , curr_view(this));
1714 // Cannot call updateTitle() synchronously, because the toggleBBox e vent is still in 1739 // Cannot call updateTitle() synchronously, because the toggleBBox e vent is still in
1715 // the queue. 1740 // the queue.
1716 post_event_to_sink(SkNEW_ARGS(SkEvent, (gUpdateWindowTitleEvtName)), this); 1741 post_event_to_sink(SkNEW_ARGS(SkEvent, (gUpdateWindowTitleEvtName)), this);
1717 this->inval(NULL); 1742 this->inval(NULL);
1718 break; 1743 break;
1719 case 'D': 1744 case 'D':
1720 toggleDistanceFieldFonts(); 1745 toggleDistanceFieldFonts();
1721 break; 1746 break;
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
2420 setenv("ANDROID_ROOT", "/android/device/data", 0); 2445 setenv("ANDROID_ROOT", "/android/device/data", 0);
2421 #endif 2446 #endif
2422 SkGraphics::Init(); 2447 SkGraphics::Init();
2423 SkEvent::Init(); 2448 SkEvent::Init();
2424 } 2449 }
2425 2450
2426 void application_term() { 2451 void application_term() {
2427 SkEvent::Term(); 2452 SkEvent::Term();
2428 SkGraphics::Term(); 2453 SkGraphics::Term();
2429 } 2454 }
OLDNEW
« gm/gm.h ('K') | « samplecode/SampleApp.h ('k') | samplecode/SampleCode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698