summaryrefslogtreecommitdiffstats
path: root/content/common/gpu/media/rendering_helper.h
diff options
context:
space:
mode:
Diffstat (limited to 'content/common/gpu/media/rendering_helper.h')
-rw-r--r--content/common/gpu/media/rendering_helper.h111
1 files changed, 72 insertions, 39 deletions
diff --git a/content/common/gpu/media/rendering_helper.h b/content/common/gpu/media/rendering_helper.h
index a2dfb1b..6b0013f 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,53 @@ 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);
+
+ private:
+ friend class base::RefCounted<VideoFrameTexture>;
+
+ uint32 texture_target_;
+ uint32 texture_id_;
+ base::Closure no_longer_needed_cb_;
+
+ ~VideoFrameTexture();
+};
+
+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 +96,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.
+ 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 +119,33 @@ 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 last (and the only one) frame in pending_frames has
+ // been rendered. We keep the last remaining frame in pending_frames even
+ // after 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();
+ ~RenderedVideo();
+ };
+
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 +158,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 +172,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_