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 <build/build_config.h> | 5 #include <build/build_config.h> |
6 | 6 |
7 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 7 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
8 #include "gpu/command_buffer/client/gles2_implementation.h" | 8 #include "gpu/command_buffer/client/gles2_implementation.h" |
9 #include "gpu/command_buffer/client/gles2_lib.h" | 9 #include "gpu/command_buffer/client/gles2_lib.h" |
10 #include "gpu/command_buffer/common/constants.h" | 10 #include "gpu/command_buffer/common/constants.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 116 |
117 gpu::ThreadLocalSetValue(g_pgl_context_key, pgl_context); | 117 gpu::ThreadLocalSetValue(g_pgl_context_key, pgl_context); |
118 if (pgl_context) { | 118 if (pgl_context) { |
119 gles2::SetGLContext(pgl_context->gles2_implementation_); | 119 gles2::SetGLContext(pgl_context->gles2_implementation_); |
120 | 120 |
121 // Don't request latest error status from service. Just use the locally | 121 // Don't request latest error status from service. Just use the locally |
122 // cached information from the last flush. | 122 // cached information from the last flush. |
123 // TODO(apatrick): I'm not sure if this should actually change the | 123 // TODO(apatrick): I'm not sure if this should actually change the |
124 // current context if it fails. For now it gets changed even if it fails | 124 // current context if it fails. For now it gets changed even if it fails |
125 // becuase making GL calls with a NULL context crashes. | 125 // becuase making GL calls with a NULL context crashes. |
| 126 #if defined(ENABLE_NEW_NPDEVICE_API) |
| 127 if (pgl_context->command_buffer_->GetCachedError() != gpu::error::kNoError) |
| 128 return PGL_FALSE; |
| 129 #else |
126 if (pgl_context->device_context_->error != NPDeviceContext3DError_NoError) | 130 if (pgl_context->device_context_->error != NPDeviceContext3DError_NoError) |
127 return PGL_FALSE; | 131 return PGL_FALSE; |
| 132 #endif |
128 } | 133 } |
129 else { | 134 else { |
130 gles2::SetGLContext(NULL); | 135 gles2::SetGLContext(NULL); |
131 } | 136 } |
132 | 137 |
133 return PGL_TRUE; | 138 return PGL_TRUE; |
134 } | 139 } |
135 | 140 |
136 PGLBoolean PGLContextImpl::SwapBuffers() { | 141 PGLBoolean PGLContextImpl::SwapBuffers() { |
137 // Don't request latest error status from service. Just use the locally cached | 142 // Don't request latest error status from service. Just use the locally cached |
138 // information from the last flush. | 143 // information from the last flush. |
| 144 #if defined(ENABLE_NEW_NPDEVICE_API) |
| 145 if (command_buffer_->GetCachedError() != gpu::error::kNoError) |
| 146 return PGL_FALSE; |
| 147 #else |
139 if (device_context_->error != NPDeviceContext3DError_NoError) | 148 if (device_context_->error != NPDeviceContext3DError_NoError) |
140 return PGL_FALSE; | 149 return PGL_FALSE; |
| 150 #endif |
141 | 151 |
142 gles2_implementation_->SwapBuffers(); | 152 gles2_implementation_->SwapBuffers(); |
143 return PGL_TRUE; | 153 return PGL_TRUE; |
144 } | 154 } |
145 | 155 |
146 PGLInt PGLContextImpl::GetError() { | 156 PGLInt PGLContextImpl::GetError() { |
147 gpu::CommandBuffer::State state = command_buffer_->GetState(); | 157 gpu::CommandBuffer::State state = command_buffer_->GetState(); |
148 if (state.error == gpu::error::kNoError) { | 158 if (state.error == gpu::error::kNoError) { |
149 return PGL_SUCCESS; | 159 return PGL_SUCCESS; |
150 } else { | 160 } else { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 return PGL_NOT_INITIALIZED; | 244 return PGL_NOT_INITIALIZED; |
235 | 245 |
236 PGLContextImpl* context = static_cast<PGLContextImpl*>( | 246 PGLContextImpl* context = static_cast<PGLContextImpl*>( |
237 pglGetCurrentContext()); | 247 pglGetCurrentContext()); |
238 if (!context) | 248 if (!context) |
239 return PGL_BAD_CONTEXT; | 249 return PGL_BAD_CONTEXT; |
240 | 250 |
241 return context->GetError(); | 251 return context->GetError(); |
242 } | 252 } |
243 } // extern "C" | 253 } // extern "C" |
OLD | NEW |