| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ppapi/shared_impl/ppb_graphics_3d_shared.h" | 5 #include "ppapi/shared_impl/ppb_graphics_3d_shared.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 8 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
| 9 #include "gpu/command_buffer/client/gles2_implementation.h" | 9 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 10 #include "gpu/command_buffer/client/transfer_buffer.h" | 10 #include "gpu/command_buffer/client/transfer_buffer.h" |
| 11 #include "ppapi/c/pp_errors.h" | 11 #include "ppapi/c/pp_errors.h" |
| 12 | 12 |
| 13 namespace ppapi { | 13 namespace ppapi { |
| 14 | 14 |
| 15 PPB_Graphics3D_Shared::PPB_Graphics3D_Shared(PP_Instance instance) | 15 PPB_Graphics3D_Shared::PPB_Graphics3D_Shared(PP_Instance instance) |
| 16 : Resource(OBJECT_IS_IMPL, instance) { | 16 : Resource(OBJECT_IS_IMPL, instance) {} |
| 17 } | |
| 18 | 17 |
| 19 PPB_Graphics3D_Shared::PPB_Graphics3D_Shared(const HostResource& host_resource) | 18 PPB_Graphics3D_Shared::PPB_Graphics3D_Shared(const HostResource& host_resource) |
| 20 : Resource(OBJECT_IS_PROXY, host_resource) { | 19 : Resource(OBJECT_IS_PROXY, host_resource) {} |
| 21 } | |
| 22 | 20 |
| 23 PPB_Graphics3D_Shared::~PPB_Graphics3D_Shared() { | 21 PPB_Graphics3D_Shared::~PPB_Graphics3D_Shared() { |
| 24 // Make sure that GLES2 implementation has already been destroyed. | 22 // Make sure that GLES2 implementation has already been destroyed. |
| 25 DCHECK(!gles2_helper_.get()); | 23 DCHECK(!gles2_helper_.get()); |
| 26 DCHECK(!transfer_buffer_.get()); | 24 DCHECK(!transfer_buffer_.get()); |
| 27 DCHECK(!gles2_impl_.get()); | 25 DCHECK(!gles2_impl_.get()); |
| 28 } | 26 } |
| 29 | 27 |
| 30 thunk::PPB_Graphics3D_API* PPB_Graphics3D_Shared::AsPPB_Graphics3D_API() { | 28 thunk::PPB_Graphics3D_API* PPB_Graphics3D_Shared::AsPPB_Graphics3D_API() { |
| 31 return this; | 29 return this; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 51 return PP_ERROR_BADARGUMENT; | 49 return PP_ERROR_BADARGUMENT; |
| 52 | 50 |
| 53 gles2_impl()->ResizeCHROMIUM(width, height, 1.f); | 51 gles2_impl()->ResizeCHROMIUM(width, height, 1.f); |
| 54 // TODO(alokp): Check if resize succeeded and return appropriate error code. | 52 // TODO(alokp): Check if resize succeeded and return appropriate error code. |
| 55 return PP_OK; | 53 return PP_OK; |
| 56 } | 54 } |
| 57 | 55 |
| 58 int32_t PPB_Graphics3D_Shared::SwapBuffers( | 56 int32_t PPB_Graphics3D_Shared::SwapBuffers( |
| 59 scoped_refptr<TrackedCallback> callback) { | 57 scoped_refptr<TrackedCallback> callback) { |
| 60 if (HasPendingSwap()) { | 58 if (HasPendingSwap()) { |
| 61 Log(PP_LOGLEVEL_ERROR, "PPB_Graphics3D.SwapBuffers: Plugin attempted swap " | 59 Log(PP_LOGLEVEL_ERROR, |
| 62 "with previous swap still pending."); | 60 "PPB_Graphics3D.SwapBuffers: Plugin attempted swap " |
| 61 "with previous swap still pending."); |
| 63 // Already a pending SwapBuffers that hasn't returned yet. | 62 // Already a pending SwapBuffers that hasn't returned yet. |
| 64 return PP_ERROR_INPROGRESS; | 63 return PP_ERROR_INPROGRESS; |
| 65 } | 64 } |
| 66 | 65 |
| 67 swap_callback_ = callback; | 66 swap_callback_ = callback; |
| 68 return DoSwapBuffers(); | 67 return DoSwapBuffers(); |
| 69 } | 68 } |
| 70 | 69 |
| 71 int32_t PPB_Graphics3D_Shared::GetAttribMaxValue(int32_t attribute, | 70 int32_t PPB_Graphics3D_Shared::GetAttribMaxValue(int32_t attribute, |
| 72 int32_t* value) { | 71 int32_t* value) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 // Create the object exposing the OpenGL API. | 123 // Create the object exposing the OpenGL API. |
| 125 gles2_impl_.reset(new gpu::gles2::GLES2Implementation( | 124 gles2_impl_.reset(new gpu::gles2::GLES2Implementation( |
| 126 gles2_helper_.get(), | 125 gles2_helper_.get(), |
| 127 share_gles2 ? share_gles2->share_group() : NULL, | 126 share_gles2 ? share_gles2->share_group() : NULL, |
| 128 transfer_buffer_.get(), | 127 transfer_buffer_.get(), |
| 129 bind_creates_resources, | 128 bind_creates_resources, |
| 130 free_everything_when_invisible, | 129 free_everything_when_invisible, |
| 131 GetGpuControl())); | 130 GetGpuControl())); |
| 132 | 131 |
| 133 if (!gles2_impl_->Initialize( | 132 if (!gles2_impl_->Initialize( |
| 134 transfer_buffer_size, | 133 transfer_buffer_size, |
| 135 kMinTransferBufferSize, | 134 kMinTransferBufferSize, |
| 136 std::max(kMaxTransferBufferSize, transfer_buffer_size), | 135 std::max(kMaxTransferBufferSize, transfer_buffer_size), |
| 137 gpu::gles2::GLES2Implementation::kNoLimit)) { | 136 gpu::gles2::GLES2Implementation::kNoLimit)) { |
| 138 return false; | 137 return false; |
| 139 } | 138 } |
| 140 | 139 |
| 141 gles2_impl_->PushGroupMarkerEXT(0, "PPAPIContext"); | 140 gles2_impl_->PushGroupMarkerEXT(0, "PPAPIContext"); |
| 142 | 141 |
| 143 return true; | 142 return true; |
| 144 } | 143 } |
| 145 | 144 |
| 146 void PPB_Graphics3D_Shared::DestroyGLES2Impl() { | 145 void PPB_Graphics3D_Shared::DestroyGLES2Impl() { |
| 147 gles2_impl_.reset(); | 146 gles2_impl_.reset(); |
| 148 transfer_buffer_.reset(); | 147 transfer_buffer_.reset(); |
| 149 gles2_helper_.reset(); | 148 gles2_helper_.reset(); |
| 150 } | 149 } |
| 151 | 150 |
| 152 } // namespace ppapi | 151 } // namespace ppapi |
| 153 | |
| OLD | NEW |