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

Side by Side Diff: tools/gpu/GrContextFactory.h

Issue 1845923004: Rename enums in GrContextFactory to remove "GL" (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 4 years, 8 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 | « tools/flags/SkCommonFlagsConfig.cpp ('k') | tools/gpu/GrContextFactory.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 2012 Google Inc. 2 * Copyright 2012 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 #ifndef GrContextFactory_DEFINED 8 #ifndef GrContextFactory_DEFINED
9 #define GrContextFactory_DEFINED 9 #define GrContextFactory_DEFINED
10 10
11 #include "GrContext.h" 11 #include "GrContext.h"
12 #include "GrContextOptions.h" 12 #include "GrContextOptions.h"
13 13
14 #include "gl/GLTestContext.h" 14 #include "gl/GLTestContext.h"
15 #include "SkTArray.h" 15 #include "SkTArray.h"
16 16
17 namespace sk_gpu_test { 17 namespace sk_gpu_test {
18 /** 18 /**
19 * This is a simple class that is useful in test apps that use different 19 * This is a simple class that is useful in test apps that use different
20 * GrContexts backed by different types of GL contexts. It manages creating the 20 * GrContexts backed by different types of GL contexts. It manages creating the
21 * GL context and a GrContext that uses it. The GL/Gr contexts persist until the 21 * GL context and a GrContext that uses it. The GL/Gr contexts persist until the
22 * factory is destroyed (though the caller can always grab a ref on the returned 22 * factory is destroyed (though the caller can always grab a ref on the returned
23 * Gr and GL contexts to make them outlive the factory). 23 * Gr and GL contexts to make them outlive the factory).
24 */ 24 */
25 class GrContextFactory : SkNoncopyable { 25 class GrContextFactory : SkNoncopyable {
26 public: 26 public:
27 enum GLContextType { 27 enum ContextType {
28 kNative_GLContextType, //! OpenGL or OpenGL ES context. 28 kGL_ContextType, //! OpenGL context.
29 kGL_GLContextType, //! OpenGL context. 29 kGLES_ContextType, //! OpenGL ES context.
30 kGLES_GLContextType, //! OpenGL ES context.
31 #if SK_ANGLE 30 #if SK_ANGLE
32 #ifdef SK_BUILD_FOR_WIN 31 #ifdef SK_BUILD_FOR_WIN
33 kANGLE_GLContextType, //! ANGLE on DirectX OpenGL ES context. 32 kANGLE_ContextType, //! ANGLE on DirectX OpenGL ES context.
34 #endif 33 #endif
35 kANGLE_GL_GLContextType, //! ANGLE on OpenGL OpenGL ES context. 34 kANGLE_GL_ContextType, //! ANGLE on OpenGL OpenGL ES context.
36 #endif 35 #endif
37 #if SK_COMMAND_BUFFER 36 #if SK_COMMAND_BUFFER
38 kCommandBuffer_GLContextType, //! Chromium command buffer OpenGL ES cont ext. 37 kCommandBuffer_ContextType, //! Chromium command buffer OpenGL ES contex t.
39 #endif 38 #endif
40 #if SK_MESA 39 #if SK_MESA
41 kMESA_GLContextType, //! MESA OpenGL context 40 kMESA_ContextType, //! MESA OpenGL context
42 #endif 41 #endif
43 kNull_GLContextType, //! Non-rendering OpenGL mock context. 42 kNullGL_ContextType, //! Non-rendering OpenGL mock context.
44 kDebug_GLContextType, //! Non-rendering, state verifying OpenGL context. 43 kDebugGL_ContextType, //! Non-rendering, state verifying OpenGL co ntext.
45 kLastGLContextType = kDebug_GLContextType 44 kLastContextType = kDebugGL_ContextType
46 }; 45 };
47 46
48 static const int kGLContextTypeCnt = kLastGLContextType + 1; 47 //! OpenGL or OpenGL ES context depending on the platform. To be removed.
48 static const ContextType kNativeGL_ContextType;
49
50 static const int kContextTypeCnt = kLastContextType + 1;
49 51
50 /** 52 /**
51 * Options for GL context creation. For historical and testing reasons the o ptions will default 53 * Options for GL context creation. For historical and testing reasons the o ptions will default
52 * to not using GL_NV_path_rendering extension even when the driver support s it. 54 * to not using GL_NV_path_rendering extension even when the driver support s it.
53 */ 55 */
54 enum GLContextOptions { 56 enum ContextOptions {
55 kNone_GLContextOptions = 0, 57 kNone_ContextOptions = 0x0,
56 kEnableNVPR_GLContextOptions = 0x1, 58 kEnableNVPR_ContextOptions = 0x1,
57 kRequireSRGBSupport_GLContextOptions = 0x2, 59 kRequireSRGBSupport_ContextOptions = 0x2,
58 }; 60 };
59 61
60 static bool IsRenderingGLContext(GLContextType type) { 62 static bool IsRenderingContext(ContextType type) {
61 switch (type) { 63 switch (type) {
62 case kNull_GLContextType: 64 case kNullGL_ContextType:
63 case kDebug_GLContextType: 65 case kDebugGL_ContextType:
64 return false; 66 return false;
65 default: 67 default:
66 return true; 68 return true;
67 } 69 }
68 } 70 }
69 71
70 static const char* GLContextTypeName(GLContextType type) { 72 static const char* ContextTypeName(ContextType type) {
71 switch (type) { 73 switch (type) {
72 case kNative_GLContextType: 74 case kGL_ContextType:
73 return "native";
74 case kGL_GLContextType:
75 return "gl"; 75 return "gl";
76 case kGLES_GLContextType: 76 case kGLES_ContextType:
77 return "gles"; 77 return "gles";
78 #if SK_ANGLE 78 #if SK_ANGLE
79 #ifdef SK_BUILD_FOR_WIN 79 #ifdef SK_BUILD_FOR_WIN
80 case kANGLE_GLContextType: 80 case kANGLE_ContextType:
81 return "angle"; 81 return "angle";
82 #endif 82 #endif
83 case kANGLE_GL_GLContextType: 83 case kANGLE_GL_ContextType:
84 return "angle-gl"; 84 return "angle-gl";
85 #endif 85 #endif
86 #if SK_COMMAND_BUFFER 86 #if SK_COMMAND_BUFFER
87 case kCommandBuffer_GLContextType: 87 case kCommandBuffer_ContextType:
88 return "commandbuffer"; 88 return "commandbuffer";
89 #endif 89 #endif
90 #if SK_MESA 90 #if SK_MESA
91 case kMESA_GLContextType: 91 case kMESA_ContextType:
92 return "mesa"; 92 return "mesa";
93 #endif 93 #endif
94 case kNull_GLContextType: 94 case kNullGL_ContextType:
95 return "null"; 95 return "null";
96 case kDebug_GLContextType: 96 case kDebugGL_ContextType:
97 return "debug"; 97 return "debug";
98 default: 98 default:
99 SkFAIL("Unknown GL Context type."); 99 SkFAIL("Unknown GL Context type.");
100 } 100 }
101 } 101 }
102 102
103 explicit GrContextFactory(const GrContextOptions& opts); 103 explicit GrContextFactory(const GrContextOptions& opts);
104 GrContextFactory(); 104 GrContextFactory();
105 105
106 ~GrContextFactory(); 106 ~GrContextFactory();
107 107
108 void destroyContexts(); 108 void destroyContexts();
109 void abandonContexts(); 109 void abandonContexts();
110 void releaseResourcesAndAbandonContexts(); 110 void releaseResourcesAndAbandonContexts();
111 111
112 struct ContextInfo { 112 struct ContextInfo {
113 ContextInfo() 113 ContextInfo()
114 : fGrContext(nullptr), fGLContext(nullptr) { } 114 : fGrContext(nullptr), fGLContext(nullptr) { }
115 ContextInfo(GrContext* grContext, GLTestContext* glContext) 115 ContextInfo(GrContext* grContext, GLTestContext* glContext)
116 : fGrContext(grContext), fGLContext(glContext) { } 116 : fGrContext(grContext), fGLContext(glContext) { }
117 GrContext* fGrContext; 117 GrContext* fGrContext;
118 GLTestContext* fGLContext; //! Valid until the factory destroys it via a bandonContexts() or 118 GLTestContext* fGLContext; //! Valid until the factory destroys it via a bandonContexts() or
119 //! destroyContexts(). 119 //! destroyContexts().
120 }; 120 };
121 121
122 /** 122 /**
123 * Get a context initialized with a type of GL context. It also makes the GL context current. 123 * Get a context initialized with a type of GL context. It also makes the GL context current.
124 */ 124 */
125 ContextInfo getContextInfo(GLContextType type, 125 ContextInfo getContextInfo(ContextType type,
126 GLContextOptions options = kNone_GLContextOptions ); 126 ContextOptions options = kNone_ContextOptions);
127 /** 127 /**
128 * Get a GrContext initialized with a type of GL context. It also makes the GL context current. 128 * Get a GrContext initialized with a type of GL context. It also makes the GL context current.
129 */ 129 */
130 GrContext* get(GLContextType type, 130 GrContext* get(ContextType type, ContextOptions options = kNone_ContextOptio ns) {
131 GLContextOptions options = kNone_GLContextOptions) {
132 return this->getContextInfo(type, options).fGrContext; 131 return this->getContextInfo(type, options).fGrContext;
133 } 132 }
134 const GrContextOptions& getGlobalOptions() const { return fGlobalOptions; } 133 const GrContextOptions& getGlobalOptions() const { return fGlobalOptions; }
135 134
136 private: 135 private:
137 struct Context { 136 struct Context {
138 GLContextType fType; 137 ContextType fType;
139 GLContextOptions fOptions; 138 ContextOptions fOptions;
140 GLTestContext* fGLContext; 139 GLTestContext* fGLContext; // null if non-GL
141 GrContext* fGrContext; 140 GrContext* fGrContext;
142 }; 141 };
143 SkTArray<Context, true> fContexts; 142 SkTArray<Context, true> fContexts;
144 const GrContextOptions fGlobalOptions; 143 const GrContextOptions fGlobalOptions;
145 }; 144 };
146 } // namespace sk_gpu_test 145 } // namespace sk_gpu_test
147 #endif 146 #endif
OLDNEW
« no previous file with comments | « tools/flags/SkCommonFlagsConfig.cpp ('k') | tools/gpu/GrContextFactory.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698