OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 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 #include "SkTypes.h" | 8 #include "SkTypes.h" |
9 #if defined(SK_BUILD_FOR_MAC) | |
10 | 9 |
11 #include "gl/SkGLContext.h" | 10 #include "gl/GLContext.h" |
12 #include "AvailabilityMacros.h" | 11 #include "AvailabilityMacros.h" |
13 | 12 |
14 #include <OpenGL/OpenGL.h> | 13 #include <OpenGL/OpenGL.h> |
15 #include <dlfcn.h> | 14 #include <dlfcn.h> |
16 | 15 |
17 namespace { | 16 namespace { |
18 class MacGLContext : public SkGLContext { | 17 class MacGLContext : public sk_gpu_test::GLContext { |
19 public: | 18 public: |
20 MacGLContext(); | 19 MacGLContext(); |
21 ~MacGLContext() override; | 20 ~MacGLContext() override; |
22 | 21 |
23 private: | 22 private: |
24 void destroyGLContext(); | 23 void destroyGLContext(); |
25 | 24 |
26 void onPlatformMakeCurrent() const override; | 25 void onPlatformMakeCurrent() const override; |
27 void onPlatformSwapBuffers() const override; | 26 void onPlatformSwapBuffers() const override; |
28 GrGLFuncPtr onPlatformGetProcAddress(const char*) const override; | 27 GrGLFuncPtr onPlatformGetProcAddress(const char*) const override; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 } | 99 } |
101 | 100 |
102 void MacGLContext::onPlatformSwapBuffers() const { | 101 void MacGLContext::onPlatformSwapBuffers() const { |
103 CGLFlushDrawable(fContext); | 102 CGLFlushDrawable(fContext); |
104 } | 103 } |
105 | 104 |
106 GrGLFuncPtr MacGLContext::onPlatformGetProcAddress(const char* procName) const { | 105 GrGLFuncPtr MacGLContext::onPlatformGetProcAddress(const char* procName) const { |
107 return reinterpret_cast<GrGLFuncPtr>(dlsym(fGLLibrary, procName)); | 106 return reinterpret_cast<GrGLFuncPtr>(dlsym(fGLLibrary, procName)); |
108 } | 107 } |
109 | 108 |
110 } // anonymous namespace | 109 } // anonymous namespace |
111 | 110 |
112 SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI, SkGLContext* s
hareContext) { | 111 namespace sk_gpu_test { |
| 112 GLContext* CreatePlatformGLContext(GrGLStandard forcedGpuAPI, GLContext* shareCo
ntext) { |
113 SkASSERT(!shareContext); | 113 SkASSERT(!shareContext); |
114 if (shareContext) { | 114 if (shareContext) { |
115 return nullptr; | 115 return nullptr; |
116 } | 116 } |
117 | 117 |
118 if (kGLES_GrGLStandard == forcedGpuAPI) { | 118 if (kGLES_GrGLStandard == forcedGpuAPI) { |
119 return nullptr; | 119 return nullptr; |
120 } | 120 } |
121 MacGLContext* ctx = new MacGLContext; | 121 MacGLContext* ctx = new MacGLContext; |
122 if (!ctx->isValid()) { | 122 if (!ctx->isValid()) { |
123 delete ctx; | 123 delete ctx; |
124 return nullptr; | 124 return nullptr; |
125 } | 125 } |
126 return ctx; | 126 return ctx; |
127 } | 127 } |
128 | 128 } // namespace sk_gpu_test |
129 #endif//defined(SK_BUILD_FOR_MAC) | |
OLD | NEW |