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

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

Issue 9416087: Add texture target field to video frame (for use by native textures). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: (c) 2011 -> (c) 2012 Created 8 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « media/base/video_frame.h ('k') | media/filters/gpu_video_decoder.h » ('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 "base/logging.h" 7 #include "base/logging.h"
8 #include "media/base/limits.h" 8 #include "media/base/limits.h"
9 #include "media/base/video_util.h" 9 #include "media/base/video_util.h"
10 10
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 return (format != VideoFrame::INVALID && 55 return (format != VideoFrame::INVALID &&
56 width > 0 && height > 0 && 56 width > 0 && height > 0 &&
57 width <= limits::kMaxDimension && height <= limits::kMaxDimension && 57 width <= limits::kMaxDimension && height <= limits::kMaxDimension &&
58 width * height <= limits::kMaxCanvas); 58 width * height <= limits::kMaxCanvas);
59 } 59 }
60 60
61 // static 61 // static
62 scoped_refptr<VideoFrame> VideoFrame::WrapNativeTexture( 62 scoped_refptr<VideoFrame> VideoFrame::WrapNativeTexture(
63 uint32 texture_id, 63 uint32 texture_id,
64 uint32 texture_target,
64 size_t width, 65 size_t width,
65 size_t height, 66 size_t height,
66 base::TimeDelta timestamp, 67 base::TimeDelta timestamp,
67 base::TimeDelta duration, 68 base::TimeDelta duration,
68 const base::Closure& no_longer_needed) { 69 const base::Closure& no_longer_needed) {
69 scoped_refptr<VideoFrame> frame( 70 scoped_refptr<VideoFrame> frame(
70 new VideoFrame(NATIVE_TEXTURE, width, height, timestamp, duration)); 71 new VideoFrame(NATIVE_TEXTURE, width, height, timestamp, duration));
71 frame->texture_id_ = texture_id; 72 frame->texture_id_ = texture_id;
73 frame->texture_target_ = texture_target;
72 frame->texture_no_longer_needed_ = no_longer_needed; 74 frame->texture_no_longer_needed_ = no_longer_needed;
73 return frame; 75 return frame;
74 } 76 }
75 77
76 // static 78 // static
77 scoped_refptr<VideoFrame> VideoFrame::CreateEmptyFrame() { 79 scoped_refptr<VideoFrame> VideoFrame::CreateEmptyFrame() {
78 return new VideoFrame( 80 return new VideoFrame(
79 VideoFrame::EMPTY, 0, 0, base::TimeDelta(), base::TimeDelta()); 81 VideoFrame::EMPTY, 0, 0, base::TimeDelta(), base::TimeDelta());
80 } 82 }
81 83
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 } 145 }
144 146
145 VideoFrame::VideoFrame(VideoFrame::Format format, 147 VideoFrame::VideoFrame(VideoFrame::Format format,
146 size_t width, 148 size_t width,
147 size_t height, 149 size_t height,
148 base::TimeDelta timestamp, 150 base::TimeDelta timestamp,
149 base::TimeDelta duration) 151 base::TimeDelta duration)
150 : format_(format), 152 : format_(format),
151 width_(width), 153 width_(width),
152 height_(height), 154 height_(height),
153 texture_id_(0) { 155 texture_id_(0),
156 texture_target_(0) {
154 SetTimestamp(timestamp); 157 SetTimestamp(timestamp);
155 SetDuration(duration); 158 SetDuration(duration);
156 memset(&strides_, 0, sizeof(strides_)); 159 memset(&strides_, 0, sizeof(strides_));
157 memset(&data_, 0, sizeof(data_)); 160 memset(&data_, 0, sizeof(data_));
158 } 161 }
159 162
160 VideoFrame::~VideoFrame() { 163 VideoFrame::~VideoFrame() {
161 if (format_ == NATIVE_TEXTURE && !texture_no_longer_needed_.is_null()) { 164 if (format_ == NATIVE_TEXTURE && !texture_no_longer_needed_.is_null()) {
162 texture_no_longer_needed_.Run(); 165 texture_no_longer_needed_.Run();
163 texture_no_longer_needed_.Reset(); 166 texture_no_longer_needed_.Reset();
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 uint8* VideoFrame::data(size_t plane) const { 256 uint8* VideoFrame::data(size_t plane) const {
254 DCHECK(IsValidPlane(plane)); 257 DCHECK(IsValidPlane(plane));
255 return data_[plane]; 258 return data_[plane];
256 } 259 }
257 260
258 uint32 VideoFrame::texture_id() const { 261 uint32 VideoFrame::texture_id() const {
259 DCHECK_EQ(format_, NATIVE_TEXTURE); 262 DCHECK_EQ(format_, NATIVE_TEXTURE);
260 return texture_id_; 263 return texture_id_;
261 } 264 }
262 265
266 uint32 VideoFrame::texture_target() const {
267 DCHECK_EQ(format_, NATIVE_TEXTURE);
268 return texture_target_;
269 }
270
263 bool VideoFrame::IsEndOfStream() const { 271 bool VideoFrame::IsEndOfStream() const {
264 return format_ == VideoFrame::EMPTY; 272 return format_ == VideoFrame::EMPTY;
265 } 273 }
266 274
267 } // namespace media 275 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_frame.h ('k') | media/filters/gpu_video_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698