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

Side by Side Diff: media/video/gpu_memory_buffer_video_frame_pool.cc

Issue 2087673002: Remove CreateGpuMemoryBufferFromClientId and plumbing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 6 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 | « media/base/video_frame.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "media/video/gpu_memory_buffer_video_frame_pool.h" 5 #include "media/video/gpu_memory_buffer_video_frame_pool.h"
6 6
7 #include <GLES2/gl2.h> 7 #include <GLES2/gl2.h>
8 #include <GLES2/gl2ext.h> 8 #include <GLES2/gl2ext.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <stdint.h> 10 #include <stdint.h>
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 if (!lock) { 536 if (!lock) {
537 frame_ready_cb.Run(video_frame); 537 frame_ready_cb.Run(video_frame);
538 return; 538 return;
539 } 539 }
540 gpu::gles2::GLES2Interface* gles2 = lock->ContextGL(); 540 gpu::gles2::GLES2Interface* gles2 = lock->ContextGL();
541 541
542 const size_t num_planes = VideoFrame::NumPlanes(output_format_); 542 const size_t num_planes = VideoFrame::NumPlanes(output_format_);
543 const size_t planes_per_copy = PlanesPerCopy(output_format_); 543 const size_t planes_per_copy = PlanesPerCopy(output_format_);
544 const gfx::Size coded_size = CodedSize(video_frame, output_format_); 544 const gfx::Size coded_size = CodedSize(video_frame, output_format_);
545 gpu::MailboxHolder mailbox_holders[VideoFrame::kMaxPlanes]; 545 gpu::MailboxHolder mailbox_holders[VideoFrame::kMaxPlanes];
546 gfx::GpuMemoryBufferId gpu_memory_buffer_ids[VideoFrame::kMaxPlanes];
547 // Set up the planes creating the mailboxes needed to refer to the textures. 546 // Set up the planes creating the mailboxes needed to refer to the textures.
548 for (size_t i = 0; i < num_planes; i += planes_per_copy) { 547 for (size_t i = 0; i < num_planes; i += planes_per_copy) {
549 PlaneResource& plane_resource = frame_resources->plane_resources[i]; 548 PlaneResource& plane_resource = frame_resources->plane_resources[i];
550 const gfx::BufferFormat buffer_format = 549 const gfx::BufferFormat buffer_format =
551 GpuMemoryBufferFormat(output_format_, i); 550 GpuMemoryBufferFormat(output_format_, i);
552 unsigned texture_target = gpu_factories_->ImageTextureTarget(buffer_format); 551 unsigned texture_target = gpu_factories_->ImageTextureTarget(buffer_format);
553 // Bind the texture and create or rebind the image. 552 // Bind the texture and create or rebind the image.
554 gles2->BindTexture(texture_target, plane_resource.texture_id); 553 gles2->BindTexture(texture_target, plane_resource.texture_id);
555 554
556 if (plane_resource.gpu_memory_buffer && !plane_resource.image_id) { 555 if (plane_resource.gpu_memory_buffer && !plane_resource.image_id) {
557 const size_t width = 556 const size_t width =
558 VideoFrame::Columns(i, output_format_, coded_size.width()); 557 VideoFrame::Columns(i, output_format_, coded_size.width());
559 const size_t height = 558 const size_t height =
560 VideoFrame::Rows(i, output_format_, coded_size.height()); 559 VideoFrame::Rows(i, output_format_, coded_size.height());
561 plane_resource.image_id = gles2->CreateImageCHROMIUM( 560 plane_resource.image_id = gles2->CreateImageCHROMIUM(
562 plane_resource.gpu_memory_buffer->AsClientBuffer(), width, height, 561 plane_resource.gpu_memory_buffer->AsClientBuffer(), width, height,
563 ImageInternalFormat(output_format_, i)); 562 ImageInternalFormat(output_format_, i));
564 } else if (plane_resource.image_id) { 563 } else if (plane_resource.image_id) {
565 gles2->ReleaseTexImage2DCHROMIUM(texture_target, plane_resource.image_id); 564 gles2->ReleaseTexImage2DCHROMIUM(texture_target, plane_resource.image_id);
566 } 565 }
567 if (plane_resource.gpu_memory_buffer)
568 gpu_memory_buffer_ids[i] = plane_resource.gpu_memory_buffer->GetId();
569 if (plane_resource.image_id) 566 if (plane_resource.image_id)
570 gles2->BindTexImage2DCHROMIUM(texture_target, plane_resource.image_id); 567 gles2->BindTexImage2DCHROMIUM(texture_target, plane_resource.image_id);
571 mailbox_holders[i] = gpu::MailboxHolder(plane_resource.mailbox, 568 mailbox_holders[i] = gpu::MailboxHolder(plane_resource.mailbox,
572 gpu::SyncToken(), texture_target); 569 gpu::SyncToken(), texture_target);
573 } 570 }
574 571
575 // Insert a sync_token, this is needed to make sure that the textures the 572 // Insert a sync_token, this is needed to make sure that the textures the
576 // mailboxes refer to will be used only after all the previous commands posted 573 // mailboxes refer to will be used only after all the previous commands posted
577 // in the command buffer have been processed. 574 // in the command buffer have been processed.
578 const GLuint64 fence_sync = gles2->InsertFenceSyncCHROMIUM(); 575 const GLuint64 fence_sync = gles2->InsertFenceSyncCHROMIUM();
579 gles2->OrderingBarrierCHROMIUM(); 576 gles2->OrderingBarrierCHROMIUM();
580 577
581 gpu::SyncToken sync_token; 578 gpu::SyncToken sync_token;
582 gles2->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); 579 gles2->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData());
583 for (size_t i = 0; i < num_planes; i += planes_per_copy) 580 for (size_t i = 0; i < num_planes; i += planes_per_copy)
584 mailbox_holders[i].sync_token = sync_token; 581 mailbox_holders[i].sync_token = sync_token;
585 582
586 583
587 auto release_mailbox_callback = BindToCurrentLoop( 584 auto release_mailbox_callback = BindToCurrentLoop(
588 base::Bind(&PoolImpl::MailboxHoldersReleased, this, frame_resources)); 585 base::Bind(&PoolImpl::MailboxHoldersReleased, this, frame_resources));
589 586
590 // Consumers should sample from NV12 textures as if they're XRGB. 587 // Consumers should sample from NV12 textures as if they're XRGB.
591 VideoPixelFormat frame_format = 588 VideoPixelFormat frame_format =
592 output_format_ == PIXEL_FORMAT_NV12 ? PIXEL_FORMAT_XRGB : output_format_; 589 output_format_ == PIXEL_FORMAT_NV12 ? PIXEL_FORMAT_XRGB : output_format_;
593 DCHECK_EQ(VideoFrame::NumPlanes(frame_format) * planes_per_copy, num_planes); 590 DCHECK_EQ(VideoFrame::NumPlanes(frame_format) * planes_per_copy, num_planes);
594 591
595 // Create the VideoFrame backed by native textures. 592 // Create the VideoFrame backed by native textures.
596 gfx::Size visible_size = video_frame->visible_rect().size(); 593 gfx::Size visible_size = video_frame->visible_rect().size();
597 scoped_refptr<VideoFrame> frame = 594 scoped_refptr<VideoFrame> frame = VideoFrame::WrapNativeTextures(
598 VideoFrame::WrapGpuMemoryBufferBackedNativeTextures( 595 frame_format, mailbox_holders, release_mailbox_callback, coded_size,
599 frame_format, mailbox_holders, gpu_memory_buffer_ids, 596 gfx::Rect(visible_size), video_frame->natural_size(),
600 release_mailbox_callback, coded_size, gfx::Rect(visible_size), 597 video_frame->timestamp());
601 video_frame->natural_size(), video_frame->timestamp());
602 598
603 if (!frame) { 599 if (!frame) {
604 release_mailbox_callback.Run(gpu::SyncToken()); 600 release_mailbox_callback.Run(gpu::SyncToken());
605 frame_ready_cb.Run(video_frame); 601 frame_ready_cb.Run(video_frame);
606 return; 602 return;
607 } 603 }
608 604
609 bool allow_overlay = false; 605 bool allow_overlay = false;
610 switch (output_format_) { 606 switch (output_format_) {
611 case PIXEL_FORMAT_I420: 607 case PIXEL_FORMAT_I420:
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 } 758 }
763 759
764 void GpuMemoryBufferVideoFramePool::MaybeCreateHardwareFrame( 760 void GpuMemoryBufferVideoFramePool::MaybeCreateHardwareFrame(
765 const scoped_refptr<VideoFrame>& video_frame, 761 const scoped_refptr<VideoFrame>& video_frame,
766 const FrameReadyCB& frame_ready_cb) { 762 const FrameReadyCB& frame_ready_cb) {
767 DCHECK(video_frame); 763 DCHECK(video_frame);
768 pool_impl_->CreateHardwareFrame(video_frame, frame_ready_cb); 764 pool_impl_->CreateHardwareFrame(video_frame, frame_ready_cb);
769 } 765 }
770 766
771 } // namespace media 767 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_frame.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698