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

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

Issue 1427543002: Modified old wait sync point functions to also accept new sync tokens. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix mock gpu video accelerator factory Created 5 years, 1 month 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 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 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // Get the resources needed for a frame out of the pool, or create them if 117 // Get the resources needed for a frame out of the pool, or create them if
118 // necessary. 118 // necessary.
119 // This also drops the LRU resources that can't be reuse for this frame. 119 // This also drops the LRU resources that can't be reuse for this frame.
120 FrameResources* GetOrCreateFrameResources(const gfx::Size& size, 120 FrameResources* GetOrCreateFrameResources(const gfx::Size& size,
121 VideoPixelFormat format); 121 VideoPixelFormat format);
122 122
123 // Callback called when a VideoFrame generated with GetFrameResources is no 123 // Callback called when a VideoFrame generated with GetFrameResources is no
124 // longer referenced. 124 // longer referenced.
125 // This could be called by any thread. 125 // This could be called by any thread.
126 void MailboxHoldersReleased(FrameResources* frame_resources, 126 void MailboxHoldersReleased(FrameResources* frame_resources,
127 uint32 sync_point); 127 uint32 sync_point,
128 const gpu::SyncToken& sync_token);
128 129
129 // Return frame resources to the pool. This has to be called on the thread 130 // Return frame resources to the pool. This has to be called on the thread
130 // where |media_task_runner_| is current. 131 // where |media_task_runner_| is current.
131 void ReturnFrameResources(FrameResources* frame_resources); 132 void ReturnFrameResources(FrameResources* frame_resources);
132 133
133 // Delete resources. This has to be called on the thread where |task_runner| 134 // Delete resources. This has to be called on the thread where |task_runner|
134 // is current. 135 // is current.
135 static void DeleteFrameResources(GpuVideoAcceleratorFactories* gpu_factories, 136 static void DeleteFrameResources(GpuVideoAcceleratorFactories* gpu_factories,
136 FrameResources* frame_resources); 137 FrameResources* frame_resources);
137 138
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 VideoFrame::Rows(i, output_format_, coded_size.height()); 548 VideoFrame::Rows(i, output_format_, coded_size.height());
548 plane_resource.image_id = gles2->CreateImageCHROMIUM( 549 plane_resource.image_id = gles2->CreateImageCHROMIUM(
549 plane_resource.gpu_memory_buffer->AsClientBuffer(), width, height, 550 plane_resource.gpu_memory_buffer->AsClientBuffer(), width, height,
550 ImageInternalFormat(output_format_, i)); 551 ImageInternalFormat(output_format_, i));
551 } else if (plane_resource.image_id) { 552 } else if (plane_resource.image_id) {
552 gles2->ReleaseTexImage2DCHROMIUM(texture_target_, 553 gles2->ReleaseTexImage2DCHROMIUM(texture_target_,
553 plane_resource.image_id); 554 plane_resource.image_id);
554 } 555 }
555 if (plane_resource.image_id) 556 if (plane_resource.image_id)
556 gles2->BindTexImage2DCHROMIUM(texture_target_, plane_resource.image_id); 557 gles2->BindTexImage2DCHROMIUM(texture_target_, plane_resource.image_id);
557 mailbox_holders[i] = 558 mailbox_holders[i] = gpu::MailboxHolder(plane_resource.mailbox, 0,
558 gpu::MailboxHolder(plane_resource.mailbox, texture_target_, 0); 559 gpu::SyncToken(), texture_target_);
559 } 560 }
560 561
561 // Insert a sync_point, this is needed to make sure that the textures the 562 // Insert a sync_point, this is needed to make sure that the textures the
562 // mailboxes refer to will be used only after all the previous commands posted 563 // mailboxes refer to will be used only after all the previous commands posted
563 // in the command buffer have been processed. 564 // in the command buffer have been processed.
564 unsigned sync_point = gles2->InsertSyncPointCHROMIUM(); 565 unsigned sync_point = gles2->InsertSyncPointCHROMIUM();
565 for (size_t i = 0; i < num_planes; i += planes_per_copy) 566 for (size_t i = 0; i < num_planes; i += planes_per_copy)
566 mailbox_holders[i].sync_point = sync_point; 567 mailbox_holders[i].sync_point = sync_point;
567 568
568 scoped_refptr<VideoFrame> frame; 569 scoped_refptr<VideoFrame> frame;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 if (plane_resource.image_id) 686 if (plane_resource.image_id)
686 gles2->DestroyImageCHROMIUM(plane_resource.image_id); 687 gles2->DestroyImageCHROMIUM(plane_resource.image_id);
687 if (plane_resource.texture_id) 688 if (plane_resource.texture_id)
688 gles2->DeleteTextures(1, &plane_resource.texture_id); 689 gles2->DeleteTextures(1, &plane_resource.texture_id);
689 } 690 }
690 } 691 }
691 692
692 // Called when a VideoFrame is no longer references. 693 // Called when a VideoFrame is no longer references.
693 void GpuMemoryBufferVideoFramePool::PoolImpl::MailboxHoldersReleased( 694 void GpuMemoryBufferVideoFramePool::PoolImpl::MailboxHoldersReleased(
694 FrameResources* frame_resources, 695 FrameResources* frame_resources,
695 uint32 sync_point) { 696 uint32 sync_point,
697 const gpu::SyncToken& sync_token) {
696 // Return the resource on the media thread. 698 // Return the resource on the media thread.
697 media_task_runner_->PostTask( 699 media_task_runner_->PostTask(
698 FROM_HERE, 700 FROM_HERE,
699 base::Bind(&PoolImpl::ReturnFrameResources, this, frame_resources)); 701 base::Bind(&PoolImpl::ReturnFrameResources, this, frame_resources));
700 } 702 }
701 703
702 // Put back the resources in the pool. 704 // Put back the resources in the pool.
703 void GpuMemoryBufferVideoFramePool::PoolImpl::ReturnFrameResources( 705 void GpuMemoryBufferVideoFramePool::PoolImpl::ReturnFrameResources(
704 FrameResources* frame_resources) { 706 FrameResources* frame_resources) {
705 auto it = std::find(resources_pool_.begin(), resources_pool_.end(), 707 auto it = std::find(resources_pool_.begin(), resources_pool_.end(),
(...skipping 24 matching lines...) Expand all
730 } 732 }
731 733
732 void GpuMemoryBufferVideoFramePool::MaybeCreateHardwareFrame( 734 void GpuMemoryBufferVideoFramePool::MaybeCreateHardwareFrame(
733 const scoped_refptr<VideoFrame>& video_frame, 735 const scoped_refptr<VideoFrame>& video_frame,
734 const FrameReadyCB& frame_ready_cb) { 736 const FrameReadyCB& frame_ready_cb) {
735 DCHECK(video_frame); 737 DCHECK(video_frame);
736 pool_impl_->CreateHardwareFrame(video_frame, frame_ready_cb); 738 pool_impl_->CreateHardwareFrame(video_frame, frame_ready_cb);
737 } 739 }
738 740
739 } // namespace media 741 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698