| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/plugins/ppapi/ppb_context_3d_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_context_3d_impl.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/shared_memory.h" | 8 #include "base/shared_memory.h" |
| 9 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 9 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
| 10 #include "gpu/command_buffer/client/gles2_implementation.h" | 10 #include "gpu/command_buffer/client/gles2_implementation.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 PPB_Surface3D_Impl* new_read = | 145 PPB_Surface3D_Impl* new_read = |
| 146 static_cast<PPB_Surface3D_Impl*>(enter_read.object()); | 146 static_cast<PPB_Surface3D_Impl*>(enter_read.object()); |
| 147 return BindSurfacesImpl(new_draw, new_read); | 147 return BindSurfacesImpl(new_draw, new_read); |
| 148 } | 148 } |
| 149 | 149 |
| 150 int32_t PPB_Context3D_Impl::BindSurfacesImpl(PPB_Surface3D_Impl* new_draw, | 150 int32_t PPB_Context3D_Impl::BindSurfacesImpl(PPB_Surface3D_Impl* new_draw, |
| 151 PPB_Surface3D_Impl* new_read) { | 151 PPB_Surface3D_Impl* new_read) { |
| 152 // TODO(alokp): Support separate draw-read surfaces. | 152 // TODO(alokp): Support separate draw-read surfaces. |
| 153 DCHECK_EQ(new_draw, new_read); | 153 DCHECK_EQ(new_draw, new_read); |
| 154 if (new_draw != new_read) | 154 if (new_draw != new_read) |
| 155 return PP_GRAPHICS3DERROR_BAD_MATCH; | 155 return PP_ERROR_NOTSUPPORTED; |
| 156 | 156 |
| 157 if (new_draw == draw_surface_) | 157 if (new_draw == draw_surface_) |
| 158 return PP_OK; | 158 return PP_OK; |
| 159 | 159 |
| 160 if (new_draw && new_draw->context()) | 160 if (new_draw && new_draw->context()) |
| 161 return PP_GRAPHICS3DERROR_BAD_ACCESS; // Already bound. | 161 return PP_ERROR_BADARGUMENT; // Already bound. |
| 162 | 162 |
| 163 if (draw_surface_) | 163 if (draw_surface_) |
| 164 draw_surface_->BindToContext(NULL); | 164 draw_surface_->BindToContext(NULL); |
| 165 if (new_draw && !new_draw->BindToContext(this)) | 165 if (new_draw && !new_draw->BindToContext(this)) |
| 166 return PP_ERROR_NOMEMORY; | 166 return PP_ERROR_NOMEMORY; |
| 167 | 167 |
| 168 draw_surface_ = new_draw; | 168 draw_surface_ = new_draw; |
| 169 read_surface_ = new_read; | 169 read_surface_ = new_read; |
| 170 return PP_OK; | 170 return PP_OK; |
| 171 } | 171 } |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 } | 295 } |
| 296 | 296 |
| 297 static const int32 kAttribs[] = { | 297 static const int32 kAttribs[] = { |
| 298 PP_GRAPHICS3DATTRIB_ALPHA_SIZE, 8, | 298 PP_GRAPHICS3DATTRIB_ALPHA_SIZE, 8, |
| 299 PP_GRAPHICS3DATTRIB_DEPTH_SIZE, 24, | 299 PP_GRAPHICS3DATTRIB_DEPTH_SIZE, 24, |
| 300 PP_GRAPHICS3DATTRIB_STENCIL_SIZE, 8, | 300 PP_GRAPHICS3DATTRIB_STENCIL_SIZE, 8, |
| 301 PP_GRAPHICS3DATTRIB_SAMPLES, 0, | 301 PP_GRAPHICS3DATTRIB_SAMPLES, 0, |
| 302 PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS, 0, | 302 PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS, 0, |
| 303 PP_GRAPHICS3DATTRIB_HEIGHT, 1, | 303 PP_GRAPHICS3DATTRIB_HEIGHT, 1, |
| 304 PP_GRAPHICS3DATTRIB_WIDTH, 1, | 304 PP_GRAPHICS3DATTRIB_WIDTH, 1, |
| 305 PP_GRAPHICS3DATTRIBVALUE_NONE, | 305 PP_GRAPHICS3DATTRIB_NONE, |
| 306 }; | 306 }; |
| 307 if (!platform_context_->Init(kAttribs)) { | 307 if (!platform_context_->Init(kAttribs)) { |
| 308 Destroy(); | 308 Destroy(); |
| 309 return false; | 309 return false; |
| 310 } | 310 } |
| 311 | 311 |
| 312 platform_context_->SetContextLostCallback( | 312 platform_context_->SetContextLostCallback( |
| 313 callback_factory_.NewCallback(&PPB_Context3D_Impl::OnContextLost)); | 313 callback_factory_.NewCallback(&PPB_Context3D_Impl::OnContextLost)); |
| 314 return true; | 314 return true; |
| 315 } | 315 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 | 368 |
| 369 void PPB_Context3D_Impl::OnContextLost() { | 369 void PPB_Context3D_Impl::OnContextLost() { |
| 370 if (draw_surface_) | 370 if (draw_surface_) |
| 371 draw_surface_->OnContextLost(); | 371 draw_surface_->OnContextLost(); |
| 372 if (read_surface_) | 372 if (read_surface_) |
| 373 read_surface_->OnContextLost(); | 373 read_surface_->OnContextLost(); |
| 374 } | 374 } |
| 375 | 375 |
| 376 } // namespace ppapi | 376 } // namespace ppapi |
| 377 } // namespace webkit | 377 } // namespace webkit |
| OLD | NEW |