OLD | NEW |
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 "base/string_piece.h" | 8 #include "base/string_piece.h" |
9 #include "media/base/limits.h" | 9 #include "media/base/limits.h" |
10 #include "media/base/video_util.h" | 10 #include "media/base/video_util.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 natural_size.width() * natural_size.height() <= limits::kMaxCanvas); | 54 natural_size.width() * natural_size.height() <= limits::kMaxCanvas); |
55 } | 55 } |
56 | 56 |
57 // static | 57 // static |
58 scoped_refptr<VideoFrame> VideoFrame::WrapNativeTexture( | 58 scoped_refptr<VideoFrame> VideoFrame::WrapNativeTexture( |
59 uint32 texture_id, | 59 uint32 texture_id, |
60 uint32 texture_target, | 60 uint32 texture_target, |
61 const gfx::Size& data_size, | 61 const gfx::Size& data_size, |
62 const gfx::Size& natural_size, | 62 const gfx::Size& natural_size, |
63 base::TimeDelta timestamp, | 63 base::TimeDelta timestamp, |
| 64 const ReadPixelsCB& read_pixels_cb, |
64 const base::Closure& no_longer_needed) { | 65 const base::Closure& no_longer_needed) { |
65 scoped_refptr<VideoFrame> frame( | 66 scoped_refptr<VideoFrame> frame( |
66 new VideoFrame(NATIVE_TEXTURE, data_size, natural_size, timestamp)); | 67 new VideoFrame(NATIVE_TEXTURE, data_size, natural_size, timestamp)); |
67 frame->texture_id_ = texture_id; | 68 frame->texture_id_ = texture_id; |
68 frame->texture_target_ = texture_target; | 69 frame->texture_target_ = texture_target; |
| 70 frame->read_pixels_cb_ = read_pixels_cb; |
69 frame->texture_no_longer_needed_ = no_longer_needed; | 71 frame->texture_no_longer_needed_ = no_longer_needed; |
70 return frame; | 72 return frame; |
71 } | 73 } |
72 | 74 |
| 75 void VideoFrame::ReadPixelsFromNativeTexture(void* pixels) { |
| 76 DCHECK_EQ(format_, NATIVE_TEXTURE); |
| 77 if (!read_pixels_cb_.is_null()) |
| 78 read_pixels_cb_.Run(pixels); |
| 79 } |
| 80 |
73 // static | 81 // static |
74 scoped_refptr<VideoFrame> VideoFrame::CreateEmptyFrame() { | 82 scoped_refptr<VideoFrame> VideoFrame::CreateEmptyFrame() { |
75 return new VideoFrame( | 83 return new VideoFrame( |
76 VideoFrame::EMPTY, gfx::Size(), gfx::Size(), base::TimeDelta()); | 84 VideoFrame::EMPTY, gfx::Size(), gfx::Size(), base::TimeDelta()); |
77 } | 85 } |
78 | 86 |
79 // static | 87 // static |
80 scoped_refptr<VideoFrame> VideoFrame::CreateBlackFrame( | 88 scoped_refptr<VideoFrame> VideoFrame::CreateBlackFrame( |
81 const gfx::Size& data_size) { | 89 const gfx::Size& data_size) { |
82 DCHECK(IsValidConfig(VideoFrame::YV12, data_size, data_size)); | 90 DCHECK(IsValidConfig(VideoFrame::YV12, data_size, data_size)); |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 break; | 304 break; |
297 for(int row = 0; row < rows(plane); row++) { | 305 for(int row = 0; row < rows(plane); row++) { |
298 base::MD5Update(context, base::StringPiece( | 306 base::MD5Update(context, base::StringPiece( |
299 reinterpret_cast<char*>(data(plane) + stride(plane) * row), | 307 reinterpret_cast<char*>(data(plane) + stride(plane) * row), |
300 row_bytes(plane))); | 308 row_bytes(plane))); |
301 } | 309 } |
302 } | 310 } |
303 } | 311 } |
304 | 312 |
305 } // namespace media | 313 } // namespace media |
OLD | NEW |