Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3401)

Unified Diff: cc/output/output_surface.h

Issue 16833003: cc: Emulate BeginFrame in OutputSurfaces that don't support it natively (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/cc_tests.gyp ('k') | cc/output/output_surface.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/output/output_surface.h
diff --git a/cc/output/output_surface.h b/cc/output/output_surface.h
index d263d3a54ac0ca7a4d4b1340e5e12a039f1802c2..8f782d77cf3241b814478526b2791172f4712f72 100644
--- a/cc/output/output_surface.h
+++ b/cc/output/output_surface.h
@@ -12,6 +12,7 @@
#include "cc/base/cc_export.h"
#include "cc/output/context_provider.h"
#include "cc/output/software_output_device.h"
+#include "cc/scheduler/frame_rate_controller.h"
#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
namespace ui { struct LatencyInfo; }
@@ -19,13 +20,16 @@ namespace ui { struct LatencyInfo; }
namespace gfx {
class Rect;
class Size;
+class Transform;
}
namespace cc {
class CompositorFrame;
+class CompositorFrameAck;
class OutputSurfaceClient;
class OutputSurfaceCallbacks;
+class Thread;
// Represents the output surface for a compositor. The compositor owns
// and manages its destruction. Its lifetime is:
@@ -34,7 +38,7 @@ class OutputSurfaceCallbacks;
// From here on, it will only be used on the compositor thread.
// 3. If the 3D context is lost, then the compositor will delete the output
// surface (on the compositor thread) and go back to step 1.
-class CC_EXPORT OutputSurface {
+class CC_EXPORT OutputSurface : public FrameRateControllerClient {
public:
explicit OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D> context3d);
@@ -83,6 +87,13 @@ class CC_EXPORT OutputSurface {
// thread.
virtual bool BindToClient(OutputSurfaceClient* client);
+ void InitializeBeginFrameEmulation(
+ Thread* thread,
+ bool throttle_frame_production,
+ base::TimeDelta interval);
+
+ void SetMaxFramesPending(int max_frames_pending);
+
virtual void EnsureBackbuffer();
virtual void DiscardBackbuffer();
@@ -103,7 +114,7 @@ class CC_EXPORT OutputSurface {
// Requests a BeginFrame notification from the output surface. The
// notification will be delivered by calling
// OutputSurfaceClient::BeginFrame until the callback is disabled.
- virtual void SetNeedsBeginFrame(bool enable) {}
+ virtual void SetNeedsBeginFrame(bool enable);
protected:
// Synchronously initialize context3d and enter hardware mode.
@@ -116,7 +127,6 @@ class CC_EXPORT OutputSurface {
void PostSwapBuffersComplete();
- OutputSurfaceClient* client_;
struct cc::OutputSurface::Capabilities capabilities_;
scoped_ptr<OutputSurfaceCallbacks> callbacks_;
scoped_ptr<WebKit::WebGraphicsContext3D> context3d_;
@@ -125,12 +135,34 @@ class CC_EXPORT OutputSurface {
bool has_swap_buffers_complete_callback_;
gfx::Size surface_size_;
float device_scale_factor_;
+ base::WeakPtrFactory<OutputSurface> weak_ptr_factory_;
+
+ // The FrameRateController is deprecated.
+ // Platforms should move to native BeginFrames instead.
+ void OnVSyncParametersChanged(base::TimeTicks timebase,
+ base::TimeDelta interval);
+ virtual void FrameRateControllerTick(bool throttled) OVERRIDE;
+ scoped_ptr<FrameRateController> frame_rate_controller_;
+ int max_frames_pending_;
+ int pending_swap_buffers_;
+ bool begin_frame_pending_;
+
+ // Forwarded to OutputSurfaceClient but threaded through OutputSurface
+ // first so OutputSurface has a chance to update the FrameRateController
+ bool HasClient() { return !!client_; }
+ void SetNeedsRedrawRect(gfx::Rect damage_rect);
+ void BeginFrame(base::TimeTicks frame_time);
+ void DidSwapBuffers();
+ void OnSwapBuffersComplete(const CompositorFrameAck* ack);
+ void DidLoseOutputSurface();
+ void SetExternalDrawConstraints(const gfx::Transform& transform,
+ gfx::Rect viewport);
private:
- void SetContext3D(scoped_ptr<WebKit::WebGraphicsContext3D> context3d);
- void SwapBuffersComplete();
+ OutputSurfaceClient* client_;
+ friend class OutputSurfaceCallbacks;
- base::WeakPtrFactory<OutputSurface> weak_ptr_factory_;
+ void SetContext3D(scoped_ptr<WebKit::WebGraphicsContext3D> context3d);
DISALLOW_COPY_AND_ASSIGN(OutputSurface);
};
« no previous file with comments | « cc/cc_tests.gyp ('k') | cc/output/output_surface.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698