Index: cc/layer_tree_host.cc |
diff --git a/cc/layer_tree_host.cc b/cc/layer_tree_host.cc |
index d120db00370db787c3fdafda604694f37e62482a..b6986dd0294afdd1273eded5ef9ccf1d1dec9b12 100644 |
--- a/cc/layer_tree_host.cc |
+++ b/cc/layer_tree_host.cc |
@@ -23,7 +23,11 @@ |
#include "cc/math_util.h" |
#include "cc/occlusion_tracker.h" |
#include "cc/overdraw_metrics.h" |
+#include "cc/pinch_zoom_scrollbar.h" |
+#include "cc/pinch_zoom_scrollbar_geometry.h" |
+#include "cc/pinch_zoom_scrollbar_painter.h" |
#include "cc/prioritized_resource_manager.h" |
+#include "cc/scrollbar_layer.h" |
#include "cc/single_thread_proxy.h" |
#include "cc/switches.h" |
#include "cc/thread.h" |
@@ -327,6 +331,11 @@ void LayerTreeHost::finishCommitOnImplThread(LayerTreeHostImpl* hostImpl) |
syncTree->ResetContentsTexturesPurged(); |
} |
+ syncTree->SetPinchZoomHorizontalLayerId( |
+ m_pinchZoomScrollbarHorizontal ? m_pinchZoomScrollbarHorizontal->id() : -1); |
+ syncTree->SetPinchZoomVerticalLayerId( |
+ m_pinchZoomScrollbarVertical ? m_pinchZoomScrollbarVertical->id() : -1); |
+ |
if (!m_settings.implSidePainting) { |
// If we're not in impl-side painting, the tree is immediately |
// considered active. |
@@ -339,6 +348,63 @@ void LayerTreeHost::finishCommitOnImplThread(LayerTreeHostImpl* hostImpl) |
m_commitNumber++; |
} |
+void LayerTreeHost::setPinchZoomScrollbarsBoundsAndPosition() |
+{ |
+ if (!m_pinchZoomScrollbarHorizontal || !m_pinchZoomScrollbarVertical) |
+ return; |
+ |
+ gfx::Size size = layoutViewportSize(); |
+ int trackWidth = PinchZoomScrollbarGeometry::kTrackWidth; |
+ |
+ m_pinchZoomScrollbarHorizontal->setBounds(gfx::Size(size.width() - trackWidth, trackWidth)); |
+ m_pinchZoomScrollbarHorizontal->setPosition(gfx::PointF(0, size.height() - trackWidth)); |
+ m_pinchZoomScrollbarHorizontal->setNeedsDisplay(); |
+ |
+ m_pinchZoomScrollbarVertical->setBounds(gfx::Size(trackWidth, size.height() - trackWidth)); |
+ m_pinchZoomScrollbarVertical->setPosition(gfx::PointF(size.width() - trackWidth, 0)); |
+ m_pinchZoomScrollbarVertical->setNeedsDisplay(); |
+} |
+ |
+static scoped_refptr<ScrollbarLayer> CreatePinchZoomScrollbar( |
+ WebKit::WebScrollbar::Orientation orientation, LayerTreeHost* owner) |
+{ |
+ scoped_refptr<ScrollbarLayer> scrollbarLayer = ScrollbarLayer::create( |
+ make_scoped_ptr( |
+ new PinchZoomScrollbar(orientation, owner)).PassAs<WebKit::WebScrollbar>(), |
jamesr
2013/03/02 03:19:14
doing make_scoped_ptr(...).PassAs<T> is just extra
wjmaclean
2013/03/04 15:53:10
Done.
|
+ make_scoped_ptr(new PinchZoomScrollbarPainter).PassAs<ScrollbarThemePainter>(), |
+ make_scoped_ptr(new PinchZoomScrollbarGeometry).PassAs<WebKit::WebScrollbarThemeGeometry>(), |
+ -1); |
+ scrollbarLayer->setIsDrawable(true); |
+ scrollbarLayer->setOpacity(0.01); //PinchZoomScrollbar::kDefaultOpacity); |
jamesr
2013/03/02 03:19:14
This doesn't make sense. If it's drawable, why is
wjmaclean
2013/03/04 15:53:10
If I make it not drawable, then later when we use
|
+ return scrollbarLayer; |
+} |
+ |
+void LayerTreeHost::createAndAddPinchZoomScrollbars() |
+{ |
+ bool needsPropertiesUpdated = false; |
+ |
+ if (!m_pinchZoomScrollbarHorizontal) { |
+ m_pinchZoomScrollbarHorizontal = CreatePinchZoomScrollbar(WebKit::WebScrollbar::Horizontal, this); |
+ needsPropertiesUpdated = true; |
+ } |
+ |
+ if (!m_pinchZoomScrollbarVertical) { |
+ m_pinchZoomScrollbarVertical = CreatePinchZoomScrollbar( WebKit::WebScrollbar::Vertical, this); |
+ needsPropertiesUpdated = true; |
+ } |
+ |
+ DCHECK(m_pinchZoomScrollbarHorizontal && m_pinchZoomScrollbarVertical); |
+ |
+ if (!m_pinchZoomScrollbarHorizontal->parent()) |
+ m_rootLayer->addChild(m_pinchZoomScrollbarHorizontal); |
+ |
+ if (!m_pinchZoomScrollbarVertical->parent()) |
+ m_rootLayer->addChild(m_pinchZoomScrollbarVertical); |
+ |
+ if (needsPropertiesUpdated) |
+ setPinchZoomScrollbarsBoundsAndPosition(); |
+} |
+ |
void LayerTreeHost::willCommit() |
{ |
m_client->willCommit(); |
@@ -353,6 +419,10 @@ void LayerTreeHost::willCommit() |
m_hudLayer->removeFromParent(); |
m_hudLayer = 0; |
} |
+ |
+ // Setup pinch-zoom scrollbars if required. |
+ if (m_settings.usePinchZoomScrollbars) |
+ createAndAddPinchZoomScrollbars(); |
} |
void LayerTreeHost::commitComplete() |
@@ -499,6 +569,7 @@ void LayerTreeHost::setViewportSize(const gfx::Size& layoutViewportSize, const g |
m_layoutViewportSize = layoutViewportSize; |
m_deviceViewportSize = deviceViewportSize; |
+ setPinchZoomScrollbarsBoundsAndPosition(); |
setNeedsCommit(); |
} |
@@ -592,6 +663,11 @@ static Layer* findFirstScrollableLayer(Layer* layer) |
return 0; |
} |
+Layer* LayerTreeHost::rootScrollLayer() const |
+{ |
+ return findFirstScrollableLayer(m_rootLayer.get()); |
+} |
+ |
void LayerTreeHost::updateLayers(Layer* rootLayer, ResourceUpdateQueue& queue) |
{ |
TRACE_EVENT0("cc", "LayerTreeHost::updateLayers"); |
@@ -883,10 +959,21 @@ void LayerTreeHost::setAnimationEventsRecursive(const AnimationEventsVector& eve |
for (size_t eventIndex = 0; eventIndex < events.size(); ++eventIndex) { |
if (layer->id() == events[eventIndex].layerId) { |
- if (events[eventIndex].type == AnimationEvent::Started) |
+ switch (events[eventIndex].type) { |
+ case AnimationEvent::Started : |
layer->notifyAnimationStarted(events[eventIndex], wallClockTime.ToDoubleT()); |
- else |
+ break; |
+ case AnimationEvent::Finished : |
layer->notifyAnimationFinished(wallClockTime.ToDoubleT()); |
+ break; |
+ |
+ case AnimationEvent::PropertyUpdate : |
+ layer->notifyAnimationPropertyUpdate(events[eventIndex]); |
+ break; |
+ |
+ default: |
+ NOTREACHED(); |
+ } |
} |
} |