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

Side by Side Diff: content/renderer/pepper/ppb_graphics_3d_impl.cc

Issue 1586883002: Converted Ppapi post swap buffer sync point to use sync tokens. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
OLDNEW
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 "content/renderer/pepper/ppb_graphics_3d_impl.h" 5 #include "content/renderer/pepper/ppb_graphics_3d_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 const int32_t kCommandBufferSize = 1024 * 1024; 44 const int32_t kCommandBufferSize = 1024 * 1024;
45 const int32_t kTransferBufferSize = 1024 * 1024; 45 const int32_t kTransferBufferSize = 1024 * 1024;
46 46
47 } // namespace 47 } // namespace
48 48
49 PPB_Graphics3D_Impl::PPB_Graphics3D_Impl(PP_Instance instance) 49 PPB_Graphics3D_Impl::PPB_Graphics3D_Impl(PP_Instance instance)
50 : PPB_Graphics3D_Shared(instance), 50 : PPB_Graphics3D_Shared(instance),
51 bound_to_instance_(false), 51 bound_to_instance_(false),
52 commit_pending_(false), 52 commit_pending_(false),
53 sync_point_(0),
54 has_alpha_(false), 53 has_alpha_(false),
55 weak_ptr_factory_(this) {} 54 weak_ptr_factory_(this) {}
56 55
57 PPB_Graphics3D_Impl::~PPB_Graphics3D_Impl() {} 56 PPB_Graphics3D_Impl::~PPB_Graphics3D_Impl() {}
58 57
59 // static 58 // static
60 PP_Resource PPB_Graphics3D_Impl::Create(PP_Instance instance, 59 PP_Resource PPB_Graphics3D_Impl::Create(PP_Instance instance,
61 PP_Resource share_context, 60 PP_Resource share_context,
62 const int32_t* attrib_list) { 61 const int32_t* attrib_list) {
63 PPB_Graphics3D_API* share_api = NULL; 62 PPB_Graphics3D_API* share_api = NULL;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 } 167 }
169 168
170 gpu::CommandBuffer* PPB_Graphics3D_Impl::GetCommandBuffer() { 169 gpu::CommandBuffer* PPB_Graphics3D_Impl::GetCommandBuffer() {
171 return command_buffer_.get(); 170 return command_buffer_.get();
172 } 171 }
173 172
174 gpu::GpuControl* PPB_Graphics3D_Impl::GetGpuControl() { 173 gpu::GpuControl* PPB_Graphics3D_Impl::GetGpuControl() {
175 return command_buffer_.get(); 174 return command_buffer_.get();
176 } 175 }
177 176
178 int32_t PPB_Graphics3D_Impl::DoSwapBuffers() { 177 int32_t PPB_Graphics3D_Impl::DoSwapBuffers(const gpu::SyncToken& sync_token) {
179 DCHECK(command_buffer_); 178 DCHECK(command_buffer_);
179 if (sync_token.HasData())
180 sync_token_ = sync_token;
181
180 // We do not have a GLES2 implementation when using an OOP proxy. 182 // We do not have a GLES2 implementation when using an OOP proxy.
181 // The plugin-side proxy is responsible for adding the SwapBuffers command 183 // The plugin-side proxy is responsible for adding the SwapBuffers command
182 // to the command buffer in that case. 184 // to the command buffer in that case.
183 if (gpu::gles2::GLES2Interface* gl = gles2_interface()) 185 if (gpu::gles2::GLES2Interface* gl = gles2_interface()) {
184 gl->SwapBuffers(); 186 gl->SwapBuffers();
185 187 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM();
186 // Since the backing texture has been updated, a new sync point should be 188 gl->OrderingBarrierCHROMIUM();
piman 2016/01/14 00:21:36 nit: maybe DCHECK(!sync_token.HasData()) in this c
David Yen 2016/01/14 00:36:38 Done.
187 // inserted. 189 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token_.GetData());
188 sync_point_ = command_buffer_->InsertSyncPoint(); 190 }
189 191
190 if (bound_to_instance_) { 192 if (bound_to_instance_) {
191 // If we are bound to the instance, we need to ask the compositor 193 // If we are bound to the instance, we need to ask the compositor
192 // to commit our backing texture so that the graphics appears on the page. 194 // to commit our backing texture so that the graphics appears on the page.
193 // When the backing texture will be committed we get notified via 195 // When the backing texture will be committed we get notified via
194 // ViewFlushedPaint(). 196 // ViewFlushedPaint().
195 // 197 //
196 // Don't need to check for NULL from GetPluginInstance since when we're 198 // Don't need to check for NULL from GetPluginInstance since when we're
197 // bound, we know our instance is valid. 199 // bound, we know our instance is valid.
198 HostGlobals::Get()->GetInstance(pp_instance())->CommitBackingTexture(); 200 HostGlobals::Get()->GetInstance(pp_instance())->CommitBackingTexture();
199 commit_pending_ = true; 201 commit_pending_ = true;
200 } else { 202 } else {
201 // Wait for the command to complete on the GPU to allow for throttling. 203 // Wait for the command to complete on the GPU to allow for throttling.
202 command_buffer_->SignalSyncPoint( 204 command_buffer_->SignalSyncToken(
203 sync_point_, 205 sync_token_,
204 base::Bind(&PPB_Graphics3D_Impl::OnSwapBuffers, 206 base::Bind(&PPB_Graphics3D_Impl::OnSwapBuffers,
205 weak_ptr_factory_.GetWeakPtr())); 207 weak_ptr_factory_.GetWeakPtr()));
206 } 208 }
207 209
208 return PP_OK_COMPLETIONPENDING; 210 return PP_OK_COMPLETIONPENDING;
209 } 211 }
210 212
211 bool PPB_Graphics3D_Impl::Init(PPB_Graphics3D_API* share_context, 213 bool PPB_Graphics3D_Impl::Init(PPB_Graphics3D_API* share_context,
212 const int32_t* attrib_list) { 214 const int32_t* attrib_list) {
213 if (!InitRaw(share_context, attrib_list, NULL, NULL, NULL)) 215 if (!InitRaw(share_context, attrib_list, NULL, NULL, NULL))
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 return false; 310 return false;
309 if (shared_state_handle) 311 if (shared_state_handle)
310 *shared_state_handle = command_buffer_->GetSharedStateHandle(); 312 *shared_state_handle = command_buffer_->GetSharedStateHandle();
311 if (capabilities) 313 if (capabilities)
312 *capabilities = command_buffer_->GetCapabilities(); 314 *capabilities = command_buffer_->GetCapabilities();
313 if (command_buffer_id) 315 if (command_buffer_id)
314 *command_buffer_id = command_buffer_->GetCommandBufferID(); 316 *command_buffer_id = command_buffer_->GetCommandBufferID();
315 mailbox_ = gpu::Mailbox::Generate(); 317 mailbox_ = gpu::Mailbox::Generate();
316 if (!command_buffer_->ProduceFrontBuffer(mailbox_)) 318 if (!command_buffer_->ProduceFrontBuffer(mailbox_))
317 return false; 319 return false;
318 sync_point_ = command_buffer_->InsertSyncPoint();
319 320
320 command_buffer_->SetContextLostCallback(base::Bind( 321 command_buffer_->SetContextLostCallback(base::Bind(
321 &PPB_Graphics3D_Impl::OnContextLost, weak_ptr_factory_.GetWeakPtr())); 322 &PPB_Graphics3D_Impl::OnContextLost, weak_ptr_factory_.GetWeakPtr()));
322 323
323 command_buffer_->SetOnConsoleMessageCallback(base::Bind( 324 command_buffer_->SetOnConsoleMessageCallback(base::Bind(
324 &PPB_Graphics3D_Impl::OnConsoleMessage, weak_ptr_factory_.GetWeakPtr())); 325 &PPB_Graphics3D_Impl::OnConsoleMessage, weak_ptr_factory_.GetWeakPtr()));
325 return true; 326 return true;
326 } 327 }
327 328
328 void PPB_Graphics3D_Impl::OnConsoleMessage(const std::string& message, int id) { 329 void PPB_Graphics3D_Impl::OnConsoleMessage(const std::string& message, int id) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 instance->module()->GetPluginInterface(PPP_GRAPHICS_3D_INTERFACE)); 383 instance->module()->GetPluginInterface(PPP_GRAPHICS_3D_INTERFACE));
383 // We have to check *again* that the instance exists, because it could have 384 // We have to check *again* that the instance exists, because it could have
384 // been deleted during GetPluginInterface(). Even the PluginModule could be 385 // been deleted during GetPluginInterface(). Even the PluginModule could be
385 // deleted, but in that case, the instance should also be gone, so the 386 // deleted, but in that case, the instance should also be gone, so the
386 // GetInstance check covers both cases. 387 // GetInstance check covers both cases.
387 if (ppp_graphics_3d && HostGlobals::Get()->GetInstance(this_pp_instance)) 388 if (ppp_graphics_3d && HostGlobals::Get()->GetInstance(this_pp_instance))
388 ppp_graphics_3d->Graphics3DContextLost(this_pp_instance); 389 ppp_graphics_3d->Graphics3DContextLost(this_pp_instance);
389 } 390 }
390 391
391 } // namespace content 392 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698