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

Side by Side Diff: media/base/video_frame.cc

Issue 2006893002: Video Gmb Pool: Plumb GpuMemoryBufferId through to compositor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add gmb ID support to unittests Created 4 years, 7 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.h ('k') | media/renderers/mock_gpu_video_accelerator_factories.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "media/base/video_frame.h" 5 #include "media/base/video_frame.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <climits> 8 #include <climits>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 << ConfigToString(format, storage, coded_size, visible_rect, 177 << ConfigToString(format, storage, coded_size, visible_rect,
178 natural_size); 178 natural_size);
179 return nullptr; 179 return nullptr;
180 } 180 }
181 181
182 return new VideoFrame(format, storage, coded_size, visible_rect, natural_size, 182 return new VideoFrame(format, storage, coded_size, visible_rect, natural_size,
183 mailbox_holders, mailbox_holder_release_cb, timestamp); 183 mailbox_holders, mailbox_holder_release_cb, timestamp);
184 } 184 }
185 185
186 // static 186 // static
187 scoped_refptr<VideoFrame> VideoFrame::WrapGpuMemoryBufferBackedNativeTextures(
188 VideoPixelFormat format,
189 const gpu::MailboxHolder (&mailbox_holders)[kMaxPlanes],
190 const gfx::GpuMemoryBufferId (&gpu_memory_buffer_ids)[kMaxPlanes],
191 const ReleaseMailboxCB& mailbox_holder_release_cb,
192 const gfx::Size& coded_size,
193 const gfx::Rect& visible_rect,
194 const gfx::Size& natural_size,
195 base::TimeDelta timestamp) {
196 scoped_refptr<VideoFrame> frame =
197 WrapNativeTextures(format, mailbox_holders, mailbox_holder_release_cb,
198 coded_size, visible_rect, natural_size, timestamp);
199 if (frame) {
200 frame->storage_type_ = STORAGE_GPU_MEMORY_BUFFERS;
201 for (size_t i = 0; i < kMaxPlanes; ++i)
202 frame->texture_gpu_memory_buffer_ids_[i] = gpu_memory_buffer_ids[i];
203 }
204 return frame;
205 }
206
207 // static
187 scoped_refptr<VideoFrame> VideoFrame::WrapExternalData( 208 scoped_refptr<VideoFrame> VideoFrame::WrapExternalData(
188 VideoPixelFormat format, 209 VideoPixelFormat format,
189 const gfx::Size& coded_size, 210 const gfx::Size& coded_size,
190 const gfx::Rect& visible_rect, 211 const gfx::Rect& visible_rect,
191 const gfx::Size& natural_size, 212 const gfx::Size& natural_size,
192 uint8_t* data, 213 uint8_t* data,
193 size_t data_size, 214 size_t data_size,
194 base::TimeDelta timestamp) { 215 base::TimeDelta timestamp) {
195 return WrapExternalStorage(format, STORAGE_UNOWNED_MEMORY, coded_size, 216 return WrapExternalStorage(format, STORAGE_UNOWNED_MEMORY, coded_size,
196 visible_rect, natural_size, data, data_size, 217 visible_rect, natural_size, data, data_size,
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 static_cast<const VideoFrame*>(this)->visible_data(plane)); 675 static_cast<const VideoFrame*>(this)->visible_data(plane));
655 } 676 }
656 677
657 const gpu::MailboxHolder& 678 const gpu::MailboxHolder&
658 VideoFrame::mailbox_holder(size_t texture_index) const { 679 VideoFrame::mailbox_holder(size_t texture_index) const {
659 DCHECK(HasTextures()); 680 DCHECK(HasTextures());
660 DCHECK(IsValidPlane(texture_index, format_)); 681 DCHECK(IsValidPlane(texture_index, format_));
661 return mailbox_holders_[texture_index]; 682 return mailbox_holders_[texture_index];
662 } 683 }
663 684
685 const gfx::GpuMemoryBufferId& VideoFrame::texture_gpu_memory_buffer_id(
686 size_t texture_index) const {
687 DCHECK(HasTextures());
688 DCHECK(IsValidPlane(texture_index, format_));
689 return texture_gpu_memory_buffer_ids_[texture_index];
690 }
691
664 base::SharedMemoryHandle VideoFrame::shared_memory_handle() const { 692 base::SharedMemoryHandle VideoFrame::shared_memory_handle() const {
665 DCHECK_EQ(storage_type_, STORAGE_SHMEM); 693 DCHECK_EQ(storage_type_, STORAGE_SHMEM);
666 DCHECK(shared_memory_handle_ != base::SharedMemory::NULLHandle()); 694 DCHECK(shared_memory_handle_ != base::SharedMemory::NULLHandle());
667 return shared_memory_handle_; 695 return shared_memory_handle_;
668 } 696 }
669 697
670 size_t VideoFrame::shared_memory_offset() const { 698 size_t VideoFrame::shared_memory_offset() const {
671 DCHECK_EQ(storage_type_, STORAGE_SHMEM); 699 DCHECK_EQ(storage_type_, STORAGE_SHMEM);
672 DCHECK(shared_memory_handle_ != base::SharedMemory::NULLHandle()); 700 DCHECK(shared_memory_handle_ != base::SharedMemory::NULLHandle());
673 return shared_memory_offset_; 701 return shared_memory_offset_;
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 if (zero_initialize_memory) 1111 if (zero_initialize_memory)
1084 memset(data, 0, data_size); 1112 memset(data, 0, data_size);
1085 1113
1086 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) 1114 for (size_t plane = 0; plane < NumPlanes(format_); ++plane)
1087 data_[plane] = data + offset[plane]; 1115 data_[plane] = data + offset[plane];
1088 1116
1089 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); 1117 AddDestructionObserver(base::Bind(&base::AlignedFree, data));
1090 } 1118 }
1091 1119
1092 } // namespace media 1120 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_frame.h ('k') | media/renderers/mock_gpu_video_accelerator_factories.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698