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

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

Issue 1490113005: 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/gpu/GrContextFactory.h ('k') | src/gpu/gl/SkNullGLContext.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 /* 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/SkANGLEGLContext.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/SkCommandBufferGLContext.h"
16 #endif 16 #endif
17 #include "gl/debug/SkDebugGLContext.h" 17 #include "gl/debug/SkDebugGLContext.h"
18 #if SK_MESA 18 #if SK_MESA
19 #include "gl/mesa/SkMesaGLContext.h" 19 #include "gl/mesa/SkMesaGLContext.h"
20 #endif 20 #endif
21 #include "gl/SkGLContext.h" 21 #include "gl/SkGLContext.h"
22 #include "gl/SkNullGLContext.h" 22 #include "gl/SkNullGLContext.h"
23 #include "gl/GrGLGpu.h" 23 #include "gl/GrGLGpu.h"
24 #include "GrCaps.h" 24 #include "GrCaps.h"
25 25
26 GrContextFactory::ContextInfo* GrContextFactory::getContextInfo(GLContextType ty pe, 26 GrContextFactory::ContextInfo* GrContextFactory::getContextInfo(GLContextType ty pe,
27 GrGLStandard for cedGpuAPI,
28 GLContextOptions options) { 27 GLContextOptions options) {
29 for (int i = 0; i < fContexts.count(); ++i) { 28 for (int i = 0; i < fContexts.count(); ++i) {
30 if (fContexts[i]->fType == type && 29 if (fContexts[i]->fType == type &&
31 fContexts[i]->fOptions == options && 30 fContexts[i]->fOptions == options) {
32 (forcedGpuAPI == kNone_GrGLStandard ||
33 forcedGpuAPI == fContexts[i]->fGLContext->gl()->fStandard)) {
34 fContexts[i]->fGLContext->makeCurrent(); 31 fContexts[i]->fGLContext->makeCurrent();
35 return fContexts[i]; 32 return fContexts[i];
36 } 33 }
37 } 34 }
38 SkAutoTUnref<SkGLContext> glCtx; 35 SkAutoTUnref<SkGLContext> glCtx;
39 SkAutoTUnref<GrContext> grCtx; 36 SkAutoTUnref<GrContext> grCtx;
40 switch (type) { 37 switch (type) {
41 case kNative_GLContextType: 38 case kNative_GLContextType:
42 glCtx.reset(SkCreatePlatformGLContext(forcedGpuAPI)); 39 glCtx.reset(SkCreatePlatformGLContext(kNone_GrGLStandard));
43 break; 40 break;
44 #ifdef SK_ANGLE 41 case kGL_GLContextType:
42 glCtx.reset(SkCreatePlatformGLContext(kGL_GrGLStandard));
43 break;
44 case kGLES_GLContextType:
45 glCtx.reset(SkCreatePlatformGLContext(kGLES_GrGLStandard));
46 break;
47 #if SK_ANGLE
48 #ifdef SK_BUILD_FOR_WIN
45 case kANGLE_GLContextType: 49 case kANGLE_GLContextType:
46 glCtx.reset(SkANGLEGLContext::Create(forcedGpuAPI, false)); 50 glCtx.reset(SkANGLEGLContext::CreateDirectX());
47 break;
48 case kANGLE_GL_GLContextType:
49 glCtx.reset(SkANGLEGLContext::Create(forcedGpuAPI, true));
50 break; 51 break;
51 #endif 52 #endif
52 #ifdef SK_COMMAND_BUFFER 53 case kANGLE_GL_GLContextType:
53 case kCommandBuffer_GLContextType: 54 glCtx.reset(SkANGLEGLContext::CreateOpenGL());
54 glCtx.reset(SkCommandBufferGLContext::Create(forcedGpuAPI));
55 break; 55 break;
56 #endif 56 #endif
57 #ifdef SK_MESA 57 #if SK_COMMAND_BUFFER
58 case kCommandBuffer_GLContextType:
59 glCtx.reset(SkCommandBufferGLContext::Create());
60 break;
61 #endif
62 #if SK_MESA
58 case kMESA_GLContextType: 63 case kMESA_GLContextType:
59 glCtx.reset(SkMesaGLContext::Create(forcedGpuAPI)); 64 glCtx.reset(SkMesaGLContext::Create());
60 break; 65 break;
61 #endif 66 #endif
62 case kNull_GLContextType: 67 case kNull_GLContextType:
63 glCtx.reset(SkNullGLContext::Create(forcedGpuAPI)); 68 glCtx.reset(SkNullGLContext::Create());
64 break; 69 break;
65 case kDebug_GLContextType: 70 case kDebug_GLContextType:
66 glCtx.reset(SkDebugGLContext::Create(forcedGpuAPI)); 71 glCtx.reset(SkDebugGLContext::Create());
67 break; 72 break;
68 } 73 }
69 if (nullptr == glCtx.get()) { 74 if (nullptr == glCtx.get()) {
70 return nullptr; 75 return nullptr;
71 } 76 }
72 77
73 SkASSERT(glCtx->isValid()); 78 SkASSERT(glCtx->isValid());
74 79
75 // Block NVPR from non-NVPR types. 80 // Block NVPR from non-NVPR types.
76 SkAutoTUnref<const GrGLInterface> glInterface(SkRef(glCtx->gl())); 81 SkAutoTUnref<const GrGLInterface> glInterface(SkRef(glCtx->gl()));
(...skipping 20 matching lines...) Expand all
97 } 102 }
98 } 103 }
99 104
100 ContextInfo* ctx = fContexts.emplace_back(new ContextInfo); 105 ContextInfo* ctx = fContexts.emplace_back(new ContextInfo);
101 ctx->fGLContext = SkRef(glCtx.get()); 106 ctx->fGLContext = SkRef(glCtx.get());
102 ctx->fGrContext = SkRef(grCtx.get()); 107 ctx->fGrContext = SkRef(grCtx.get());
103 ctx->fType = type; 108 ctx->fType = type;
104 ctx->fOptions = options; 109 ctx->fOptions = options;
105 return ctx; 110 return ctx;
106 } 111 }
OLDNEW
« no previous file with comments | « src/gpu/GrContextFactory.h ('k') | src/gpu/gl/SkNullGLContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698