OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "GrContextFactory.h" | 9 #include "GrContextFactory.h" |
10 #include "gl/GLTestContext.h" | 10 #include "gl/GLContext.h" |
11 | 11 |
12 #if SK_ANGLE | 12 #if SK_ANGLE |
13 #include "gl/angle/GLTestContext_angle.h" | 13 #include "gl/angle/GLContext_angle.h" |
14 #endif | 14 #endif |
15 #if SK_COMMAND_BUFFER | 15 #if SK_COMMAND_BUFFER |
16 #include "gl/command_buffer/GLTestContext_command_buffer.h" | 16 #include "gl/command_buffer/GLContext_command_buffer.h" |
17 #endif | 17 #endif |
18 #include "gl/debug/DebugGLTestContext.h" | 18 #include "gl/debug/DebugGLContext.h" |
19 #if SK_MESA | 19 #if SK_MESA |
20 #include "gl/mesa/GLTestContext_mesa.h" | 20 #include "gl/mesa/GLContext_mesa.h" |
21 #endif | 21 #endif |
22 #include "gl/null/NullGLTestContext.h" | 22 #include "gl/null/NullGLContext.h" |
23 #include "gl/GrGLGpu.h" | 23 #include "gl/GrGLGpu.h" |
24 #include "GrCaps.h" | 24 #include "GrCaps.h" |
25 | 25 |
26 namespace sk_gpu_test { | 26 namespace sk_gpu_test { |
27 GrContextFactory::GrContextFactory() { } | 27 GrContextFactory::GrContextFactory() { } |
28 | 28 |
29 GrContextFactory::GrContextFactory(const GrContextOptions& opts) | 29 GrContextFactory::GrContextFactory(const GrContextOptions& opts) |
30 : fGlobalOptions(opts) { | 30 : fGlobalOptions(opts) { |
31 } | 31 } |
32 | 32 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 Context& context = fContexts[i]; | 66 Context& context = fContexts[i]; |
67 if (!context.fGLContext) { | 67 if (!context.fGLContext) { |
68 continue; | 68 continue; |
69 } | 69 } |
70 if (context.fType == type && | 70 if (context.fType == type && |
71 context.fOptions == options) { | 71 context.fOptions == options) { |
72 context.fGLContext->makeCurrent(); | 72 context.fGLContext->makeCurrent(); |
73 return ContextInfo(context.fGrContext, context.fGLContext); | 73 return ContextInfo(context.fGrContext, context.fGLContext); |
74 } | 74 } |
75 } | 75 } |
76 SkAutoTDelete<GLTestContext> glCtx; | 76 SkAutoTDelete<GLContext> glCtx; |
77 SkAutoTUnref<GrContext> grCtx; | 77 SkAutoTUnref<GrContext> grCtx; |
78 switch (type) { | 78 switch (type) { |
79 case kNative_GLContextType: | 79 case kNative_GLContextType: |
80 glCtx.reset(CreatePlatformGLTestContext(kNone_GrGLStandard)); | 80 glCtx.reset(CreatePlatformGLContext(kNone_GrGLStandard)); |
81 break; | 81 break; |
82 case kGL_GLContextType: | 82 case kGL_GLContextType: |
83 glCtx.reset(CreatePlatformGLTestContext(kGL_GrGLStandard)); | 83 glCtx.reset(CreatePlatformGLContext(kGL_GrGLStandard)); |
84 break; | 84 break; |
85 case kGLES_GLContextType: | 85 case kGLES_GLContextType: |
86 glCtx.reset(CreatePlatformGLTestContext(kGLES_GrGLStandard)); | 86 glCtx.reset(CreatePlatformGLContext(kGLES_GrGLStandard)); |
87 break; | 87 break; |
88 #if SK_ANGLE | 88 #if SK_ANGLE |
89 #ifdef SK_BUILD_FOR_WIN | 89 #ifdef SK_BUILD_FOR_WIN |
90 case kANGLE_GLContextType: | 90 case kANGLE_GLContextType: |
91 glCtx.reset(CreateANGLEDirect3DGLTestContext()); | 91 glCtx.reset(CreateANGLEDirect3DGLContext()); |
92 break; | 92 break; |
93 #endif | 93 #endif |
94 case kANGLE_GL_GLContextType: | 94 case kANGLE_GL_GLContextType: |
95 glCtx.reset(CreateANGLEOpenGLGLTestContext()); | 95 glCtx.reset(CreateANGLEOpenGLGLContext()); |
96 break; | 96 break; |
97 #endif | 97 #endif |
98 #if SK_COMMAND_BUFFER | 98 #if SK_COMMAND_BUFFER |
99 case kCommandBuffer_GLContextType: | 99 case kCommandBuffer_GLContextType: |
100 glCtx.reset(CommandBufferGLTestContext::Create()); | 100 glCtx.reset(CommandBufferGLContext::Create()); |
101 break; | 101 break; |
102 #endif | 102 #endif |
103 #if SK_MESA | 103 #if SK_MESA |
104 case kMESA_GLContextType: | 104 case kMESA_GLContextType: |
105 glCtx.reset(CreateMesaGLTestContext()); | 105 glCtx.reset(CreateMesaGLContext()); |
106 break; | 106 break; |
107 #endif | 107 #endif |
108 case kNull_GLContextType: | 108 case kNull_GLContextType: |
109 glCtx.reset(CreateNullGLTestContext()); | 109 glCtx.reset(CreateNullGLContext()); |
110 break; | 110 break; |
111 case kDebug_GLContextType: | 111 case kDebug_GLContextType: |
112 glCtx.reset(CreateDebugGLTestContext()); | 112 glCtx.reset(CreateDebugGLContext()); |
113 break; | 113 break; |
114 } | 114 } |
115 if (nullptr == glCtx.get()) { | 115 if (nullptr == glCtx.get()) { |
116 return ContextInfo(); | 116 return ContextInfo(); |
117 } | 117 } |
118 | 118 |
119 SkASSERT(glCtx->isValid()); | 119 SkASSERT(glCtx->isValid()); |
120 | 120 |
121 // Block NVPR from non-NVPR types. | 121 // Block NVPR from non-NVPR types. |
122 SkAutoTUnref<const GrGLInterface> glInterface(SkRef(glCtx->gl())); | 122 SkAutoTUnref<const GrGLInterface> glInterface(SkRef(glCtx->gl())); |
(...skipping 30 matching lines...) Expand all Loading... |
153 } | 153 } |
154 | 154 |
155 Context& context = fContexts.push_back(); | 155 Context& context = fContexts.push_back(); |
156 context.fGLContext = glCtx.release(); | 156 context.fGLContext = glCtx.release(); |
157 context.fGrContext = SkRef(grCtx.get()); | 157 context.fGrContext = SkRef(grCtx.get()); |
158 context.fType = type; | 158 context.fType = type; |
159 context.fOptions = options; | 159 context.fOptions = options; |
160 return ContextInfo(context.fGrContext, context.fGLContext); | 160 return ContextInfo(context.fGrContext, context.fGLContext); |
161 } | 161 } |
162 } // namespace sk_gpu_test | 162 } // namespace sk_gpu_test |
OLD | NEW |