OLD | NEW |
---|---|
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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_LAYER_TREE_HOST_H_ | 5 #ifndef CC_LAYER_TREE_HOST_H_ |
6 #define CC_LAYER_TREE_HOST_H_ | 6 #define CC_LAYER_TREE_HOST_H_ |
7 | 7 |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/cancelable_callback.h" | 11 #include "base/cancelable_callback.h" |
12 #include "base/hash_tables.h" | 12 #include "base/hash_tables.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
16 #include "cc/animation_events.h" | 16 #include "cc/animation_events.h" |
17 #include "cc/cc_export.h" | 17 #include "cc/cc_export.h" |
18 #include "cc/graphics_context.h" | 18 #include "cc/graphics_context.h" |
19 #include "cc/heads_up_display_layer.h" | |
19 #include "cc/layer_tree_host_client.h" | 20 #include "cc/layer_tree_host_client.h" |
20 #include "cc/layer_tree_host_common.h" | 21 #include "cc/layer_tree_host_common.h" |
21 #include "cc/occlusion_tracker.h" | 22 #include "cc/occlusion_tracker.h" |
22 #include "cc/prioritized_resource_manager.h" | 23 #include "cc/prioritized_resource_manager.h" |
23 #include "cc/proxy.h" | 24 #include "cc/proxy.h" |
24 #include "cc/rate_limiter.h" | 25 #include "cc/rate_limiter.h" |
25 #include "cc/rendering_stats.h" | 26 #include "cc/rendering_stats.h" |
26 #include "cc/scoped_ptr_vector.h" | 27 #include "cc/scoped_ptr_vector.h" |
27 #include "third_party/skia/include/core/SkColor.h" | 28 #include "third_party/skia/include/core/SkColor.h" |
28 #include "ui/gfx/rect.h" | 29 #include "ui/gfx/rect.h" |
29 | 30 |
30 #if defined(COMPILER_GCC) | 31 #if defined(COMPILER_GCC) |
31 namespace BASE_HASH_NAMESPACE { | 32 namespace BASE_HASH_NAMESPACE { |
32 template<> | 33 template<> |
33 struct hash<WebKit::WebGraphicsContext3D*> { | 34 struct hash<WebKit::WebGraphicsContext3D*> { |
34 size_t operator()(WebKit::WebGraphicsContext3D* ptr) const { | 35 size_t operator()(WebKit::WebGraphicsContext3D* ptr) const { |
35 return hash<size_t>()(reinterpret_cast<size_t>(ptr)); | 36 return hash<size_t>()(reinterpret_cast<size_t>(ptr)); |
36 } | 37 } |
37 }; | 38 }; |
38 } // namespace BASE_HASH_NAMESPACE | 39 } // namespace BASE_HASH_NAMESPACE |
39 #endif // COMPILER | 40 #endif // COMPILER |
40 | 41 |
41 namespace cc { | 42 namespace cc { |
42 | 43 |
43 class FontAtlas; | |
44 class Layer; | 44 class Layer; |
45 class LayerTreeHostImpl; | 45 class LayerTreeHostImpl; |
46 class LayerTreeHostImplClient; | 46 class LayerTreeHostImplClient; |
47 class PrioritizedResourceManager; | 47 class PrioritizedResourceManager; |
48 class ResourceUpdateQueue; | 48 class ResourceUpdateQueue; |
49 class HeadsUpDisplayLayer; | |
50 class Region; | 49 class Region; |
51 struct ScrollAndScaleSet; | 50 struct ScrollAndScaleSet; |
52 | 51 |
53 struct CC_EXPORT LayerTreeSettings { | 52 struct CC_EXPORT LayerTreeSettings { |
54 LayerTreeSettings(); | 53 LayerTreeSettings(); |
55 ~LayerTreeSettings(); | 54 ~LayerTreeSettings(); |
56 | 55 |
57 bool acceleratePainting; | 56 bool acceleratePainting; |
58 bool showDebugBorders; | 57 bool showDebugBorders; |
59 bool showPlatformLayerTree; | |
60 bool showPaintRects; | |
61 bool showPropertyChangedRects; | |
62 bool showSurfaceDamageRects; | |
63 bool showScreenSpaceRects; | |
64 bool showReplicaScreenSpaceRects; | |
65 bool showOccludingRects; | |
66 bool showNonOccludingRects; | |
67 bool renderVSyncEnabled; | 58 bool renderVSyncEnabled; |
68 bool perTilePaintingEnabled; | 59 bool perTilePaintingEnabled; |
69 bool partialSwapEnabled; | 60 bool partialSwapEnabled; |
70 bool acceleratedAnimationEnabled; | 61 bool acceleratedAnimationEnabled; |
71 bool pageScalePinchZoomEnabled; | 62 bool pageScalePinchZoomEnabled; |
72 bool backgroundColorInsteadOfCheckerboard; | 63 bool backgroundColorInsteadOfCheckerboard; |
73 bool showOverdrawInTracing; | 64 bool showOverdrawInTracing; |
74 double refreshRate; | 65 double refreshRate; |
75 size_t maxPartialTextureUpdates; | 66 size_t maxPartialTextureUpdates; |
76 gfx::Size defaultTileSize; | 67 gfx::Size defaultTileSize; |
77 gfx::Size maxUntiledLayerSize; | 68 gfx::Size maxUntiledLayerSize; |
78 gfx::Size minimumOcclusionTrackingSize; | 69 gfx::Size minimumOcclusionTrackingSize; |
79 | 70 |
80 bool showDebugInfo() const { return showPlatformLayerTree || showDebugRects( ); } | 71 HeadsUpDisplayLayerSettings globalHudLayerSettings; |
egraether
2012/11/20 21:30:30
substructure for the commandline settings
danakj
2012/11/20 22:12:22
rename to initial instead of global?
| |
81 bool showDebugRects() const { return showPaintRects || showPropertyChangedRe cts || showSurfaceDamageRects || showScreenSpaceRects || showReplicaScreenSpaceR ects || showOccludingRects || showNonOccludingRects; } | |
82 }; | 72 }; |
83 | 73 |
84 // Provides information on an Impl's rendering capabilities back to the LayerTre eHost | 74 // Provides information on an Impl's rendering capabilities back to the LayerTre eHost |
85 struct CC_EXPORT RendererCapabilities { | 75 struct CC_EXPORT RendererCapabilities { |
86 RendererCapabilities(); | 76 RendererCapabilities(); |
87 ~RendererCapabilities(); | 77 ~RendererCapabilities(); |
88 | 78 |
89 GLenum bestTextureFormat; | 79 GLenum bestTextureFormat; |
90 bool contextHasCachedFrontBuffer; | 80 bool contextHasCachedFrontBuffer; |
91 bool usingPartialSwap; | 81 bool usingPartialSwap; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
209 | 199 |
210 // RateLimitClient implementation | 200 // RateLimitClient implementation |
211 virtual void rateLimit() OVERRIDE; | 201 virtual void rateLimit() OVERRIDE; |
212 | 202 |
213 bool bufferedUpdates(); | 203 bool bufferedUpdates(); |
214 bool requestPartialTextureUpdate(); | 204 bool requestPartialTextureUpdate(); |
215 | 205 |
216 void setDeviceScaleFactor(float); | 206 void setDeviceScaleFactor(float); |
217 float deviceScaleFactor() const { return m_deviceScaleFactor; } | 207 float deviceScaleFactor() const { return m_deviceScaleFactor; } |
218 | 208 |
219 void setShowFPSCounter(bool show); | 209 HeadsUpDisplayLayer* hudLayer() const { return m_hudLayer.get(); } |
220 void setFontAtlas(scoped_ptr<FontAtlas>); | 210 HeadsUpDisplayLayer* requestHudLayer(); |
221 | 211 |
222 HeadsUpDisplayLayer* hudLayer() const { return m_hudLayer.get(); } | 212 void setHudLayerSettings(const HeadsUpDisplayLayerSettings& settings); |
213 const HeadsUpDisplayLayerSettings& hudLayerSettings() const { return m_local HUDLayerSettings; } | |
223 | 214 |
224 Proxy* proxy() const { return m_proxy.get(); } | 215 Proxy* proxy() const { return m_proxy.get(); } |
225 | 216 |
226 protected: | 217 protected: |
227 LayerTreeHost(LayerTreeHostClient*, const LayerTreeSettings&); | 218 LayerTreeHost(LayerTreeHostClient*, const LayerTreeSettings&); |
228 bool initialize(scoped_ptr<Thread> implThread); | 219 bool initialize(scoped_ptr<Thread> implThread); |
229 | 220 |
230 private: | 221 private: |
231 typedef std::vector<scoped_refptr<Layer> > LayerList; | 222 typedef std::vector<scoped_refptr<Layer> > LayerList; |
232 | 223 |
233 void initializeRenderer(); | 224 void initializeRenderer(); |
234 | 225 |
235 void update(Layer*, ResourceUpdateQueue&, const OcclusionTracker*); | 226 void update(Layer*, ResourceUpdateQueue&, const OcclusionTracker*); |
236 bool paintLayerContents(const LayerList&, ResourceUpdateQueue&); | 227 bool paintLayerContents(const LayerList&, ResourceUpdateQueue&); |
237 bool paintMasksForRenderSurface(Layer*, ResourceUpdateQueue&); | 228 bool paintMasksForRenderSurface(Layer*, ResourceUpdateQueue&); |
238 | 229 |
239 void updateLayers(Layer*, ResourceUpdateQueue&); | 230 void updateLayers(Layer*, ResourceUpdateQueue&); |
240 void triggerPrepaint(); | 231 void triggerPrepaint(); |
241 | 232 |
242 void prioritizeTextures(const LayerList&, OverdrawMetrics&); | 233 void prioritizeTextures(const LayerList&, OverdrawMetrics&); |
243 void setPrioritiesForSurfaces(size_t surfaceMemoryBytes); | 234 void setPrioritiesForSurfaces(size_t surfaceMemoryBytes); |
244 void setPrioritiesForLayers(const LayerList&); | 235 void setPrioritiesForLayers(const LayerList&); |
245 size_t calculateMemoryForRenderSurfaces(const LayerList& updateList); | 236 size_t calculateMemoryForRenderSurfaces(const LayerList& updateList); |
246 | 237 |
247 void animateLayers(base::TimeTicks monotonicTime); | 238 void animateLayers(base::TimeTicks monotonicTime); |
248 bool animateLayersRecursive(Layer* current, base::TimeTicks time); | 239 bool animateLayersRecursive(Layer* current, base::TimeTicks time); |
249 void setAnimationEventsRecursive(const AnimationEventsVector&, Layer*, base: :Time wallClockTime); | 240 void setAnimationEventsRecursive(const AnimationEventsVector&, Layer*, base: :Time wallClockTime); |
250 | 241 |
251 void createHUDLayerIfNeeded(); | |
252 | |
253 bool m_animating; | 242 bool m_animating; |
254 bool m_needsAnimateLayers; | 243 bool m_needsAnimateLayers; |
255 | 244 |
256 base::CancelableClosure m_prepaintCallback; | 245 base::CancelableClosure m_prepaintCallback; |
257 | 246 |
258 LayerTreeHostClient* m_client; | 247 LayerTreeHostClient* m_client; |
259 scoped_ptr<Proxy> m_proxy; | 248 scoped_ptr<Proxy> m_proxy; |
260 | 249 |
261 int m_commitNumber; | 250 int m_commitNumber; |
262 RenderingStats m_renderingStats; | 251 RenderingStats m_renderingStats; |
263 | 252 |
264 bool m_rendererInitialized; | 253 bool m_rendererInitialized; |
265 bool m_contextLost; | 254 bool m_contextLost; |
266 int m_numTimesRecreateShouldFail; | 255 int m_numTimesRecreateShouldFail; |
267 int m_numFailedRecreateAttempts; | 256 int m_numFailedRecreateAttempts; |
268 | 257 |
269 scoped_refptr<Layer> m_rootLayer; | 258 scoped_refptr<Layer> m_rootLayer; |
270 scoped_refptr<HeadsUpDisplayLayer> m_hudLayer; | 259 scoped_refptr<HeadsUpDisplayLayer> m_hudLayer; |
271 | 260 |
272 scoped_ptr<PrioritizedResourceManager> m_contentsTextureManager; | 261 scoped_ptr<PrioritizedResourceManager> m_contentsTextureManager; |
273 scoped_ptr<PrioritizedResource> m_surfaceMemoryPlaceholder; | 262 scoped_ptr<PrioritizedResource> m_surfaceMemoryPlaceholder; |
274 | 263 |
275 LayerTreeSettings m_settings; | 264 LayerTreeSettings m_settings; |
265 HeadsUpDisplayLayerSettings m_localHUDLayerSettings; | |
276 | 266 |
277 gfx::Size m_layoutViewportSize; | 267 gfx::Size m_layoutViewportSize; |
278 gfx::Size m_deviceViewportSize; | 268 gfx::Size m_deviceViewportSize; |
279 float m_deviceScaleFactor; | 269 float m_deviceScaleFactor; |
280 | 270 |
281 bool m_visible; | 271 bool m_visible; |
282 | 272 |
283 typedef base::hash_map<WebKit::WebGraphicsContext3D*, scoped_refptr<RateLimi ter> > RateLimiterMap; | 273 typedef base::hash_map<WebKit::WebGraphicsContext3D*, scoped_refptr<RateLimi ter> > RateLimiterMap; |
284 RateLimiterMap m_rateLimiters; | 274 RateLimiterMap m_rateLimiters; |
285 | 275 |
286 float m_pageScaleFactor; | 276 float m_pageScaleFactor; |
287 float m_minPageScaleFactor, m_maxPageScaleFactor; | 277 float m_minPageScaleFactor, m_maxPageScaleFactor; |
288 WebKit::WebTransformationMatrix m_implTransform; | 278 WebKit::WebTransformationMatrix m_implTransform; |
289 bool m_triggerIdleUpdates; | 279 bool m_triggerIdleUpdates; |
290 | 280 |
291 SkColor m_backgroundColor; | 281 SkColor m_backgroundColor; |
292 bool m_hasTransparentBackground; | 282 bool m_hasTransparentBackground; |
293 | 283 |
294 typedef ScopedPtrVector<PrioritizedResource> TextureList; | 284 typedef ScopedPtrVector<PrioritizedResource> TextureList; |
295 size_t m_partialTextureUpdateRequests; | 285 size_t m_partialTextureUpdateRequests; |
296 | 286 |
297 static bool s_needsFilterContext; | 287 static bool s_needsFilterContext; |
298 | 288 |
299 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); | 289 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); |
300 }; | 290 }; |
301 | 291 |
302 } // namespace cc | 292 } // namespace cc |
303 | 293 |
304 #endif // CC_LAYER_TREE_HOST_H_ | 294 #endif // CC_LAYER_TREE_HOST_H_ |
OLD | NEW |