Commit a3029014 authored by enne@chromium.org's avatar enne@chromium.org

cc: Move more functionality from host to LayerTreeImpl

This cleans up some longstanding TODOs that were creating when splitting
out logic into LayerTreeImpl.  It's possible that some of the helpers to
get at active tree layers (root, scrolling, etc) could be moved, but
given that scrolling only happens on the active tree (with the pending
tree being updated with the result), these accessors could arguably stay
permanently.

This also moves background color / has transparent background to the tree
itself, so that these changes will synchronize with any content on that
tree.  Things like viewport, device scale, and debug state are considered
host-specific and take effect immediately.

R=nduca@chromium.org
BUG=155209


Review URL: https://chromiumcodereview.appspot.com/11704003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175252 0039d316-1c4b-4281-b951-d872f2087c98
parent 5c53cb02
......@@ -6,6 +6,7 @@
#include "cc/append_quads_data.h"
#include "cc/layer_tree_host_impl.h"
#include "cc/layer_tree_impl.h"
#include "cc/quad_sink.h"
#include "cc/render_pass_draw_quad.h"
#include "cc/scoped_ptr_vector.h"
......@@ -106,7 +107,7 @@ public:
// Get the RenderPass generated by layerBefore to come before the delegated RenderPasses.
rootLayer->addChild(layerBefore.Pass());
m_hostImpl->setRootLayer(rootLayer.Pass());
m_hostImpl->activeTree()->SetRootLayer(rootLayer.Pass());
}
protected:
......@@ -422,7 +423,7 @@ public:
rootLayer->addChild(delegatedRendererLayer.PassAs<LayerImpl>());
m_hostImpl->setRootLayer(rootLayer.Pass());
m_hostImpl->activeTree()->SetRootLayer(rootLayer.Pass());
}
protected:
......
......@@ -332,13 +332,13 @@ void LayerTreeHost::finishCommitOnImplThread(LayerTreeHostImpl* hostImpl)
else
syncTree->set_hud_layer(0);
// TODO(enne): Do these need to be moved to layer tree as well?
syncTree->set_source_frame_number(commitNumber());
syncTree->set_background_color(m_backgroundColor);
syncTree->set_has_transparent_background(m_hasTransparentBackground);
hostImpl->setViewportSize(layoutViewportSize(), deviceViewportSize());
hostImpl->setDeviceScaleFactor(deviceScaleFactor());
hostImpl->setPageScaleFactorAndLimits(m_pageScaleFactor, m_minPageScaleFactor, m_maxPageScaleFactor);
hostImpl->setBackgroundColor(m_backgroundColor);
hostImpl->setHasTransparentBackground(m_hasTransparentBackground);
hostImpl->setDebugState(m_debugState);
m_commitNumber++;
......
......@@ -219,8 +219,6 @@ LayerTreeHostImpl::LayerTreeHostImpl(const LayerTreeSettings& settings, LayerTre
ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING,
0,
ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING)
, m_backgroundColor(0)
, m_hasTransparentBackground(false)
, m_needsUpdateDrawProperties(false)
, m_pinchGestureActive(false)
, m_fpsCounter(FrameRateCounter::create(m_proxy->hasImplThread()))
......@@ -614,9 +612,9 @@ bool LayerTreeHostImpl::calculateRenderPasses(FrameData& frame)
}
#endif
if (!m_hasTransparentBackground) {
if (!activeTree()->has_transparent_background()) {
frame.renderPasses.last()->has_transparent_background = false;
appendQuadsToFillScreen(frame.renderPasses.last(), rootLayer(), m_backgroundColor, occlusionTracker);
appendQuadsToFillScreen(frame.renderPasses.last(), rootLayer(), activeTree()->background_color(), occlusionTracker);
}
if (drawFrame)
......@@ -1000,12 +998,6 @@ static LayerImpl* findScrollLayerForContentLayer(LayerImpl* layerImpl)
return 0;
}
void LayerTreeHostImpl::setRootLayer(scoped_ptr<LayerImpl> layer)
{
m_activeTree->SetRootLayer(layer.Pass());
setNeedsUpdateDrawProperties();
}
void LayerTreeHostImpl::createPendingTree()
{
CHECK(!m_pendingTree);
......@@ -1046,12 +1038,6 @@ void LayerTreeHostImpl::activatePendingTree()
m_client->onHasPendingTreeStateChanged(pendingTree());
}
scoped_ptr<LayerImpl> LayerTreeHostImpl::detachLayerTree()
{
scoped_ptr<LayerImpl> layer = m_activeTree->DetachLayerTree();
return layer.Pass();
}
void LayerTreeHostImpl::setVisible(bool visible)
{
DCHECK(m_proxy->isImplThread());
......
......@@ -214,17 +214,9 @@ public:
void createPendingTree();
virtual void activatePendingTreeIfNeeded();
// TODO(nduca): Remove these in favor of LayerTreeImpl.
void setRootLayer(scoped_ptr<LayerImpl>);
// Shortcuts to layers on the active tree.
LayerImpl* rootLayer() const;
// Release ownership of the current layer tree and replace it with an empty
// tree. Returns the root layer of the detached tree.
scoped_ptr<LayerImpl> detachLayerTree();
LayerImpl* rootScrollLayer() const;
// TOOD(nduca): This goes away when scrolling moves to LayerTreeImpl.
LayerImpl* currentlyScrollingLayer() const;
bool visible() const { return m_visible; }
......@@ -249,11 +241,6 @@ public:
void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration);
SkColor backgroundColor() const { return m_backgroundColor; }
void setBackgroundColor(SkColor color) { m_backgroundColor = color; }
bool hasTransparentBackground() const { return m_hasTransparentBackground; }
void setHasTransparentBackground(bool transparent) { m_hasTransparentBackground = transparent; }
bool needsAnimateLayers() const { return !m_animationRegistrar->active_animation_controllers().empty(); }
bool needsUpdateDrawProperties() const { return m_needsUpdateDrawProperties; }
......@@ -377,9 +364,6 @@ private:
bool m_contentsTexturesPurged;
ManagedMemoryPolicy m_managedMemoryPolicy;
SkColor m_backgroundColor;
bool m_hasTransparentBackground;
bool m_needsUpdateDrawProperties;
bool m_pinchGestureActive;
gfx::Point m_previousPinchAnchor;
......
This diff is collapsed.
......@@ -641,7 +641,7 @@ public:
virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE
{
EXPECT_EQ(gfx::Size(20, 20), impl->layoutViewportSize());
EXPECT_EQ(SK_ColorGRAY, impl->backgroundColor());
EXPECT_EQ(SK_ColorGRAY, impl->activeTree()->background_color());
EXPECT_EQ(5, impl->pageScaleFactor());
endTest();
......
......@@ -17,6 +17,8 @@ LayerTreeImpl::LayerTreeImpl(LayerTreeHostImpl* layer_tree_host_impl)
, hud_layer_(0)
, root_scroll_layer_(0)
, currently_scrolling_layer_(0)
, background_color_(0)
, has_transparent_background_(false)
, scrolling_layer_id_from_previous_tree_(0) {
}
......
......@@ -78,22 +78,40 @@ class CC_EXPORT LayerTreeImpl {
scoped_ptr<LayerImpl> DetachLayerTree();
int source_frame_number() const { return source_frame_number_; }
void set_source_frame_number(int frame_number) { source_frame_number_ = frame_number; }
void set_source_frame_number(int frame_number) {
source_frame_number_ = frame_number;
}
HeadsUpDisplayLayerImpl* hud_layer() { return hud_layer_; }
void set_hud_layer(HeadsUpDisplayLayerImpl* layer_impl) { hud_layer_ = layer_impl; }
void set_hud_layer(HeadsUpDisplayLayerImpl* layer_impl) {
hud_layer_ = layer_impl;
}
LayerImpl* root_scroll_layer() { return root_scroll_layer_; }
const LayerImpl* root_scroll_layer() const { return root_scroll_layer_; }
void set_root_scroll_layer(LayerImpl* layer_impl) { root_scroll_layer_ = layer_impl; }
void set_root_scroll_layer(LayerImpl* layer_impl) {
root_scroll_layer_ = layer_impl;
}
LayerImpl* currently_scrolling_layer() { return currently_scrolling_layer_; }
void set_currently_scrolling_layer(LayerImpl* layer_impl) { currently_scrolling_layer_ = layer_impl; }
void set_currently_scrolling_layer(LayerImpl* layer_impl) {
currently_scrolling_layer_ = layer_impl;
}
void ClearCurrentlyScrollingLayer();
void UpdateMaxScrollOffset();
SkColor background_color() const { return background_color_; }
void set_background_color(SkColor color) { background_color_ = color; }
bool has_transparent_background() const {
return has_transparent_background_;
}
void set_has_transparent_background(bool transparent) {
has_transparent_background_ = transparent;
}
// Updates draw properties and render surface layer list
void UpdateDrawProperties();
......@@ -120,6 +138,8 @@ protected:
HeadsUpDisplayLayerImpl* hud_layer_;
LayerImpl* root_scroll_layer_;
LayerImpl* currently_scrolling_layer_;
SkColor background_color_;
bool has_transparent_background_;
typedef base::hash_map<int, LayerImpl*> LayerIdMap;
LayerIdMap layer_id_map_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment