Home | History | Annotate | Download | only in trees
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef CC_TREES_LAYER_TREE_HOST_IMPL_H_
      6 #define CC_TREES_LAYER_TREE_HOST_IMPL_H_
      7 
      8 #include <list>
      9 #include <string>
     10 #include <vector>
     11 
     12 #include "base/basictypes.h"
     13 #include "base/containers/hash_tables.h"
     14 #include "base/memory/scoped_ptr.h"
     15 #include "base/time/time.h"
     16 #include "cc/animation/animation_events.h"
     17 #include "cc/animation/animation_registrar.h"
     18 #include "cc/base/cc_export.h"
     19 #include "cc/input/input_handler.h"
     20 #include "cc/input/layer_scroll_offset_delegate.h"
     21 #include "cc/input/top_controls_manager_client.h"
     22 #include "cc/layers/layer_lists.h"
     23 #include "cc/layers/render_pass_sink.h"
     24 #include "cc/output/begin_frame_args.h"
     25 #include "cc/output/managed_memory_policy.h"
     26 #include "cc/output/output_surface_client.h"
     27 #include "cc/output/renderer.h"
     28 #include "cc/quads/render_pass.h"
     29 #include "cc/resources/resource_provider.h"
     30 #include "cc/resources/tile_manager.h"
     31 #include "skia/ext/refptr.h"
     32 #include "third_party/skia/include/core/SkColor.h"
     33 #include "ui/gfx/rect.h"
     34 
     35 namespace cc {
     36 
     37 class CompletionEvent;
     38 class CompositorFrameMetadata;
     39 class DebugRectHistory;
     40 class FrameRateCounter;
     41 class LayerImpl;
     42 class LayerTreeHostImplTimeSourceAdapter;
     43 class LayerTreeImpl;
     44 class PageScaleAnimation;
     45 class PaintTimeCounter;
     46 class MemoryHistory;
     47 class RenderingStatsInstrumentation;
     48 class RenderPassDrawQuad;
     49 class TopControlsManager;
     50 class UIResourceBitmap;
     51 struct RendererCapabilities;
     52 struct UIResourceRequest;
     53 
     54 // LayerTreeHost->Proxy callback interface.
     55 class LayerTreeHostImplClient {
     56  public:
     57   virtual void DidTryInitializeRendererOnImplThread(
     58       bool success,
     59       scoped_refptr<ContextProvider> offscreen_context_provider) = 0;
     60   virtual void DidLoseOutputSurfaceOnImplThread() = 0;
     61   virtual void OnSwapBuffersCompleteOnImplThread() = 0;
     62   virtual void BeginFrameOnImplThread(const BeginFrameArgs& args) = 0;
     63   virtual void OnCanDrawStateChanged(bool can_draw) = 0;
     64   virtual void OnHasPendingTreeStateChanged(bool has_pending_tree) = 0;
     65   virtual void SetNeedsRedrawOnImplThread() = 0;
     66   virtual void SetNeedsRedrawRectOnImplThread(gfx::Rect damage_rect) = 0;
     67   virtual void DidInitializeVisibleTileOnImplThread() = 0;
     68   virtual void SetNeedsCommitOnImplThread() = 0;
     69   virtual void PostAnimationEventsToMainThreadOnImplThread(
     70       scoped_ptr<AnimationEventsVector> events,
     71       base::Time wall_clock_time) = 0;
     72   // Returns true if resources were deleted by this call.
     73   virtual bool ReduceContentsTextureMemoryOnImplThread(
     74       size_t limit_bytes,
     75       int priority_cutoff) = 0;
     76   virtual void ReduceWastedContentsTextureMemoryOnImplThread() = 0;
     77   virtual void SendManagedMemoryStats() = 0;
     78   virtual bool IsInsideDraw() = 0;
     79   virtual void RenewTreePriority() = 0;
     80   virtual void RequestScrollbarAnimationOnImplThread(base::TimeDelta delay) = 0;
     81   virtual void DidActivatePendingTree() = 0;
     82 
     83  protected:
     84   virtual ~LayerTreeHostImplClient() {}
     85 };
     86 
     87 // LayerTreeHostImpl owns the LayerImpl trees as well as associated rendering
     88 // state.
     89 class CC_EXPORT LayerTreeHostImpl
     90     : public InputHandler,
     91       public RendererClient,
     92       public TileManagerClient,
     93       public OutputSurfaceClient,
     94       public TopControlsManagerClient,
     95       public base::SupportsWeakPtr<LayerTreeHostImpl> {
     96  public:
     97   static scoped_ptr<LayerTreeHostImpl> Create(
     98       const LayerTreeSettings& settings,
     99       LayerTreeHostImplClient* client,
    100       Proxy* proxy,
    101       RenderingStatsInstrumentation* rendering_stats_instrumentation);
    102   virtual ~LayerTreeHostImpl();
    103 
    104   // InputHandler implementation
    105   virtual void BindToClient(InputHandlerClient* client) OVERRIDE;
    106   virtual InputHandler::ScrollStatus ScrollBegin(
    107       gfx::Point viewport_point,
    108       InputHandler::ScrollInputType type) OVERRIDE;
    109   virtual bool ScrollBy(gfx::Point viewport_point,
    110                         gfx::Vector2dF scroll_delta) OVERRIDE;
    111   virtual bool ScrollVerticallyByPage(gfx::Point viewport_point,
    112                                       ScrollDirection direction) OVERRIDE;
    113   virtual void SetRootLayerScrollOffsetDelegate(
    114       LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate) OVERRIDE;
    115   virtual void OnRootLayerDelegatedScrollOffsetChanged() OVERRIDE;
    116   virtual void ScrollEnd() OVERRIDE;
    117   virtual InputHandler::ScrollStatus FlingScrollBegin() OVERRIDE;
    118   virtual void NotifyCurrentFlingVelocity(gfx::Vector2dF velocity) OVERRIDE;
    119   virtual void PinchGestureBegin() OVERRIDE;
    120   virtual void PinchGestureUpdate(float magnify_delta,
    121                                   gfx::Point anchor) OVERRIDE;
    122   virtual void PinchGestureEnd() OVERRIDE;
    123   virtual void StartPageScaleAnimation(gfx::Vector2d target_offset,
    124                                        bool anchor_point,
    125                                        float page_scale,
    126                                        base::TimeTicks start_time,
    127                                        base::TimeDelta duration) OVERRIDE;
    128   virtual void ScheduleAnimation() OVERRIDE;
    129   virtual bool HaveTouchEventHandlersAt(gfx::Point viewport_port) OVERRIDE;
    130   virtual void SetLatencyInfoForInputEvent(const ui::LatencyInfo& latency_info)
    131       OVERRIDE;
    132 
    133   // TopControlsManagerClient implementation.
    134   virtual void DidChangeTopControlsPosition() OVERRIDE;
    135   virtual bool HaveRootScrollLayer() const OVERRIDE;
    136 
    137   void StartScrollbarAnimation();
    138 
    139   struct CC_EXPORT FrameData : public RenderPassSink {
    140     FrameData();
    141     virtual ~FrameData();
    142     scoped_ptr<base::Value> AsValue() const;
    143 
    144     std::vector<gfx::Rect> occluding_screen_space_rects;
    145     std::vector<gfx::Rect> non_occluding_screen_space_rects;
    146     RenderPassList render_passes;
    147     RenderPassIdHashMap render_passes_by_id;
    148     const LayerImplList* render_surface_layer_list;
    149     LayerImplList will_draw_layers;
    150     bool contains_incomplete_tile;
    151     bool has_no_damage;
    152 
    153     // RenderPassSink implementation.
    154     virtual void AppendRenderPass(scoped_ptr<RenderPass> render_pass) OVERRIDE;
    155   };
    156 
    157   virtual void BeginCommit();
    158   virtual void CommitComplete();
    159   virtual void Animate(base::TimeTicks monotonic_time,
    160                        base::Time wall_clock_time);
    161   virtual void UpdateAnimationState(bool start_ready_animations);
    162   void MainThreadHasStoppedFlinging();
    163   void UpdateBackgroundAnimateTicking(bool should_background_tick);
    164   void SetViewportDamage(gfx::Rect damage_rect);
    165 
    166   void ManageTiles();
    167 
    168   // Returns false if problems occured preparing the frame, and we should try
    169   // to avoid displaying the frame. If PrepareToDraw is called, DidDrawAllLayers
    170   // must also be called, regardless of whether DrawLayers is called between the
    171   // two.
    172   virtual bool PrepareToDraw(FrameData* frame,
    173                              gfx::Rect device_viewport_damage_rect);
    174   virtual void DrawLayers(FrameData* frame, base::TimeTicks frame_begin_time);
    175   // Must be called if and only if PrepareToDraw was called.
    176   void DidDrawAllLayers(const FrameData& frame);
    177 
    178   const LayerTreeSettings& settings() const { return settings_; }
    179 
    180   // Returns the currently visible viewport size in DIP. This value excludes
    181   // the URL bar and non-overlay scrollbars.
    182   gfx::SizeF UnscaledScrollableViewportSize() const;
    183 
    184   // Evict all textures by enforcing a memory policy with an allocation of 0.
    185   void EvictTexturesForTesting();
    186 
    187   bool device_viewport_valid_for_tile_management() const {
    188     return device_viewport_valid_for_tile_management_;
    189   }
    190 
    191   // RendererClient implementation
    192   virtual gfx::Rect DeviceViewport() const OVERRIDE;
    193   virtual gfx::Rect DeviceClip() const OVERRIDE;
    194  private:
    195   virtual float DeviceScaleFactor() const OVERRIDE;
    196   virtual const LayerTreeSettings& Settings() const OVERRIDE;
    197  public:
    198   virtual void SetFullRootLayerDamage() OVERRIDE;
    199   virtual bool HasImplThread() const OVERRIDE;
    200   virtual bool ShouldClearRootRenderPass() const OVERRIDE;
    201   virtual CompositorFrameMetadata MakeCompositorFrameMetadata() const OVERRIDE;
    202   virtual bool AllowPartialSwap() const OVERRIDE;
    203   virtual bool ExternalStencilTestEnabled() const OVERRIDE;
    204 
    205   // TileManagerClient implementation.
    206   virtual void NotifyReadyToActivate() OVERRIDE;
    207 
    208   // OutputSurfaceClient implementation.
    209   virtual bool DeferredInitialize(
    210       scoped_refptr<ContextProvider> offscreen_context_provider) OVERRIDE;
    211   virtual void ReleaseGL() OVERRIDE;
    212   virtual void SetNeedsRedrawRect(gfx::Rect rect) OVERRIDE;
    213   virtual void BeginFrame(const BeginFrameArgs& args) OVERRIDE;
    214   virtual void SetExternalDrawConstraints(
    215       const gfx::Transform& transform,
    216       gfx::Rect viewport,
    217       gfx::Rect clip,
    218       bool valid_for_tile_management) OVERRIDE;
    219   virtual void SetExternalStencilTest(bool enabled) OVERRIDE;
    220   virtual void DidLoseOutputSurface() OVERRIDE;
    221   virtual void OnSwapBuffersComplete(const CompositorFrameAck* ack) OVERRIDE;
    222   virtual void SetMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE;
    223   virtual void SetDiscardBackBufferWhenNotVisible(bool discard) OVERRIDE;
    224   virtual void SetTreeActivationCallback(const base::Closure& callback)
    225       OVERRIDE;
    226 
    227   // Called from LayerTreeImpl.
    228   void OnCanDrawStateChangedForTree();
    229 
    230   // Implementation
    231   bool CanDraw() const;
    232   OutputSurface* output_surface() const { return output_surface_.get(); }
    233 
    234   std::string LayerTreeAsJson() const;
    235 
    236   void FinishAllRendering();
    237   int SourceAnimationFrameNumber() const;
    238 
    239   virtual bool InitializeRenderer(scoped_ptr<OutputSurface> output_surface);
    240   bool IsContextLost();
    241   TileManager* tile_manager() { return tile_manager_.get(); }
    242   Renderer* renderer() { return renderer_.get(); }
    243   const RendererCapabilities& GetRendererCapabilities() const;
    244 
    245   virtual bool SwapBuffers(const FrameData& frame);
    246   void SetNeedsBeginFrame(bool enable);
    247   void SetNeedsManageTiles() { manage_tiles_needed_ = true; }
    248 
    249   void Readback(void* pixels, gfx::Rect rect_in_device_viewport);
    250 
    251   LayerTreeImpl* active_tree() { return active_tree_.get(); }
    252   const LayerTreeImpl* active_tree() const { return active_tree_.get(); }
    253   LayerTreeImpl* pending_tree() { return pending_tree_.get(); }
    254   const LayerTreeImpl* pending_tree() const { return pending_tree_.get(); }
    255   const LayerTreeImpl* recycle_tree() const { return recycle_tree_.get(); }
    256   virtual void CreatePendingTree();
    257   void UpdateVisibleTiles();
    258   virtual void ActivatePendingTreeIfNeeded();
    259 
    260   // Shortcuts to layers on the active tree.
    261   LayerImpl* RootLayer() const;
    262   LayerImpl* RootScrollLayer() const;
    263   LayerImpl* CurrentlyScrollingLayer() const;
    264 
    265   bool IsCurrentlyScrolling() const;
    266 
    267   virtual void SetVisible(bool visible);
    268   bool visible() const { return visible_; }
    269 
    270   void SetNeedsCommit() { client_->SetNeedsCommitOnImplThread(); }
    271   void SetNeedsRedraw() { client_->SetNeedsRedrawOnImplThread(); }
    272 
    273   ManagedMemoryPolicy ActualManagedMemoryPolicy() const;
    274 
    275   size_t memory_allocation_limit_bytes() const;
    276 
    277   void SetViewportSize(gfx::Size device_viewport_size);
    278 
    279   void SetOverdrawBottomHeight(float overdraw_bottom_height);
    280   float overdraw_bottom_height() const { return overdraw_bottom_height_; }
    281 
    282   void SetDeviceScaleFactor(float device_scale_factor);
    283   float device_scale_factor() const { return device_scale_factor_; }
    284 
    285   const gfx::Transform& DeviceTransform() const;
    286 
    287   scoped_ptr<ScrollAndScaleSet> ProcessScrollDeltas();
    288 
    289   bool needs_animate_layers() const {
    290     return !animation_registrar_->active_animation_controllers().empty();
    291   }
    292 
    293   void SendManagedMemoryStats(
    294       size_t memory_visible_bytes,
    295       size_t memory_visible_and_nearby_bytes,
    296       size_t memory_use_bytes);
    297 
    298   void set_max_memory_needed_bytes(size_t bytes) {
    299     max_memory_needed_bytes_ = bytes;
    300   }
    301 
    302   FrameRateCounter* fps_counter() {
    303     return fps_counter_.get();
    304   }
    305   PaintTimeCounter* paint_time_counter() {
    306     return paint_time_counter_.get();
    307   }
    308   MemoryHistory* memory_history() {
    309     return memory_history_.get();
    310   }
    311   DebugRectHistory* debug_rect_history() {
    312     return debug_rect_history_.get();
    313   }
    314   ResourceProvider* resource_provider() {
    315     return resource_provider_.get();
    316   }
    317   TopControlsManager* top_controls_manager() {
    318     return top_controls_manager_.get();
    319   }
    320 
    321   Proxy* proxy() const { return proxy_; }
    322 
    323   AnimationRegistrar* animation_registrar() const {
    324     return animation_registrar_.get();
    325   }
    326 
    327   void SetDebugState(const LayerTreeDebugState& new_debug_state);
    328   const LayerTreeDebugState& debug_state() const { return debug_state_; }
    329 
    330   class CC_EXPORT CullRenderPassesWithCachedTextures {
    331  public:
    332     bool ShouldRemoveRenderPass(const RenderPassDrawQuad& quad,
    333                                 const FrameData& frame) const;
    334 
    335     // Iterates from the root first, in order to remove the surfaces closest
    336     // to the root with cached textures, and all surfaces that draw into
    337     // them.
    338     size_t RenderPassListBegin(const RenderPassList& list) const {
    339       return list.size() - 1;
    340     }
    341     size_t RenderPassListEnd(const RenderPassList& list) const { return 0 - 1; }
    342     size_t RenderPassListNext(size_t it) const { return it - 1; }
    343 
    344     explicit CullRenderPassesWithCachedTextures(Renderer* renderer)
    345         : renderer_(renderer) {}
    346  private:
    347     Renderer* renderer_;
    348   };
    349 
    350   class CC_EXPORT CullRenderPassesWithNoQuads {
    351  public:
    352     bool ShouldRemoveRenderPass(const RenderPassDrawQuad& quad,
    353                                 const FrameData& frame) const;
    354 
    355     // Iterates in draw order, so that when a surface is removed, and its
    356     // target becomes empty, then its target can be removed also.
    357     size_t RenderPassListBegin(const RenderPassList& list) const { return 0; }
    358     size_t RenderPassListEnd(const RenderPassList& list) const {
    359       return list.size();
    360     }
    361     size_t RenderPassListNext(size_t it) const { return it + 1; }
    362   };
    363 
    364   template <typename RenderPassCuller>
    365       static void RemoveRenderPasses(RenderPassCuller culler, FrameData* frame);
    366 
    367   gfx::Vector2dF accumulated_root_overscroll() const {
    368     return accumulated_root_overscroll_;
    369   }
    370   gfx::Vector2dF current_fling_velocity() const {
    371     return current_fling_velocity_;
    372   }
    373 
    374   bool pinch_gesture_active() const { return pinch_gesture_active_; }
    375 
    376   void SetTreePriority(TreePriority priority);
    377 
    378   void ResetCurrentFrameTimeForNextFrame();
    379   base::TimeTicks CurrentFrameTimeTicks();
    380   base::Time CurrentFrameTime();
    381 
    382   virtual base::TimeTicks CurrentPhysicalTimeTicks() const;
    383 
    384   scoped_ptr<base::Value> AsValue() const { return AsValueWithFrame(NULL); }
    385   scoped_ptr<base::Value> AsValueWithFrame(FrameData* frame) const;
    386   scoped_ptr<base::Value> ActivationStateAsValue() const;
    387 
    388   bool page_scale_animation_active() const { return !!page_scale_animation_; }
    389 
    390   void CreateUIResource(UIResourceId uid,
    391                         scoped_refptr<UIResourceBitmap> bitmap);
    392   // Deletes a UI resource.  May safely be called more than once.
    393   void DeleteUIResource(UIResourceId uid);
    394 
    395   ResourceProvider::ResourceId ResourceIdForUIResource(UIResourceId uid) const;
    396 
    397  protected:
    398   LayerTreeHostImpl(
    399       const LayerTreeSettings& settings,
    400       LayerTreeHostImplClient* client,
    401       Proxy* proxy,
    402       RenderingStatsInstrumentation* rendering_stats_instrumentation);
    403   virtual void ActivatePendingTree();
    404 
    405   // Virtual for testing.
    406   virtual void AnimateLayers(base::TimeTicks monotonic_time,
    407                              base::Time wall_clock_time);
    408 
    409   // Virtual for testing.
    410   virtual base::TimeDelta LowFrequencyAnimationInterval() const;
    411 
    412   const AnimationRegistrar::AnimationControllerMap&
    413       active_animation_controllers() const {
    414     return animation_registrar_->active_animation_controllers();
    415   }
    416 
    417   LayerTreeHostImplClient* client_;
    418   Proxy* proxy_;
    419 
    420  private:
    421   void CreateAndSetRenderer(OutputSurface* output_surface,
    422                             ResourceProvider* resource_provider,
    423                             bool skip_gl_renderer);
    424   void CreateAndSetTileManager(ResourceProvider* resource_provider,
    425                                bool using_map_image);
    426   void ReleaseTreeResources();
    427   void EnforceZeroBudget(bool zero_budget);
    428 
    429   void AnimatePageScale(base::TimeTicks monotonic_time);
    430   void AnimateScrollbars(base::TimeTicks monotonic_time);
    431   void AnimateTopControls(base::TimeTicks monotonic_time);
    432 
    433   gfx::Vector2dF ScrollLayerWithViewportSpaceDelta(
    434       LayerImpl* layer_impl,
    435       float scale_from_viewport_to_screen_space,
    436       gfx::PointF viewport_point,
    437       gfx::Vector2dF viewport_delta);
    438 
    439   void UpdateMaxScrollOffset();
    440   void TrackDamageForAllSurfaces(
    441       LayerImpl* root_draw_layer,
    442       const LayerImplList& render_surface_layer_list);
    443 
    444   void UpdateTileManagerMemoryPolicy(const ManagedMemoryPolicy& policy);
    445 
    446   // Returns false if the frame should not be displayed. This function should
    447   // only be called from PrepareToDraw, as DidDrawAllLayers must be called
    448   // if this helper function is called.
    449   bool CalculateRenderPasses(FrameData* frame);
    450 
    451   void SendReleaseResourcesRecursive(LayerImpl* current);
    452   bool EnsureRenderSurfaceLayerList();
    453   void ClearCurrentlyScrollingLayer();
    454 
    455   void AnimateScrollbarsRecursive(LayerImpl* layer,
    456                                   base::TimeTicks time);
    457 
    458   void UpdateCurrentFrameTime(base::TimeTicks* ticks, base::Time* now) const;
    459 
    460   void StartScrollbarAnimationRecursive(LayerImpl* layer, base::TimeTicks time);
    461   void SetManagedMemoryPolicy(const ManagedMemoryPolicy& policy,
    462                               bool zero_budget);
    463   void EnforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy);
    464 
    465   void DidInitializeVisibleTile();
    466 
    467   typedef base::hash_map<UIResourceId, ResourceProvider::ResourceId>
    468       UIResourceMap;
    469   UIResourceMap ui_resource_map_;
    470 
    471   scoped_ptr<OutputSurface> output_surface_;
    472 
    473   // |resource_provider_| and |tile_manager_| can be NULL, e.g. when using tile-
    474   // free rendering - see OutputSurface::ForcedDrawToSoftwareDevice().
    475   scoped_ptr<ResourceProvider> resource_provider_;
    476   scoped_ptr<TileManager> tile_manager_;
    477   scoped_ptr<Renderer> renderer_;
    478 
    479   // Tree currently being drawn.
    480   scoped_ptr<LayerTreeImpl> active_tree_;
    481 
    482   // In impl-side painting mode, tree with possibly incomplete rasterized
    483   // content. May be promoted to active by ActivatePendingTreeIfNeeded().
    484   scoped_ptr<LayerTreeImpl> pending_tree_;
    485 
    486   // In impl-side painting mode, inert tree with layers that can be recycled
    487   // by the next sync from the main thread.
    488   scoped_ptr<LayerTreeImpl> recycle_tree_;
    489 
    490   InputHandlerClient* input_handler_client_;
    491   bool did_lock_scrolling_layer_;
    492   bool should_bubble_scrolls_;
    493   bool wheel_scrolling_;
    494 
    495   bool manage_tiles_needed_;
    496 
    497   // The optional delegate for the root layer scroll offset.
    498   LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate_;
    499   LayerTreeSettings settings_;
    500   LayerTreeDebugState debug_state_;
    501   bool visible_;
    502   ManagedMemoryPolicy cached_managed_memory_policy_;
    503 
    504   gfx::Vector2dF accumulated_root_overscroll_;
    505   gfx::Vector2dF current_fling_velocity_;
    506 
    507   bool pinch_gesture_active_;
    508   gfx::Point previous_pinch_anchor_;
    509 
    510   // This is set by AnimateLayers() and used by UpdateAnimationState()
    511   // when sending animation events to the main thread.
    512   base::Time last_animation_time_;
    513 
    514   scoped_ptr<TopControlsManager> top_controls_manager_;
    515 
    516   scoped_ptr<PageScaleAnimation> page_scale_animation_;
    517 
    518   // This is used for ticking animations slowly when hidden.
    519   scoped_ptr<LayerTreeHostImplTimeSourceAdapter> time_source_client_adapter_;
    520 
    521   scoped_ptr<FrameRateCounter> fps_counter_;
    522   scoped_ptr<PaintTimeCounter> paint_time_counter_;
    523   scoped_ptr<MemoryHistory> memory_history_;
    524   scoped_ptr<DebugRectHistory> debug_rect_history_;
    525 
    526   // The maximum memory that would be used by the prioritized resource
    527   // manager, if there were no limit on memory usage.
    528   size_t max_memory_needed_bytes_;
    529 
    530   size_t last_sent_memory_visible_bytes_;
    531   size_t last_sent_memory_visible_and_nearby_bytes_;
    532   size_t last_sent_memory_use_bytes_;
    533   bool zero_budget_;
    534 
    535   // Viewport size passed in from the main thread, in physical pixels.
    536   gfx::Size device_viewport_size_;
    537 
    538   // Conversion factor from CSS pixels to physical pixels when
    539   // pageScaleFactor=1.
    540   float device_scale_factor_;
    541 
    542   // Vertical amount of the viewport size that's known to covered by a
    543   // browser-side UI element, such as an on-screen-keyboard.  This affects
    544   // scrollable size since we want to still be able to scroll to the bottom of
    545   // the page when the keyboard is up.
    546   float overdraw_bottom_height_;
    547 
    548   // Optional top-level constraints that can be set by the OutputSurface.
    549   // - external_transform_ applies a transform above the root layer
    550   // - external_viewport_ is used DrawProperties, tile management and
    551   // glViewport/window projection matrix.
    552   // - external_clip_ specifies a top-level clip rect
    553   // - external_stencil_test_enabled_ tells CC to respect existing stencil bits
    554   // (When these are specified, device_viewport_size_ remains used only for
    555   // scrollable size.)
    556   gfx::Transform external_transform_;
    557   gfx::Rect external_viewport_;
    558   gfx::Rect external_clip_;
    559   bool device_viewport_valid_for_tile_management_;
    560   bool external_stencil_test_enabled_;
    561 
    562   gfx::Rect viewport_damage_rect_;
    563 
    564   base::TimeTicks current_frame_timeticks_;
    565   base::Time current_frame_time_;
    566 
    567   scoped_ptr<AnimationRegistrar> animation_registrar_;
    568 
    569   RenderingStatsInstrumentation* rendering_stats_instrumentation_;
    570 
    571   bool need_to_update_visible_tiles_before_draw_;
    572 
    573   // Optional callback to notify of new tree activations.
    574   base::Closure tree_activation_callback_;
    575 
    576   DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl);
    577 };
    578 
    579 }  // namespace cc
    580 
    581 #endif  // CC_TREES_LAYER_TREE_HOST_IMPL_H_
    582