Chromium Code Reviews| Index: media/video/picture.cc |
| diff --git a/media/video/picture.cc b/media/video/picture.cc |
| index dd57e4af4d3f3ce89d9fd6d85104fd9c48e73df7..1e0a1851ec5781ad29c62fc8f69d6be8d8579db8 100644 |
| --- a/media/video/picture.cc |
| +++ b/media/video/picture.cc |
| @@ -4,69 +4,93 @@ |
| #include "media/video/picture.h" |
| +#include "base/logging.h" |
| + |
| namespace media { |
| -// PictureBuffer implementation. |
| -PictureBuffer::PictureBuffer(int32 id, |
| - gfx::Size pixel_size, |
| - std::vector<uint32> color_format, |
| - MemoryType memory_type, |
| - std::vector<DataPlaneHandle> data_plane_handles) |
| - : id_(id), |
| - pixel_size_(pixel_size), |
| - color_format_(color_format), |
| - memory_type_(memory_type), |
| - data_plane_handles_(data_plane_handles) { |
| +PictureBuffer::Data::Data() { |
|
Ami GONE FROM CHROMIUM
2011/04/29 18:40:34
Hopefully this can go away.
vrk (LEFT CHROMIUM)
2011/05/03 18:19:58
Yup! Gone.
|
| + // Initialize an empty union to null. |
| + memset(this, 0, sizeof(Data)); |
|
scherkus (not reviewing)
2011/04/29 20:33:01
pedantic nit: use variables for sizeof() calculati
vrk (LEFT CHROMIUM)
2011/05/03 18:19:58
n/a now!
|
| } |
| -PictureBuffer::~PictureBuffer() {} |
| - |
| -int32 PictureBuffer::GetId() { |
| - return id_; |
| +PictureBuffer::PictureBuffer() |
| + : id_(-1), |
| + memory_type_(PICTUREBUFFER_MEMORYTYPE_NONE), |
| + dimensions_(gfx::Size()), |
| + data_(Data()), |
|
Ami GONE FROM CHROMIUM
2011/04/29 18:40:34
FWIW you can omit the explicit ctor name:
dimensio
vrk (LEFT CHROMIUM)
2011/05/03 18:19:58
Totally forgot about that, thanks Ami!! N/A anymor
|
| + initialized_(false) { |
| } |
| -gfx::Size PictureBuffer::GetSize() { |
| - return pixel_size_; |
| +void PictureBuffer::Initialize(int32 id, |
| + PictureBuffer::MemoryType memory_type, |
| + gfx::Size dimensions, |
| + PictureBuffer::Data data) { |
| + DCHECK(!initialized_); |
|
Ami GONE FROM CHROMIUM
2011/04/29 18:40:34
Wait, what? If you don't want to allow *re*-initi
vrk (LEFT CHROMIUM)
2011/05/03 18:19:58
Explained offline. Fixed now!
|
| + id_ = id; |
| + memory_type_ = memory_type; |
| + dimensions_ = dimensions; |
| + data_ = data; |
| + initialized_ = true; |
| } |
| -const std::vector<uint32>& PictureBuffer::GetColorFormat() { |
| - return color_format_; |
| +int32 PictureBuffer::GetId() const { |
| + DCHECK(initialized_); |
| + return id_; |
| } |
| -PictureBuffer::MemoryType PictureBuffer::GetMemoryType() { |
| +PictureBuffer::MemoryType PictureBuffer::GetMemoryType() const { |
| + DCHECK(initialized_); |
| return memory_type_; |
| } |
| -std::vector<PictureBuffer::DataPlaneHandle>& PictureBuffer::GetPlaneHandles() { |
| - return data_plane_handles_; |
| +gfx::Size PictureBuffer::GetDimensions() const { |
| + DCHECK(initialized_); |
| + return dimensions_; |
| } |
| -// Picture implementation. |
| -Picture::Picture(PictureBuffer* picture_buffer, gfx::Size decoded_pixel_size, |
| - gfx::Size visible_pixel_size, void* user_handle) |
| - : picture_buffer_(picture_buffer), |
| - decoded_pixel_size_(decoded_pixel_size), |
| - visible_pixel_size_(visible_pixel_size), |
| - user_handle_(user_handle) { |
| +PictureBuffer::Data PictureBuffer::GetData() const { |
| + DCHECK(initialized_); |
| + return data_; |
| } |
| -Picture::~Picture() {} |
| +Picture::Picture() |
| + : picture_buffer_id_(-1), |
| + decoded_pixel_size_(gfx::Size()), |
| + visible_pixel_size_(gfx::Size()), |
| + user_handle_(NULL), |
| + initialized_(false) { |
| +} |
| + |
| +void Picture::Initialize(int32 picture_buffer_id, |
| + gfx::Size decoded_pixel_size, |
| + gfx::Size visible_pixel_size, |
| + void* user_handle) { |
| + DCHECK(!initialized_); |
| + picture_buffer_id_ = picture_buffer_id; |
| + decoded_pixel_size_ = decoded_pixel_size; |
| + visible_pixel_size_ = visible_pixel_size; |
| + user_handle_ = user_handle; |
| + initialized_ = true; |
| +} |
| -PictureBuffer* Picture::picture_buffer() { |
| - return picture_buffer_; |
| +int32 Picture::GetId() const { |
| + DCHECK(initialized_); |
| + return picture_buffer_id_; |
| } |
| gfx::Size Picture::GetDecodedSize() const { |
| + DCHECK(initialized_); |
| return decoded_pixel_size_; |
| } |
| gfx::Size Picture::GetVisibleSize() const { |
| + DCHECK(initialized_); |
| return visible_pixel_size_; |
| } |
| -void* Picture::GetUserHandle() { |
| +void* Picture::GetUserHandle() const { |
| + DCHECK(initialized_); |
| return user_handle_; |
| } |
| } // namespace media |
| - |