Index: content/common/gpu/media/rendering_helper.h |
diff --git a/content/common/gpu/media/rendering_helper.h b/content/common/gpu/media/rendering_helper.h |
index a2dfb1bbf492690104ee2f183aa076ccfc60a3a3..e7fb9a4af3ac2f53a28c16a5ceda16780a16be85 100644 |
--- a/content/common/gpu/media/rendering_helper.h |
+++ b/content/common/gpu/media/rendering_helper.h |
@@ -6,6 +6,7 @@ |
#define CONTENT_COMMON_GPU_MEDIA_RENDERING_HELPER_H_ |
#include <map> |
+#include <queue> |
#include <vector> |
#include "base/basictypes.h" |
@@ -24,25 +25,50 @@ class WaitableEvent; |
namespace content { |
-struct RenderingHelperParams; |
+class VideoFrameTexture : public base::RefCounted<VideoFrameTexture> { |
+ public: |
+ uint32 texture_id() const { return texture_id_; } |
+ uint32 texture_target() const { return texture_target_; } |
+ |
+ VideoFrameTexture(uint32 texture_target, |
+ uint32 texture_id, |
+ const base::Closure& no_longer_needed_cb); |
+ ~VideoFrameTexture(); |
+ |
+ private: |
+ uint32 texture_target_; |
+ uint32 texture_id_; |
+ base::Closure no_longer_needed_cb_; |
+}; |
+ |
+struct RenderingHelperParams { |
+ RenderingHelperParams(); |
+ ~RenderingHelperParams(); |
+ |
+ // The rendering FPS. |
+ int rendering_fps; |
+ |
+ // The desired size of each window. We play each stream in its own window |
+ // on the screen. |
+ std::vector<gfx::Size> window_sizes; |
+ |
+ // The members below are only used for the thumbnail mode where all frames |
+ // are rendered in sequence onto one FBO for comparison/verification purposes. |
+ |
+ // Whether the frames are rendered as scaled thumbnails within a |
+ // larger FBO that is in turn rendered to the window. |
+ bool render_as_thumbnails; |
+ // The size of the FBO containing all visible thumbnails. |
+ gfx::Size thumbnails_page_size; |
+ // The size of each thumbnail within the FBO. |
+ gfx::Size thumbnail_size; |
+}; |
// Creates and draws textures used by the video decoder. |
// This class is not thread safe and thus all the methods of this class |
// (except for ctor/dtor) ensure they're being run on a single thread. |
class RenderingHelper { |
public: |
- // Interface for the content provider of the RenderingHelper. |
- class Client { |
- public: |
- // Callback to tell client to render the content. |
- virtual void RenderContent(RenderingHelper* helper) = 0; |
- |
- // Callback to get the desired window size of the client. |
- virtual const gfx::Size& GetWindowSize() = 0; |
- |
- protected: |
- virtual ~Client() {} |
- }; |
RenderingHelper(); |
~RenderingHelper(); |
@@ -67,9 +93,12 @@ class RenderingHelper { |
// |texture_target|. |
void RenderThumbnail(uint32 texture_target, uint32 texture_id); |
- // Render |texture_id| to the current view port of the screen using target |
- // |texture_target|. |
- void RenderTexture(uint32 texture_target, uint32 texture_id); |
+ // Queues the video_frame for rendering. |
Pawel Osciak
2014/08/20 10:26:26
Nit: |video_frame|
Owen Lin
2014/08/21 03:45:18
Done.
|
+ void QueueVideoFrame(size_t window_id, |
+ scoped_refptr<VideoFrameTexture> video_frame); |
+ |
+ // Drops all the pending video frames of the specified window. |
+ void DropPendingFrames(size_t window_id); |
// Delete |texture_id|. |
void DeleteTexture(uint32 texture_id); |
@@ -87,11 +116,32 @@ class RenderingHelper { |
base::WaitableEvent* done); |
private: |
+ struct RenderedVideo { |
+ // The rect on the screen where the video will be rendered. |
+ gfx::Rect render_area; |
+ |
+ // True if the oldest (and the only one) frame in pending_frames has |
Pawel Osciak
2014/08/20 10:26:26
Sorry, actually it should be the newest, my bad. B
Owen Lin
2014/08/21 03:45:18
Done.
|
+ // been rendered. We keep the last remaining frame in pending_frames even |
Pawel Osciak
2014/08/20 10:26:26
s/even/even after/
Owen Lin
2014/08/21 03:45:18
Done.
|
+ // it has been rendered, so that we have something to display if the |
+ // client is falling behind on providing us with new frames during |
+ // timer-driven playback. |
+ bool last_frame_rendered; |
+ |
+ // The video frames pending for rendering. |
+ std::queue<scoped_refptr<VideoFrameTexture> > pending_frames; |
+ |
+ RenderedVideo() : last_frame_rendered(false) {} |
+ }; |
+ |
void Clear(); |
void RenderContent(); |
- void LayoutRenderingAreas(); |
+ void LayoutRenderingAreas(const std::vector<gfx::Size>& window_sizes); |
+ |
+ // Render |texture_id| to the current view port of the screen using target |
+ // |texture_target|. |
+ void RenderTexture(uint32 texture_target, uint32 texture_id); |
// Timer to trigger the RenderContent() repeatly. |
scoped_ptr<base::RepeatingTimer<RenderingHelper> > render_timer_; |
@@ -104,10 +154,7 @@ class RenderingHelper { |
gfx::Size screen_size_; |
- // The rendering area of each window on the screen. |
- std::vector<gfx::Rect> render_areas_; |
- |
- std::vector<base::WeakPtr<Client> > clients_; |
+ std::vector<RenderedVideo> videos_; |
bool render_as_thumbnails_; |
int frame_count_; |
@@ -121,24 +168,6 @@ class RenderingHelper { |
DISALLOW_COPY_AND_ASSIGN(RenderingHelper); |
}; |
-struct RenderingHelperParams { |
- RenderingHelperParams(); |
- ~RenderingHelperParams(); |
- |
- // The rendering FPS. |
- int rendering_fps; |
- |
- // The clients who provide the content for rendering. |
- std::vector<base::WeakPtr<RenderingHelper::Client> > clients; |
- |
- // Whether the frames are rendered as scaled thumbnails within a |
- // larger FBO that is in turn rendered to the window. |
- bool render_as_thumbnails; |
- // The size of the FBO containing all visible thumbnails. |
- gfx::Size thumbnails_page_size; |
- // The size of each thumbnail within the FBO. |
- gfx::Size thumbnail_size; |
-}; |
} // namespace content |
#endif // CONTENT_COMMON_GPU_MEDIA_RENDERING_HELPER_H_ |