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