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

Side by Side Diff: samplecode/SampleApp.cpp

Issue 1272063002: allow for stepping through a picture with 'n' and 'p' (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') | samplecode/SamplePictFile.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 * 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 805 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 fFatBitsScale = 8; 816 fFatBitsScale = 8;
817 fTypeface = SkTypeface::CreateFromTypeface(NULL, SkTypeface::kBold); 817 fTypeface = SkTypeface::CreateFromTypeface(NULL, SkTypeface::kBold);
818 fShowZoomer = false; 818 fShowZoomer = false;
819 819
820 fZoomLevel = 0; 820 fZoomLevel = 0;
821 fZoomScale = SK_Scalar1; 821 fZoomScale = SK_Scalar1;
822 822
823 fMagnify = false; 823 fMagnify = false;
824 824
825 fSaveToPdf = false; 825 fSaveToPdf = false;
826 826 fSaveToSKP = false;
827 fTransitionNext = 6;
828 fTransitionPrev = 2;
829 827
830 int sinkID = this->getSinkID(); 828 int sinkID = this->getSinkID();
831 fAppMenu = new SkOSMenu; 829 fAppMenu = new SkOSMenu;
832 fAppMenu->setTitle("Global Settings"); 830 fAppMenu->setTitle("Global Settings");
833 int itemID; 831 int itemID;
834 832
835 itemID =fAppMenu->appendList("Device Type", "Device Type", sinkID, 0, 833 itemID =fAppMenu->appendList("Device Type", "Device Type", sinkID, 0,
836 "Raster", "Picture", "OpenGL", "Deferred", 834 "Raster", "Picture", "OpenGL", "Deferred",
837 #if SK_ANGLE 835 #if SK_ANGLE
838 "ANGLE", 836 "ANGLE",
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 itemID = fAppMenu->appendSwitch("Clip", "Clip" , sinkID, fUseClip); 879 itemID = fAppMenu->appendSwitch("Clip", "Clip" , sinkID, fUseClip);
882 fAppMenu->assignKeyEquivalentToItem(itemID, 'c'); 880 fAppMenu->assignKeyEquivalentToItem(itemID, 'c');
883 itemID = fAppMenu->appendSwitch("Flip X", "Flip X" , sinkID, false); 881 itemID = fAppMenu->appendSwitch("Flip X", "Flip X" , sinkID, false);
884 fAppMenu->assignKeyEquivalentToItem(itemID, 'x'); 882 fAppMenu->assignKeyEquivalentToItem(itemID, 'x');
885 itemID = fAppMenu->appendSwitch("Flip Y", "Flip Y" , sinkID, false); 883 itemID = fAppMenu->appendSwitch("Flip Y", "Flip Y" , sinkID, false);
886 fAppMenu->assignKeyEquivalentToItem(itemID, 'y'); 884 fAppMenu->assignKeyEquivalentToItem(itemID, 'y');
887 itemID = fAppMenu->appendSwitch("Zoomer", "Zoomer" , sinkID, fShowZoomer); 885 itemID = fAppMenu->appendSwitch("Zoomer", "Zoomer" , sinkID, fShowZoomer);
888 fAppMenu->assignKeyEquivalentToItem(itemID, 'z'); 886 fAppMenu->assignKeyEquivalentToItem(itemID, 'z');
889 itemID = fAppMenu->appendSwitch("Magnify", "Magnify" , sinkID, fMagnify); 887 itemID = fAppMenu->appendSwitch("Magnify", "Magnify" , sinkID, fMagnify);
890 fAppMenu->assignKeyEquivalentToItem(itemID, 'm'); 888 fAppMenu->assignKeyEquivalentToItem(itemID, 'm');
891 itemID =fAppMenu->appendList("Transition-Next", "Transition-Next", sinkID, 889
892 fTransitionNext, "Up", "Up and Right", "Right",
893 "Down and Right", "Down", "Down and Left",
894 "Left", "Up and Left", NULL);
895 fAppMenu->assignKeyEquivalentToItem(itemID, 'j');
896 itemID =fAppMenu->appendList("Transition-Prev", "Transition-Prev", sinkID,
897 fTransitionPrev, "Up", "Up and Right", "Right",
898 "Down and Right", "Down", "Down and Left",
899 "Left", "Up and Left", NULL);
900 fAppMenu->assignKeyEquivalentToItem(itemID, 'k');
901 itemID = fAppMenu->appendAction("Save to PDF", sinkID); 890 itemID = fAppMenu->appendAction("Save to PDF", sinkID);
902 fAppMenu->assignKeyEquivalentToItem(itemID, 'e'); 891 fAppMenu->assignKeyEquivalentToItem(itemID, 'e');
903 892
904 this->addMenu(fAppMenu); 893 this->addMenu(fAppMenu);
905 fSlideMenu = new SkOSMenu; 894 fSlideMenu = new SkOSMenu;
906 this->addMenu(fSlideMenu); 895 this->addMenu(fSlideMenu);
907 896
908 this->setVisibleP(true); 897 this->setVisibleP(true);
909 this->setClipToBounds(false); 898 this->setClipToBounds(false);
910 899
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 SkString name; 1241 SkString name;
1253 name.printf("sample_grab_%d.png", gSampleGrabCounter++); 1242 name.printf("sample_grab_%d.png", gSampleGrabCounter++);
1254 SkImageEncoder::EncodeFile(name.c_str(), bmp, 1243 SkImageEncoder::EncodeFile(name.c_str(), bmp,
1255 SkImageEncoder::kPNG_Type, 100); 1244 SkImageEncoder::kPNG_Type, 100);
1256 } 1245 }
1257 } 1246 }
1258 1247
1259 if (kPicture_DeviceType == fDeviceType) { 1248 if (kPicture_DeviceType == fDeviceType) {
1260 SkAutoTUnref<const SkPicture> picture(fRecorder.endRecording()); 1249 SkAutoTUnref<const SkPicture> picture(fRecorder.endRecording());
1261 1250
1251 if (fSaveToSKP) {
1252 SkFILEWStream stream("sample_app.skp");
1253 picture->serialize(&stream);
1254 fSaveToSKP = false;
1255 }
1256
1262 if (true) { 1257 if (true) {
1263 if (true) { 1258 if (true) {
1264 SkImageInfo info; 1259 SkImageInfo info;
1265 size_t rowBytes; 1260 size_t rowBytes;
1266 void* addr = orig->accessTopLayerPixels(&info, &rowBytes); 1261 void* addr = orig->accessTopLayerPixels(&info, &rowBytes);
1267 if (addr) { 1262 if (addr) {
1268 SkSurface* surfs[4]; 1263 SkSurface* surfs[4];
1269 SkMultiPictureDraw md; 1264 SkMultiPictureDraw md;
1270 1265
1271 SkImageInfo n = SkImageInfo::Make(info.width()/2, info.heigh t()/2, 1266 SkImageInfo n = SkImageInfo::Make(info.width()/2, info.heigh t()/2,
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1489 this->toggleSlideshow(); 1484 this->toggleSlideshow();
1490 return true; 1485 return true;
1491 } 1486 }
1492 if (SkOSMenu::FindTriState(evt, "AA", &fAAState) || 1487 if (SkOSMenu::FindTriState(evt, "AA", &fAAState) ||
1493 SkOSMenu::FindTriState(evt, "LCD", &fLCDState) || 1488 SkOSMenu::FindTriState(evt, "LCD", &fLCDState) ||
1494 SkOSMenu::FindListIndex(evt, "FilterQuality", &fFilterQualityIndex) || 1489 SkOSMenu::FindListIndex(evt, "FilterQuality", &fFilterQualityIndex) ||
1495 SkOSMenu::FindTriState(evt, "Subpixel", &fSubpixelState) || 1490 SkOSMenu::FindTriState(evt, "Subpixel", &fSubpixelState) ||
1496 SkOSMenu::FindListIndex(evt, "Hinting", &fHintingState) || 1491 SkOSMenu::FindListIndex(evt, "Hinting", &fHintingState) ||
1497 SkOSMenu::FindSwitchState(evt, "Clip", &fUseClip) || 1492 SkOSMenu::FindSwitchState(evt, "Clip", &fUseClip) ||
1498 SkOSMenu::FindSwitchState(evt, "Zoomer", &fShowZoomer) || 1493 SkOSMenu::FindSwitchState(evt, "Zoomer", &fShowZoomer) ||
1499 SkOSMenu::FindSwitchState(evt, "Magnify", &fMagnify) || 1494 SkOSMenu::FindSwitchState(evt, "Magnify", &fMagnify))
1500 SkOSMenu::FindListIndex(evt, "Transition-Next", &fTransitionNext) || 1495 {
1501 SkOSMenu::FindListIndex(evt, "Transition-Prev", &fTransitionPrev)) {
1502 this->inval(NULL); 1496 this->inval(NULL);
1503 this->updateTitle(); 1497 this->updateTitle();
1504 return true; 1498 return true;
1505 } 1499 }
1506 if (SkOSMenu::FindListIndex(evt, "Tiling", &fTilingMode)) { 1500 if (SkOSMenu::FindListIndex(evt, "Tiling", &fTilingMode)) {
1507 if (SampleView::IsSampleView(curr_view(this))) { 1501 if (SampleView::IsSampleView(curr_view(this))) {
1508 ((SampleView*)curr_view(this))->onTileSizeChanged(this->tileSize()); 1502 ((SampleView*)curr_view(this))->onTileSizeChanged(this->tileSize());
1509 } 1503 }
1510 this->inval(NULL); 1504 this->inval(NULL);
1511 this->updateTitle(); 1505 this->updateTitle();
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1646 case 'r': 1640 case 'r':
1647 fRotate = !fRotate; 1641 fRotate = !fRotate;
1648 this->inval(NULL); 1642 this->inval(NULL);
1649 this->updateTitle(); 1643 this->updateTitle();
1650 return true; 1644 return true;
1651 case 'k': 1645 case 'k':
1652 fPerspAnim = !fPerspAnim; 1646 fPerspAnim = !fPerspAnim;
1653 this->inval(NULL); 1647 this->inval(NULL);
1654 this->updateTitle(); 1648 this->updateTitle();
1655 return true; 1649 return true;
1650 case 'K':
1651 fSaveToSKP = true;
1652 this->inval(NULL);
1653 return true;
1656 #if SK_SUPPORT_GPU 1654 #if SK_SUPPORT_GPU
1657 case 'p': 1655 case 'p':
1658 { 1656 {
1659 GrContext* grContext = this->getGrContext(); 1657 GrContext* grContext = this->getGrContext();
1660 if (grContext) { 1658 if (grContext) {
1661 size_t cacheBytes; 1659 size_t cacheBytes;
1662 grContext->getResourceCacheUsage(NULL, &cacheBytes); 1660 grContext->getResourceCacheUsage(NULL, &cacheBytes);
1663 grContext->freeGpuResources(); 1661 grContext->freeGpuResources();
1664 SkDebugf("Purged %d bytes from the GPU resource cache.\n", c acheBytes); 1662 SkDebugf("Purged %d bytes from the GPU resource cache.\n", c acheBytes);
1665 } 1663 }
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
2304 setenv("ANDROID_ROOT", "/android/device/data", 0); 2302 setenv("ANDROID_ROOT", "/android/device/data", 0);
2305 #endif 2303 #endif
2306 SkGraphics::Init(); 2304 SkGraphics::Init();
2307 SkEvent::Init(); 2305 SkEvent::Init();
2308 } 2306 }
2309 2307
2310 void application_term() { 2308 void application_term() {
2311 SkEvent::Term(); 2309 SkEvent::Term();
2312 SkGraphics::Term(); 2310 SkGraphics::Term();
2313 } 2311 }
OLDNEW
« no previous file with comments | « samplecode/SampleApp.h ('k') | samplecode/SamplePictFile.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698