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

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: Removed some .get() booleans 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
« no previous file with comments | « content/renderer/pepper/ppb_graphics_3d_impl.h ('k') | ppapi/proxy/ppapi_messages.h » ('j') | 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) 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()) {
186 // A valid sync token would indicate a swap buffer already happened somehow.
187 DCHECK(!sync_token.HasData());
188
184 gl->SwapBuffers(); 189 gl->SwapBuffers();
185 190 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM();
186 // Since the backing texture has been updated, a new sync point should be 191 gl->OrderingBarrierCHROMIUM();
187 // inserted. 192 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token_.GetData());
188 sync_point_ = command_buffer_->InsertSyncPoint(); 193 }
189 194
190 if (bound_to_instance_) { 195 if (bound_to_instance_) {
191 // If we are bound to the instance, we need to ask the compositor 196 // 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. 197 // 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 198 // When the backing texture will be committed we get notified via
194 // ViewFlushedPaint(). 199 // ViewFlushedPaint().
195 // 200 //
196 // Don't need to check for NULL from GetPluginInstance since when we're 201 // Don't need to check for NULL from GetPluginInstance since when we're
197 // bound, we know our instance is valid. 202 // bound, we know our instance is valid.
198 HostGlobals::Get()->GetInstance(pp_instance())->CommitBackingTexture(); 203 HostGlobals::Get()->GetInstance(pp_instance())->CommitBackingTexture();
199 commit_pending_ = true; 204 commit_pending_ = true;
200 } else { 205 } else {
201 // Wait for the command to complete on the GPU to allow for throttling. 206 // Wait for the command to complete on the GPU to allow for throttling.
202 command_buffer_->SignalSyncPoint( 207 command_buffer_->SignalSyncToken(
203 sync_point_, 208 sync_token_,
204 base::Bind(&PPB_Graphics3D_Impl::OnSwapBuffers, 209 base::Bind(&PPB_Graphics3D_Impl::OnSwapBuffers,
205 weak_ptr_factory_.GetWeakPtr())); 210 weak_ptr_factory_.GetWeakPtr()));
206 } 211 }
207 212
208 return PP_OK_COMPLETIONPENDING; 213 return PP_OK_COMPLETIONPENDING;
209 } 214 }
210 215
211 bool PPB_Graphics3D_Impl::Init(PPB_Graphics3D_API* share_context, 216 bool PPB_Graphics3D_Impl::Init(PPB_Graphics3D_API* share_context,
212 const int32_t* attrib_list) { 217 const int32_t* attrib_list) {
213 if (!InitRaw(share_context, attrib_list, NULL, NULL, NULL)) 218 if (!InitRaw(share_context, attrib_list, NULL, NULL, NULL))
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 return false; 313 return false;
309 if (shared_state_handle) 314 if (shared_state_handle)
310 *shared_state_handle = command_buffer_->GetSharedStateHandle(); 315 *shared_state_handle = command_buffer_->GetSharedStateHandle();
311 if (capabilities) 316 if (capabilities)
312 *capabilities = command_buffer_->GetCapabilities(); 317 *capabilities = command_buffer_->GetCapabilities();
313 if (command_buffer_id) 318 if (command_buffer_id)
314 *command_buffer_id = command_buffer_->GetCommandBufferID(); 319 *command_buffer_id = command_buffer_->GetCommandBufferID();
315 mailbox_ = gpu::Mailbox::Generate(); 320 mailbox_ = gpu::Mailbox::Generate();
316 if (!command_buffer_->ProduceFrontBuffer(mailbox_)) 321 if (!command_buffer_->ProduceFrontBuffer(mailbox_))
317 return false; 322 return false;
318 sync_point_ = command_buffer_->InsertSyncPoint();
319 323
320 command_buffer_->SetContextLostCallback(base::Bind( 324 command_buffer_->SetContextLostCallback(base::Bind(
321 &PPB_Graphics3D_Impl::OnContextLost, weak_ptr_factory_.GetWeakPtr())); 325 &PPB_Graphics3D_Impl::OnContextLost, weak_ptr_factory_.GetWeakPtr()));
322 326
323 command_buffer_->SetOnConsoleMessageCallback(base::Bind( 327 command_buffer_->SetOnConsoleMessageCallback(base::Bind(
324 &PPB_Graphics3D_Impl::OnConsoleMessage, weak_ptr_factory_.GetWeakPtr())); 328 &PPB_Graphics3D_Impl::OnConsoleMessage, weak_ptr_factory_.GetWeakPtr()));
325 return true; 329 return true;
326 } 330 }
327 331
328 void PPB_Graphics3D_Impl::OnConsoleMessage(const std::string& message, int id) { 332 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)); 386 instance->module()->GetPluginInterface(PPP_GRAPHICS_3D_INTERFACE));
383 // We have to check *again* that the instance exists, because it could have 387 // We have to check *again* that the instance exists, because it could have
384 // been deleted during GetPluginInterface(). Even the PluginModule could be 388 // been deleted during GetPluginInterface(). Even the PluginModule could be
385 // deleted, but in that case, the instance should also be gone, so the 389 // deleted, but in that case, the instance should also be gone, so the
386 // GetInstance check covers both cases. 390 // GetInstance check covers both cases.
387 if (ppp_graphics_3d && HostGlobals::Get()->GetInstance(this_pp_instance)) 391 if (ppp_graphics_3d && HostGlobals::Get()->GetInstance(this_pp_instance))
388 ppp_graphics_3d->Graphics3DContextLost(this_pp_instance); 392 ppp_graphics_3d->Graphics3DContextLost(this_pp_instance);
389 } 393 }
390 394
391 } // namespace content 395 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/ppb_graphics_3d_impl.h ('k') | ppapi/proxy/ppapi_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698