#include "cc/quads/render_pass.h"
#include "cc/resources/resource_provider.h"
#include "cc/resources/tile_manager.h"
-#include "cc/scheduler/draw_swap_readback_result.h"
+#include "cc/scheduler/draw_result.h"
#include "skia/ext/refptr.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/rect.h"
class CompletionEvent;
class CompositorFrameMetadata;
class DebugRectHistory;
+class EvictionTilePriorityQueue;
class FrameRateCounter;
class LayerImpl;
class LayerTreeHostImplTimeSourceAdapter;
class MemoryHistory;
class PageScaleAnimation;
class PaintTimeCounter;
+class PictureLayerImpl;
+class RasterTilePriorityQueue;
class RasterWorkerPool;
class RenderPassDrawQuad;
class RenderingStatsInstrumentation;
virtual bool ReduceContentsTextureMemoryOnImplThread(
size_t limit_bytes,
int priority_cutoff) = 0;
- virtual void SendManagedMemoryStats() = 0;
virtual bool IsInsideDraw() = 0;
virtual void RenewTreePriority() = 0;
virtual void PostDelayedScrollbarFadeOnImplThread(
const base::Closure& start_fade,
base::TimeDelta delay) = 0;
- virtual void DidActivatePendingTree() = 0;
+ virtual void DidActivateSyncTree() = 0;
virtual void DidManageTiles() = 0;
protected:
virtual InputHandler::ScrollStatus ScrollBegin(
const gfx::Point& viewport_point,
InputHandler::ScrollInputType type) OVERRIDE;
+ virtual InputHandler::ScrollStatus ScrollAnimated(
+ const gfx::Point& viewport_point,
+ const gfx::Vector2dF& scroll_delta) OVERRIDE;
virtual bool ScrollBy(const gfx::Point& viewport_point,
const gfx::Vector2dF& scroll_delta) OVERRIDE;
virtual bool ScrollVerticallyByPage(const gfx::Point& viewport_point,
virtual void PinchGestureUpdate(float magnify_delta,
const gfx::Point& anchor) OVERRIDE;
virtual void PinchGestureEnd() OVERRIDE;
- virtual void StartPageScaleAnimation(const gfx::Vector2d& target_offset,
- bool anchor_point,
- float page_scale,
- base::TimeDelta duration) OVERRIDE;
virtual void SetNeedsAnimate() OVERRIDE;
virtual bool IsCurrentlyScrollingLayerAt(
const gfx::Point& viewport_point,
ui::LatencyInfo* latency) OVERRIDE;
// TopControlsManagerClient implementation.
+ virtual void SetControlsTopOffset(float offset) OVERRIDE;
+ virtual float ControlsTopOffset() const OVERRIDE;
virtual void DidChangeTopControlsPosition() OVERRIDE;
virtual bool HaveRootScrollLayer() const OVERRIDE;
struct CC_EXPORT FrameData : public RenderPassSink {
FrameData();
virtual ~FrameData();
- scoped_ptr<base::Value> AsValue() const;
+ void AsValueInto(base::debug::TracedValue* value) const;
std::vector<gfx::Rect> occluding_screen_space_rects;
std::vector<gfx::Rect> non_occluding_screen_space_rects;
virtual void ManageTiles();
- // Returns false if problems occured preparing the frame, and we should try
- // to avoid displaying the frame. If PrepareToDraw is called, DidDrawAllLayers
- // must also be called, regardless of whether DrawLayers is called between the
- // two.
- virtual DrawSwapReadbackResult::DrawResult PrepareToDraw(
- FrameData* frame,
- const gfx::Rect& damage_rect);
+ // Returns DRAW_SUCCESS unless problems occured preparing the frame, and we
+ // should try to avoid displaying the frame. If PrepareToDraw is called,
+ // DidDrawAllLayers must also be called, regardless of whether DrawLayers is
+ // called between the two.
+ virtual DrawResult PrepareToDraw(FrameData* frame);
virtual void DrawLayers(FrameData* frame, base::TimeTicks frame_begin_time);
// Must be called if and only if PrepareToDraw was called.
void DidDrawAllLayers(const FrameData& frame);
// This allows us to inject DidInitializeVisibleTile events for testing.
void DidInitializeVisibleTileForTesting();
- bool device_viewport_valid_for_tile_management() const {
- return device_viewport_valid_for_tile_management_;
- }
+ // Resets all of the trees to an empty state.
+ void ResetTreesForTesting();
+ void ResetRecycleTreeForTesting();
+
+ DrawMode GetDrawMode() const;
// Viewport size in draw space: this size is in physical pixels and is used
// for draw properties, tilings, quads and render passes.
gfx::Size DrawViewportSize() const;
- // Viewport size for scrolling and fixed-position compensation. This value
- // excludes the URL bar and non-overlay scrollbars and is in DIP (and
- // invariant relative to page scale).
- gfx::SizeF UnscaledScrollableViewportSize() const;
- float VerticalAdjust() const;
+ // Viewport rect in view space used for tiling prioritization.
+ const gfx::Rect ViewportRectForTilePriority() const;
// RendererClient implementation.
virtual void SetFullRootLayerDamage() OVERRIDE;
// TileManagerClient implementation.
+ virtual const std::vector<PictureLayerImpl*>& GetPictureLayers()
+ const OVERRIDE;
virtual void NotifyReadyToActivate() OVERRIDE;
- virtual void NotifyTileInitialized(const Tile* tile) OVERRIDE;
+ virtual void NotifyTileStateChanged(const Tile* tile) OVERRIDE;
+ virtual void BuildRasterQueue(RasterTilePriorityQueue* queue,
+ TreePriority tree_priority) OVERRIDE;
+ virtual void BuildEvictionQueue(EvictionTilePriorityQueue* queue,
+ TreePriority tree_priority) OVERRIDE;
// ScrollbarAnimationControllerClient implementation.
virtual void PostDelayedScrollbarFade(const base::Closure& start_fade,
base::TimeDelta interval) OVERRIDE;
virtual void SetNeedsRedrawRect(const gfx::Rect& rect) OVERRIDE;
virtual void BeginFrame(const BeginFrameArgs& args) OVERRIDE;
+
virtual void SetExternalDrawConstraints(
const gfx::Transform& transform,
const gfx::Rect& viewport,
const gfx::Rect& clip,
- bool valid_for_tile_management) OVERRIDE;
+ const gfx::Rect& viewport_rect_for_tile_priority,
+ const gfx::Transform& transform_for_tile_priority,
+ bool resourceless_software_draw) OVERRIDE;
virtual void DidLoseOutputSurface() OVERRIDE;
virtual void DidSwapBuffers() OVERRIDE;
virtual void DidSwapBuffersComplete() OVERRIDE;
void OnCanDrawStateChangedForTree();
// Implementation.
+ int id() const { return id_; }
bool CanDraw() const;
OutputSurface* output_surface() const { return output_surface_.get(); }
int SourceAnimationFrameNumber() const;
virtual bool InitializeRenderer(scoped_ptr<OutputSurface> output_surface);
- bool IsContextLost();
TileManager* tile_manager() { return tile_manager_.get(); }
+ void SetUseGpuRasterization(bool use_gpu);
+ bool use_gpu_rasterization() const { return use_gpu_rasterization_; }
+ bool create_low_res_tiling() const {
+ return settings_.create_low_res_tiling && !use_gpu_rasterization_;
+ }
ResourcePool* resource_pool() { return resource_pool_.get(); }
Renderer* renderer() { return renderer_.get(); }
const RendererCapabilitiesImpl& GetRendererCapabilities() const;
virtual void WillBeginImplFrame(const BeginFrameArgs& args);
void DidModifyTilePriorities();
- void Readback(void* pixels, const gfx::Rect& rect_in_device_viewport);
-
LayerTreeImpl* active_tree() { return active_tree_.get(); }
const LayerTreeImpl* active_tree() const { return active_tree_.get(); }
LayerTreeImpl* pending_tree() { return pending_tree_.get(); }
const LayerTreeImpl* pending_tree() const { return pending_tree_.get(); }
+ LayerTreeImpl* recycle_tree() { return recycle_tree_.get(); }
const LayerTreeImpl* recycle_tree() const { return recycle_tree_.get(); }
+ // Returns the tree LTH synchronizes with.
+ LayerTreeImpl* sync_tree() {
+ return pending_tree_ ? pending_tree_.get() : active_tree_.get();
+ }
virtual void CreatePendingTree();
virtual void UpdateVisibleTiles();
- virtual void ActivatePendingTree();
+ virtual void ActivateSyncTree();
// Shortcuts to layers on the active tree.
LayerImpl* RootLayer() const;
bool scroll_affects_scroll_handler() const {
return scroll_affects_scroll_handler_;
}
+ void QueueSwapPromiseForMainThreadScrollUpdate(
+ scoped_ptr<SwapPromise> swap_promise);
- bool IsCurrentlyScrolling() const;
+ bool IsActivelyScrolling() const;
virtual void SetVisible(bool visible);
bool visible() const { return visible_; }
void SetViewportSize(const gfx::Size& device_viewport_size);
gfx::Size device_viewport_size() const { return device_viewport_size_; }
- void SetOverdrawBottomHeight(float overdraw_bottom_height);
- float overdraw_bottom_height() const { return overdraw_bottom_height_; }
-
void SetOverhangUIResource(UIResourceId overhang_ui_resource_id,
const gfx::Size& overhang_ui_resource_size);
return !animation_registrar_->active_animation_controllers().empty();
}
- void SendManagedMemoryStats(
- size_t memory_visible_bytes,
- size_t memory_visible_and_nearby_bytes,
- size_t memory_use_bytes);
-
void set_max_memory_needed_bytes(size_t bytes) {
max_memory_needed_bytes_ = bytes;
}
const LayerTreeDebugState& debug_state() const { return debug_state_; }
class CC_EXPORT CullRenderPassesWithNoQuads {
- public:
+ public:
bool ShouldRemoveRenderPass(const RenderPassDrawQuad& quad,
const FrameData& frame) const;
void SetTreePriority(TreePriority priority);
- void UpdateCurrentFrameTime();
- void ResetCurrentFrameTimeForNextFrame();
- virtual base::TimeTicks CurrentFrameTimeTicks();
+ void UpdateCurrentBeginFrameArgs(const BeginFrameArgs& args);
+ void ResetCurrentBeginFrameArgsForNextFrame();
+ virtual BeginFrameArgs CurrentBeginFrameArgs() const;
// Expected time between two begin impl frame calls.
base::TimeDelta begin_impl_frame_interval() const {
return begin_impl_frame_interval_;
}
- scoped_ptr<base::Value> AsValue() const { return AsValueWithFrame(NULL); }
- scoped_ptr<base::Value> AsValueWithFrame(FrameData* frame) const;
- scoped_ptr<base::Value> ActivationStateAsValue() const;
+ void AsValueInto(base::debug::TracedValue* value) const {
+ return AsValueWithFrameInto(NULL, value);
+ }
+ void AsValueWithFrameInto(FrameData* frame,
+ base::debug::TracedValue* value) const;
+ scoped_refptr<base::debug::ConvertableToTraceFormat> AsValue() const;
+ scoped_refptr<base::debug::ConvertableToTraceFormat> AsValueWithFrame(
+ FrameData* frame) const;
+ scoped_refptr<base::debug::ConvertableToTraceFormat> ActivationStateAsValue()
+ const;
+ void ActivationStateAsValueInto(base::debug::TracedValue* value) const;
bool page_scale_animation_active() const { return !!page_scale_animation_; }
void InsertSwapPromiseMonitor(SwapPromiseMonitor* monitor);
void RemoveSwapPromiseMonitor(SwapPromiseMonitor* monitor);
+ void RegisterPictureLayerImpl(PictureLayerImpl* layer);
+ void UnregisterPictureLayerImpl(PictureLayerImpl* layer);
+
+ void GetPictureLayerImplPairs(
+ std::vector<PictureLayerImpl::Pair>* layers) const;
+
+ void SetTopControlsLayoutHeight(float height);
+
protected:
LayerTreeHostImpl(
const LayerTreeSettings& settings,
SharedBitmapManager* manager,
int id);
- gfx::SizeF ComputeInnerViewportContainerSize() const;
void UpdateInnerViewportContainerSize();
// Virtual for testing.
Proxy* proxy_;
private:
- void CreateAndSetRenderer(
- OutputSurface* output_surface,
- ResourceProvider* resource_provider,
- bool skip_gl_renderer);
- void CreateAndSetTileManager(ResourceProvider* resource_provider,
- ContextProvider* context_provider,
- bool use_zero_copy,
- bool use_one_copy,
- bool allow_rasterize_on_demand);
+ void CreateAndSetRenderer();
+ void CreateAndSetTileManager();
+ void DestroyTileManager();
void ReleaseTreeResources();
void EnforceZeroBudget(bool zero_budget);
+ bool UsePendingTreeForSync() const;
+ bool UseZeroCopyRasterizer() const;
+ bool UseOneCopyRasterizer() const;
+
void ScrollViewportBy(gfx::Vector2dF scroll_delta);
void AnimatePageScale(base::TimeTicks monotonic_time);
void AnimateScrollbars(base::TimeTicks monotonic_time);
// This function should only be called from PrepareToDraw, as DidDrawAllLayers
// must be called if this helper function is called. Returns DRAW_SUCCESS if
// the frame should be drawn.
- DrawSwapReadbackResult::DrawResult CalculateRenderPasses(FrameData* frame);
+ DrawResult CalculateRenderPasses(FrameData* frame);
- bool EnsureRenderSurfaceLayerList();
void ClearCurrentlyScrollingLayer();
bool HandleMouseOverScrollbar(LayerImpl* layer_impl,
void MarkUIResourceNotEvicted(UIResourceId uid);
void NotifySwapPromiseMonitorsOfSetNeedsRedraw();
+ void NotifySwapPromiseMonitorsOfForwardingToMainThread();
typedef base::hash_map<UIResourceId, UIResourceData>
UIResourceMap;
std::set<UIResourceId> evicted_ui_resources_;
scoped_ptr<OutputSurface> output_surface_;
- scoped_refptr<ContextProvider> offscreen_context_provider_;
// |resource_provider_| and |tile_manager_| can be NULL, e.g. when using tile-
// free rendering - see OutputSurface::ForcedDrawToSoftwareDevice().
scoped_ptr<ResourceProvider> resource_provider_;
scoped_ptr<TileManager> tile_manager_;
+ bool use_gpu_rasterization_;
scoped_ptr<RasterWorkerPool> raster_worker_pool_;
- scoped_ptr<RasterWorkerPool> direct_raster_worker_pool_;
scoped_ptr<ResourcePool> resource_pool_;
scoped_ptr<ResourcePool> staging_resource_pool_;
scoped_ptr<Renderer> renderer_;
bool wheel_scrolling_;
bool scroll_affects_scroll_handler_;
int scroll_layer_id_when_mouse_over_scrollbar_;
+ ScopedPtrVector<SwapPromise> swap_promises_for_main_thread_scroll_update_;
bool tile_priorities_dirty_;
// manager, if there were no limit on memory usage.
size_t max_memory_needed_bytes_;
- size_t last_sent_memory_visible_bytes_;
- size_t last_sent_memory_visible_and_nearby_bytes_;
- size_t last_sent_memory_use_bytes_;
bool zero_budget_;
// Viewport size passed in from the main thread, in physical pixels. This
UIResourceId overhang_ui_resource_id_;
gfx::Size overhang_ui_resource_size_;
- // Vertical amount of the viewport size that's known to covered by a
- // browser-side UI element, such as an on-screen-keyboard. This affects
- // scrollable size since we want to still be able to scroll to the bottom of
- // the page when the keyboard is up.
- float overdraw_bottom_height_;
-
// Optional top-level constraints that can be set by the OutputSurface.
// - external_transform_ applies a transform above the root layer
// - external_viewport_ is used DrawProperties, tile management and
// glViewport/window projection matrix.
// - external_clip_ specifies a top-level clip rect
+ // - viewport_rect_for_tile_priority_ is the rect in view space used for
+ // tiling priority.
gfx::Transform external_transform_;
gfx::Rect external_viewport_;
gfx::Rect external_clip_;
- bool device_viewport_valid_for_tile_management_;
+ gfx::Rect viewport_rect_for_tile_priority_;
+ bool resourceless_software_draw_;
gfx::Rect viewport_damage_rect_;
- base::TimeTicks current_frame_timeticks_;
+ BeginFrameArgs current_begin_frame_args_;
// Expected time between two begin impl frame calls.
base::TimeDelta begin_impl_frame_interval_;
MicroBenchmarkControllerImpl micro_benchmark_controller_;
bool need_to_update_visible_tiles_before_draw_;
-#if DCHECK_IS_ON
- bool did_lose_called_;
-#endif
// Optional callback to notify of new tree activations.
base::Closure tree_activation_callback_;
std::set<SwapPromiseMonitor*> swap_promise_monitor_;
- size_t transfer_buffer_memory_limit_;
+ std::vector<PictureLayerImpl*> picture_layers_;
+ std::vector<PictureLayerImpl::Pair> picture_layer_pairs_;
DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl);
};