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

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

Issue 7260008: Implement proper synchronization between HW video decode IPC and CommandBuffer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 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 | 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 "webkit/plugins/ppapi/ppb_video_decoder_impl.h" 5 #include "webkit/plugins/ppapi/ppb_video_decoder_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "gpu/command_buffer/client/gles2_implementation.h"
11 #include "media/video/picture.h" 12 #include "media/video/picture.h"
12 #include "ppapi/c/dev/pp_video_dev.h" 13 #include "ppapi/c/dev/pp_video_dev.h"
13 #include "ppapi/c/dev/ppb_video_decoder_dev.h" 14 #include "ppapi/c/dev/ppb_video_decoder_dev.h"
14 #include "ppapi/c/dev/ppp_video_decoder_dev.h" 15 #include "ppapi/c/dev/ppp_video_decoder_dev.h"
15 #include "ppapi/c/pp_completion_callback.h" 16 #include "ppapi/c/pp_completion_callback.h"
16 #include "ppapi/c/pp_errors.h" 17 #include "ppapi/c/pp_errors.h"
17 #include "ppapi/thunk/enter.h" 18 #include "ppapi/thunk/enter.h"
18 #include "webkit/plugins/ppapi/common.h" 19 #include "webkit/plugins/ppapi/common.h"
19 #include "webkit/plugins/ppapi/plugin_module.h" 20 #include "webkit/plugins/ppapi/plugin_module.h"
20 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 21 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 PPB_Context3D_Impl* context3d = 121 PPB_Context3D_Impl* context3d =
121 static_cast<PPB_Context3D_Impl*>(enter.object()); 122 static_cast<PPB_Context3D_Impl*>(enter.object());
122 123
123 int command_buffer_route_id = 124 int command_buffer_route_id =
124 context3d->platform_context()->GetCommandBufferRouteId(); 125 context3d->platform_context()->GetCommandBufferRouteId();
125 if (command_buffer_route_id == 0) 126 if (command_buffer_route_id == 0)
126 return PP_ERROR_FAILED; 127 return PP_ERROR_FAILED;
127 128
128 platform_video_decoder_.reset( 129 platform_video_decoder_.reset(
129 instance()->delegate()->CreateVideoDecoder( 130 instance()->delegate()->CreateVideoDecoder(
130 this, command_buffer_route_id)); 131 this, command_buffer_route_id, context3d->gles2_impl()->helper()));
piman 2011/06/28 01:19:22 FYI, context3d->gles2_impl() will be NULL in out-o
Ami GONE FROM CHROMIUM 2011/06/28 21:00:53 Done.
131 132
132 if (!platform_video_decoder_.get()) 133 if (!platform_video_decoder_.get())
133 return PP_ERROR_FAILED; 134 return PP_ERROR_FAILED;
134 135
135 std::vector<uint32> copied; 136 std::vector<uint32> copied;
136 // TODO(vrk): Validate configs before copy. 137 // TODO(vrk): Validate configs before copy.
137 CopyToConfigList(decoder_config, &copied); 138 CopyToConfigList(decoder_config, &copied);
138 if (platform_video_decoder_->Initialize(copied)) { 139 if (platform_video_decoder_->Initialize(copied)) {
139 initialization_callback_ = callback; 140 initialization_callback_ = callback;
140 return PP_OK_COMPLETIONPENDING; 141 return PP_OK_COMPLETIONPENDING;
(...skipping 12 matching lines...) Expand all
153 if (enter.failed()) 154 if (enter.failed())
154 return PP_ERROR_FAILED; 155 return PP_ERROR_FAILED;
155 156
156 PPB_Buffer_Impl* buffer = static_cast<PPB_Buffer_Impl*>(enter.object()); 157 PPB_Buffer_Impl* buffer = static_cast<PPB_Buffer_Impl*>(enter.object());
157 media::BitstreamBuffer decode_buffer(bitstream_buffer->id, 158 media::BitstreamBuffer decode_buffer(bitstream_buffer->id,
158 buffer->shared_memory()->handle(), 159 buffer->shared_memory()->handle(),
159 static_cast<size_t>(buffer->size())); 160 static_cast<size_t>(buffer->size()));
160 CHECK(bitstream_buffer_callbacks_.insert(std::make_pair( 161 CHECK(bitstream_buffer_callbacks_.insert(std::make_pair(
161 bitstream_buffer->id, callback)).second); 162 bitstream_buffer->id, callback)).second);
162 163
163 if (platform_video_decoder_->Decode(decode_buffer)) 164 platform_video_decoder_->Decode(decode_buffer);
164 return PP_OK_COMPLETIONPENDING; 165 return PP_OK_COMPLETIONPENDING;
165 else
166 return PP_ERROR_FAILED;
167 } 166 }
168 167
169 void PPB_VideoDecoder_Impl::AssignGLESBuffers( 168 void PPB_VideoDecoder_Impl::AssignGLESBuffers(
170 uint32_t no_of_buffers, 169 uint32_t no_of_buffers,
171 const PP_GLESBuffer_Dev* buffers) { 170 const PP_GLESBuffer_Dev* buffers) {
172 if (!platform_video_decoder_.get()) 171 if (!platform_video_decoder_.get())
173 return; 172 return;
174 173
175 std::vector<media::GLESBuffer> wrapped_buffers; 174 std::vector<media::GLESBuffer> wrapped_buffers;
176 for (uint32 i = 0; i < no_of_buffers; i++) { 175 for (uint32 i = 0; i < no_of_buffers; i++) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 } 215 }
217 216
218 int32_t PPB_VideoDecoder_Impl::Flush(PP_CompletionCallback callback) { 217 int32_t PPB_VideoDecoder_Impl::Flush(PP_CompletionCallback callback) {
219 if (!platform_video_decoder_.get()) 218 if (!platform_video_decoder_.get())
220 return PP_ERROR_BADRESOURCE; 219 return PP_ERROR_BADRESOURCE;
221 220
222 // Store the callback to be called when Flush() is done. 221 // Store the callback to be called when Flush() is done.
223 // TODO(vmr): Check for current flush/abort operations. 222 // TODO(vmr): Check for current flush/abort operations.
224 flush_callback_ = callback; 223 flush_callback_ = callback;
225 224
226 if (platform_video_decoder_->Flush()) 225 platform_video_decoder_->Flush();
227 return PP_OK_COMPLETIONPENDING; 226 return PP_OK_COMPLETIONPENDING;
228 else
229 return PP_ERROR_FAILED;
230 } 227 }
231 228
232 int32_t PPB_VideoDecoder_Impl::Abort(PP_CompletionCallback callback) { 229 int32_t PPB_VideoDecoder_Impl::Abort(PP_CompletionCallback callback) {
233 if (!platform_video_decoder_.get()) 230 if (!platform_video_decoder_.get())
234 return PP_ERROR_BADRESOURCE; 231 return PP_ERROR_BADRESOURCE;
235 232
236 // Store the callback to be called when Abort() is done. 233 // Store the callback to be called when Abort() is done.
237 // TODO(vmr): Check for current flush/abort operations. 234 // TODO(vmr): Check for current flush/abort operations.
238 abort_callback_ = callback; 235 abort_callback_ = callback;
239 236
240 if (platform_video_decoder_->Abort()) 237 platform_video_decoder_->Abort();
241 return PP_OK_COMPLETIONPENDING; 238 return PP_OK_COMPLETIONPENDING;
242 else
243 return PP_ERROR_FAILED;
244 } 239 }
245 240
246 void PPB_VideoDecoder_Impl::ProvidePictureBuffers( 241 void PPB_VideoDecoder_Impl::ProvidePictureBuffers(
247 uint32 requested_num_of_buffers, 242 uint32 requested_num_of_buffers,
248 const gfx::Size& dimensions, 243 const gfx::Size& dimensions,
249 media::VideoDecodeAccelerator::MemoryType type) { 244 media::VideoDecodeAccelerator::MemoryType type) {
250 if (!ppp_videodecoder_) 245 if (!ppp_videodecoder_)
251 return; 246 return;
252 247
253 // TODO(vrk): Compiler assert or use switch statement instead of making 248 // TODO(vrk): Compiler assert or use switch statement instead of making
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 326
332 void PPB_VideoDecoder_Impl::NotifyInitializeDone() { 327 void PPB_VideoDecoder_Impl::NotifyInitializeDone() {
333 if (initialization_callback_.func == NULL) 328 if (initialization_callback_.func == NULL)
334 return; 329 return;
335 330
336 PP_RunAndClearCompletionCallback(&initialization_callback_, PP_OK); 331 PP_RunAndClearCompletionCallback(&initialization_callback_, PP_OK);
337 } 332 }
338 333
339 } // namespace ppapi 334 } // namespace ppapi
340 } // namespace webkit 335 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698