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_TREES_LAYER_TREE_HOST_IMPL_H_ | 5 #ifndef CC_TREES_LAYER_TREE_HOST_IMPL_H_ |
6 #define CC_TREES_LAYER_TREE_HOST_IMPL_H_ | 6 #define CC_TREES_LAYER_TREE_HOST_IMPL_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 // must also be called, regardless of whether DrawLayers is called between the | 167 // must also be called, regardless of whether DrawLayers is called between the |
168 // two. | 168 // two. |
169 virtual bool PrepareToDraw(FrameData* frame, | 169 virtual bool PrepareToDraw(FrameData* frame, |
170 gfx::Rect device_viewport_damage_rect); | 170 gfx::Rect device_viewport_damage_rect); |
171 virtual void DrawLayers(FrameData* frame, base::TimeTicks frame_begin_time); | 171 virtual void DrawLayers(FrameData* frame, base::TimeTicks frame_begin_time); |
172 // Must be called if and only if PrepareToDraw was called. | 172 // Must be called if and only if PrepareToDraw was called. |
173 void DidDrawAllLayers(const FrameData& frame); | 173 void DidDrawAllLayers(const FrameData& frame); |
174 | 174 |
175 const LayerTreeSettings& settings() const { return settings_; } | 175 const LayerTreeSettings& settings() const { return settings_; } |
176 | 176 |
177 // Returns the currently visible viewport size in DIP. This value excludes | |
178 // the URL bar and non-overlay scrollbars. | |
179 gfx::SizeF VisibleViewportSize() const; | |
180 | |
181 // Evict all textures by enforcing a memory policy with an allocation of 0. | 177 // Evict all textures by enforcing a memory policy with an allocation of 0. |
182 void EvictTexturesForTesting(); | 178 void EvictTexturesForTesting(); |
183 | 179 |
184 // When blocking, this prevents client_->NotifyReadyToActivate() from being | 180 // When blocking, this prevents client_->NotifyReadyToActivate() from being |
185 // called. When disabled, it calls client_->NotifyReadyToActivate() | 181 // called. When disabled, it calls client_->NotifyReadyToActivate() |
186 // immediately if any notifications had been blocked while blocking. | 182 // immediately if any notifications had been blocked while blocking. |
187 virtual void BlockNotifyReadyToActivateForTesting(bool block); | 183 virtual void BlockNotifyReadyToActivateForTesting(bool block); |
188 | 184 |
| 185 bool device_viewport_valid_for_tile_management() const { |
| 186 return device_viewport_valid_for_tile_management_; |
| 187 } |
| 188 |
| 189 // Viewport size in draw space: this size is in physical pixels and is used |
| 190 // for draw properties, tilings, quads and render passes. |
| 191 gfx::Size DrawViewportSize() const; |
| 192 |
| 193 // Viewport size for scrolling and fixed-position compensation. This value |
| 194 // excludes the URL bar and non-overlay scrollbars and is in DIP (and |
| 195 // invariant relative to page scale). |
| 196 gfx::SizeF UnscaledScrollableViewportSize() const; |
| 197 |
189 // RendererClient implementation | 198 // RendererClient implementation |
| 199 |
| 200 // Viewport rectangle and clip in nonflipped window space. These rects |
| 201 // should only be used by Renderer subclasses to populate glViewport/glClip |
| 202 // and their software-mode equivalents. |
190 virtual gfx::Rect DeviceViewport() const OVERRIDE; | 203 virtual gfx::Rect DeviceViewport() const OVERRIDE; |
| 204 virtual gfx::Rect DeviceClip() const OVERRIDE; |
191 private: | 205 private: |
192 virtual float DeviceScaleFactor() const OVERRIDE; | 206 virtual float DeviceScaleFactor() const OVERRIDE; |
193 virtual const LayerTreeSettings& Settings() const OVERRIDE; | 207 virtual const LayerTreeSettings& Settings() const OVERRIDE; |
194 public: | 208 public: |
195 virtual void SetFullRootLayerDamage() OVERRIDE; | 209 virtual void SetFullRootLayerDamage() OVERRIDE; |
196 virtual bool HasImplThread() const OVERRIDE; | 210 virtual bool HasImplThread() const OVERRIDE; |
197 virtual bool ShouldClearRootRenderPass() const OVERRIDE; | 211 virtual bool ShouldClearRootRenderPass() const OVERRIDE; |
198 virtual CompositorFrameMetadata MakeCompositorFrameMetadata() const OVERRIDE; | 212 virtual CompositorFrameMetadata MakeCompositorFrameMetadata() const OVERRIDE; |
199 virtual bool AllowPartialSwap() const OVERRIDE; | 213 virtual bool AllowPartialSwap() const OVERRIDE; |
200 virtual bool ExternalStencilTestEnabled() const OVERRIDE; | 214 virtual bool ExternalStencilTestEnabled() const OVERRIDE; |
201 | 215 |
202 // TileManagerClient implementation. | 216 // TileManagerClient implementation. |
203 virtual void NotifyReadyToActivate() OVERRIDE; | 217 virtual void NotifyReadyToActivate() OVERRIDE; |
204 | 218 |
205 // OutputSurfaceClient implementation. | 219 // OutputSurfaceClient implementation. |
206 virtual bool DeferredInitialize( | 220 virtual bool DeferredInitialize( |
207 scoped_refptr<ContextProvider> offscreen_context_provider) OVERRIDE; | 221 scoped_refptr<ContextProvider> offscreen_context_provider) OVERRIDE; |
208 virtual void ReleaseGL() OVERRIDE; | 222 virtual void ReleaseGL() OVERRIDE; |
209 virtual void SetNeedsRedrawRect(gfx::Rect rect) OVERRIDE; | 223 virtual void SetNeedsRedrawRect(gfx::Rect rect) OVERRIDE; |
210 virtual void BeginFrame(const BeginFrameArgs& args) OVERRIDE; | 224 virtual void BeginFrame(const BeginFrameArgs& args) OVERRIDE; |
211 virtual void SetExternalDrawConstraints(const gfx::Transform& transform, | 225 virtual void SetExternalDrawConstraints( |
212 gfx::Rect viewport) OVERRIDE; | 226 const gfx::Transform& transform, |
| 227 gfx::Rect viewport, |
| 228 gfx::Rect clip, |
| 229 bool valid_for_tile_management) OVERRIDE; |
213 virtual void SetExternalStencilTest(bool enabled) OVERRIDE; | 230 virtual void SetExternalStencilTest(bool enabled) OVERRIDE; |
214 virtual void DidLoseOutputSurface() OVERRIDE; | 231 virtual void DidLoseOutputSurface() OVERRIDE; |
215 virtual void OnSwapBuffersComplete(const CompositorFrameAck* ack) OVERRIDE; | 232 virtual void OnSwapBuffersComplete(const CompositorFrameAck* ack) OVERRIDE; |
216 virtual void SetMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE; | 233 virtual void SetMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE; |
217 virtual void SetDiscardBackBufferWhenNotVisible(bool discard) OVERRIDE; | 234 virtual void SetDiscardBackBufferWhenNotVisible(bool discard) OVERRIDE; |
218 virtual void SetTreeActivationCallback(const base::Closure& callback) | 235 virtual void SetTreeActivationCallback(const base::Closure& callback) |
219 OVERRIDE; | 236 OVERRIDE; |
220 | 237 |
221 // Called from LayerTreeImpl. | 238 // Called from LayerTreeImpl. |
222 void OnCanDrawStateChangedForTree(); | 239 void OnCanDrawStateChangedForTree(); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 bool visible() const { return visible_; } | 283 bool visible() const { return visible_; } |
267 | 284 |
268 void SetNeedsCommit() { client_->SetNeedsCommitOnImplThread(); } | 285 void SetNeedsCommit() { client_->SetNeedsCommitOnImplThread(); } |
269 void SetNeedsRedraw() { client_->SetNeedsRedrawOnImplThread(); } | 286 void SetNeedsRedraw() { client_->SetNeedsRedrawOnImplThread(); } |
270 | 287 |
271 ManagedMemoryPolicy ActualManagedMemoryPolicy() const; | 288 ManagedMemoryPolicy ActualManagedMemoryPolicy() const; |
272 | 289 |
273 size_t memory_allocation_limit_bytes() const; | 290 size_t memory_allocation_limit_bytes() const; |
274 | 291 |
275 void SetViewportSize(gfx::Size device_viewport_size); | 292 void SetViewportSize(gfx::Size device_viewport_size); |
276 gfx::Size device_viewport_size() const { return device_viewport_size_; } | |
277 | 293 |
278 void SetOverdrawBottomHeight(float overdraw_bottom_height); | 294 void SetOverdrawBottomHeight(float overdraw_bottom_height); |
279 float overdraw_bottom_height() const { return overdraw_bottom_height_; } | 295 float overdraw_bottom_height() const { return overdraw_bottom_height_; } |
280 | 296 |
281 void SetOverhangUIResource(UIResourceId overhang_ui_resource_id, | 297 void SetOverhangUIResource(UIResourceId overhang_ui_resource_id, |
282 gfx::Size overhang_ui_resource_size); | 298 gfx::Size overhang_ui_resource_size); |
283 | 299 |
284 void SetDeviceScaleFactor(float device_scale_factor); | 300 void SetDeviceScaleFactor(float device_scale_factor); |
285 float device_scale_factor() const { return device_scale_factor_; } | 301 float device_scale_factor() const { return device_scale_factor_; } |
286 | 302 |
287 const gfx::Transform& DeviceTransform() const; | 303 const gfx::Transform& DrawTransform() const; |
288 | 304 |
289 scoped_ptr<ScrollAndScaleSet> ProcessScrollDeltas(); | 305 scoped_ptr<ScrollAndScaleSet> ProcessScrollDeltas(); |
290 | 306 |
291 bool needs_animate_layers() const { | 307 bool needs_animate_layers() const { |
292 return !animation_registrar_->active_animation_controllers().empty(); | 308 return !animation_registrar_->active_animation_controllers().empty(); |
293 } | 309 } |
294 | 310 |
295 void SendManagedMemoryStats( | 311 void SendManagedMemoryStats( |
296 size_t memory_visible_bytes, | 312 size_t memory_visible_bytes, |
297 size_t memory_visible_and_nearby_bytes, | 313 size_t memory_visible_and_nearby_bytes, |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 } | 387 } |
372 gfx::Vector2dF current_fling_velocity() const { | 388 gfx::Vector2dF current_fling_velocity() const { |
373 return current_fling_velocity_; | 389 return current_fling_velocity_; |
374 } | 390 } |
375 | 391 |
376 bool pinch_gesture_active() const { return pinch_gesture_active_; } | 392 bool pinch_gesture_active() const { return pinch_gesture_active_; } |
377 | 393 |
378 void SetTreePriority(TreePriority priority); | 394 void SetTreePriority(TreePriority priority); |
379 | 395 |
380 void ResetCurrentFrameTimeForNextFrame(); | 396 void ResetCurrentFrameTimeForNextFrame(); |
381 base::TimeTicks CurrentFrameTimeTicks(); | 397 virtual base::TimeTicks CurrentFrameTimeTicks(); |
382 base::Time CurrentFrameTime(); | 398 base::Time CurrentFrameTime(); |
383 | 399 |
384 virtual base::TimeTicks CurrentPhysicalTimeTicks() const; | 400 virtual base::TimeTicks CurrentPhysicalTimeTicks() const; |
385 | 401 |
386 scoped_ptr<base::Value> AsValue() const { return AsValueWithFrame(NULL); } | 402 scoped_ptr<base::Value> AsValue() const { return AsValueWithFrame(NULL); } |
387 scoped_ptr<base::Value> AsValueWithFrame(FrameData* frame) const; | 403 scoped_ptr<base::Value> AsValueWithFrame(FrameData* frame) const; |
388 scoped_ptr<base::Value> ActivationStateAsValue() const; | 404 scoped_ptr<base::Value> ActivationStateAsValue() const; |
389 | 405 |
390 bool page_scale_animation_active() const { return !!page_scale_animation_; } | 406 bool page_scale_animation_active() const { return !!page_scale_animation_; } |
391 | 407 |
(...skipping 16 matching lines...) Expand all Loading... |
408 base::Time wall_clock_time); | 424 base::Time wall_clock_time); |
409 | 425 |
410 // Virtual for testing. | 426 // Virtual for testing. |
411 virtual base::TimeDelta LowFrequencyAnimationInterval() const; | 427 virtual base::TimeDelta LowFrequencyAnimationInterval() const; |
412 | 428 |
413 const AnimationRegistrar::AnimationControllerMap& | 429 const AnimationRegistrar::AnimationControllerMap& |
414 active_animation_controllers() const { | 430 active_animation_controllers() const { |
415 return animation_registrar_->active_animation_controllers(); | 431 return animation_registrar_->active_animation_controllers(); |
416 } | 432 } |
417 | 433 |
| 434 bool manage_tiles_needed() const { return manage_tiles_needed_; } |
| 435 |
418 LayerTreeHostImplClient* client_; | 436 LayerTreeHostImplClient* client_; |
419 Proxy* proxy_; | 437 Proxy* proxy_; |
420 | 438 |
421 private: | 439 private: |
422 void CreateAndSetRenderer( | 440 void CreateAndSetRenderer( |
423 OutputSurface* output_surface, | 441 OutputSurface* output_surface, |
424 ResourceProvider* resource_provider, | 442 ResourceProvider* resource_provider, |
425 bool skip_gl_renderer); | 443 bool skip_gl_renderer); |
426 void CreateAndSetTileManager(ResourceProvider* resource_provider, | 444 void CreateAndSetTileManager(ResourceProvider* resource_provider, |
427 bool using_map_image); | 445 bool using_map_image); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 | 546 |
529 // The maximum memory that would be used by the prioritized resource | 547 // The maximum memory that would be used by the prioritized resource |
530 // manager, if there were no limit on memory usage. | 548 // manager, if there were no limit on memory usage. |
531 size_t max_memory_needed_bytes_; | 549 size_t max_memory_needed_bytes_; |
532 | 550 |
533 size_t last_sent_memory_visible_bytes_; | 551 size_t last_sent_memory_visible_bytes_; |
534 size_t last_sent_memory_visible_and_nearby_bytes_; | 552 size_t last_sent_memory_visible_and_nearby_bytes_; |
535 size_t last_sent_memory_use_bytes_; | 553 size_t last_sent_memory_use_bytes_; |
536 bool zero_budget_; | 554 bool zero_budget_; |
537 | 555 |
538 // Viewport size passed in from the main thread, in physical pixels. | 556 // Viewport size passed in from the main thread, in physical pixels. This |
| 557 // value is the default size for all concepts of physical viewport (draw |
| 558 // viewport, scrolling viewport and device viewport), but it can be |
| 559 // overridden. |
539 gfx::Size device_viewport_size_; | 560 gfx::Size device_viewport_size_; |
540 | 561 |
541 // Conversion factor from CSS pixels to physical pixels when | 562 // Conversion factor from CSS pixels to physical pixels when |
542 // pageScaleFactor=1. | 563 // pageScaleFactor=1. |
543 float device_scale_factor_; | 564 float device_scale_factor_; |
544 | 565 |
545 // UI resource to use for drawing overhang gutters. | 566 // UI resource to use for drawing overhang gutters. |
546 UIResourceId overhang_ui_resource_id_; | 567 UIResourceId overhang_ui_resource_id_; |
547 gfx::Size overhang_ui_resource_size_; | 568 gfx::Size overhang_ui_resource_size_; |
548 | 569 |
549 // Vertical amount of the viewport size that's known to covered by a | 570 // Vertical amount of the viewport size that's known to covered by a |
550 // browser-side UI element, such as an on-screen-keyboard. This affects | 571 // browser-side UI element, such as an on-screen-keyboard. This affects |
551 // scrollable size since we want to still be able to scroll to the bottom of | 572 // scrollable size since we want to still be able to scroll to the bottom of |
552 // the page when the keyboard is up. | 573 // the page when the keyboard is up. |
553 float overdraw_bottom_height_; | 574 float overdraw_bottom_height_; |
554 | 575 |
555 // Optional top-level constraints that can be set by the OutputSurface. The | 576 // Optional top-level constraints that can be set by the OutputSurface. |
556 // external_viewport_'s size takes precedence over device_viewport_size_ for | 577 // - external_transform_ applies a transform above the root layer |
557 // DrawQuad generation and Renderer; however, device_viewport_size_ is still | 578 // - external_viewport_ is used DrawProperties, tile management and |
558 // used for scrollable size. | 579 // glViewport/window projection matrix. |
| 580 // - external_clip_ specifies a top-level clip rect |
| 581 // - external_stencil_test_enabled_ tells CC to respect existing stencil bits |
| 582 // (When these are specified, device_viewport_size_ remains used only for |
| 583 // scrollable size.) |
559 gfx::Transform external_transform_; | 584 gfx::Transform external_transform_; |
560 gfx::Rect external_viewport_; | 585 gfx::Rect external_viewport_; |
| 586 gfx::Rect external_clip_; |
| 587 bool device_viewport_valid_for_tile_management_; |
561 bool external_stencil_test_enabled_; | 588 bool external_stencil_test_enabled_; |
562 | 589 |
563 gfx::Rect viewport_damage_rect_; | 590 gfx::Rect viewport_damage_rect_; |
564 | 591 |
565 base::TimeTicks current_frame_timeticks_; | 592 base::TimeTicks current_frame_timeticks_; |
566 base::Time current_frame_time_; | 593 base::Time current_frame_time_; |
567 | 594 |
568 scoped_ptr<AnimationRegistrar> animation_registrar_; | 595 scoped_ptr<AnimationRegistrar> animation_registrar_; |
569 | 596 |
570 RenderingStatsInstrumentation* rendering_stats_instrumentation_; | 597 RenderingStatsInstrumentation* rendering_stats_instrumentation_; |
571 | 598 |
572 bool need_to_update_visible_tiles_before_draw_; | 599 bool need_to_update_visible_tiles_before_draw_; |
573 | 600 |
574 // Optional callback to notify of new tree activations. | 601 // Optional callback to notify of new tree activations. |
575 base::Closure tree_activation_callback_; | 602 base::Closure tree_activation_callback_; |
576 | 603 |
577 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); | 604 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); |
578 }; | 605 }; |
579 | 606 |
580 } // namespace cc | 607 } // namespace cc |
581 | 608 |
582 #endif // CC_TREES_LAYER_TREE_HOST_IMPL_H_ | 609 #endif // CC_TREES_LAYER_TREE_HOST_IMPL_H_ |
OLD | NEW |