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

Side by Side Diff: ppapi/proxy/ppb_graphics_3d_proxy.cc

Issue 2136743002: Simplify ppapi Graphics3D size propagation a bit (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_attr_parse_to_pepper
Patch Set: fix win64+gyp build Created 4 years, 5 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 | « ppapi/proxy/ppb_graphics_3d_proxy.h ('k') | ppapi/proxy/video_decoder_resource_unittest.cc » ('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 "ppapi/proxy/ppb_graphics_3d_proxy.h" 5 #include "ppapi/proxy/ppb_graphics_3d_proxy.h"
6 6
7 #include "base/numerics/safe_conversions.h" 7 #include "base/numerics/safe_conversions.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "gpu/command_buffer/client/gles2_implementation.h" 9 #include "gpu/command_buffer/client/gles2_implementation.h"
10 #include "gpu/command_buffer/common/command_buffer.h" 10 #include "gpu/command_buffer/common/command_buffer.h"
(...skipping 30 matching lines...) Expand all
41 #endif // !defined(OS_NACL) 41 #endif // !defined(OS_NACL)
42 42
43 gpu::CommandBuffer::State GetErrorState() { 43 gpu::CommandBuffer::State GetErrorState() {
44 gpu::CommandBuffer::State error_state; 44 gpu::CommandBuffer::State error_state;
45 error_state.error = gpu::error::kGenericError; 45 error_state.error = gpu::error::kGenericError;
46 return error_state; 46 return error_state;
47 } 47 }
48 48
49 } // namespace 49 } // namespace
50 50
51 Graphics3D::Graphics3D(const HostResource& resource) 51 Graphics3D::Graphics3D(const HostResource& resource, const gfx::Size& size)
52 : PPB_Graphics3D_Shared(resource) { 52 : PPB_Graphics3D_Shared(resource, size) {
53 } 53 }
54 54
55 Graphics3D::~Graphics3D() { 55 Graphics3D::~Graphics3D() {
56 DestroyGLES2Impl(); 56 DestroyGLES2Impl();
57 } 57 }
58 58
59 bool Graphics3D::Init(gpu::gles2::GLES2Implementation* share_gles2, 59 bool Graphics3D::Init(gpu::gles2::GLES2Implementation* share_gles2,
60 const gpu::Capabilities& capabilities, 60 const gpu::Capabilities& capabilities,
61 const SerializedHandle& shared_state, 61 const SerializedHandle& shared_state,
62 gpu::CommandBufferId command_buffer_id) { 62 gpu::CommandBufferId command_buffer_id) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 gpu::CommandBuffer* Graphics3D::GetCommandBuffer() { 112 gpu::CommandBuffer* Graphics3D::GetCommandBuffer() {
113 return command_buffer_.get(); 113 return command_buffer_.get();
114 } 114 }
115 115
116 gpu::GpuControl* Graphics3D::GetGpuControl() { 116 gpu::GpuControl* Graphics3D::GetGpuControl() {
117 return command_buffer_.get(); 117 return command_buffer_.get();
118 } 118 }
119 119
120 int32_t Graphics3D::DoSwapBuffers(const gpu::SyncToken& sync_token, 120 int32_t Graphics3D::DoSwapBuffers(const gpu::SyncToken& sync_token,
121 int32_t width, 121 const gfx::Size& size) {
122 int32_t height) {
123 // A valid sync token would indicate a swap buffer already happened somehow. 122 // A valid sync token would indicate a swap buffer already happened somehow.
124 DCHECK(!sync_token.HasData()); 123 DCHECK(!sync_token.HasData());
125 124
126 gpu::gles2::GLES2Implementation* gl = gles2_impl(); 125 gpu::gles2::GLES2Implementation* gl = gles2_impl();
127 gl->SwapBuffers(); 126 gl->SwapBuffers();
128 127
129 PluginDispatcher::GetForResource(this)->Send( 128 PluginDispatcher::GetForResource(this)->Send(
130 new PpapiHostMsg_PPBGraphics3D_TakeFrontBuffer(API_ID_PPB_GRAPHICS_3D, 129 new PpapiHostMsg_PPBGraphics3D_TakeFrontBuffer(API_ID_PPB_GRAPHICS_3D,
131 host_resource())); 130 host_resource()));
132 131
133 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); 132 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM();
134 gl->ShallowFlushCHROMIUM(); 133 gl->ShallowFlushCHROMIUM();
135 134
136 gpu::SyncToken new_sync_token; 135 gpu::SyncToken new_sync_token;
137 gl->GenSyncTokenCHROMIUM(fence_sync, new_sync_token.GetData()); 136 gl->GenSyncTokenCHROMIUM(fence_sync, new_sync_token.GetData());
138 137
139 IPC::Message* msg = new PpapiHostMsg_PPBGraphics3D_SwapBuffers( 138 IPC::Message* msg = new PpapiHostMsg_PPBGraphics3D_SwapBuffers(
140 API_ID_PPB_GRAPHICS_3D, host_resource(), new_sync_token, width, 139 API_ID_PPB_GRAPHICS_3D, host_resource(), new_sync_token, size);
141 height);
142 msg->set_unblock(true); 140 msg->set_unblock(true);
143 PluginDispatcher::GetForResource(this)->Send(msg); 141 PluginDispatcher::GetForResource(this)->Send(msg);
144 142
145 return PP_OK_COMPLETIONPENDING; 143 return PP_OK_COMPLETIONPENDING;
146 } 144 }
147 145
148 PPB_Graphics3D_Proxy::PPB_Graphics3D_Proxy(Dispatcher* dispatcher) 146 PPB_Graphics3D_Proxy::PPB_Graphics3D_Proxy(Dispatcher* dispatcher)
149 : InterfaceProxy(dispatcher), 147 : InterfaceProxy(dispatcher),
150 callback_factory_(this) { 148 callback_factory_(this) {
151 } 149 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 gpu::Capabilities capabilities; 206 gpu::Capabilities capabilities;
209 ppapi::proxy::SerializedHandle shared_state; 207 ppapi::proxy::SerializedHandle shared_state;
210 gpu::CommandBufferId command_buffer_id; 208 gpu::CommandBufferId command_buffer_id;
211 dispatcher->Send(new PpapiHostMsg_PPBGraphics3D_Create( 209 dispatcher->Send(new PpapiHostMsg_PPBGraphics3D_Create(
212 API_ID_PPB_GRAPHICS_3D, instance, share_host, attrib_helper, &result, 210 API_ID_PPB_GRAPHICS_3D, instance, share_host, attrib_helper, &result,
213 &capabilities, &shared_state, &command_buffer_id)); 211 &capabilities, &shared_state, &command_buffer_id));
214 212
215 if (result.is_null()) 213 if (result.is_null())
216 return 0; 214 return 0;
217 215
218 scoped_refptr<Graphics3D> graphics_3d(new Graphics3D(result)); 216 scoped_refptr<Graphics3D> graphics_3d(
217 new Graphics3D(result, attrib_helper.offscreen_framebuffer_size));
219 if (!graphics_3d->Init(share_gles2, capabilities, shared_state, 218 if (!graphics_3d->Init(share_gles2, capabilities, shared_state,
220 command_buffer_id)) { 219 command_buffer_id)) {
221 return 0; 220 return 0;
222 } 221 }
223 return graphics_3d->GetReference(); 222 return graphics_3d->GetReference();
224 } 223 }
225 224
226 bool PPB_Graphics3D_Proxy::OnMessageReceived(const IPC::Message& msg) { 225 bool PPB_Graphics3D_Proxy::OnMessageReceived(const IPC::Message& msg) {
227 bool handled = true; 226 bool handled = true;
228 IPC_BEGIN_MESSAGE_MAP(PPB_Graphics3D_Proxy, msg) 227 IPC_BEGIN_MESSAGE_MAP(PPB_Graphics3D_Proxy, msg)
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 void PPB_Graphics3D_Proxy::OnMsgDestroyTransferBuffer( 353 void PPB_Graphics3D_Proxy::OnMsgDestroyTransferBuffer(
355 const HostResource& context, 354 const HostResource& context,
356 int32_t id) { 355 int32_t id) {
357 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); 356 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context);
358 if (enter.succeeded()) 357 if (enter.succeeded())
359 enter.object()->DestroyTransferBuffer(id); 358 enter.object()->DestroyTransferBuffer(id);
360 } 359 }
361 360
362 void PPB_Graphics3D_Proxy::OnMsgSwapBuffers(const HostResource& context, 361 void PPB_Graphics3D_Proxy::OnMsgSwapBuffers(const HostResource& context,
363 const gpu::SyncToken& sync_token, 362 const gpu::SyncToken& sync_token,
364 int32_t width, 363 const gfx::Size& size) {
365 int32_t height) {
366 EnterHostFromHostResourceForceCallback<PPB_Graphics3D_API> enter( 364 EnterHostFromHostResourceForceCallback<PPB_Graphics3D_API> enter(
367 context, callback_factory_, 365 context, callback_factory_,
368 &PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin, context); 366 &PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin, context);
369 if (enter.succeeded()) 367 if (enter.succeeded())
370 enter.SetResult(enter.object()->SwapBuffersWithSyncToken( 368 enter.SetResult(enter.object()->SwapBuffersWithSyncToken(
371 enter.callback(), sync_token, width, height)); 369 enter.callback(), sync_token, size));
372 } 370 }
373 371
374 void PPB_Graphics3D_Proxy::OnMsgTakeFrontBuffer(const HostResource& context) { 372 void PPB_Graphics3D_Proxy::OnMsgTakeFrontBuffer(const HostResource& context) {
375 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); 373 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context);
376 if (enter.succeeded()) 374 if (enter.succeeded())
377 enter.object()->TakeFrontBuffer(); 375 enter.object()->TakeFrontBuffer();
378 } 376 }
379 377
380 void PPB_Graphics3D_Proxy::OnMsgEnsureWorkVisible(const HostResource& context) { 378 void PPB_Graphics3D_Proxy::OnMsgEnsureWorkVisible(const HostResource& context) {
381 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); 379 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context);
(...skipping 13 matching lines...) Expand all
395 void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin( 393 void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin(
396 int32_t result, 394 int32_t result,
397 const HostResource& context) { 395 const HostResource& context) {
398 dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK( 396 dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK(
399 API_ID_PPB_GRAPHICS_3D, context, result)); 397 API_ID_PPB_GRAPHICS_3D, context, result));
400 } 398 }
401 #endif // !defined(OS_NACL) 399 #endif // !defined(OS_NACL)
402 400
403 } // namespace proxy 401 } // namespace proxy
404 } // namespace ppapi 402 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_graphics_3d_proxy.h ('k') | ppapi/proxy/video_decoder_resource_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698