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

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

Issue 1815823002: Move SkGLContext and some GrGLInterface implementations to skgputest module (Closed) Base URL: https://chromium.googlesource.com/skia.git@debugobject
Patch Set: rebase, readd null interface to main lib 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
OLDNEW
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 10
11 #if SK_ANGLE 11 #if SK_ANGLE
12 #include "gl/angle/SkANGLEGLContext.h" 12 #include "gl/angle/GLContext_angle.h"
13 #endif 13 #endif
14 #if SK_COMMAND_BUFFER 14 #if SK_COMMAND_BUFFER
15 #include "gl/command_buffer/SkCommandBufferGLContext.h" 15 #include "gl/command_buffer/GLContext_command_buffer.h"
16 #endif 16 #endif
17 #include "gl/debug/SkDebugGLContext.h" 17 #include "gl/debug/DebugGLContext.h"
18 #if SK_MESA 18 #if SK_MESA
19 #include "gl/mesa/SkMesaGLContext.h" 19 #include "gl/mesa/GLContext_mesa.h"
20 #endif 20 #endif
21 #if SK_VULKAN 21 #if SK_VULKAN
22 #include "vk/GrVkBackendContext.h" 22 #include "vk/GrVkBackendContext.h"
23 #endif 23 #endif
24 #include "gl/SkGLContext.h" 24 #include "gl/GLContext.h"
25 #include "gl/SkNullGLContext.h" 25 #include "gl/null/NullGLContext.h"
26 #include "gl/GrGLGpu.h" 26 #include "gl/GrGLGpu.h"
27 #include "GrCaps.h" 27 #include "GrCaps.h"
28 28
29 GrContextFactory::GrContextFactory() { } 29 namespace sk_gpu_test {
30 GrContextFactory::GrContextFactory() {}
30 31
31 GrContextFactory::GrContextFactory(const GrContextOptions& opts) 32 GrContextFactory::GrContextFactory(const GrContextOptions& opts)
32 : fGlobalOptions(opts) { 33 : fGlobalOptions(opts) {
33 } 34 }
34 35
35 GrContextFactory::~GrContextFactory() { 36 GrContextFactory::~GrContextFactory() {
36 this->destroyContexts(); 37 this->destroyContexts();
37 } 38 }
38 39
39 void GrContextFactory::destroyContexts() { 40 void GrContextFactory::destroyContexts() {
(...skipping 28 matching lines...) Expand all
68 Context& context = fContexts[i]; 69 Context& context = fContexts[i];
69 if (!context.fGLContext) { 70 if (!context.fGLContext) {
70 continue; 71 continue;
71 } 72 }
72 if (context.fType == type && 73 if (context.fType == type &&
73 context.fOptions == options) { 74 context.fOptions == options) {
74 context.fGLContext->makeCurrent(); 75 context.fGLContext->makeCurrent();
75 return ContextInfo(context.fGrContext, context.fGLContext); 76 return ContextInfo(context.fGrContext, context.fGLContext);
76 } 77 }
77 } 78 }
78 SkAutoTDelete<SkGLContext> glCtx; 79 SkAutoTDelete<GLContext> glCtx;
79 SkAutoTUnref<GrContext> grCtx; 80 SkAutoTUnref<GrContext> grCtx;
80 switch (type) { 81 switch (type) {
81 case kNative_GLContextType: 82 case kNative_GLContextType:
82 glCtx.reset(SkCreatePlatformGLContext(kNone_GrGLStandard)); 83 glCtx.reset(CreatePlatformGLContext(kNone_GrGLStandard));
83 break; 84 break;
84 case kGL_GLContextType: 85 case kGL_GLContextType:
85 glCtx.reset(SkCreatePlatformGLContext(kGL_GrGLStandard)); 86 glCtx.reset(CreatePlatformGLContext(kGL_GrGLStandard));
86 break; 87 break;
87 case kGLES_GLContextType: 88 case kGLES_GLContextType:
88 glCtx.reset(SkCreatePlatformGLContext(kGLES_GrGLStandard)); 89 glCtx.reset(CreatePlatformGLContext(kGLES_GrGLStandard));
89 break; 90 break;
90 #if SK_ANGLE 91 #if SK_ANGLE
91 #ifdef SK_BUILD_FOR_WIN 92 #ifdef SK_BUILD_FOR_WIN
92 case kANGLE_GLContextType: 93 case kANGLE_GLContextType:
93 glCtx.reset(SkANGLEGLContext::CreateDirectX()); 94 glCtx.reset(CreateANGLEDirect3DGLContext());
94 break; 95 break;
95 #endif 96 #endif
96 case kANGLE_GL_GLContextType: 97 case kANGLE_GL_GLContextType:
97 glCtx.reset(SkANGLEGLContext::CreateOpenGL()); 98 glCtx.reset(CreateANGLEOpenGLGLContext());
98 break; 99 break;
99 #endif 100 #endif
100 #if SK_COMMAND_BUFFER 101 #if SK_COMMAND_BUFFER
101 case kCommandBuffer_GLContextType: 102 case kCommandBuffer_GLContextType:
102 glCtx.reset(SkCommandBufferGLContext::Create()); 103 glCtx.reset(CommandBufferGLContext::Create());
103 break; 104 break;
104 #endif 105 #endif
105 #if SK_MESA 106 #if SK_MESA
106 case kMESA_GLContextType: 107 case kMESA_GLContextType:
107 glCtx.reset(SkMesaGLContext::Create()); 108 glCtx.reset(CreateMesaGLContext());
108 break; 109 break;
109 #endif 110 #endif
110 case kNull_GLContextType: 111 case kNull_GLContextType:
111 glCtx.reset(SkNullGLContext::Create()); 112 glCtx.reset(CreateNullGLContext());
112 break; 113 break;
113 case kDebug_GLContextType: 114 case kDebug_GLContextType:
114 glCtx.reset(SkDebugGLContext::Create()); 115 glCtx.reset(CreateDebugGLContext());
115 break; 116 break;
116 } 117 }
117 if (nullptr == glCtx.get()) { 118 if (nullptr == glCtx.get()) {
118 return ContextInfo(); 119 return ContextInfo();
119 } 120 }
120 121
121 SkASSERT(glCtx->isValid()); 122 SkASSERT(glCtx->isValid());
122 123
123 // Block NVPR from non-NVPR types. 124 // Block NVPR from non-NVPR types.
124 SkAutoTUnref<const GrGLInterface> glInterface(SkRef(glCtx->gl())); 125 SkAutoTUnref<const GrGLInterface> glInterface(SkRef(glCtx->gl()));
(...skipping 25 matching lines...) Expand all
150 } 151 }
151 } 152 }
152 153
153 Context& context = fContexts.push_back(); 154 Context& context = fContexts.push_back();
154 context.fGLContext = glCtx.release(); 155 context.fGLContext = glCtx.release();
155 context.fGrContext = SkRef(grCtx.get()); 156 context.fGrContext = SkRef(grCtx.get());
156 context.fType = type; 157 context.fType = type;
157 context.fOptions = options; 158 context.fOptions = options;
158 return ContextInfo(context.fGrContext, context.fGLContext); 159 return ContextInfo(context.fGrContext, context.fGLContext);
159 } 160 }
161 } // namespace sk_gpu_test
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698