OLD | NEW |
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/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 explicit OutputSurface(scoped_ptr<cc::SoftwareOutputDevice> software_device); | 40 explicit OutputSurface(scoped_ptr<cc::SoftwareOutputDevice> software_device); |
41 | 41 |
42 OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D> context3d, | 42 OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D> context3d, |
43 scoped_ptr<cc::SoftwareOutputDevice> software_device); | 43 scoped_ptr<cc::SoftwareOutputDevice> software_device); |
44 | 44 |
45 virtual ~OutputSurface(); | 45 virtual ~OutputSurface(); |
46 | 46 |
47 struct Capabilities { | 47 struct Capabilities { |
48 Capabilities() | 48 Capabilities() |
49 : has_parent_compositor(false), | 49 : delegated_rendering(false), |
50 max_frames_pending(0), | 50 max_frames_pending(0), |
51 deferred_gl_initialization(false) {} | 51 deferred_gl_initialization(false) {} |
52 | 52 |
53 bool has_parent_compositor; | 53 bool delegated_rendering; |
54 int max_frames_pending; | 54 int max_frames_pending; |
55 bool deferred_gl_initialization; | 55 bool deferred_gl_initialization; |
56 }; | 56 }; |
57 | 57 |
58 const Capabilities& capabilities() const { | 58 const Capabilities& capabilities() const { |
59 return capabilities_; | 59 return capabilities_; |
60 } | 60 } |
61 | 61 |
62 // Obtain the 3d context or the software device associated with this output | 62 // Obtain the 3d context or the software device associated with this output |
63 // surface. Either of these may return a null pointer, but not both. | 63 // surface. Either of these may return a null pointer, but not both. |
(...skipping 11 matching lines...) Expand all Loading... |
75 // (namely Android WebView), this is called to determine whether the software | 75 // (namely Android WebView), this is called to determine whether the software |
76 // device should be used on the current frame. | 76 // device should be used on the current frame. |
77 virtual bool ForcedDrawToSoftwareDevice() const; | 77 virtual bool ForcedDrawToSoftwareDevice() const; |
78 | 78 |
79 // Called by the compositor on the compositor thread. This is a place where | 79 // Called by the compositor on the compositor thread. This is a place where |
80 // thread-specific data for the output surface can be initialized, since from | 80 // thread-specific data for the output surface can be initialized, since from |
81 // this point on the output surface will only be used on the compositor | 81 // this point on the output surface will only be used on the compositor |
82 // thread. | 82 // thread. |
83 virtual bool BindToClient(OutputSurfaceClient* client); | 83 virtual bool BindToClient(OutputSurfaceClient* client); |
84 | 84 |
85 // Sends frame data to the parent compositor. This should only be called when | |
86 // capabilities().has_parent_compositor. The implementation may destroy or | |
87 // steal the contents of the CompositorFrame passed in. | |
88 virtual void SendFrameToParentCompositor(CompositorFrame* frame); | |
89 | |
90 virtual void EnsureBackbuffer(); | 85 virtual void EnsureBackbuffer(); |
91 virtual void DiscardBackbuffer(); | 86 virtual void DiscardBackbuffer(); |
92 | 87 |
93 virtual void Reshape(gfx::Size size, float scale_factor); | 88 virtual void Reshape(gfx::Size size, float scale_factor); |
94 virtual gfx::Size SurfaceSize() const; | 89 virtual gfx::Size SurfaceSize() const; |
95 | 90 |
96 virtual void BindFramebuffer(); | 91 virtual void BindFramebuffer(); |
97 | 92 |
98 virtual void PostSubBuffer(gfx::Rect rect, const ui::LatencyInfo&); | 93 // The implementation may destroy or steal the contents of the CompositorFrame |
99 virtual void SwapBuffers(const ui::LatencyInfo&); | 94 // passed in (though it will not take ownership of the CompositorFrame |
| 95 // itself). |
| 96 virtual void SwapBuffers(CompositorFrame* frame); |
100 | 97 |
101 // Notifies frame-rate smoothness preference. If true, all non-critical | 98 // Notifies frame-rate smoothness preference. If true, all non-critical |
102 // processing should be stopped, or lowered in priority. | 99 // processing should be stopped, or lowered in priority. |
103 virtual void UpdateSmoothnessTakesPriority(bool prefer_smoothness) {} | 100 virtual void UpdateSmoothnessTakesPriority(bool prefer_smoothness) {} |
104 | 101 |
105 // Requests a BeginFrame notification from the output surface. The | 102 // Requests a BeginFrame notification from the output surface. The |
106 // notification will be delivered by calling | 103 // notification will be delivered by calling |
107 // OutputSurfaceClient::BeginFrame until the callback is disabled. | 104 // OutputSurfaceClient::BeginFrame until the callback is disabled. |
108 virtual void SetNeedsBeginFrame(bool enable) {} | 105 virtual void SetNeedsBeginFrame(bool enable) {} |
109 | 106 |
110 protected: | 107 protected: |
111 // Synchronously initialize context3d and enter hardware mode. | 108 // Synchronously initialize context3d and enter hardware mode. |
112 // This can only supported in threaded compositing mode. | 109 // This can only supported in threaded compositing mode. |
113 // |offscreen_context_provider| should match what is returned by | 110 // |offscreen_context_provider| should match what is returned by |
114 // LayerTreeClient::OffscreenContextProviderForCompositorThread. | 111 // LayerTreeClient::OffscreenContextProviderForCompositorThread. |
115 bool InitializeAndSetContext3D( | 112 bool InitializeAndSetContext3D( |
116 scoped_ptr<WebKit::WebGraphicsContext3D> context3d, | 113 scoped_ptr<WebKit::WebGraphicsContext3D> context3d, |
117 scoped_refptr<ContextProvider> offscreen_context_provider); | 114 scoped_refptr<ContextProvider> offscreen_context_provider); |
118 | 115 |
119 OutputSurfaceClient* client_; | 116 OutputSurfaceClient* client_; |
120 struct cc::OutputSurface::Capabilities capabilities_; | 117 struct cc::OutputSurface::Capabilities capabilities_; |
121 scoped_ptr<OutputSurfaceCallbacks> callbacks_; | 118 scoped_ptr<OutputSurfaceCallbacks> callbacks_; |
122 scoped_ptr<WebKit::WebGraphicsContext3D> context3d_; | 119 scoped_ptr<WebKit::WebGraphicsContext3D> context3d_; |
123 scoped_ptr<cc::SoftwareOutputDevice> software_device_; | 120 scoped_ptr<cc::SoftwareOutputDevice> software_device_; |
124 bool has_gl_discard_backbuffer_; | 121 bool has_gl_discard_backbuffer_; |
| 122 bool has_swap_buffers_complete_callback_; |
125 gfx::Size surface_size_; | 123 gfx::Size surface_size_; |
126 float device_scale_factor_; | 124 float device_scale_factor_; |
127 | 125 |
128 private: | 126 private: |
129 void SetContext3D(scoped_ptr<WebKit::WebGraphicsContext3D> context3d); | 127 void SetContext3D(scoped_ptr<WebKit::WebGraphicsContext3D> context3d); |
130 DISALLOW_COPY_AND_ASSIGN(OutputSurface); | 128 DISALLOW_COPY_AND_ASSIGN(OutputSurface); |
131 }; | 129 }; |
132 | 130 |
133 } // namespace cc | 131 } // namespace cc |
134 | 132 |
135 #endif // CC_OUTPUT_OUTPUT_SURFACE_H_ | 133 #endif // CC_OUTPUT_OUTPUT_SURFACE_H_ |
OLD | NEW |