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