| 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_graphics_3d_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "gpu/command_buffer/client/gles2_implementation.h" | 8 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 9 #include "webkit/plugins/ppapi/plugin_module.h" | 9 #include "webkit/plugins/ppapi/plugin_module.h" |
| 10 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 10 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 | 134 |
| 135 PP_Graphics3DTrustedState PPB_Graphics3D_Impl::FlushSyncFast( | 135 PP_Graphics3DTrustedState PPB_Graphics3D_Impl::FlushSyncFast( |
| 136 int32_t put_offset, | 136 int32_t put_offset, |
| 137 int32_t last_known_get) { | 137 int32_t last_known_get) { |
| 138 return PPStateFromGPUState( | 138 return PPStateFromGPUState( |
| 139 GetCommandBuffer()->FlushSync(put_offset, last_known_get)); | 139 GetCommandBuffer()->FlushSync(put_offset, last_known_get)); |
| 140 } | 140 } |
| 141 | 141 |
| 142 bool PPB_Graphics3D_Impl::BindToInstance(bool bind) { | 142 bool PPB_Graphics3D_Impl::BindToInstance(bool bind) { |
| 143 bound_to_instance_ = bind; | 143 bound_to_instance_ = bind; |
| 144 if (bind && gles2_impl()) { | |
| 145 // Resize the backing texture to the size of the instance when it is bound. | |
| 146 // TODO(alokp): This should be the responsibility of plugins. | |
| 147 const gfx::Size& size = instance()->position().size(); | |
| 148 gles2_impl()->ResizeCHROMIUM(size.width(), size.height()); | |
| 149 } | |
| 150 return true; | 144 return true; |
| 151 } | 145 } |
| 152 | 146 |
| 153 unsigned int PPB_Graphics3D_Impl::GetBackingTextureId() { | 147 unsigned int PPB_Graphics3D_Impl::GetBackingTextureId() { |
| 154 return platform_context_->GetBackingTextureId(); | 148 return platform_context_->GetBackingTextureId(); |
| 155 } | 149 } |
| 156 | 150 |
| 157 void PPB_Graphics3D_Impl::ViewInitiatedPaint() { | 151 void PPB_Graphics3D_Impl::ViewInitiatedPaint() { |
| 158 } | 152 } |
| 159 | 153 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 const int32_t* attrib_list) { | 190 const int32_t* attrib_list) { |
| 197 // TODO(alokp): Support shared context. | 191 // TODO(alokp): Support shared context. |
| 198 DCHECK_EQ(0, share_context); | 192 DCHECK_EQ(0, share_context); |
| 199 if (share_context != 0) | 193 if (share_context != 0) |
| 200 return 0; | 194 return 0; |
| 201 | 195 |
| 202 platform_context_.reset(instance()->CreateContext3D()); | 196 platform_context_.reset(instance()->CreateContext3D()); |
| 203 if (!platform_context_.get()) | 197 if (!platform_context_.get()) |
| 204 return false; | 198 return false; |
| 205 | 199 |
| 206 if (!platform_context_->Init()) | 200 if (!platform_context_->Init(attrib_list)) |
| 207 return false; | 201 return false; |
| 208 | 202 |
| 209 platform_context_->SetContextLostCallback( | 203 platform_context_->SetContextLostCallback( |
| 210 callback_factory_.NewCallback(&PPB_Graphics3D_Impl::OnContextLost)); | 204 callback_factory_.NewCallback(&PPB_Graphics3D_Impl::OnContextLost)); |
| 211 platform_context_->SetSwapBuffersCallback( | 205 platform_context_->SetSwapBuffersCallback( |
| 212 callback_factory_.NewCallback(&PPB_Graphics3D_Impl::OnSwapBuffers)); | 206 callback_factory_.NewCallback(&PPB_Graphics3D_Impl::OnSwapBuffers)); |
| 213 return true; | 207 return true; |
| 214 } | 208 } |
| 215 | 209 |
| 216 void PPB_Graphics3D_Impl::OnSwapBuffers() { | 210 void PPB_Graphics3D_Impl::OnSwapBuffers() { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 const PPP_Graphics3D_Dev* ppp_graphics_3d = | 243 const PPP_Graphics3D_Dev* ppp_graphics_3d = |
| 250 static_cast<const PPP_Graphics3D_Dev*>( | 244 static_cast<const PPP_Graphics3D_Dev*>( |
| 251 instance()->module()->GetPluginInterface( | 245 instance()->module()->GetPluginInterface( |
| 252 PPP_GRAPHICS_3D_DEV_INTERFACE)); | 246 PPP_GRAPHICS_3D_DEV_INTERFACE)); |
| 253 if (ppp_graphics_3d) | 247 if (ppp_graphics_3d) |
| 254 ppp_graphics_3d->Graphics3DContextLost(instance()->pp_instance()); | 248 ppp_graphics_3d->Graphics3DContextLost(instance()->pp_instance()); |
| 255 } | 249 } |
| 256 | 250 |
| 257 } // namespace ppapi | 251 } // namespace ppapi |
| 258 } // namespace webkit | 252 } // namespace webkit |
| OLD | NEW |