Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1614)

Unified Diff: cc/layer_tree_host.cc

Issue 11550035: Implement pinch-zoom scaling for main-frame scrollbars and pinch-zoom overlay scrollbars. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added missing files. Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/layer_tree_host.cc
diff --git a/cc/layer_tree_host.cc b/cc/layer_tree_host.cc
index fbd6e6ac14d03fae7346f95edaab1614b976cbaf..f77e806bf37e67843c39e133e790a479184380fa 100644
--- a/cc/layer_tree_host.cc
+++ b/cc/layer_tree_host.cc
@@ -21,6 +21,8 @@
#include "cc/math_util.h"
#include "cc/occlusion_tracker.h"
#include "cc/overdraw_metrics.h"
+#include "cc/pinch_zoom_scrollbar_layer.h"
+#include "cc/scrollbar_layer_impl.h"
#include "cc/single_thread_proxy.h"
#include "cc/switches.h"
#include "cc/thread.h"
@@ -92,6 +94,11 @@ LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client, const LayerTreeSetting
, m_partialTextureUpdateRequests(0)
{
numLayerTreeInstances++;
+
+ if (m_settings.pageScalePinchZoomEnabled) {
+ m_pinchZoomScrollbarVertical = PinchZoomScrollbarLayer::create();
+ m_pinchZoomScrollbarHorizontal = PinchZoomScrollbarLayer::create();
+ }
}
bool LayerTreeHost::initialize(scoped_ptr<Thread> implThread)
@@ -280,6 +287,16 @@ void LayerTreeHost::finishCommitOnImplThread(LayerTreeHostImpl* hostImpl)
else
hostImpl->activeTree()->set_hud_layer(0);
+ if (m_rootLayer && m_pinchZoomScrollbarVertical)
+ hostImpl->activeTree()->set_pinch_zoom_scrollbar_vertical(static_cast<ScrollbarLayerImpl*>(LayerTreeHostCommon::findLayerInSubtree(hostImpl->rootLayer(), m_pinchZoomScrollbarVertical->id())));
+ else
+ hostImpl->activeTree()->set_pinch_zoom_scrollbar_vertical(0);
+
+ if (m_rootLayer && m_pinchZoomScrollbarHorizontal)
+ hostImpl->activeTree()->set_pinch_zoom_scrollbar_horizontal(static_cast<ScrollbarLayerImpl*>(LayerTreeHostCommon::findLayerInSubtree(hostImpl->rootLayer(), m_pinchZoomScrollbarHorizontal->id())));
+ else
+ hostImpl->activeTree()->set_pinch_zoom_scrollbar_horizontal(0);
+
// We may have added an animation during the tree sync. This will cause both layer tree hosts
// to visit their controllers.
if (rootLayer() && m_needsAnimateLayers)
@@ -313,6 +330,16 @@ void LayerTreeHost::willCommit()
m_hudLayer->removeFromParent();
m_hudLayer = 0;
}
+
+ if (m_settings.pageScalePinchZoomEnabled && m_rootLayer) {
+ DCHECK(m_pinchZoomScrollbarVertical);
+ if (m_pinchZoomScrollbarVertical && !m_pinchZoomScrollbarVertical->parent())
+ m_rootLayer->addChild(m_pinchZoomScrollbarVertical);
+
+ DCHECK(m_pinchZoomScrollbarHorizontal);
+ if (m_pinchZoomScrollbarHorizontal && !m_pinchZoomScrollbarHorizontal->parent())
+ m_rootLayer->addChild(m_pinchZoomScrollbarHorizontal);
+ }
}
void LayerTreeHost::commitComplete()
@@ -438,6 +465,12 @@ void LayerTreeHost::setRootLayer(scoped_refptr<Layer> rootLayer)
if (m_hudLayer)
m_hudLayer->removeFromParent();
+ if (m_pinchZoomScrollbarVertical)
+ m_pinchZoomScrollbarVertical->removeFromParent();
+
+ if (m_pinchZoomScrollbarHorizontal)
+ m_pinchZoomScrollbarHorizontal->removeFromParent();
+
setNeedsFullTreeSync();
}
@@ -568,9 +601,13 @@ void LayerTreeHost::updateLayers(Layer* rootLayer, ResourceUpdateQueue& queue)
{
if (m_settings.pageScalePinchZoomEnabled) {
- Layer* rootScroll = findFirstScrollableLayer(rootLayer);
- if (rootScroll)
- rootScroll->setImplTransform(m_implTransform);
+ const LayerList& children = m_rootLayer->children();
+ for (size_t i = 0; i < children.size(); ++i) {
+ Layer* layer = children[i].get();
+ if (layer != m_pinchZoomScrollbarVertical.get()
+ && layer != m_pinchZoomScrollbarHorizontal.get())
+ layer->setImplTransform(m_implTransform);
+ }
}
TRACE_EVENT0("cc", "LayerTreeHost::updateLayers::calcDrawEtc");
« no previous file with comments | « cc/layer_tree_host.h ('k') | cc/layer_tree_host_impl.h » ('j') | cc/layer_tree_host_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698