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

Side by Side Diff: ppapi/shared_impl/ppb_graphics_3d_shared.cc

Issue 9053003: Convert ppapi/shared to use TrackedCallback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review comments Created 8 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 | Annotate | Revision Log
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 "ppapi/shared_impl/ppb_graphics_3d_shared.h" 5 #include "ppapi/shared_impl/ppb_graphics_3d_shared.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "gpu/command_buffer/client/gles2_cmd_helper.h" 8 #include "gpu/command_buffer/client/gles2_cmd_helper.h"
9 #include "gpu/command_buffer/client/gles2_implementation.h" 9 #include "gpu/command_buffer/client/gles2_implementation.h"
10 #include "ppapi/c/pp_errors.h" 10 #include "ppapi/c/pp_errors.h"
11 11
12 namespace ppapi { 12 namespace ppapi {
13 13
14 PPB_Graphics3D_Shared::PPB_Graphics3D_Shared() 14 PPB_Graphics3D_Shared::PPB_Graphics3D_Shared(PP_Instance instance)
15 : transfer_buffer_id_(-1), 15 : Resource(instance),
16 swap_callback_(PP_BlockUntilComplete()) { 16 transfer_buffer_id_(-1) {
17 }
18
19 PPB_Graphics3D_Shared::PPB_Graphics3D_Shared(const HostResource& host_resource)
20 : Resource(host_resource),
21 transfer_buffer_id_(-1) {
17 } 22 }
18 23
19 PPB_Graphics3D_Shared::~PPB_Graphics3D_Shared() { 24 PPB_Graphics3D_Shared::~PPB_Graphics3D_Shared() {
20 // Make sure that GLES2 implementation has already been destroyed. 25 // Make sure that GLES2 implementation has already been destroyed.
21 DCHECK_EQ(transfer_buffer_id_, -1); 26 DCHECK_EQ(transfer_buffer_id_, -1);
22 DCHECK(!gles2_helper_.get()); 27 DCHECK(!gles2_helper_.get());
23 DCHECK(!gles2_impl_.get()); 28 DCHECK(!gles2_impl_.get());
24 } 29 }
25 30
31 thunk::PPB_Graphics3D_API* PPB_Graphics3D_Shared::AsPPB_Graphics3D_API() {
32 return this;
33 }
34
26 int32_t PPB_Graphics3D_Shared::GetAttribs(int32_t* attrib_list) { 35 int32_t PPB_Graphics3D_Shared::GetAttribs(int32_t* attrib_list) {
27 // TODO(alokp): Implement me. 36 // TODO(alokp): Implement me.
28 return PP_ERROR_FAILED; 37 return PP_ERROR_FAILED;
29 } 38 }
30 39
31 int32_t PPB_Graphics3D_Shared::SetAttribs(int32_t* attrib_list) { 40 int32_t PPB_Graphics3D_Shared::SetAttribs(int32_t* attrib_list) {
32 // TODO(alokp): Implement me. 41 // TODO(alokp): Implement me.
33 return PP_ERROR_FAILED; 42 return PP_ERROR_FAILED;
34 } 43 }
35 44
(...skipping 16 matching lines...) Expand all
52 // Blocking SwapBuffers isn't supported (since we have to be on the main 61 // Blocking SwapBuffers isn't supported (since we have to be on the main
53 // thread). 62 // thread).
54 return PP_ERROR_BADARGUMENT; 63 return PP_ERROR_BADARGUMENT;
55 } 64 }
56 65
57 if (HasPendingSwap()) { 66 if (HasPendingSwap()) {
58 // Already a pending SwapBuffers that hasn't returned yet. 67 // Already a pending SwapBuffers that hasn't returned yet.
59 return PP_ERROR_INPROGRESS; 68 return PP_ERROR_INPROGRESS;
60 } 69 }
61 70
62 swap_callback_ = callback; 71 swap_callback_ = new TrackedCallback(this, callback);
63 return DoSwapBuffers(); 72 return DoSwapBuffers();
64 } 73 }
65 74
66 void* PPB_Graphics3D_Shared::MapTexSubImage2DCHROMIUM(GLenum target, 75 void* PPB_Graphics3D_Shared::MapTexSubImage2DCHROMIUM(GLenum target,
67 GLint level, 76 GLint level,
68 GLint xoffset, 77 GLint xoffset,
69 GLint yoffset, 78 GLint yoffset,
70 GLsizei width, 79 GLsizei width,
71 GLsizei height, 80 GLsizei height,
72 GLenum format, 81 GLenum format,
73 GLenum type, 82 GLenum type,
74 GLenum access) { 83 GLenum access) {
75 return gles2_impl_->MapTexSubImage2DCHROMIUM( 84 return gles2_impl_->MapTexSubImage2DCHROMIUM(
76 target, level, xoffset, yoffset, width, height, format, type, access); 85 target, level, xoffset, yoffset, width, height, format, type, access);
77 } 86 }
78 87
79 void PPB_Graphics3D_Shared::UnmapTexSubImage2DCHROMIUM(const void* mem) { 88 void PPB_Graphics3D_Shared::UnmapTexSubImage2DCHROMIUM(const void* mem) {
80 gles2_impl_->UnmapTexSubImage2DCHROMIUM(mem); 89 gles2_impl_->UnmapTexSubImage2DCHROMIUM(mem);
81 } 90 }
82 91
83 void PPB_Graphics3D_Shared::SwapBuffersACK(int32_t pp_error) { 92 void PPB_Graphics3D_Shared::SwapBuffersACK(int32_t pp_error) {
84 DCHECK(HasPendingSwap()); 93 DCHECK(HasPendingSwap());
85 PP_RunAndClearCompletionCallback(&swap_callback_, pp_error); 94 TrackedCallback::ClearAndRun(&swap_callback_, pp_error);
95 }
96
97 bool PPB_Graphics3D_Shared::HasPendingSwap() const {
98 return !!swap_callback_.get();
viettrungluu 2012/01/04 01:15:14 TrackedCallback::IsPending()?
viettrungluu 2012/01/04 01:15:14 "
86 } 99 }
87 100
88 bool PPB_Graphics3D_Shared::CreateGLES2Impl(int32 command_buffer_size, 101 bool PPB_Graphics3D_Shared::CreateGLES2Impl(int32 command_buffer_size,
89 int32 transfer_buffer_size) { 102 int32 transfer_buffer_size) {
90 gpu::CommandBuffer* command_buffer = GetCommandBuffer(); 103 gpu::CommandBuffer* command_buffer = GetCommandBuffer();
91 DCHECK(command_buffer); 104 DCHECK(command_buffer);
92 105
93 // Create the GLES2 helper, which writes the command buffer protocol. 106 // Create the GLES2 helper, which writes the command buffer protocol.
94 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(command_buffer)); 107 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(command_buffer));
95 if (!gles2_helper_->Initialize(command_buffer_size)) 108 if (!gles2_helper_->Initialize(command_buffer_size))
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 DCHECK(command_buffer); 141 DCHECK(command_buffer);
129 command_buffer->DestroyTransferBuffer(transfer_buffer_id_); 142 command_buffer->DestroyTransferBuffer(transfer_buffer_id_);
130 transfer_buffer_id_ = -1; 143 transfer_buffer_id_ = -1;
131 } 144 }
132 145
133 gles2_helper_.reset(); 146 gles2_helper_.reset();
134 } 147 }
135 148
136 } // namespace ppapi 149 } // namespace ppapi
137 150
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698