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

Side by Side Diff: cc/output/output_surface.h

Issue 15836005: cc: Emulate BeginFrame in OutputSurfaces that don't support it natively (Closed) Base URL: http://git.chromium.org/chromium/src.git@nofrc
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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_OUTPUT_OUTPUT_SURFACE_H_ 5 #ifndef CC_OUTPUT_OUTPUT_SURFACE_H_
6 #define CC_OUTPUT_OUTPUT_SURFACE_H_ 6 #define CC_OUTPUT_OUTPUT_SURFACE_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "cc/base/cc_export.h" 10 #include "cc/base/cc_export.h"
11 #include "cc/output/software_output_device.h" 11 #include "cc/output/software_output_device.h"
12 #include "cc/scheduler/frame_rate_controller.h"
12 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" 13 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
13 14
14 namespace ui { struct LatencyInfo; } 15 namespace ui { struct LatencyInfo; }
15 16
16 namespace gfx { 17 namespace gfx {
17 class Rect; 18 class Rect;
18 class Size; 19 class Size;
19 } 20 }
20 21
21 namespace cc { 22 namespace cc {
22 23
23 class CompositorFrame; 24 class CompositorFrame;
25 class CompositorFrameAck;
24 class OutputSurfaceClient; 26 class OutputSurfaceClient;
25 class OutputSurfaceCallbacks; 27 class OutputSurfaceCallbacks;
28 class Thread;
26 29
27 // Represents the output surface for a compositor. The compositor owns 30 // Represents the output surface for a compositor. The compositor owns
28 // and manages its destruction. Its lifetime is: 31 // and manages its destruction. Its lifetime is:
29 // 1. Created on the main thread by the LayerTreeHost through its client. 32 // 1. Created on the main thread by the LayerTreeHost through its client.
30 // 2. Passed to the compositor thread and bound to a client via BindToClient. 33 // 2. Passed to the compositor thread and bound to a client via BindToClient.
31 // From here on, it will only be used on the compositor thread. 34 // From here on, it will only be used on the compositor thread.
32 // 3. If the 3D context is lost, then the compositor will delete the output 35 // 3. If the 3D context is lost, then the compositor will delete the output
33 // surface (on the compositor thread) and go back to step 1. 36 // surface (on the compositor thread) and go back to step 1.
34 class CC_EXPORT OutputSurface { 37 class CC_EXPORT OutputSurface : public FrameRateControllerClient {
35 public: 38 public:
36 explicit OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D> context3d); 39 explicit OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D> context3d);
37 40
38 explicit OutputSurface(scoped_ptr<cc::SoftwareOutputDevice> software_device); 41 explicit OutputSurface(scoped_ptr<cc::SoftwareOutputDevice> software_device);
39 42
40 OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D> context3d, 43 OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D> context3d,
41 scoped_ptr<cc::SoftwareOutputDevice> software_device); 44 scoped_ptr<cc::SoftwareOutputDevice> software_device);
42 45
43 virtual ~OutputSurface(); 46 virtual ~OutputSurface();
44 47
(...skipping 27 matching lines...) Expand all
72 // In the case where both the context3d and software_device are present 75 // In the case where both the context3d and software_device are present
73 // (namely Android WebView), this is called to determine whether the software 76 // (namely Android WebView), this is called to determine whether the software
74 // device should be used on the current frame. 77 // device should be used on the current frame.
75 virtual bool ForcedDrawToSoftwareDevice() const; 78 virtual bool ForcedDrawToSoftwareDevice() const;
76 79
77 // Called by the compositor on the compositor thread. This is a place where 80 // Called by the compositor on the compositor thread. This is a place where
78 // thread-specific data for the output surface can be initialized, since from 81 // thread-specific data for the output surface can be initialized, since from
79 // this point on the output surface will only be used on the compositor 82 // this point on the output surface will only be used on the compositor
80 // thread. 83 // thread.
81 virtual bool BindToClient(OutputSurfaceClient* client); 84 virtual bool BindToClient(OutputSurfaceClient* client);
85 void InitializeBeginFrameEmulation(
86 Thread* thread,
87 bool throttle_frame_production,
88 base::TimeDelta interval,
89 int max_frames_pending,
90 bool swap_buffers_complete_supported);
82 91
83 // Sends frame data to the parent compositor. This should only be called when 92 // Sends frame data to the parent compositor. This should only be called when
84 // capabilities().has_parent_compositor. The implementation may destroy or 93 // capabilities().has_parent_compositor. The implementation may destroy or
85 // steal the contents of the CompositorFrame passed in. 94 // steal the contents of the CompositorFrame passed in.
86 virtual void SendFrameToParentCompositor(CompositorFrame* frame); 95 virtual void SendFrameToParentCompositor(CompositorFrame* frame);
87 96
88 virtual void EnsureBackbuffer(); 97 virtual void EnsureBackbuffer();
89 virtual void DiscardBackbuffer(); 98 virtual void DiscardBackbuffer();
90 99
91 virtual void Reshape(gfx::Size size, float scale_factor); 100 virtual void Reshape(gfx::Size size, float scale_factor);
92 101
93 virtual void BindFramebuffer(); 102 virtual void BindFramebuffer();
94 103
95 virtual void PostSubBuffer(gfx::Rect rect, const ui::LatencyInfo&); 104 virtual void PostSubBuffer(gfx::Rect rect, const ui::LatencyInfo&);
96 virtual void SwapBuffers(const ui::LatencyInfo&); 105 virtual void SwapBuffers(const ui::LatencyInfo&);
97 106
98 // Notifies frame-rate smoothness preference. If true, all non-critical 107 // Notifies frame-rate smoothness preference. If true, all non-critical
99 // processing should be stopped, or lowered in priority. 108 // processing should be stopped, or lowered in priority.
100 virtual void UpdateSmoothnessTakesPriority(bool prefer_smoothness) {} 109 virtual void UpdateSmoothnessTakesPriority(bool prefer_smoothness) {}
101 110
102 // Requests a BeginFrame notification from the output surface. The 111 // Requests a BeginFrame notification from the output surface. The
103 // notification will be delivered by calling 112 // notification will be delivered by calling
104 // OutputSurfaceClient::BeginFrame until the callback is disabled. 113 // OutputSurfaceClient::BeginFrame until the callback is disabled.
105 virtual void SetNeedsBeginFrame(bool enable) {} 114 virtual void SetNeedsBeginFrame(bool enable);
115
116 private:
117 OutputSurfaceClient* client_;
118 friend class OutputSurfaceCallbacks;
106 119
107 protected: 120 protected:
108 OutputSurfaceClient* client_;
109 struct cc::OutputSurface::Capabilities capabilities_; 121 struct cc::OutputSurface::Capabilities capabilities_;
110 scoped_ptr<WebKit::WebGraphicsContext3D> context3d_; 122 scoped_ptr<WebKit::WebGraphicsContext3D> context3d_;
111 scoped_ptr<cc::SoftwareOutputDevice> software_device_; 123 scoped_ptr<cc::SoftwareOutputDevice> software_device_;
112 bool has_gl_discard_backbuffer_; 124 bool has_gl_discard_backbuffer_;
113 125
114 scoped_ptr<OutputSurfaceCallbacks> callbacks_; 126 scoped_ptr<OutputSurfaceCallbacks> callbacks_;
115 127
116 private: 128 // The FrameRateController is depricated.
Sami 2013/06/03 17:30:33 Typo: deprecated.
brianderson 2013/06/03 18:51:40 Done.
129 // Platforms should move to native BeginFrames instead.
130 void OnVSyncParametersChanged(base::TimeTicks timebase,
131 base::TimeDelta interval);
132 virtual void FrameRateControllerTick(bool throttled) OVERRIDE;
133 scoped_ptr<FrameRateController> frame_rate_controller_;
134 int pending_begin_frames_;
135
136 // Forwarded to OutputSurfaceClient but threaded through OutputSurface
137 // first so OutputSurface has a chance to update the FrameRateController
138 bool hasClient() { return !!client_; }
139 void SetNeedsRedrawRect(gfx::Rect damage_rect);
140 void BeginFrame(base::TimeTicks frame_time);
141 void OnSendFrameToParentCompositorAck(const CompositorFrameAck&);
142 void OnSwapBuffersComplete();
143 void DidLoseOutputSurface();
144
117 DISALLOW_COPY_AND_ASSIGN(OutputSurface); 145 DISALLOW_COPY_AND_ASSIGN(OutputSurface);
118 }; 146 };
119 147
120 } // namespace cc 148 } // namespace cc
121 149
122 #endif // CC_OUTPUT_OUTPUT_SURFACE_H_ 150 #endif // CC_OUTPUT_OUTPUT_SURFACE_H_
OLDNEW
« no previous file with comments | « cc/cc_tests.gyp ('k') | cc/output/output_surface.cc » ('j') | cc/output/output_surface.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698