1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef MEDIA_VIDEO_PICTURE_H_ 6 #define MEDIA_VIDEO_PICTURE_H_ 7 8 #include "base/basictypes.h" 9 #include "gpu/command_buffer/common/mailbox.h" 10 #include "media/base/media_export.h" 11 #include "ui/gfx/geometry/rect.h" 12 #include "ui/gfx/size.h" 13 14 namespace media { 15 16 // A picture buffer that is composed of a GLES2 texture. 17 // This is the media-namespace equivalent of PP_PictureBuffer_Dev. 18 class MEDIA_EXPORT PictureBuffer { 19 public: 20 PictureBuffer(int32 id, gfx::Size size, uint32 texture_id); 21 PictureBuffer(int32 id, 22 gfx::Size size, 23 uint32 texture_id, 24 const gpu::Mailbox& texture_mailbox); 25 26 // Returns the client-specified id of the buffer. id()27 int32 id() const { 28 return id_; 29 } 30 31 // Returns the size of the buffer. size()32 gfx::Size size() const { 33 return size_; 34 } 35 36 // Returns the id of the texture. 37 // NOTE: The texture id in the renderer process corresponds to a different 38 // texture id in the GPU process. texture_id()39 uint32 texture_id() const { 40 return texture_id_; 41 } 42 texture_mailbox()43 const gpu::Mailbox& texture_mailbox() const { 44 return texture_mailbox_; 45 } 46 47 private: 48 int32 id_; 49 gfx::Size size_; 50 uint32 texture_id_; 51 gpu::Mailbox texture_mailbox_; 52 }; 53 54 // A decoded picture frame. 55 // This is the media-namespace equivalent of PP_Picture_Dev. 56 class MEDIA_EXPORT Picture { 57 public: 58 Picture(int32 picture_buffer_id, 59 int32 bitstream_buffer_id, 60 const gfx::Rect& visible_rect); 61 62 // Returns the id of the picture buffer where this picture is contained. picture_buffer_id()63 int32 picture_buffer_id() const { 64 return picture_buffer_id_; 65 } 66 67 // Returns the id of the bitstream buffer from which this frame was decoded. bitstream_buffer_id()68 int32 bitstream_buffer_id() const { 69 return bitstream_buffer_id_; 70 } 71 set_bitstream_buffer_id(int32 bitstream_buffer_id)72 void set_bitstream_buffer_id(int32 bitstream_buffer_id) { 73 bitstream_buffer_id_ = bitstream_buffer_id; 74 } 75 76 // Returns the visible rectangle of the picture. Its size may be smaller 77 // than the size of the PictureBuffer, as it is the only visible part of the 78 // Picture contained in the PictureBuffer. visible_rect()79 gfx::Rect visible_rect() const { return visible_rect_; } 80 81 private: 82 int32 picture_buffer_id_; 83 int32 bitstream_buffer_id_; 84 gfx::Rect visible_rect_; 85 }; 86 87 } // namespace media 88 89 #endif // MEDIA_VIDEO_PICTURE_H_ 90