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

Side by Side Diff: content/renderer/media/renderer_gpu_video_decoder_factories.cc

Issue 14199002: Send hardware video frames with mailboxes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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) 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/media/renderer_gpu_video_decoder_factories.h" 5 #include "content/renderer/media/renderer_gpu_video_decoder_factories.h"
6 6
7 #include <GLES2/gl2.h> 7 #include <GLES2/gl2.h>
8 #include <GLES2/gl2ext.h> 8 #include <GLES2/gl2ext.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 void RendererGpuVideoDecoderFactories::AsyncDeleteTexture(uint32 texture_id) { 153 void RendererGpuVideoDecoderFactories::AsyncDeleteTexture(uint32 texture_id) {
154 DCHECK(message_loop_->BelongsToCurrentThread()); 154 DCHECK(message_loop_->BelongsToCurrentThread());
155 if (!context_) 155 if (!context_)
156 return; 156 return;
157 157
158 gpu::gles2::GLES2Implementation* gles2 = context_->GetImplementation(); 158 gpu::gles2::GLES2Implementation* gles2 = context_->GetImplementation();
159 gles2->DeleteTextures(1, &texture_id); 159 gles2->DeleteTextures(1, &texture_id);
160 DCHECK_EQ(gles2->GetError(), static_cast<GLenum>(GL_NO_ERROR)); 160 DCHECK_EQ(gles2->GetError(), static_cast<GLenum>(GL_NO_ERROR));
161 } 161 }
162 162
163 gpu::Mailbox RendererGpuVideoDecoderFactories::ProduceTextureToMailbox(
164 uint32 texture_id) {
165 gpu::Mailbox mailbox;
166 if (message_loop_->BelongsToCurrentThread()) {
167 AsyncProduceTextureToMailbox(texture_id, &mailbox);
168 return mailbox;
169 }
170
171 message_loop_->PostTask(FROM_HERE, base::Bind(
172 &RendererGpuVideoDecoderFactories::AsyncProduceTextureToMailbox,
173 this,
174 texture_id,
175 &mailbox));
176 base::WaitableEvent* objects[] = {&aborted_waiter_, &async_waiter_};
177 base::WaitableEvent::WaitMany(objects, arraysize(objects));
178 return mailbox;
179 }
180
181 void RendererGpuVideoDecoderFactories::AsyncProduceTextureToMailbox(
182 uint32 texture_id, gpu::Mailbox* mailbox) {
183 DCHECK(message_loop_->BelongsToCurrentThread());
184 if (!context_) {
185 async_waiter_.Signal();
186 return;
187 }
188
189 gpu::gles2::GLES2Implementation* gles2 = context_->GetImplementation();
190 gles2->GenMailboxCHROMIUM(mailbox->name);
191 gles2->BindTexture(GL_TEXTURE_2D, texture_id);
192 gles2->ProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox->name);
piman 2013/04/11 22:57:58 You probably need to shallow Flush so that the com
danakj 2013/04/12 00:01:39 Should be fine to stick a sync point into the Vide
193 }
194
195 void RendererGpuVideoDecoderFactories::ConsumeMailboxToTexture(
196 const gpu::Mailbox& mailbox, uint32 texture_id) {
197 if (message_loop_->BelongsToCurrentThread()) {
198 AsyncConsumeMailboxToTexture(mailbox, texture_id);
199 return;
200 }
201
202 message_loop_->PostTask(FROM_HERE, base::Bind(
203 &RendererGpuVideoDecoderFactories::AsyncConsumeMailboxToTexture,
204 this,
205 mailbox,
206 texture_id));
207 base::WaitableEvent* objects[] = {&aborted_waiter_, &async_waiter_};
208 base::WaitableEvent::WaitMany(objects, arraysize(objects));
209 }
210
211 void RendererGpuVideoDecoderFactories::AsyncConsumeMailboxToTexture(
212 const gpu::Mailbox& mailbox, uint32 texture_id) {
213 DCHECK(message_loop_->BelongsToCurrentThread());
214 if (!context_) {
215 async_waiter_.Signal();
216 return;
217 }
218
219 gpu::gles2::GLES2Implementation* gles2 = context_->GetImplementation();
220 gles2->BindTexture(GL_TEXTURE_2D, texture_id);
221 gles2->ConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
222 }
223
163 void RendererGpuVideoDecoderFactories::ReadPixels( 224 void RendererGpuVideoDecoderFactories::ReadPixels(
164 uint32 texture_id, uint32 texture_target, const gfx::Size& size, 225 uint32 texture_id, uint32 texture_target, const gfx::Size& size,
165 const SkBitmap& pixels) { 226 const SkBitmap& pixels) {
166 // SkBitmaps use the SkPixelRef object to refcount the underlying pixels. 227 // SkBitmaps use the SkPixelRef object to refcount the underlying pixels.
167 // Multiple SkBitmaps can share a SkPixelRef instance. We use this to 228 // Multiple SkBitmaps can share a SkPixelRef instance. We use this to
168 // ensure that the underlying pixels in the SkBitmap passed in remain valid 229 // ensure that the underlying pixels in the SkBitmap passed in remain valid
169 // until the AsyncReadPixels() call completes. 230 // until the AsyncReadPixels() call completes.
170 read_pixels_bitmap_.setPixelRef(pixels.pixelRef()); 231 read_pixels_bitmap_.setPixelRef(pixels.pixelRef());
171 232
172 if (!message_loop_->BelongsToCurrentThread()) { 233 if (!message_loop_->BelongsToCurrentThread()) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 return aborted_waiter_.IsSignaled(); 312 return aborted_waiter_.IsSignaled();
252 } 313 }
253 314
254 void RendererGpuVideoDecoderFactories::AsyncDestroyVideoDecodeAccelerator() { 315 void RendererGpuVideoDecoderFactories::AsyncDestroyVideoDecodeAccelerator() {
255 // OK to release because Destroy() will delete the VDA instance. 316 // OK to release because Destroy() will delete the VDA instance.
256 if (vda_) 317 if (vda_)
257 vda_.release()->Destroy(); 318 vda_.release()->Destroy();
258 } 319 }
259 320
260 } // namespace content 321 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698