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

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

Issue 1915443003: Replace scoped_ptr with std::unique_ptr in //media. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptr-media-base
Patch Set: scopedptr-media: rebase Created 4 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
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>
11 11
12 #include <algorithm> 12 #include <algorithm>
13 #include <list> 13 #include <list>
14 #include <memory>
14 #include <utility> 15 #include <utility>
15 16
16 #include "base/barrier_closure.h" 17 #include "base/barrier_closure.h"
17 #include "base/bind.h" 18 #include "base/bind.h"
18 #include "base/containers/stack_container.h" 19 #include "base/containers/stack_container.h"
19 #include "base/location.h" 20 #include "base/location.h"
20 #include "base/macros.h" 21 #include "base/macros.h"
21 #include "base/memory/linked_ptr.h" 22 #include "base/memory/linked_ptr.h"
22 #include "base/strings/stringprintf.h" 23 #include "base/strings/stringprintf.h"
23 #include "base/trace_event/memory_dump_provider.h" 24 #include "base/trace_event/memory_dump_provider.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 base::trace_event::ProcessMemoryDump* pmd) override; 69 base::trace_event::ProcessMemoryDump* pmd) override;
69 70
70 private: 71 private:
71 friend class base::RefCountedThreadSafe< 72 friend class base::RefCountedThreadSafe<
72 GpuMemoryBufferVideoFramePool::PoolImpl>; 73 GpuMemoryBufferVideoFramePool::PoolImpl>;
73 ~PoolImpl() override; 74 ~PoolImpl() override;
74 75
75 // Resource to represent a plane. 76 // Resource to represent a plane.
76 struct PlaneResource { 77 struct PlaneResource {
77 gfx::Size size; 78 gfx::Size size;
78 scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer; 79 std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer;
79 unsigned texture_id = 0u; 80 unsigned texture_id = 0u;
80 unsigned image_id = 0u; 81 unsigned image_id = 0u;
81 gpu::Mailbox mailbox; 82 gpu::Mailbox mailbox;
82 }; 83 };
83 84
84 // All the resources needed to compose a frame. 85 // All the resources needed to compose a frame.
85 struct FrameResources { 86 struct FrameResources {
86 explicit FrameResources(const gfx::Size& size) : size(size) {} 87 explicit FrameResources(const gfx::Size& size) : size(size) {}
87 void SetIsInUse(bool in_use) { in_use_ = in_use; } 88 void SetIsInUse(bool in_use) { in_use_ = in_use; }
88 bool IsInUse() const { 89 bool IsInUse() const {
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 } 534 }
534 } 535 }
535 } 536 }
536 } 537 }
537 538
538 void GpuMemoryBufferVideoFramePool::PoolImpl:: 539 void GpuMemoryBufferVideoFramePool::PoolImpl::
539 BindAndCreateMailboxesHardwareFrameResources( 540 BindAndCreateMailboxesHardwareFrameResources(
540 const scoped_refptr<VideoFrame>& video_frame, 541 const scoped_refptr<VideoFrame>& video_frame,
541 FrameResources* frame_resources, 542 FrameResources* frame_resources,
542 const FrameReadyCB& frame_ready_cb) { 543 const FrameReadyCB& frame_ready_cb) {
543 scoped_ptr<GpuVideoAcceleratorFactories::ScopedGLContextLock> lock( 544 std::unique_ptr<GpuVideoAcceleratorFactories::ScopedGLContextLock> lock(
544 gpu_factories_->GetGLContextLock()); 545 gpu_factories_->GetGLContextLock());
545 if (!lock) { 546 if (!lock) {
546 frame_ready_cb.Run(video_frame); 547 frame_ready_cb.Run(video_frame);
547 return; 548 return;
548 } 549 }
549 gpu::gles2::GLES2Interface* gles2 = lock->ContextGL(); 550 gpu::gles2::GLES2Interface* gles2 = lock->ContextGL();
550 551
551 const size_t num_planes = VideoFrame::NumPlanes(output_format_); 552 const size_t num_planes = VideoFrame::NumPlanes(output_format_);
552 const size_t planes_per_copy = PlanesPerCopy(output_format_); 553 const size_t planes_per_copy = PlanesPerCopy(output_format_);
553 const gfx::Size coded_size = CodedSize(video_frame, output_format_); 554 const gfx::Size coded_size = CodedSize(video_frame, output_format_);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 resources_pool_.erase(it++); 671 resources_pool_.erase(it++);
671 DeleteFrameResources(gpu_factories_, frame_resources); 672 DeleteFrameResources(gpu_factories_, frame_resources);
672 delete frame_resources; 673 delete frame_resources;
673 } 674 }
674 } else { 675 } else {
675 it++; 676 it++;
676 } 677 }
677 } 678 }
678 679
679 // Create the resources. 680 // Create the resources.
680 scoped_ptr<GpuVideoAcceleratorFactories::ScopedGLContextLock> lock( 681 std::unique_ptr<GpuVideoAcceleratorFactories::ScopedGLContextLock> lock(
681 gpu_factories_->GetGLContextLock()); 682 gpu_factories_->GetGLContextLock());
682 if (!lock) 683 if (!lock)
683 return nullptr; 684 return nullptr;
684 685
685 gpu::gles2::GLES2Interface* gles2 = lock->ContextGL(); 686 gpu::gles2::GLES2Interface* gles2 = lock->ContextGL();
686 gles2->ActiveTexture(GL_TEXTURE0); 687 gles2->ActiveTexture(GL_TEXTURE0);
687 size_t num_planes = VideoFrame::NumPlanes(format); 688 size_t num_planes = VideoFrame::NumPlanes(format);
688 FrameResources* frame_resources = new FrameResources(size); 689 FrameResources* frame_resources = new FrameResources(size);
689 resources_pool_.push_back(frame_resources); 690 resources_pool_.push_back(frame_resources);
690 for (size_t i = 0; i < num_planes; i += PlanesPerCopy(format)) { 691 for (size_t i = 0; i < num_planes; i += PlanesPerCopy(format)) {
(...skipping 21 matching lines...) Expand all
712 } 713 }
713 714
714 // static 715 // static
715 void GpuMemoryBufferVideoFramePool::PoolImpl::DeleteFrameResources( 716 void GpuMemoryBufferVideoFramePool::PoolImpl::DeleteFrameResources(
716 GpuVideoAcceleratorFactories* gpu_factories, 717 GpuVideoAcceleratorFactories* gpu_factories,
717 FrameResources* frame_resources) { 718 FrameResources* frame_resources) {
718 // TODO(dcastagna): As soon as the context lost is dealt with in media, 719 // TODO(dcastagna): As soon as the context lost is dealt with in media,
719 // make sure that we won't execute this callback (use a weak pointer to 720 // make sure that we won't execute this callback (use a weak pointer to
720 // the old context). 721 // the old context).
721 722
722 scoped_ptr<GpuVideoAcceleratorFactories::ScopedGLContextLock> lock( 723 std::unique_ptr<GpuVideoAcceleratorFactories::ScopedGLContextLock> lock(
723 gpu_factories->GetGLContextLock()); 724 gpu_factories->GetGLContextLock());
724 if (!lock) 725 if (!lock)
725 return; 726 return;
726 gpu::gles2::GLES2Interface* gles2 = lock->ContextGL(); 727 gpu::gles2::GLES2Interface* gles2 = lock->ContextGL();
727 728
728 for (PlaneResource& plane_resource : frame_resources->plane_resources) { 729 for (PlaneResource& plane_resource : frame_resources->plane_resources) {
729 if (plane_resource.image_id) 730 if (plane_resource.image_id)
730 gles2->DestroyImageCHROMIUM(plane_resource.image_id); 731 gles2->DestroyImageCHROMIUM(plane_resource.image_id);
731 if (plane_resource.texture_id) 732 if (plane_resource.texture_id)
732 gles2->DeleteTextures(1, &plane_resource.texture_id); 733 gles2->DeleteTextures(1, &plane_resource.texture_id);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 } 768 }
768 769
769 void GpuMemoryBufferVideoFramePool::MaybeCreateHardwareFrame( 770 void GpuMemoryBufferVideoFramePool::MaybeCreateHardwareFrame(
770 const scoped_refptr<VideoFrame>& video_frame, 771 const scoped_refptr<VideoFrame>& video_frame,
771 const FrameReadyCB& frame_ready_cb) { 772 const FrameReadyCB& frame_ready_cb) {
772 DCHECK(video_frame); 773 DCHECK(video_frame);
773 pool_impl_->CreateHardwareFrame(video_frame, frame_ready_cb); 774 pool_impl_->CreateHardwareFrame(video_frame, frame_ready_cb);
774 } 775 }
775 776
776 } // namespace media 777 } // namespace media
OLDNEW
« no previous file with comments | « media/test/pipeline_integration_test_base.cc ('k') | media/video/gpu_memory_buffer_video_frame_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698