Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: webkit/plugins/ppapi/ppb_surface_3d_impl.cc

Issue 7762013: Added GPU process "echo" IPC message. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/plugins/ppapi/ppb_surface_3d_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_surface_3d_impl.h" 5 #include "webkit/plugins/ppapi/ppb_surface_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 "gpu/command_buffer/common/command_buffer.h" 9 #include "gpu/command_buffer/common/command_buffer.h"
10 #include "ppapi/c/dev/ppb_graphics_3d_dev.h" 10 #include "ppapi/c/dev/ppb_graphics_3d_dev.h"
11 #include "ppapi/c/dev/ppp_graphics_3d_dev.h" 11 #include "ppapi/c/dev/ppp_graphics_3d_dev.h"
12 #include "webkit/plugins/ppapi/common.h" 12 #include "webkit/plugins/ppapi/common.h"
13 #include "webkit/plugins/ppapi/plugin_module.h" 13 #include "webkit/plugins/ppapi/plugin_module.h"
14 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 14 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
15 #include "webkit/plugins/ppapi/ppb_context_3d_impl.h" 15 #include "webkit/plugins/ppapi/ppb_context_3d_impl.h"
16 #include "webkit/plugins/ppapi/resource_helper.h" 16 #include "webkit/plugins/ppapi/resource_helper.h"
17 17
18 using ppapi::thunk::PPB_Surface3D_API; 18 using ppapi::thunk::PPB_Surface3D_API;
19 19
20 namespace webkit { 20 namespace webkit {
21 namespace ppapi { 21 namespace ppapi {
22 22
23 PPB_Surface3D_Impl::PPB_Surface3D_Impl(PP_Instance instance) 23 PPB_Surface3D_Impl::PPB_Surface3D_Impl(PP_Instance instance)
24 : Resource(instance), 24 : Resource(instance),
25 bound_to_instance_(false), 25 bound_to_instance_(false),
26 swap_initiated_(false), 26 swap_initiated_(false),
27 context_(NULL) { 27 context_(NULL),
28 method_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
28 } 29 }
29 30
30 PPB_Surface3D_Impl::~PPB_Surface3D_Impl() { 31 PPB_Surface3D_Impl::~PPB_Surface3D_Impl() {
31 if (context_) 32 if (context_)
32 context_->BindSurfacesImpl(NULL, NULL); 33 context_->BindSurfacesImpl(NULL, NULL);
33 } 34 }
34 35
35 // static 36 // static
36 PP_Resource PPB_Surface3D_Impl::Create(PP_Instance instance, 37 PP_Resource PPB_Surface3D_Impl::Create(PP_Instance instance,
37 PP_Config3D_Dev config, 38 PP_Config3D_Dev config,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 75
75 PluginModule* plugin_module = ResourceHelper::GetPluginModule(this); 76 PluginModule* plugin_module = ResourceHelper::GetPluginModule(this);
76 if (!plugin_module) 77 if (!plugin_module)
77 return PP_ERROR_FAILED; 78 return PP_ERROR_FAILED;
78 79
79 swap_callback_ = new TrackedCompletionCallback( 80 swap_callback_ = new TrackedCompletionCallback(
80 plugin_module->GetCallbackTracker(), pp_resource(), callback); 81 plugin_module->GetCallbackTracker(), pp_resource(), callback);
81 gpu::gles2::GLES2Implementation* impl = context_->gles2_impl(); 82 gpu::gles2::GLES2Implementation* impl = context_->gles2_impl();
82 if (impl) 83 if (impl)
83 context_->gles2_impl()->SwapBuffers(); 84 context_->gles2_impl()->SwapBuffers();
85 context_->platform_context()->Echo(method_factory_.NewRunnableMethod(
86 &PPB_Surface3D_Impl::OnSwapBuffers));
84 // |SwapBuffers()| should not call us back synchronously, but double-check. 87 // |SwapBuffers()| should not call us back synchronously, but double-check.
85 DCHECK(!swap_callback_->completed()); 88 DCHECK(!swap_callback_->completed());
86 return PP_OK_COMPLETIONPENDING; 89 return PP_OK_COMPLETIONPENDING;
87 } 90 }
88 91
89 bool PPB_Surface3D_Impl::Init(PP_Config3D_Dev config, 92 bool PPB_Surface3D_Impl::Init(PP_Config3D_Dev config,
90 const int32_t* attrib_list) { 93 const int32_t* attrib_list) {
91 return true; 94 return true;
92 } 95 }
93 96
94 bool PPB_Surface3D_Impl::BindToInstance(bool bind) { 97 bool PPB_Surface3D_Impl::BindToInstance(bool bind) {
95 bound_to_instance_ = bind; 98 bound_to_instance_ = bind;
96 return true; 99 return true;
97 } 100 }
98 101
99 bool PPB_Surface3D_Impl::BindToContext(PPB_Context3D_Impl* context) { 102 bool PPB_Surface3D_Impl::BindToContext(PPB_Context3D_Impl* context) {
100 if (context == context_) 103 if (context == context_)
101 return true; 104 return true;
102 105
103 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); 106 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
104 if (!plugin_instance) 107 if (!plugin_instance)
105 return false; 108 return false;
106 109
107 if (!context && bound_to_instance_) 110 if (!context && bound_to_instance_)
108 plugin_instance->BindGraphics(pp_instance(), 0); 111 plugin_instance->BindGraphics(pp_instance(), 0);
109 112
110 // Unbind from the current context. 113 // Unbind from the current context.
111 if (context_ && context_->platform_context())
112 context_->platform_context()->SetSwapBuffersCallback(NULL);
113 if (context && context->platform_context()) { 114 if (context && context->platform_context()) {
114 // Resize the backing texture to the size of the instance when it is bound. 115 // Resize the backing texture to the size of the instance when it is bound.
115 // TODO(alokp): This should be the responsibility of plugins. 116 // TODO(alokp): This should be the responsibility of plugins.
116 gpu::gles2::GLES2Implementation* impl = context->gles2_impl(); 117 gpu::gles2::GLES2Implementation* impl = context->gles2_impl();
117 if (impl) { 118 if (impl) {
118 const gfx::Size& size = plugin_instance->position().size(); 119 const gfx::Size& size = plugin_instance->position().size();
119 impl->ResizeCHROMIUM(size.width(), size.height()); 120 impl->ResizeCHROMIUM(size.width(), size.height());
120 } 121 }
121
122 context->platform_context()->SetSwapBuffersCallback(
123 NewCallback(this, &PPB_Surface3D_Impl::OnSwapBuffers));
124 } 122 }
125 context_ = context; 123 context_ = context;
126 return true; 124 return true;
127 } 125 }
128 126
129 void PPB_Surface3D_Impl::ViewInitiatedPaint() { 127 void PPB_Surface3D_Impl::ViewInitiatedPaint() {
130 } 128 }
131 129
132 void PPB_Surface3D_Impl::ViewFlushedPaint() { 130 void PPB_Surface3D_Impl::ViewFlushedPaint() {
133 if (swap_initiated_ && swap_callback_.get() && !swap_callback_->completed()) { 131 if (swap_initiated_ && swap_callback_.get() && !swap_callback_->completed()) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 const PPP_Graphics3D_Dev* ppp_graphics_3d = 183 const PPP_Graphics3D_Dev* ppp_graphics_3d =
186 static_cast<const PPP_Graphics3D_Dev*>( 184 static_cast<const PPP_Graphics3D_Dev*>(
187 plugin_instance->module()->GetPluginInterface( 185 plugin_instance->module()->GetPluginInterface(
188 PPP_GRAPHICS_3D_DEV_INTERFACE)); 186 PPP_GRAPHICS_3D_DEV_INTERFACE));
189 if (ppp_graphics_3d) 187 if (ppp_graphics_3d)
190 ppp_graphics_3d->Graphics3DContextLost(pp_instance()); 188 ppp_graphics_3d->Graphics3DContextLost(pp_instance());
191 } 189 }
192 190
193 } // namespace ppapi 191 } // namespace ppapi
194 } // namespace webkit 192 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppb_surface_3d_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698