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

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

Issue 1548683002: Revert of Add config options to run different GPU APIs to dm and nanobench (Closed) Base URL: https://skia.googlesource.com/skia.git@commandbuffer-as-api-03-context-factory-glcontext-type
Patch Set: Created 5 years 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 | « src/core/SkString.cpp ('k') | src/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/SkGLContext.h" 14 #include "gl/SkGLContext.h"
15 #include "SkTArray.h" 15 #include "SkTArray.h"
16 16
17 /** 17 /**
18 * This is a simple class that is useful in test apps that use different 18 * This is a simple class that is useful in test apps that use different
19 * GrContexts backed by different types of GL contexts. It manages creating the 19 * GrContexts backed by different types of GL contexts. It manages creating the
20 * GL context and a GrContext that uses it. The GL/Gr contexts persist until the 20 * GL context and a GrContext that uses it. The GL/Gr contexts persist until the
21 * factory is destroyed (though the caller can always grab a ref on the returned 21 * factory is destroyed (though the caller can always grab a ref on the returned
22 * Gr and GL contexts to make them outlive the factory). 22 * Gr and GL contexts to make them outlive the factory).
23 */ 23 */
24 class GrContextFactory : SkNoncopyable { 24 class GrContextFactory : SkNoncopyable {
25 public: 25 public:
26 enum GLContextType { 26 enum GLContextType {
27 kNative_GLContextType, //! OpenGL or OpenGL ES context. 27 kNative_GLContextType,
28 kGL_GLContextType, //! OpenGL context.
29 kGLES_GLContextType, //! OpenGL ES context.
30 #if SK_ANGLE 28 #if SK_ANGLE
31 #ifdef SK_BUILD_FOR_WIN 29 kANGLE_GLContextType,
32 kANGLE_GLContextType, //! ANGLE on DirectX OpenGL ES context. 30 kANGLE_GL_GLContextType,
33 #endif
34 kANGLE_GL_GLContextType, //! ANGLE on OpenGL OpenGL ES context.
35 #endif 31 #endif
36 #if SK_COMMAND_BUFFER 32 #if SK_COMMAND_BUFFER
37 kCommandBuffer_GLContextType, //! Chromium command buffer OpenGL ES cont ext. 33 kCommandBuffer_GLContextType,
38 #endif 34 #endif
39 #if SK_MESA 35 #if SK_MESA
40 kMESA_GLContextType, //! MESA OpenGL context 36 kMESA_GLContextType,
41 #endif 37 #endif
42 kNull_GLContextType, //! Non-rendering OpenGL mock context. 38 kNull_GLContextType,
43 kDebug_GLContextType, //! Non-rendering, state verifying OpenGL context. 39 kDebug_GLContextType,
44 kLastGLContextType = kDebug_GLContextType 40 kLastGLContextType = kDebug_GLContextType
45 }; 41 };
46 42
47 static const int kGLContextTypeCnt = kLastGLContextType + 1; 43 static const int kGLContextTypeCnt = kLastGLContextType + 1;
48 44
49 /** 45 /**
50 * Options for GL context creation. For historical and testing reasons the o ptions will default 46 * Options for GL context creation. For historical and testing reasons the o ptions will default
51 * to not using GL_NV_path_rendering extension even when the driver support s it. 47 * to not using GL_NV_path_rendering extension even when the driver support s it.
52 */ 48 */
53 enum GLContextOptions { 49 enum GLContextOptions {
54 kNone_GLContextOptions = 0, 50 kNone_GLContextOptions = 0,
55 kEnableNVPR_GLContextOptions = 0x1, 51 kEnableNVPR_GLContextOptions = 0x1,
56 }; 52 };
57 53
58 static bool IsRenderingGLContext(GLContextType type) { 54 static bool IsRenderingGLContext(GLContextType type) {
59 switch (type) { 55 switch (type) {
60 case kNull_GLContextType: 56 case kNull_GLContextType:
61 case kDebug_GLContextType: 57 case kDebug_GLContextType:
62 return false; 58 return false;
63 default: 59 default:
64 return true; 60 return true;
65 } 61 }
66 } 62 }
67 63
68 static const char* GLContextTypeName(GLContextType type) { 64 static const char* GLContextTypeName(GLContextType type) {
69 switch (type) { 65 switch (type) {
70 case kNative_GLContextType: 66 case kNative_GLContextType:
71 return "native"; 67 return "native";
72 case kGL_GLContextType: 68 case kNull_GLContextType:
73 return "gl"; 69 return "null";
74 case kGLES_GLContextType:
75 return "gles";
76 #if SK_ANGLE 70 #if SK_ANGLE
77 #ifdef SK_BUILD_FOR_WIN
78 case kANGLE_GLContextType: 71 case kANGLE_GLContextType:
79 return "angle"; 72 return "angle";
80 #endif
81 case kANGLE_GL_GLContextType: 73 case kANGLE_GL_GLContextType:
82 return "angle-gl"; 74 return "angle-gl";
83 #endif 75 #endif
84 #if SK_COMMAND_BUFFER 76 #if SK_COMMAND_BUFFER
85 case kCommandBuffer_GLContextType: 77 case kCommandBuffer_GLContextType:
86 return "commandbuffer"; 78 return "commandbuffer";
87 #endif 79 #endif
88 #if SK_MESA 80 #if SK_MESA
89 case kMESA_GLContextType: 81 case kMESA_GLContextType:
90 return "mesa"; 82 return "mesa";
91 #endif 83 #endif
92 case kNull_GLContextType:
93 return "null";
94 case kDebug_GLContextType: 84 case kDebug_GLContextType:
95 return "debug"; 85 return "debug";
96 default: 86 default:
97 SkFAIL("Unknown GL Context type."); 87 SkFAIL("Unknown GL Context type.");
98 } 88 }
99 } 89 }
100 90
101 explicit GrContextFactory(const GrContextOptions& opts) : fGlobalOptions(opt s) { } 91 explicit GrContextFactory(const GrContextOptions& opts) : fGlobalOptions(opt s) { }
102 GrContextFactory() { } 92 GrContextFactory() { }
103 93
(...skipping 23 matching lines...) Expand all
127 struct ContextInfo { 117 struct ContextInfo {
128 GLContextType fType; 118 GLContextType fType;
129 GLContextOptions fOptions; 119 GLContextOptions fOptions;
130 SkGLContext* fGLContext; 120 SkGLContext* fGLContext;
131 GrContext* fGrContext; 121 GrContext* fGrContext;
132 }; 122 };
133 /** 123 /**
134 * Get a context initialized with a type of GL context. It also makes the GL context current. 124 * Get a context initialized with a type of GL context. It also makes the GL context current.
135 * Pointer is valid until destroyContexts() is called. 125 * Pointer is valid until destroyContexts() is called.
136 */ 126 */
137 ContextInfo* getContextInfo(GLContextType type, 127 ContextInfo* getContextInfo(GLContextType type, GrGLStandard forcedGpuAPI = kNone_GrGLStandard,
138 GLContextOptions options = kNone_GLContextOption s); 128 GLContextOptions options = kNone_GLContextOption s);
139 129
140 /** 130 /**
141 * Get a GrContext initialized with a type of GL context. It also makes the GL context current. 131 * Get a GrContext initialized with a type of GL context. It also makes the GL context current.
142 */ 132 */
143 GrContext* get(GLContextType type, GLContextOptions options = kNone_GLContex tOptions) { 133 GrContext* get(GLContextType type, GrGLStandard forcedGpuAPI = kNone_GrGLSta ndard,
144 if (ContextInfo* info = this->getContextInfo(type, options)) { 134 GLContextOptions options = kNone_GLContextOptions) {
135 if (ContextInfo* info = this->getContextInfo(type, forcedGpuAPI, options )) {
145 return info->fGrContext; 136 return info->fGrContext;
146 } 137 }
147 return nullptr; 138 return nullptr;
148 } 139 }
149 const GrContextOptions& getGlobalOptions() const { return fGlobalOptions; } 140 const GrContextOptions& getGlobalOptions() const { return fGlobalOptions; }
150 141
151 private: 142 private:
152 SkTArray<SkAutoTDelete<ContextInfo>, true> fContexts; 143 SkTArray<SkAutoTDelete<ContextInfo>, true> fContexts;
153 const GrContextOptions fGlobalOptions; 144 const GrContextOptions fGlobalOptions;
154 }; 145 };
155 146
156 #endif 147 #endif
OLDNEW
« no previous file with comments | « src/core/SkString.cpp ('k') | src/gpu/GrContextFactory.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698