OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 5 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
6 #include "gpu/command_buffer/client/gles2_implementation.h" | 6 #include "gpu/command_buffer/client/gles2_implementation.h" |
7 #include "gpu/command_buffer/client/gles2_lib.h" | 7 #include "gpu/command_buffer/client/gles2_lib.h" |
8 #include "gpu/pgl/command_buffer_pepper.h" | 8 #include "gpu/pgl/command_buffer_pepper.h" |
9 #include "gpu/pgl/pgl.h" | 9 #include "gpu/pgl/pgl.h" |
10 | 10 |
11 #if defined(_MSC_VER) | |
12 #define THREAD_LOCAL __declspec(thread) | |
13 #else | |
14 #define THREAD_LOCAL __thread | |
15 #endif | |
16 | |
17 namespace { | 11 namespace { |
18 const int32 kTransferBufferSize = 512 * 1024; | 12 const int32 kTransferBufferSize = 512 * 1024; |
19 | 13 |
20 class PGLContextImpl { | 14 class PGLContextImpl { |
21 public: | 15 public: |
22 PGLContextImpl(NPP npp, | 16 PGLContextImpl(NPP npp, |
23 NPDevice* device, | 17 NPDevice* device, |
24 NPDeviceContext3D* device_context); | 18 NPDeviceContext3D* device_context); |
25 ~PGLContextImpl(); | 19 ~PGLContextImpl(); |
26 | 20 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 delete gles2_helper_; | 98 delete gles2_helper_; |
105 gles2_helper_ = NULL; | 99 gles2_helper_ = NULL; |
106 | 100 |
107 delete command_buffer_; | 101 delete command_buffer_; |
108 command_buffer_ = NULL; | 102 command_buffer_ = NULL; |
109 } | 103 } |
110 | 104 |
111 bool PGLContextImpl::MakeCurrent(PGLContextImpl* pgl_context) { | 105 bool PGLContextImpl::MakeCurrent(PGLContextImpl* pgl_context) { |
112 g_current_pgl_context = pgl_context; | 106 g_current_pgl_context = pgl_context; |
113 if (pgl_context) | 107 if (pgl_context) |
114 gles2::g_gl_impl = pgl_context->gles2_implementation_; | 108 gles2::SetGLContext(pgl_context->gles2_implementation_); |
115 else | 109 else |
116 gles2::g_gl_impl = NULL; | 110 gles2::SetGLContext(NULL); |
117 | 111 |
118 return true; | 112 return true; |
119 } | 113 } |
120 | 114 |
121 bool PGLContextImpl::SwapBuffers() { | 115 bool PGLContextImpl::SwapBuffers() { |
122 gles2_implementation_->SwapBuffers(); | 116 gles2_implementation_->SwapBuffers(); |
123 return true; | 117 return true; |
124 } | 118 } |
125 } // namespace anonymous | 119 } // namespace anonymous |
126 | 120 |
127 extern "C" { | 121 extern "C" { |
128 | 122 |
129 PGLContext pglCreateContext(NPP npp, | 123 PGLContext pglCreateContext(NPP npp, |
130 NPDevice* device, | 124 NPDevice* device, |
131 NPDeviceContext3D* device_context) { | 125 NPDeviceContext3D* device_context) { |
132 PGLContextImpl* pgl_context = new PGLContextImpl( | 126 PGLContextImpl* pgl_context = new PGLContextImpl( |
133 npp, device, device_context); | 127 npp, device, device_context); |
134 if (pgl_context->Initialize(kTransferBufferSize)) { | 128 if (pgl_context->Initialize(kTransferBufferSize)) { |
135 return pgl_context; | 129 return pgl_context; |
136 } | 130 } |
137 | 131 |
138 delete pgl_context; | 132 delete pgl_context; |
139 return NULL; | 133 return NULL; |
140 } | 134 } |
141 | 135 |
142 PGLBoolean pglMakeCurrent(PGLContext pgl_context) { | 136 PGLBoolean pglMakeCurrent(PGLContext pgl_context) { |
143 return PGLContextImpl::MakeCurrent(static_cast<PGLContextImpl*>(pgl_context)); | 137 return PGLContextImpl::MakeCurrent(static_cast<PGLContextImpl*>(pgl_context)); |
144 } | 138 } |
145 | 139 |
146 PGLBoolean pglSwapBuffers() { | 140 PGLContext pglGetCurrentContext(void) { |
| 141 return g_current_pgl_context; |
| 142 } |
| 143 |
| 144 PGLBoolean pglSwapBuffers(void) { |
147 if (!g_current_pgl_context) | 145 if (!g_current_pgl_context) |
148 return false; | 146 return false; |
149 | 147 |
150 return g_current_pgl_context->SwapBuffers(); | 148 return g_current_pgl_context->SwapBuffers(); |
151 } | 149 } |
152 | 150 |
153 PGLBoolean pglDestroyContext(PGLContext pgl_context) { | 151 PGLBoolean pglDestroyContext(PGLContext pgl_context) { |
154 if (!pgl_context) | 152 if (!pgl_context) |
155 return false; | 153 return false; |
156 | 154 |
157 delete static_cast<PGLContextImpl*>(pgl_context); | 155 delete static_cast<PGLContextImpl*>(pgl_context); |
158 return true; | 156 return true; |
159 } | 157 } |
160 | 158 |
161 } // extern "C" | 159 } // extern "C" |
OLD | NEW |