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

Side by Side Diff: samplecode/SampleApp.cpp

Issue 1306823003: skia: add ability to load command_buffer_gles2 (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: and NULL->nullptr, just because. Created 5 years, 3 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/gpu/GrContextFactory.h » ('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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 #ifdef PIPE_FILE 74 #ifdef PIPE_FILE
75 #define FILE_PATH "/path/to/drawing.data" 75 #define FILE_PATH "/path/to/drawing.data"
76 #endif 76 #endif
77 77
78 #define PIPE_NETx 78 #define PIPE_NETx
79 #ifdef PIPE_NET 79 #ifdef PIPE_NET
80 #include "SkSockets.h" 80 #include "SkSockets.h"
81 SkTCPServer gServer; 81 SkTCPServer gServer;
82 #endif 82 #endif
83 83
84 #if SK_ANGLE 84 #if SK_COMMAND_BUFFER
85 #define DEFAULT_TO_COMMAND_BUFFER 1
86 #elif SK_ANGLE
85 //#define DEFAULT_TO_ANGLE 1 87 //#define DEFAULT_TO_ANGLE 1
86 #else 88 #else
87 #define DEFAULT_TO_GPU 0 // if 1 default rendering is on GPU 89 #define DEFAULT_TO_GPU 0 // if 1 default rendering is on GPU
88 #endif 90 #endif
89 91
90 #define ANIMATING_EVENTTYPE "nextSample" 92 #define ANIMATING_EVENTTYPE "nextSample"
91 #define ANIMATING_DELAY 250 93 #define ANIMATING_DELAY 250
92 94
93 #ifdef SK_DEBUG 95 #ifdef SK_DEBUG
94 #define FPS_REPEAT_MULTIPLIER 1 96 #define FPS_REPEAT_MULTIPLIER 1
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 case kGPU_DeviceType: 192 case kGPU_DeviceType:
191 // all these guys use the native backend 193 // all these guys use the native backend
192 fBackend = kNativeGL_BackEndType; 194 fBackend = kNativeGL_BackEndType;
193 break; 195 break;
194 #if SK_ANGLE 196 #if SK_ANGLE
195 case kANGLE_DeviceType: 197 case kANGLE_DeviceType:
196 // ANGLE is really the only odd man out 198 // ANGLE is really the only odd man out
197 fBackend = kANGLE_BackEndType; 199 fBackend = kANGLE_BackEndType;
198 break; 200 break;
199 #endif // SK_ANGLE 201 #endif // SK_ANGLE
202 #if SK_COMMAND_BUFFER
203 case kCommandBuffer_DeviceType:
204 // Command buffer is really the only other odd man out :D
205 fBackend = kCommandBuffer_BackEndType;
206 break;
207 #endif // SK_COMMAND_BUFFER
200 default: 208 default:
201 SkASSERT(false); 209 SkASSERT(false);
202 break; 210 break;
203 } 211 }
204 AttachmentInfo attachmentInfo; 212 AttachmentInfo attachmentInfo;
205 bool result = win->attach(fBackend, msaaSampleCount, &attachmentInfo); 213 bool result = win->attach(fBackend, msaaSampleCount, &attachmentInfo);
206 if (!result) { 214 if (!result) {
207 SkDebugf("Failed to initialize GL"); 215 SkDebugf("Failed to initialize GL");
208 return; 216 return;
209 } 217 }
210 fMSAASampleCount = msaaSampleCount; 218 fMSAASampleCount = msaaSampleCount;
211 219
212 SkASSERT(nullptr == fCurIntf); 220 SkASSERT(nullptr == fCurIntf);
213 SkAutoTUnref<const GrGLInterface> glInterface; 221 SkAutoTUnref<const GrGLInterface> glInterface;
214 switch (win->getDeviceType()) { 222 switch (win->getDeviceType()) {
215 case kRaster_DeviceType: // fallthrough 223 case kRaster_DeviceType: // fallthrough
216 case kPicture_DeviceType: // fallthrough 224 case kPicture_DeviceType: // fallthrough
217 case kGPU_DeviceType: 225 case kGPU_DeviceType:
218 // all these guys use the native interface 226 // all these guys use the native interface
219 glInterface.reset(GrGLCreateNativeInterface()); 227 glInterface.reset(GrGLCreateNativeInterface());
220 break; 228 break;
221 #if SK_ANGLE 229 #if SK_ANGLE
222 case kANGLE_DeviceType: 230 case kANGLE_DeviceType:
223 glInterface.reset(GrGLCreateANGLEInterface()); 231 glInterface.reset(GrGLCreateANGLEInterface());
224 break; 232 break;
225 #endif // SK_ANGLE 233 #endif // SK_ANGLE
234 #if SK_COMMAND_BUFFER
235 case kCommandBuffer_DeviceType:
236 glInterface.reset(GrGLCreateCommandBufferInterface());
237 break;
238 #endif // SK_COMMAND_BUFFER
226 default: 239 default:
227 SkASSERT(false); 240 SkASSERT(false);
228 break; 241 break;
229 } 242 }
230 243
231 // Currently SampleApp does not use NVPR. TODO: Provide an NVPR device t ype that is skipped 244 // Currently SampleApp does not use NVPR. TODO: Provide an NVPR device t ype that is skipped
232 // when the driver doesn't support NVPR. 245 // when the driver doesn't support NVPR.
233 fCurIntf = GrGLInterfaceRemoveNVPR(glInterface.get()); 246 fCurIntf = GrGLInterfaceRemoveNVPR(glInterface.get());
234 247
235 SkASSERT(nullptr == fCurContext); 248 SkASSERT(nullptr == fCurContext);
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 } 676 }
664 677
665 static inline SampleWindow::DeviceType cycle_devicetype(SampleWindow::DeviceType ct) { 678 static inline SampleWindow::DeviceType cycle_devicetype(SampleWindow::DeviceType ct) {
666 static const SampleWindow::DeviceType gCT[] = { 679 static const SampleWindow::DeviceType gCT[] = {
667 SampleWindow::kPicture_DeviceType, 680 SampleWindow::kPicture_DeviceType,
668 #if SK_SUPPORT_GPU 681 #if SK_SUPPORT_GPU
669 SampleWindow::kGPU_DeviceType, 682 SampleWindow::kGPU_DeviceType,
670 #if SK_ANGLE 683 #if SK_ANGLE
671 SampleWindow::kANGLE_DeviceType, 684 SampleWindow::kANGLE_DeviceType,
672 #endif // SK_ANGLE 685 #endif // SK_ANGLE
686 #if SK_COMMAND_BUFFER
687 SampleWindow::kCommandBuffer_DeviceType,
688 #endif // SK_COMMAND_BUFFER
673 #endif // SK_SUPPORT_GPU 689 #endif // SK_SUPPORT_GPU
674 SampleWindow::kRaster_DeviceType, 690 SampleWindow::kRaster_DeviceType,
675 }; 691 };
676 static_assert(SK_ARRAY_COUNT(gCT) == SampleWindow::kDeviceTypeCnt, "array_si ze_mismatch"); 692 static_assert(SK_ARRAY_COUNT(gCT) == SampleWindow::kDeviceTypeCnt, "array_si ze_mismatch");
677 return gCT[ct]; 693 return gCT[ct];
678 } 694 }
679 695
680 static SkString getSampleTitle(const SkViewFactory* sampleFactory) { 696 static SkString getSampleTitle(const SkViewFactory* sampleFactory) {
681 SkView* view = (*sampleFactory)(); 697 SkView* view = (*sampleFactory)();
682 SkString title; 698 SkString title;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 #endif 799 #endif
784 800
785 fDeviceType = kRaster_DeviceType; 801 fDeviceType = kRaster_DeviceType;
786 802
787 #if DEFAULT_TO_GPU 803 #if DEFAULT_TO_GPU
788 fDeviceType = kGPU_DeviceType; 804 fDeviceType = kGPU_DeviceType;
789 #endif 805 #endif
790 #if SK_ANGLE && DEFAULT_TO_ANGLE 806 #if SK_ANGLE && DEFAULT_TO_ANGLE
791 fDeviceType = kANGLE_DeviceType; 807 fDeviceType = kANGLE_DeviceType;
792 #endif 808 #endif
809 #if SK_COMMAND_BUFFER && DEFAULT_TO_COMMAND_BUFFER
810 fDeviceType = kCommandBuffer_DeviceType;
811 #endif
793 812
794 fUseClip = false; 813 fUseClip = false;
795 fAnimating = false; 814 fAnimating = false;
796 fRotate = false; 815 fRotate = false;
797 fPerspAnim = false; 816 fPerspAnim = false;
798 fRequestGrabImage = false; 817 fRequestGrabImage = false;
799 fPipeState = SkOSMenu::kOffState; 818 fPipeState = SkOSMenu::kOffState;
800 fTilingMode = kNo_Tiling; 819 fTilingMode = kNo_Tiling;
801 fMeasureFPS = false; 820 fMeasureFPS = false;
802 fLCDState = SkOSMenu::kMixedState; 821 fLCDState = SkOSMenu::kMixedState;
(...skipping 20 matching lines...) Expand all
823 int sinkID = this->getSinkID(); 842 int sinkID = this->getSinkID();
824 fAppMenu = new SkOSMenu; 843 fAppMenu = new SkOSMenu;
825 fAppMenu->setTitle("Global Settings"); 844 fAppMenu->setTitle("Global Settings");
826 int itemID; 845 int itemID;
827 846
828 itemID =fAppMenu->appendList("Device Type", "Device Type", sinkID, 0, 847 itemID =fAppMenu->appendList("Device Type", "Device Type", sinkID, 0,
829 "Raster", "Picture", "OpenGL", 848 "Raster", "Picture", "OpenGL",
830 #if SK_ANGLE 849 #if SK_ANGLE
831 "ANGLE", 850 "ANGLE",
832 #endif 851 #endif
852 #if SK_COMMAND_BUFFER
853 "Command Buffer",
854 #endif
833 nullptr); 855 nullptr);
834 fAppMenu->assignKeyEquivalentToItem(itemID, 'd'); 856 fAppMenu->assignKeyEquivalentToItem(itemID, 'd');
835 itemID = fAppMenu->appendTriState("AA", "AA", sinkID, fAAState); 857 itemID = fAppMenu->appendTriState("AA", "AA", sinkID, fAAState);
836 fAppMenu->assignKeyEquivalentToItem(itemID, 'b'); 858 fAppMenu->assignKeyEquivalentToItem(itemID, 'b');
837 itemID = fAppMenu->appendTriState("LCD", "LCD", sinkID, fLCDState); 859 itemID = fAppMenu->appendTriState("LCD", "LCD", sinkID, fLCDState);
838 fAppMenu->assignKeyEquivalentToItem(itemID, 'l'); 860 fAppMenu->assignKeyEquivalentToItem(itemID, 'l');
839 itemID = fAppMenu->appendList("FilterQuality", "FilterQuality", sinkID, fFil terQualityIndex, 861 itemID = fAppMenu->appendList("FilterQuality", "FilterQuality", sinkID, fFil terQualityIndex,
840 gFilterQualityStates[0].fName, 862 gFilterQualityStates[0].fName,
841 gFilterQualityStates[1].fName, 863 gFilterQualityStates[1].fName,
842 gFilterQualityStates[2].fName, 864 gFilterQualityStates[2].fName,
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after
1932 } 1954 }
1933 1955
1934 static const char* gDeviceTypePrefix[] = { 1956 static const char* gDeviceTypePrefix[] = {
1935 "raster: ", 1957 "raster: ",
1936 "picture: ", 1958 "picture: ",
1937 #if SK_SUPPORT_GPU 1959 #if SK_SUPPORT_GPU
1938 "opengl: ", 1960 "opengl: ",
1939 #if SK_ANGLE 1961 #if SK_ANGLE
1940 "angle: ", 1962 "angle: ",
1941 #endif // SK_ANGLE 1963 #endif // SK_ANGLE
1964 #if SK_COMMAND_BUFFER
1965 "command buffer: ",
1966 #endif // SK_COMMAND_BUFFER
1942 #endif // SK_SUPPORT_GPU 1967 #endif // SK_SUPPORT_GPU
1943 }; 1968 };
1944 static_assert(SK_ARRAY_COUNT(gDeviceTypePrefix) == SampleWindow::kDeviceTypeCnt, 1969 static_assert(SK_ARRAY_COUNT(gDeviceTypePrefix) == SampleWindow::kDeviceTypeCnt,
1945 "array_size_mismatch"); 1970 "array_size_mismatch");
1946 1971
1947 static const char* trystate_str(SkOSMenu::TriState state, 1972 static const char* trystate_str(SkOSMenu::TriState state,
1948 const char trueStr[], const char falseStr[]) { 1973 const char trueStr[], const char falseStr[]) {
1949 if (SkOSMenu::kOnState == state) { 1974 if (SkOSMenu::kOnState == state) {
1950 return trueStr; 1975 return trueStr;
1951 } else if (SkOSMenu::kOffState == state) { 1976 } else if (SkOSMenu::kOffState == state) {
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
2367 setenv("ANDROID_ROOT", "/android/device/data", 0); 2392 setenv("ANDROID_ROOT", "/android/device/data", 0);
2368 #endif 2393 #endif
2369 SkGraphics::Init(); 2394 SkGraphics::Init();
2370 SkEvent::Init(); 2395 SkEvent::Init();
2371 } 2396 }
2372 2397
2373 void application_term() { 2398 void application_term() {
2374 SkEvent::Term(); 2399 SkEvent::Term();
2375 SkGraphics::Term(); 2400 SkGraphics::Term();
2376 } 2401 }
OLDNEW
« no previous file with comments | « samplecode/SampleApp.h ('k') | src/gpu/GrContextFactory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698