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

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

Issue 23542060: Use GL_TEXTURE_2D for pixel readback path in GpuVideoAcceleratorFactories (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@git-svn
Patch Set: 58c9bd02 git cl format Created 7 years, 3 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_accelerator_factories.h" 5 #include "content/renderer/media/renderer_gpu_video_accelerator_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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 message_loop_async_waiter_.Signal(); 295 message_loop_async_waiter_.Signal();
296 return; 296 return;
297 } 297 }
298 298
299 gpu::gles2::GLES2Implementation* gles2 = context->GetImplementation(); 299 gpu::gles2::GLES2Implementation* gles2 = context->GetImplementation();
300 gles2->WaitSyncPointCHROMIUM(sync_point); 300 gles2->WaitSyncPointCHROMIUM(sync_point);
301 message_loop_async_waiter_.Signal(); 301 message_loop_async_waiter_.Signal();
302 } 302 }
303 303
304 void RendererGpuVideoAcceleratorFactories::ReadPixels(uint32 texture_id, 304 void RendererGpuVideoAcceleratorFactories::ReadPixels(uint32 texture_id,
305 uint32 texture_target,
306 const gfx::Size& size, 305 const gfx::Size& size,
307 const SkBitmap& pixels) { 306 const SkBitmap& pixels) {
308 // SkBitmaps use the SkPixelRef object to refcount the underlying pixels. 307 // SkBitmaps use the SkPixelRef object to refcount the underlying pixels.
309 // Multiple SkBitmaps can share a SkPixelRef instance. We use this to 308 // Multiple SkBitmaps can share a SkPixelRef instance. We use this to
310 // ensure that the underlying pixels in the SkBitmap passed in remain valid 309 // ensure that the underlying pixels in the SkBitmap passed in remain valid
311 // until the AsyncReadPixels() call completes. 310 // until the AsyncReadPixels() call completes.
312 read_pixels_bitmap_.setPixelRef(pixels.pixelRef()); 311 read_pixels_bitmap_.setPixelRef(pixels.pixelRef());
313 312
314 if (!message_loop_->BelongsToCurrentThread()) { 313 if (!message_loop_->BelongsToCurrentThread()) {
315 message_loop_->PostTask( 314 message_loop_->PostTask(
316 FROM_HERE, 315 FROM_HERE,
317 base::Bind(&RendererGpuVideoAcceleratorFactories::AsyncReadPixels, 316 base::Bind(&RendererGpuVideoAcceleratorFactories::AsyncReadPixels,
318 this, 317 this,
319 texture_id, 318 texture_id,
320 texture_target,
321 size)); 319 size));
322 base::WaitableEvent* objects[] = {&aborted_waiter_, 320 base::WaitableEvent* objects[] = {&aborted_waiter_,
323 &message_loop_async_waiter_}; 321 &message_loop_async_waiter_};
324 if (base::WaitableEvent::WaitMany(objects, arraysize(objects)) == 0) 322 if (base::WaitableEvent::WaitMany(objects, arraysize(objects)) == 0)
325 return; 323 return;
326 } else { 324 } else {
327 AsyncReadPixels(texture_id, texture_target, size); 325 AsyncReadPixels(texture_id, size);
328 message_loop_async_waiter_.Reset(); 326 message_loop_async_waiter_.Reset();
329 } 327 }
330 read_pixels_bitmap_.setPixelRef(NULL); 328 read_pixels_bitmap_.setPixelRef(NULL);
331 } 329 }
332 330
333 void RendererGpuVideoAcceleratorFactories::AsyncReadPixels( 331 void RendererGpuVideoAcceleratorFactories::AsyncReadPixels(
334 uint32 texture_id, 332 uint32 texture_id,
335 uint32 texture_target,
336 const gfx::Size& size) { 333 const gfx::Size& size) {
337 DCHECK(message_loop_->BelongsToCurrentThread()); 334 DCHECK(message_loop_->BelongsToCurrentThread());
338 WebGraphicsContext3DCommandBufferImpl* context = GetContext3d(); 335 WebGraphicsContext3DCommandBufferImpl* context = GetContext3d();
339 if (!context) { 336 if (!context) {
340 message_loop_async_waiter_.Signal(); 337 message_loop_async_waiter_.Signal();
341 return; 338 return;
342 } 339 }
343 340
344 gpu::gles2::GLES2Implementation* gles2 = context->GetImplementation(); 341 gpu::gles2::GLES2Implementation* gles2 = context->GetImplementation();
345 342
346 GLuint tmp_texture; 343 GLuint tmp_texture;
347 gles2->GenTextures(1, &tmp_texture); 344 gles2->GenTextures(1, &tmp_texture);
348 gles2->BindTexture(texture_target, tmp_texture); 345 gles2->BindTexture(GL_TEXTURE_2D, tmp_texture);
349 gles2->TexParameteri(texture_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 346 gles2->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
350 gles2->TexParameteri(texture_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 347 gles2->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
351 gles2->TexParameteri(texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 348 gles2->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
352 gles2->TexParameteri(texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 349 gles2->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
353 context->copyTextureCHROMIUM( 350 context->copyTextureCHROMIUM(
354 texture_target, texture_id, tmp_texture, 0, GL_RGBA, GL_UNSIGNED_BYTE); 351 GL_TEXTURE_2D, texture_id, tmp_texture, 0, GL_RGBA, GL_UNSIGNED_BYTE);
355 352
356 GLuint fb; 353 GLuint fb;
357 gles2->GenFramebuffers(1, &fb); 354 gles2->GenFramebuffers(1, &fb);
358 gles2->BindFramebuffer(GL_FRAMEBUFFER, fb); 355 gles2->BindFramebuffer(GL_FRAMEBUFFER, fb);
359 gles2->FramebufferTexture2D( 356 gles2->FramebufferTexture2D(
360 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texture_target, tmp_texture, 0); 357 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tmp_texture, 0);
361 gles2->PixelStorei(GL_PACK_ALIGNMENT, 4); 358 gles2->PixelStorei(GL_PACK_ALIGNMENT, 4);
362 gles2->ReadPixels(0, 359 gles2->ReadPixels(0,
363 0, 360 0,
364 size.width(), 361 size.width(),
365 size.height(), 362 size.height(),
366 GL_BGRA_EXT, 363 GL_BGRA_EXT,
367 GL_UNSIGNED_BYTE, 364 GL_UNSIGNED_BYTE,
368 read_pixels_bitmap_.pixelRef()->pixels()); 365 read_pixels_bitmap_.pixelRef()->pixels());
369 gles2->DeleteFramebuffers(1, &fb); 366 gles2->DeleteFramebuffers(1, &fb);
370 gles2->DeleteTextures(1, &tmp_texture); 367 gles2->DeleteTextures(1, &tmp_texture);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 } 404 }
408 405
409 void 406 void
410 RendererGpuVideoAcceleratorFactories::AsyncDestroyVideoEncodeAccelerator() { 407 RendererGpuVideoAcceleratorFactories::AsyncDestroyVideoEncodeAccelerator() {
411 // OK to release because Destroy() will delete the VDA instance. 408 // OK to release because Destroy() will delete the VDA instance.
412 if (vea_) 409 if (vea_)
413 vea_.release()->Destroy(); 410 vea_.release()->Destroy();
414 } 411 }
415 412
416 } // namespace content 413 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/renderer_gpu_video_accelerator_factories.h ('k') | content/renderer/media/rtc_video_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698