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 <limits> | |
9 | |
8 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
9 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
12 #include "cc/base/cc_export.h" | 14 #include "cc/base/cc_export.h" |
13 #include "cc/output/context_provider.h" | 15 #include "cc/output/context_provider.h" |
14 #include "cc/output/software_output_device.h" | 16 #include "cc/output/software_output_device.h" |
15 #include "cc/scheduler/frame_rate_controller.h" | 17 #include "cc/scheduler/frame_rate_controller.h" |
16 | 18 |
17 namespace base { class SingleThreadTaskRunner; } | 19 namespace base { class SingleThreadTaskRunner; } |
(...skipping 19 matching lines...) Expand all Loading... | |
37 // 2. Passed to the compositor thread and bound to a client via BindToClient. | 39 // 2. Passed to the compositor thread and bound to a client via BindToClient. |
38 // From here on, it will only be used on the compositor thread. | 40 // From here on, it will only be used on the compositor thread. |
39 // 3. If the 3D context is lost, then the compositor will delete the output | 41 // 3. If the 3D context is lost, then the compositor will delete the output |
40 // surface (on the compositor thread) and go back to step 1. | 42 // surface (on the compositor thread) and go back to step 1. |
41 class CC_EXPORT OutputSurface : public FrameRateControllerClient { | 43 class CC_EXPORT OutputSurface : public FrameRateControllerClient { |
42 public: | 44 public: |
43 enum { | 45 enum { |
44 DEFAULT_MAX_FRAMES_PENDING = 2 | 46 DEFAULT_MAX_FRAMES_PENDING = 2 |
45 }; | 47 }; |
46 | 48 |
47 explicit OutputSurface(scoped_refptr<ContextProvider> context_provider); | 49 OutputSurface(scoped_refptr<ContextProvider> context_provider, |
50 size_t max_transfer_buffer_usage_bytes); | |
danakj
2013/08/27 16:55:39
Since there is only one subclass of this class tha
| |
48 | 51 |
49 explicit OutputSurface(scoped_ptr<cc::SoftwareOutputDevice> software_device); | 52 OutputSurface(scoped_ptr<cc::SoftwareOutputDevice> software_device, |
53 size_t max_transfer_buffer_usage_bytes); | |
50 | 54 |
51 OutputSurface(scoped_refptr<ContextProvider> context_provider, | 55 OutputSurface(scoped_refptr<ContextProvider> context_provider, |
52 scoped_ptr<cc::SoftwareOutputDevice> software_device); | 56 scoped_ptr<cc::SoftwareOutputDevice> software_device, |
57 size_t max_transfer_buffer_usage_bytes); | |
53 | 58 |
54 virtual ~OutputSurface(); | 59 virtual ~OutputSurface(); |
55 | 60 |
56 struct Capabilities { | 61 struct Capabilities { |
57 Capabilities() | 62 Capabilities() |
58 : delegated_rendering(false), | 63 : delegated_rendering(false), |
59 max_frames_pending(0), | 64 max_frames_pending(0), |
60 deferred_gl_initialization(false), | 65 deferred_gl_initialization(false), |
61 draw_and_swap_full_viewport_every_frame(false), | 66 draw_and_swap_full_viewport_every_frame(false), |
62 adjust_deadline_for_parent(true) {} | 67 adjust_deadline_for_parent(true), |
68 max_transfer_buffer_usage_bytes(std::numeric_limits<size_t>::max()) {} | |
danakj
2013/08/27 16:55:39
why not kDefault...?
| |
63 bool delegated_rendering; | 69 bool delegated_rendering; |
64 int max_frames_pending; | 70 int max_frames_pending; |
65 bool deferred_gl_initialization; | 71 bool deferred_gl_initialization; |
66 bool draw_and_swap_full_viewport_every_frame; | 72 bool draw_and_swap_full_viewport_every_frame; |
67 // This doesn't handle the <webview> case, but once BeginFrame is | 73 // This doesn't handle the <webview> case, but once BeginFrame is |
68 // supported natively, we shouldn't need adjust_deadline_for_parent. | 74 // supported natively, we shouldn't need adjust_deadline_for_parent. |
69 bool adjust_deadline_for_parent; | 75 bool adjust_deadline_for_parent; |
76 size_t max_transfer_buffer_usage_bytes; | |
70 }; | 77 }; |
71 | 78 |
72 const Capabilities& capabilities() const { | 79 const Capabilities& capabilities() const { |
73 return capabilities_; | 80 return capabilities_; |
74 } | 81 } |
75 | 82 |
76 // Obtain the 3d context or the software device associated with this output | 83 // Obtain the 3d context or the software device associated with this output |
77 // surface. Either of these may return a null pointer, but not both. | 84 // surface. Either of these may return a null pointer, but not both. |
78 // In the event of a lost context, the entire output surface should be | 85 // In the event of a lost context, the entire output surface should be |
79 // recreated. | 86 // recreated. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 // processing should be stopped, or lowered in priority. | 126 // processing should be stopped, or lowered in priority. |
120 virtual void UpdateSmoothnessTakesPriority(bool prefer_smoothness) {} | 127 virtual void UpdateSmoothnessTakesPriority(bool prefer_smoothness) {} |
121 | 128 |
122 // Requests a BeginFrame notification from the output surface. The | 129 // Requests a BeginFrame notification from the output surface. The |
123 // notification will be delivered by calling | 130 // notification will be delivered by calling |
124 // OutputSurfaceClient::BeginFrame until the callback is disabled. | 131 // OutputSurfaceClient::BeginFrame until the callback is disabled. |
125 virtual void SetNeedsBeginFrame(bool enable); | 132 virtual void SetNeedsBeginFrame(bool enable); |
126 | 133 |
127 bool HasClient() { return !!client_; } | 134 bool HasClient() { return !!client_; } |
128 | 135 |
136 static const size_t kDefaultMaxTransferBufferUsageBytes; | |
137 | |
129 protected: | 138 protected: |
130 // Synchronously initialize context3d and enter hardware mode. | 139 // Synchronously initialize context3d and enter hardware mode. |
131 // This can only supported in threaded compositing mode. | 140 // This can only supported in threaded compositing mode. |
132 // |offscreen_context_provider| should match what is returned by | 141 // |offscreen_context_provider| should match what is returned by |
133 // LayerTreeClient::OffscreenContextProviderForCompositorThread. | 142 // LayerTreeClient::OffscreenContextProviderForCompositorThread. |
134 bool InitializeAndSetContext3d( | 143 bool InitializeAndSetContext3d( |
135 scoped_refptr<ContextProvider> context_provider, | 144 scoped_refptr<ContextProvider> context_provider, |
136 scoped_refptr<ContextProvider> offscreen_context_provider); | 145 scoped_refptr<ContextProvider> offscreen_context_provider); |
137 void ReleaseGL(); | 146 void ReleaseGL(); |
138 | 147 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 // check_for_retroactive_begin_frame_pending_ is used to avoid posting | 200 // check_for_retroactive_begin_frame_pending_ is used to avoid posting |
192 // redundant checks for a retroactive BeginFrame. | 201 // redundant checks for a retroactive BeginFrame. |
193 bool check_for_retroactive_begin_frame_pending_; | 202 bool check_for_retroactive_begin_frame_pending_; |
194 | 203 |
195 DISALLOW_COPY_AND_ASSIGN(OutputSurface); | 204 DISALLOW_COPY_AND_ASSIGN(OutputSurface); |
196 }; | 205 }; |
197 | 206 |
198 } // namespace cc | 207 } // namespace cc |
199 | 208 |
200 #endif // CC_OUTPUT_OUTPUT_SURFACE_H_ | 209 #endif // CC_OUTPUT_OUTPUT_SURFACE_H_ |
OLD | NEW |