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

Side by Side Diff: samplecode/SampleApp.cpp

Issue 2061233002: Remove command buffer sample app support. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 6 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') | src/views/win/SkOSWindow_win.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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 class PdfFileViewerFactory : public SkViewFactory { 85 class PdfFileViewerFactory : public SkViewFactory {
86 SkString fFilename; 86 SkString fFilename;
87 public: 87 public:
88 PdfFileViewerFactory(const SkString& filename) : fFilename(filename) {} 88 PdfFileViewerFactory(const SkString& filename) : fFilename(filename) {}
89 SkView* operator() () const override { 89 SkView* operator() () const override {
90 return CreateSamplePdfFileViewer(fFilename.c_str()); 90 return CreateSamplePdfFileViewer(fFilename.c_str());
91 } 91 }
92 }; 92 };
93 #endif // SAMPLE_PDF_FILE_VIEWER 93 #endif // SAMPLE_PDF_FILE_VIEWER
94 94
95 #if SK_COMMAND_BUFFER 95 #if SK_ANGLE
96 #define DEFAULT_TO_COMMAND_BUFFER 1
97 #elif SK_ANGLE
98 //#define DEFAULT_TO_ANGLE 1 96 //#define DEFAULT_TO_ANGLE 1
99 #else 97 #else
100 #define DEFAULT_TO_GPU 0 // if 1 default rendering is on GPU 98 #define DEFAULT_TO_GPU 0 // if 1 default rendering is on GPU
101 #endif 99 #endif
102 100
103 #define ANIMATING_EVENTTYPE "nextSample" 101 #define ANIMATING_EVENTTYPE "nextSample"
104 #define ANIMATING_DELAY 250 102 #define ANIMATING_DELAY 250
105 103
106 #ifdef SK_DEBUG 104 #ifdef SK_DEBUG
107 #define FPS_REPEAT_MULTIPLIER 1 105 #define FPS_REPEAT_MULTIPLIER 1
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 case kGPU_DeviceType: 202 case kGPU_DeviceType:
205 // all these guys use the native backend 203 // all these guys use the native backend
206 fBackend = kNativeGL_BackEndType; 204 fBackend = kNativeGL_BackEndType;
207 break; 205 break;
208 #if SK_ANGLE 206 #if SK_ANGLE
209 case kANGLE_DeviceType: 207 case kANGLE_DeviceType:
210 // ANGLE is really the only odd man out 208 // ANGLE is really the only odd man out
211 fBackend = kANGLE_BackEndType; 209 fBackend = kANGLE_BackEndType;
212 break; 210 break;
213 #endif // SK_ANGLE 211 #endif // SK_ANGLE
214 #if SK_COMMAND_BUFFER
215 case kCommandBuffer_DeviceType:
216 // Command buffer is really the only other odd man out :D
217 fBackend = kCommandBuffer_BackEndType;
218 break;
219 #endif // SK_COMMAND_BUFFER
220 default: 212 default:
221 SkASSERT(false); 213 SkASSERT(false);
222 break; 214 break;
223 } 215 }
224 AttachmentInfo attachmentInfo; 216 AttachmentInfo attachmentInfo;
225 bool result = win->attach(fBackend, msaaSampleCount, deepColor, &attachm entInfo); 217 bool result = win->attach(fBackend, msaaSampleCount, deepColor, &attachm entInfo);
226 if (!result) { 218 if (!result) {
227 SkDebugf("Failed to initialize GL"); 219 SkDebugf("Failed to initialize GL");
228 return; 220 return;
229 } 221 }
230 fMSAASampleCount = msaaSampleCount; 222 fMSAASampleCount = msaaSampleCount;
231 fDeepColor = deepColor; 223 fDeepColor = deepColor;
232 // Assume that we have at least 24-bit output, for backends that don't s upply this data 224 // Assume that we have at least 24-bit output, for backends that don't s upply this data
233 fActualColorBits = SkTMax(attachmentInfo.fColorBits, 24); 225 fActualColorBits = SkTMax(attachmentInfo.fColorBits, 24);
234 226
235 SkASSERT(nullptr == fCurIntf); 227 SkASSERT(nullptr == fCurIntf);
236 SkAutoTUnref<const GrGLInterface> glInterface; 228 SkAutoTUnref<const GrGLInterface> glInterface;
237 switch (win->getDeviceType()) { 229 switch (win->getDeviceType()) {
238 case kRaster_DeviceType: // fallthrough 230 case kRaster_DeviceType: // fallthrough
239 case kGPU_DeviceType: 231 case kGPU_DeviceType:
240 // all these guys use the native interface 232 // all these guys use the native interface
241 glInterface.reset(GrGLCreateNativeInterface()); 233 glInterface.reset(GrGLCreateNativeInterface());
242 break; 234 break;
243 #if SK_ANGLE 235 #if SK_ANGLE
244 case kANGLE_DeviceType: 236 case kANGLE_DeviceType:
245 glInterface.reset(sk_gpu_test::CreateANGLEGLInterface()); 237 glInterface.reset(sk_gpu_test::CreateANGLEGLInterface());
246 break; 238 break;
247 #endif // SK_ANGLE 239 #endif // SK_ANGLE
248 #if SK_COMMAND_BUFFER
249 case kCommandBuffer_DeviceType:
250 glInterface.reset(GrGLCreateCommandBufferInterface());
251 break;
252 #endif // SK_COMMAND_BUFFER
253 default: 240 default:
254 SkASSERT(false); 241 SkASSERT(false);
255 break; 242 break;
256 } 243 }
257 244
258 // Currently SampleApp does not use NVPR. TODO: Provide an NVPR device t ype that is skipped 245 // Currently SampleApp does not use NVPR. TODO: Provide an NVPR device t ype that is skipped
259 // when the driver doesn't support NVPR. 246 // when the driver doesn't support NVPR.
260 fCurIntf = GrGLInterfaceRemoveNVPR(glInterface.get()); 247 fCurIntf = GrGLInterfaceRemoveNVPR(glInterface.get());
261 248
262 SkASSERT(nullptr == fCurContext); 249 SkASSERT(nullptr == fCurContext);
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 } 724 }
738 725
739 static inline SampleWindow::DeviceType cycle_devicetype(SampleWindow::DeviceType ct) { 726 static inline SampleWindow::DeviceType cycle_devicetype(SampleWindow::DeviceType ct) {
740 static const SampleWindow::DeviceType gCT[] = { 727 static const SampleWindow::DeviceType gCT[] = {
741 SampleWindow::kRaster_DeviceType 728 SampleWindow::kRaster_DeviceType
742 #if SK_SUPPORT_GPU 729 #if SK_SUPPORT_GPU
743 , SampleWindow::kGPU_DeviceType 730 , SampleWindow::kGPU_DeviceType
744 #if SK_ANGLE 731 #if SK_ANGLE
745 , SampleWindow::kANGLE_DeviceType 732 , SampleWindow::kANGLE_DeviceType
746 #endif // SK_ANGLE 733 #endif // SK_ANGLE
747 #if SK_COMMAND_BUFFER
748 , SampleWindow::kCommandBuffer_DeviceType
749 #endif // SK_COMMAND_BUFFER
750 #endif // SK_SUPPORT_GPU 734 #endif // SK_SUPPORT_GPU
751 }; 735 };
752 static_assert(SK_ARRAY_COUNT(gCT) == SampleWindow::kDeviceTypeCnt, "array_si ze_mismatch"); 736 static_assert(SK_ARRAY_COUNT(gCT) == SampleWindow::kDeviceTypeCnt, "array_si ze_mismatch");
753 return gCT[ct]; 737 return gCT[ct];
754 } 738 }
755 739
756 static SkString getSampleTitle(const SkViewFactory* sampleFactory) { 740 static SkString getSampleTitle(const SkViewFactory* sampleFactory) {
757 SkView* view = (*sampleFactory)(); 741 SkView* view = (*sampleFactory)();
758 SkString title; 742 SkString title;
759 SampleCode::RequestTitle(view, &title); 743 SampleCode::RequestTitle(view, &title);
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 fDeviceType = kGPU_DeviceType; 890 fDeviceType = kGPU_DeviceType;
907 } 891 }
908 #endif 892 #endif
909 893
910 #if DEFAULT_TO_GPU 894 #if DEFAULT_TO_GPU
911 fDeviceType = kGPU_DeviceType; 895 fDeviceType = kGPU_DeviceType;
912 #endif 896 #endif
913 #if SK_ANGLE && DEFAULT_TO_ANGLE 897 #if SK_ANGLE && DEFAULT_TO_ANGLE
914 fDeviceType = kANGLE_DeviceType; 898 fDeviceType = kANGLE_DeviceType;
915 #endif 899 #endif
916 #if SK_COMMAND_BUFFER && DEFAULT_TO_COMMAND_BUFFER
917 fDeviceType = kCommandBuffer_DeviceType;
918 #endif
919 900
920 fUseClip = false; 901 fUseClip = false;
921 fUsePicture = false; 902 fUsePicture = false;
922 fAnimating = false; 903 fAnimating = false;
923 fRotate = false; 904 fRotate = false;
924 fPerspAnim = false; 905 fPerspAnim = false;
925 fRequestGrabImage = false; 906 fRequestGrabImage = false;
926 fTilingMode = kNo_Tiling; 907 fTilingMode = kNo_Tiling;
927 fMeasureFPS = false; 908 fMeasureFPS = false;
928 fLCDState = SkOSMenu::kMixedState; 909 fLCDState = SkOSMenu::kMixedState;
(...skipping 28 matching lines...) Expand all
957 fAppMenu->assignKeyEquivalentToItem(itemID, 'C'); 938 fAppMenu->assignKeyEquivalentToItem(itemID, 'C');
958 itemID = fAppMenu->appendSwitch("sRGB SkColor", "sRGB SkColor", sinkID, gTre atSkColorAsSRGB); 939 itemID = fAppMenu->appendSwitch("sRGB SkColor", "sRGB SkColor", sinkID, gTre atSkColorAsSRGB);
959 fAppMenu->assignKeyEquivalentToItem(itemID, 'S'); 940 fAppMenu->assignKeyEquivalentToItem(itemID, 'S');
960 941
961 itemID = fAppMenu->appendList("Device Type", "Device Type", sinkID, 0, 942 itemID = fAppMenu->appendList("Device Type", "Device Type", sinkID, 0,
962 "Raster", 943 "Raster",
963 "OpenGL", 944 "OpenGL",
964 #if SK_ANGLE 945 #if SK_ANGLE
965 "ANGLE", 946 "ANGLE",
966 #endif 947 #endif
967 #if SK_COMMAND_BUFFER
968 "Command Buffer",
969 #endif
970 nullptr); 948 nullptr);
971 fAppMenu->assignKeyEquivalentToItem(itemID, 'd'); 949 fAppMenu->assignKeyEquivalentToItem(itemID, 'd');
972 itemID = fAppMenu->appendTriState("AA", "AA", sinkID, fAAState); 950 itemID = fAppMenu->appendTriState("AA", "AA", sinkID, fAAState);
973 fAppMenu->assignKeyEquivalentToItem(itemID, 'b'); 951 fAppMenu->assignKeyEquivalentToItem(itemID, 'b');
974 itemID = fAppMenu->appendTriState("LCD", "LCD", sinkID, fLCDState); 952 itemID = fAppMenu->appendTriState("LCD", "LCD", sinkID, fLCDState);
975 fAppMenu->assignKeyEquivalentToItem(itemID, 'l'); 953 fAppMenu->assignKeyEquivalentToItem(itemID, 'l');
976 itemID = fAppMenu->appendList("FilterQuality", "FilterQuality", sinkID, fFil terQualityIndex, 954 itemID = fAppMenu->appendList("FilterQuality", "FilterQuality", sinkID, fFil terQualityIndex,
977 gFilterQualityStates[0].fName, 955 gFilterQualityStates[0].fName,
978 gFilterQualityStates[1].fName, 956 gFilterQualityStates[1].fName,
979 gFilterQualityStates[2].fName, 957 gFilterQualityStates[2].fName,
(...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after
2093 this->updateTitle(); 2071 this->updateTitle();
2094 } 2072 }
2095 2073
2096 static const char* gDeviceTypePrefix[] = { 2074 static const char* gDeviceTypePrefix[] = {
2097 "raster: ", 2075 "raster: ",
2098 #if SK_SUPPORT_GPU 2076 #if SK_SUPPORT_GPU
2099 "opengl: ", 2077 "opengl: ",
2100 #if SK_ANGLE 2078 #if SK_ANGLE
2101 "angle: ", 2079 "angle: ",
2102 #endif // SK_ANGLE 2080 #endif // SK_ANGLE
2103 #if SK_COMMAND_BUFFER
2104 "command buffer: ",
2105 #endif // SK_COMMAND_BUFFER
2106 #endif // SK_SUPPORT_GPU 2081 #endif // SK_SUPPORT_GPU
2107 }; 2082 };
2108 static_assert(SK_ARRAY_COUNT(gDeviceTypePrefix) == SampleWindow::kDeviceTypeCnt, 2083 static_assert(SK_ARRAY_COUNT(gDeviceTypePrefix) == SampleWindow::kDeviceTypeCnt,
2109 "array_size_mismatch"); 2084 "array_size_mismatch");
2110 2085
2111 static const char* trystate_str(SkOSMenu::TriState state, 2086 static const char* trystate_str(SkOSMenu::TriState state,
2112 const char trueStr[], const char falseStr[]) { 2087 const char trueStr[], const char falseStr[]) {
2113 if (SkOSMenu::kOnState == state) { 2088 if (SkOSMenu::kOnState == state) {
2114 return trueStr; 2089 return trueStr;
2115 } else if (SkOSMenu::kOffState == state) { 2090 } else if (SkOSMenu::kOffState == state) {
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
2424 #ifdef SK_BUILD_FOR_MAC 2399 #ifdef SK_BUILD_FOR_MAC
2425 setenv("ANDROID_ROOT", "/android/device/data", 0); 2400 setenv("ANDROID_ROOT", "/android/device/data", 0);
2426 #endif 2401 #endif
2427 SkGraphics::Init(); 2402 SkGraphics::Init();
2428 SkEvent::Init(); 2403 SkEvent::Init();
2429 } 2404 }
2430 2405
2431 void application_term() { 2406 void application_term() {
2432 SkEvent::Term(); 2407 SkEvent::Term();
2433 } 2408 }
OLDNEW
« no previous file with comments | « samplecode/SampleApp.h ('k') | src/views/win/SkOSWindow_win.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698