summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cc/layer_impl.cc16
-rw-r--r--cc/layer_tree_host_unittest_context.cc4
-rw-r--r--cc/scrollbar_animation_controller_linear_fade_unittest.cc2
-rw-r--r--cc/scrollbar_layer.cc624
-rw-r--r--cc/scrollbar_layer.h139
-rw-r--r--cc/scrollbar_layer_impl.cc481
-rw-r--r--cc/scrollbar_layer_impl.h210
-rw-r--r--cc/scrollbar_layer_impl_base.h20
-rw-r--r--cc/scrollbar_layer_unittest.cc46
-rw-r--r--cc/test/fake_scrollbar_layer.cc2
-rw-r--r--cc/test/fake_web_scrollbar.h2
-rw-r--r--cc/tree_synchronizer.cc4
-rw-r--r--webkit/compositor_bindings/web_scrollbar_layer_impl.cc4
13 files changed, 834 insertions, 720 deletions
diff --git a/cc/layer_impl.cc b/cc/layer_impl.cc
index 638b016..6ddaee7 100644
--- a/cc/layer_impl.cc
+++ b/cc/layer_impl.cc
@@ -827,14 +827,14 @@ void LayerImpl::updateScrollbarPositions()
gfx::Vector2dF currentOffset = m_scrollOffset + m_scrollDelta;
if (m_horizontalScrollbarLayer) {
- m_horizontalScrollbarLayer->setCurrentPos(currentOffset.x());
- m_horizontalScrollbarLayer->setTotalSize(m_bounds.width());
- m_horizontalScrollbarLayer->setMaximum(m_maxScrollOffset.x());
+ m_horizontalScrollbarLayer->SetCurrentPos(currentOffset.x());
+ m_horizontalScrollbarLayer->SetTotalSize(m_bounds.width());
+ m_horizontalScrollbarLayer->SetMaximum(m_maxScrollOffset.x());
}
if (m_verticalScrollbarLayer) {
- m_verticalScrollbarLayer->setCurrentPos(currentOffset.y());
- m_verticalScrollbarLayer->setTotalSize(m_bounds.height());
- m_verticalScrollbarLayer->setMaximum(m_maxScrollOffset.y());
+ m_verticalScrollbarLayer->SetCurrentPos(currentOffset.y());
+ m_verticalScrollbarLayer->SetTotalSize(m_bounds.height());
+ m_verticalScrollbarLayer->SetMaximum(m_maxScrollOffset.y());
}
if (currentOffset == m_lastScrollOffset)
@@ -959,14 +959,14 @@ void LayerImpl::setHorizontalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer)
{
m_horizontalScrollbarLayer = scrollbarLayer;
if (m_horizontalScrollbarLayer)
- m_horizontalScrollbarLayer->setScrollLayerId(id());
+ m_horizontalScrollbarLayer->set_scroll_layer_id(id());
}
void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer)
{
m_verticalScrollbarLayer = scrollbarLayer;
if (m_verticalScrollbarLayer)
- m_verticalScrollbarLayer->setScrollLayerId(id());
+ m_verticalScrollbarLayer->set_scroll_layer_id(id());
}
void LayerImpl::AsValueInto(base::DictionaryValue* dict) const
diff --git a/cc/layer_tree_host_unittest_context.cc b/cc/layer_tree_host_unittest_context.cc
index bd82138..a9ccc63 100644
--- a/cc/layer_tree_host_unittest_context.cc
+++ b/cc/layer_tree_host_unittest_context.cc
@@ -959,8 +959,8 @@ class LayerTreeHostContextTestDontUseLostResources :
bool paint_scrollbar = true;
bool has_thumb = true;
- scoped_refptr<ScrollbarLayer> scrollbar_ = ScrollbarLayer::create(
- FakeWebScrollbar::create().PassAs<WebKit::WebScrollbar>(),
+ scoped_refptr<ScrollbarLayer> scrollbar_ = ScrollbarLayer::Create(
+ FakeWebScrollbar::Create().PassAs<WebKit::WebScrollbar>(),
FakeScrollbarThemePainter::Create(paint_scrollbar)
.PassAs<ScrollbarThemePainter>(),
FakeWebScrollbarThemeGeometry::create(has_thumb)
diff --git a/cc/scrollbar_animation_controller_linear_fade_unittest.cc b/cc/scrollbar_animation_controller_linear_fade_unittest.cc
index 28b26c2..46061da 100644
--- a/cc/scrollbar_animation_controller_linear_fade_unittest.cc
+++ b/cc/scrollbar_animation_controller_linear_fade_unittest.cc
@@ -26,7 +26,7 @@ protected:
{
m_scrollLayer = LayerImpl::create(m_hostImpl.activeTree(), 1);
scoped_ptr<ScrollbarGeometryFixedThumb> geometry(ScrollbarGeometryFixedThumb::create(FakeWebScrollbarThemeGeometry::create(false)));
- m_scrollbarLayer = ScrollbarLayerImpl::create(m_hostImpl.activeTree(), 2, geometry.Pass());
+ m_scrollbarLayer = ScrollbarLayerImpl::Create(m_hostImpl.activeTree(), 2, geometry.Pass());
m_scrollLayer->setMaxScrollOffset(gfx::Vector2d(50, 50));
m_scrollLayer->setBounds(gfx::Size(50, 50));
diff --git a/cc/scrollbar_layer.cc b/cc/scrollbar_layer.cc
index 04f49bf..98e78bd 100644
--- a/cc/scrollbar_layer.cc
+++ b/cc/scrollbar_layer.cc
@@ -17,18 +17,24 @@
namespace cc {
-scoped_ptr<LayerImpl> ScrollbarLayer::createLayerImpl(LayerTreeImpl* treeImpl)
-{
- return ScrollbarLayerImpl::create(treeImpl, id(), ScrollbarGeometryFixedThumb::create(make_scoped_ptr(m_geometry->clone()))).PassAs<LayerImpl>();
+scoped_ptr<LayerImpl> ScrollbarLayer::createLayerImpl(
+ LayerTreeImpl* tree_impl) {
+ return ScrollbarLayerImpl::Create(
+ tree_impl,
+ id(),
+ ScrollbarGeometryFixedThumb::create(make_scoped_ptr(geometry_->clone())))
+ .PassAs<LayerImpl>();
}
-scoped_refptr<ScrollbarLayer> ScrollbarLayer::create(
+scoped_refptr<ScrollbarLayer> ScrollbarLayer::Create(
scoped_ptr<WebKit::WebScrollbar> scrollbar,
scoped_ptr<ScrollbarThemePainter> painter,
scoped_ptr<WebKit::WebScrollbarThemeGeometry> geometry,
- int scrollLayerId)
-{
- return make_scoped_refptr(new ScrollbarLayer(scrollbar.Pass(), painter.Pass(), geometry.Pass(), scrollLayerId));
+ int scrollLayerId) {
+ return make_scoped_refptr(new ScrollbarLayer(scrollbar.Pass(),
+ painter.Pass(),
+ geometry.Pass(),
+ scrollLayerId));
}
ScrollbarLayer::ScrollbarLayer(
@@ -36,320 +42,390 @@ ScrollbarLayer::ScrollbarLayer(
scoped_ptr<ScrollbarThemePainter> painter,
scoped_ptr<WebKit::WebScrollbarThemeGeometry> geometry,
int scrollLayerId)
- : m_scrollbar(scrollbar.Pass())
- , m_painter(painter.Pass())
- , m_geometry(geometry.Pass())
- , m_scrollLayerId(scrollLayerId)
- , m_textureFormat(GL_INVALID_ENUM)
-{
- if (!m_scrollbar->isOverlay())
- setShouldScrollOnMainThread(true);
+ : scrollbar_(scrollbar.Pass()),
+ painter_(painter.Pass()),
+ geometry_(geometry.Pass()),
+ scroll_layer_id_(scrollLayerId),
+ texture_format_(GL_INVALID_ENUM) {
+ if (!scrollbar_->isOverlay())
+ setShouldScrollOnMainThread(true);
}
-ScrollbarLayer::~ScrollbarLayer()
-{
-}
+ScrollbarLayer::~ScrollbarLayer() {}
-void ScrollbarLayer::setScrollLayerId(int id)
-{
- if (id == m_scrollLayerId)
- return;
+void ScrollbarLayer::SetScrollLayerId(int id) {
+ if (id == scroll_layer_id_)
+ return;
- m_scrollLayerId = id;
- setNeedsFullTreeSync();
+ scroll_layer_id_ = id;
+ setNeedsFullTreeSync();
}
-WebKit::WebScrollbar::Orientation ScrollbarLayer::orientation() const
-{
- return m_scrollbar->orientation();
+WebKit::WebScrollbar::Orientation ScrollbarLayer::Orientation() const {
+ return scrollbar_->orientation();
}
-int ScrollbarLayer::maxTextureSize() {
- DCHECK(layerTreeHost());
- return layerTreeHost()->rendererCapabilities().maxTextureSize;
+int ScrollbarLayer::MaxTextureSize() {
+ DCHECK(layerTreeHost());
+ return layerTreeHost()->rendererCapabilities().maxTextureSize;
}
-float ScrollbarLayer::clampScaleToMaxTextureSize(float scale) {
- if (layerTreeHost()->settings().solidColorScrollbars)
- return scale;
-
- // If the scaled contentBounds() is bigger than the max texture size of the
- // device, we need to clamp it by rescaling, since contentBounds() is used
- // below to set the texture size.
- gfx::Size scaledBounds = computeContentBoundsForScale(scale, scale);
- if (scaledBounds.width() > maxTextureSize() || scaledBounds.height() > maxTextureSize()) {
- if (scaledBounds.width() > scaledBounds.height())
- return (maxTextureSize() - 1) / static_cast<float>(bounds().width());
- else
- return (maxTextureSize() - 1) / static_cast<float>(bounds().height());
- }
+float ScrollbarLayer::ClampScaleToMaxTextureSize(float scale) {
+ if (layerTreeHost()->settings().solidColorScrollbars)
return scale;
+
+ // If the scaled contentBounds() is bigger than the max texture size of the
+ // device, we need to clamp it by rescaling, since contentBounds() is used
+ // below to set the texture size.
+ gfx::Size scaled_bounds = computeContentBoundsForScale(scale, scale);
+ if (scaled_bounds.width() > MaxTextureSize() ||
+ scaled_bounds.height() > MaxTextureSize()) {
+ if (scaled_bounds.width() > scaled_bounds.height())
+ return (MaxTextureSize() - 1) / static_cast<float>(bounds().width());
+ else
+ return (MaxTextureSize() - 1) / static_cast<float>(bounds().height());
+ }
+ return scale;
}
-void ScrollbarLayer::calculateContentsScale(
- float idealContentsScale,
- bool animatingTransformToScreen,
- float* contentsScaleX,
- float* contentsScaleY,
- gfx::Size* contentBounds)
-{
- ContentsScalingLayer::calculateContentsScale(
- clampScaleToMaxTextureSize(idealContentsScale),
- animatingTransformToScreen,
- contentsScaleX,
- contentsScaleY,
- contentBounds);
- DCHECK_LE(contentBounds->width(), maxTextureSize());
- DCHECK_LE(contentBounds->height(), maxTextureSize());
+void ScrollbarLayer::calculateContentsScale(float ideal_contents_scale,
+ bool animating_transform_to_screen,
+ float* contents_scale_x,
+ float* contents_scale_y,
+ gfx::Size* contentBounds) {
+ ContentsScalingLayer::calculateContentsScale(
+ ClampScaleToMaxTextureSize(ideal_contents_scale),
+ animating_transform_to_screen,
+ contents_scale_x,
+ contents_scale_y,
+ contentBounds);
+ DCHECK_LE(contentBounds->width(), MaxTextureSize());
+ DCHECK_LE(contentBounds->height(), MaxTextureSize());
}
-void ScrollbarLayer::pushPropertiesTo(LayerImpl* layer)
-{
- ContentsScalingLayer::pushPropertiesTo(layer);
+void ScrollbarLayer::pushPropertiesTo(LayerImpl* layer) {
+ ContentsScalingLayer::pushPropertiesTo(layer);
- ScrollbarLayerImpl* scrollbarLayer = static_cast<ScrollbarLayerImpl*>(layer);
+ ScrollbarLayerImpl* scrollbar_layer = static_cast<ScrollbarLayerImpl*>(layer);
- scrollbarLayer->setScrollbarData(m_scrollbar.get());
- scrollbarLayer->setThumbSize(m_thumbSize);
+ scrollbar_layer->SetScrollbarData(scrollbar_.get());
+ scrollbar_layer->SetThumbSize(thumb_size_);
- if (m_backTrack && m_backTrack->texture()->haveBackingTexture())
- scrollbarLayer->setBackTrackResourceId(m_backTrack->texture()->resourceId());
- else
- scrollbarLayer->setBackTrackResourceId(0);
+ if (back_track_ && back_track_->texture()->haveBackingTexture()) {
+ scrollbar_layer->set_back_track_resource_id(
+ back_track_->texture()->resourceId());
+ } else {
+ scrollbar_layer->set_back_track_resource_id(0);
+ }
- if (m_foreTrack && m_foreTrack->texture()->haveBackingTexture())
- scrollbarLayer->setForeTrackResourceId(m_foreTrack->texture()->resourceId());
- else
- scrollbarLayer->setForeTrackResourceId(0);
+ if (fore_track_ && fore_track_->texture()->haveBackingTexture()) {
+ scrollbar_layer->set_fore_track_resource_id(
+ fore_track_->texture()->resourceId());
+ } else {
+ scrollbar_layer->set_fore_track_resource_id(0);
+ }
- if (m_thumb && m_thumb->texture()->haveBackingTexture())
- scrollbarLayer->setThumbResourceId(m_thumb->texture()->resourceId());
- else
- scrollbarLayer->setThumbResourceId(0);
+ if (thumb_ && thumb_->texture()->haveBackingTexture())
+ scrollbar_layer->set_thumb_resource_id(thumb_->texture()->resourceId());
+ else
+ scrollbar_layer->set_thumb_resource_id(0);
}
-ScrollbarLayer* ScrollbarLayer::toScrollbarLayer()
-{
- return this;
+ScrollbarLayer* ScrollbarLayer::toScrollbarLayer() {
+ return this;
}
class ScrollbarBackgroundPainter : public LayerPainter {
-public:
- static scoped_ptr<ScrollbarBackgroundPainter> create(WebKit::WebScrollbar* scrollbar, ScrollbarThemePainter *painter, WebKit::WebScrollbarThemeGeometry* geometry, WebKit::WebScrollbar::ScrollbarPart trackPart)
- {
- return make_scoped_ptr(new ScrollbarBackgroundPainter(scrollbar, painter, geometry, trackPart));
+ public:
+ static scoped_ptr<ScrollbarBackgroundPainter> Create(
+ WebKit::WebScrollbar* scrollbar,
+ ScrollbarThemePainter *painter,
+ WebKit::WebScrollbarThemeGeometry* geometry,
+ WebKit::WebScrollbar::ScrollbarPart trackPart) {
+ return make_scoped_ptr(new ScrollbarBackgroundPainter(scrollbar,
+ painter,
+ geometry,
+ trackPart));
+ }
+
+ virtual void Paint(SkCanvas* canvas,
+ gfx::Rect content_rect,
+ gfx::RectF* opaque) OVERRIDE {
+ // The following is a simplification of ScrollbarThemeComposite::paint.
+ painter_->PaintScrollbarBackground(canvas, content_rect);
+
+ if (geometry_->hasButtons(scrollbar_)) {
+ gfx::Rect back_button_start_paint_rect =
+ geometry_->backButtonStartRect(scrollbar_);
+ painter_->PaintBackButtonStart(canvas, back_button_start_paint_rect);
+
+ gfx::Rect back_button_end_paint_rect =
+ geometry_->backButtonEndRect(scrollbar_);
+ painter_->PaintBackButtonEnd(canvas, back_button_end_paint_rect);
+
+ gfx::Rect forward_button_start_paint_rect =
+ geometry_->forwardButtonStartRect(scrollbar_);
+ painter_->PaintForwardButtonStart(canvas,
+ forward_button_start_paint_rect);
+
+ gfx::Rect forward_button_end_paint_rect =
+ geometry_->forwardButtonEndRect(scrollbar_);
+ painter_->PaintForwardButtonEnd(canvas, forward_button_end_paint_rect);
}
- virtual void Paint(SkCanvas* canvas, gfx::Rect contentRect, gfx::RectF* opaque) OVERRIDE
- {
- // The following is a simplification of ScrollbarThemeComposite::paint.
- m_painter->PaintScrollbarBackground(canvas, contentRect);
-
- if (m_geometry->hasButtons(m_scrollbar)) {
- gfx::Rect backButtonStartPaintRect = m_geometry->backButtonStartRect(m_scrollbar);
- m_painter->PaintBackButtonStart(canvas, backButtonStartPaintRect);
-
- gfx::Rect backButtonEndPaintRect = m_geometry->backButtonEndRect(m_scrollbar);
- m_painter->PaintBackButtonEnd(canvas, backButtonEndPaintRect);
-
- gfx::Rect forwardButtonStartPaintRect = m_geometry->forwardButtonStartRect(m_scrollbar);
- m_painter->PaintForwardButtonStart(canvas, forwardButtonStartPaintRect);
-
- gfx::Rect forwardButtonEndPaintRect = m_geometry->forwardButtonEndRect(m_scrollbar);
- m_painter->PaintForwardButtonEnd(canvas, forwardButtonEndPaintRect);
- }
+ gfx::Rect track_paint_rect = geometry_->trackRect(scrollbar_);
+ painter_->PaintTrackBackground(canvas, track_paint_rect);
- gfx::Rect trackPaintRect = m_geometry->trackRect(m_scrollbar);
- m_painter->PaintTrackBackground(canvas, trackPaintRect);
-
- bool thumbPresent = m_geometry->hasThumb(m_scrollbar);
- if (thumbPresent) {
- if (m_trackPart == WebKit::WebScrollbar::ForwardTrackPart)
- m_painter->PaintForwardTrackPart(canvas, trackPaintRect);
- else
- m_painter->PaintBackTrackPart(canvas, trackPaintRect);
- }
-
- m_painter->PaintTickmarks(canvas, trackPaintRect);
- }
-private:
- ScrollbarBackgroundPainter(WebKit::WebScrollbar* scrollbar, ScrollbarThemePainter *painter, WebKit::WebScrollbarThemeGeometry* geometry, WebKit::WebScrollbar::ScrollbarPart trackPart)
- : m_scrollbar(scrollbar)
- , m_painter(painter)
- , m_geometry(geometry)
- , m_trackPart(trackPart)
- {
+ bool thumb_present = geometry_->hasThumb(scrollbar_);
+ if (thumb_present) {
+ if (track_part_ == WebKit::WebScrollbar::ForwardTrackPart)
+ painter_->PaintForwardTrackPart(canvas, track_paint_rect);
+ else
+ painter_->PaintBackTrackPart(canvas, track_paint_rect);
}
- WebKit::WebScrollbar* m_scrollbar;
- ScrollbarThemePainter* m_painter;
- WebKit::WebScrollbarThemeGeometry* m_geometry;
- WebKit::WebScrollbar::ScrollbarPart m_trackPart;
-
- DISALLOW_COPY_AND_ASSIGN(ScrollbarBackgroundPainter);
+ painter_->PaintTickmarks(canvas, track_paint_rect);
+ }
+ private:
+ ScrollbarBackgroundPainter(WebKit::WebScrollbar* scrollbar,
+ ScrollbarThemePainter *painter,
+ WebKit::WebScrollbarThemeGeometry* geometry,
+ WebKit::WebScrollbar::ScrollbarPart trackPart)
+ : scrollbar_(scrollbar),
+ painter_(painter),
+ geometry_(geometry),
+ track_part_(trackPart) {}
+
+ WebKit::WebScrollbar* scrollbar_;
+ ScrollbarThemePainter* painter_;
+ WebKit::WebScrollbarThemeGeometry* geometry_;
+ WebKit::WebScrollbar::ScrollbarPart track_part_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScrollbarBackgroundPainter);
};
class ScrollbarThumbPainter : public LayerPainter {
-public:
- static scoped_ptr<ScrollbarThumbPainter> create(WebKit::WebScrollbar* scrollbar, ScrollbarThemePainter* painter, WebKit::WebScrollbarThemeGeometry* geometry)
- {
- return make_scoped_ptr(new ScrollbarThumbPainter(scrollbar, painter, geometry));
- }
-
- virtual void Paint(SkCanvas* canvas, gfx::Rect contentRect, gfx::RectF* opaque) OVERRIDE
- {
- // Consider the thumb to be at the origin when painting.
- gfx::Rect thumbRect = m_geometry->thumbRect(m_scrollbar);
- m_painter->PaintThumb(canvas, gfx::Rect(thumbRect.size()));
- }
-
-private:
- ScrollbarThumbPainter(WebKit::WebScrollbar* scrollbar, ScrollbarThemePainter* painter, WebKit::WebScrollbarThemeGeometry* geometry)
- : m_scrollbar(scrollbar)
- , m_painter(painter)
- , m_geometry(geometry)
- {
- }
-
- WebKit::WebScrollbar* m_scrollbar;
- ScrollbarThemePainter* m_painter;
- WebKit::WebScrollbarThemeGeometry* m_geometry;
-
- DISALLOW_COPY_AND_ASSIGN(ScrollbarThumbPainter);
+ public:
+ static scoped_ptr<ScrollbarThumbPainter> Create(
+ WebKit::WebScrollbar* scrollbar,
+ ScrollbarThemePainter* painter,
+ WebKit::WebScrollbarThemeGeometry* geometry) {
+ return make_scoped_ptr(new ScrollbarThumbPainter(scrollbar,
+ painter,
+ geometry));
+ }
+
+ virtual void Paint(SkCanvas* canvas,
+ gfx::Rect content_rect,
+ gfx::RectF* opaque) OVERRIDE {
+ // Consider the thumb to be at the origin when painting.
+ gfx::Rect thumb_rect = geometry_->thumbRect(scrollbar_);
+ painter_->PaintThumb(canvas, gfx::Rect(thumb_rect.size()));
+ }
+
+ private:
+ ScrollbarThumbPainter(WebKit::WebScrollbar* scrollbar,
+ ScrollbarThemePainter* painter,
+ WebKit::WebScrollbarThemeGeometry* geometry)
+ : scrollbar_(scrollbar),
+ painter_(painter),
+ geometry_(geometry) {}
+
+ WebKit::WebScrollbar* scrollbar_;
+ ScrollbarThemePainter* painter_;
+ WebKit::WebScrollbarThemeGeometry* geometry_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScrollbarThumbPainter);
};
-void ScrollbarLayer::setLayerTreeHost(LayerTreeHost* host)
-{
- if (!host || host != layerTreeHost()) {
- m_backTrackUpdater = NULL;
- m_backTrack.reset();
- m_thumbUpdater = NULL;
- m_thumb.reset();
- }
+void ScrollbarLayer::setLayerTreeHost(LayerTreeHost* host) {
+ if (!host || host != layerTreeHost()) {
+ back_track_updater_ = NULL;
+ back_track_.reset();
+ thumb_updater_ = NULL;
+ thumb_.reset();
+ }
- ContentsScalingLayer::setLayerTreeHost(host);
+ ContentsScalingLayer::setLayerTreeHost(host);
}
-void ScrollbarLayer::createUpdaterIfNeeded()
-{
- if (layerTreeHost()->settings().solidColorScrollbars)
- return;
-
- m_textureFormat = layerTreeHost()->rendererCapabilities().bestTextureFormat;
-
- if (!m_backTrackUpdater)
- m_backTrackUpdater = CachingBitmapContentLayerUpdater::Create(ScrollbarBackgroundPainter::create(m_scrollbar.get(), m_painter.get(), m_geometry.get(), WebKit::WebScrollbar::BackTrackPart).PassAs<LayerPainter>());
- if (!m_backTrack)
- m_backTrack = m_backTrackUpdater->createResource(layerTreeHost()->contentsTextureManager());
-
- // Only create two-part track if we think the two parts could be different in appearance.
- if (m_scrollbar->isCustomScrollbar()) {
- if (!m_foreTrackUpdater)
- m_foreTrackUpdater = CachingBitmapContentLayerUpdater::Create(ScrollbarBackgroundPainter::create(m_scrollbar.get(), m_painter.get(), m_geometry.get(), WebKit::WebScrollbar::ForwardTrackPart).PassAs<LayerPainter>());
- if (!m_foreTrack)
- m_foreTrack = m_foreTrackUpdater->createResource(layerTreeHost()->contentsTextureManager());
+void ScrollbarLayer::CreateUpdaterIfNeeded() {
+ if (layerTreeHost()->settings().solidColorScrollbars)
+ return;
+
+ texture_format_ = layerTreeHost()->rendererCapabilities().bestTextureFormat;
+
+ if (!back_track_updater_) {
+ back_track_updater_ = CachingBitmapContentLayerUpdater::Create(
+ ScrollbarBackgroundPainter::Create(
+ scrollbar_.get(),
+ painter_.get(),
+ geometry_.get(),
+ WebKit::WebScrollbar::BackTrackPart).PassAs<LayerPainter>());
+ }
+ if (!back_track_) {
+ back_track_ = back_track_updater_->createResource(
+ layerTreeHost()->contentsTextureManager());
+ }
+
+ // Only create two-part track if we think the two parts could be different in
+ // appearance.
+ if (scrollbar_->isCustomScrollbar()) {
+ if (!fore_track_updater_) {
+ fore_track_updater_ = CachingBitmapContentLayerUpdater::Create(
+ ScrollbarBackgroundPainter::Create(
+ scrollbar_.get(),
+ painter_.get(),
+ geometry_.get(),
+ WebKit::WebScrollbar::ForwardTrackPart).PassAs<LayerPainter>());
}
-
- if (!m_thumbUpdater)
- m_thumbUpdater = CachingBitmapContentLayerUpdater::Create(ScrollbarThumbPainter::create(m_scrollbar.get(), m_painter.get(), m_geometry.get()).PassAs<LayerPainter>());
- if (!m_thumb)
- m_thumb = m_thumbUpdater->createResource(layerTreeHost()->contentsTextureManager());
-}
-
-void ScrollbarLayer::updatePart(CachingBitmapContentLayerUpdater* painter, LayerUpdater::Resource* resource, const gfx::Rect& rect, ResourceUpdateQueue& queue, RenderingStats* stats)
-{
- if (layerTreeHost()->settings().solidColorScrollbars)
- return;
-
- // Skip painting and uploading if there are no invalidations and
- // we already have valid texture data.
- if (resource->texture()->haveBackingTexture() &&
- resource->texture()->size() == rect.size() &&
- !isDirty())
- return;
-
- // We should always have enough memory for UI.
- DCHECK(resource->texture()->canAcquireBackingTexture());
- if (!resource->texture()->canAcquireBackingTexture())
- return;
-
- // Paint and upload the entire part.
- gfx::Rect paintedOpaqueRect;
- painter->prepareToUpdate(rect, rect.size(), contentsScaleX(), contentsScaleY(), paintedOpaqueRect, stats);
- if (!painter->pixelsDidChange() && resource->texture()->haveBackingTexture()) {
- TRACE_EVENT_INSTANT0("cc","ScrollbarLayer::updatePart no texture upload needed");
- return;
+ if (!fore_track_) {
+ fore_track_ = fore_track_updater_->createResource(
+ layerTreeHost()->contentsTextureManager());
}
-
- bool partialUpdatesAllowed = layerTreeHost()->settings().maxPartialTextureUpdates > 0;
- if (!partialUpdatesAllowed)
- resource->texture()->returnBackingTexture();
-
- gfx::Vector2d destOffset(0, 0);
- resource->update(queue, rect, destOffset, partialUpdatesAllowed, stats);
+ }
+
+ if (!thumb_updater_) {
+ thumb_updater_ = CachingBitmapContentLayerUpdater::Create(
+ ScrollbarThumbPainter::Create(scrollbar_.get(),
+ painter_.get(),
+ geometry_.get()).PassAs<LayerPainter>());
+ }
+ if (!thumb_) {
+ thumb_ = thumb_updater_->createResource(
+ layerTreeHost()->contentsTextureManager());
+ }
}
-gfx::Rect ScrollbarLayer::scrollbarLayerRectToContentRect(const gfx::Rect& layerRect) const
-{
- // Don't intersect with the bounds as in layerRectToContentRect() because
- // layerRect here might be in coordinates of the containing layer.
- gfx::RectF contentRect = gfx::ScaleRect(layerRect, contentsScaleX(), contentsScaleY());
- return gfx::ToEnclosingRect(contentRect);
+void ScrollbarLayer::UpdatePart(CachingBitmapContentLayerUpdater* painter,
+ LayerUpdater::Resource* resource,
+ gfx::Rect rect,
+ ResourceUpdateQueue* queue,
+ RenderingStats* stats) {
+ if (layerTreeHost()->settings().solidColorScrollbars)
+ return;
+
+ // Skip painting and uploading if there are no invalidations and
+ // we already have valid texture data.
+ if (resource->texture()->haveBackingTexture() &&
+ resource->texture()->size() == rect.size() &&
+ !is_dirty())
+ return;
+
+ // We should always have enough memory for UI.
+ DCHECK(resource->texture()->canAcquireBackingTexture());
+ if (!resource->texture()->canAcquireBackingTexture())
+ return;
+
+ // Paint and upload the entire part.
+ gfx::Rect painted_opaque_rect;
+ painter->prepareToUpdate(rect,
+ rect.size(),
+ contentsScaleX(),
+ contentsScaleY(),
+ painted_opaque_rect,
+ stats);
+ if (!painter->pixelsDidChange() &&
+ resource->texture()->haveBackingTexture()) {
+ TRACE_EVENT_INSTANT0("cc",
+ "ScrollbarLayer::updatePart no texture upload needed");
+ return;
+ }
+
+ bool partial_updates_allowed =
+ layerTreeHost()->settings().maxPartialTextureUpdates > 0;
+ if (!partial_updates_allowed)
+ resource->texture()->returnBackingTexture();
+
+ gfx::Vector2d dest_offset(0, 0);
+ resource->update(*queue, rect, dest_offset, partial_updates_allowed, stats);
}
-void ScrollbarLayer::setTexturePriorities(const PriorityCalculator&)
-{
- if (layerTreeHost()->settings().solidColorScrollbars)
- return;
-
- if (contentBounds().IsEmpty())
- return;
- DCHECK_LE(contentBounds().width(), maxTextureSize());
- DCHECK_LE(contentBounds().height(), maxTextureSize());
-
- createUpdaterIfNeeded();
-
- bool drawsToRoot = !renderTarget()->parent();
- if (m_backTrack) {
- m_backTrack->texture()->setDimensions(contentBounds(), m_textureFormat);
- m_backTrack->texture()->setRequestPriority(PriorityCalculator::uiPriority(drawsToRoot));
- }
- if (m_foreTrack) {
- m_foreTrack->texture()->setDimensions(contentBounds(), m_textureFormat);
- m_foreTrack->texture()->setRequestPriority(PriorityCalculator::uiPriority(drawsToRoot));
- }
- if (m_thumb) {
- gfx::Size thumbSize = scrollbarLayerRectToContentRect(m_geometry->thumbRect(m_scrollbar.get())).size();
- m_thumb->texture()->setDimensions(thumbSize, m_textureFormat);
- m_thumb->texture()->setRequestPriority(PriorityCalculator::uiPriority(drawsToRoot));
- }
+gfx::Rect ScrollbarLayer::ScrollbarLayerRectToContentRect(
+ gfx::Rect layer_rect) const {
+ // Don't intersect with the bounds as in layerRectToContentRect() because
+ // layer_rect here might be in coordinates of the containing layer.
+ gfx::RectF content_rect = gfx::ScaleRect(layer_rect,
+ contentsScaleY(),
+ contentsScaleY());
+ return gfx::ToEnclosingRect(content_rect);
}
-void ScrollbarLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats* stats)
-{
- ContentsScalingLayer::update(queue, occlusion, stats);
-
- m_dirtyRect.Union(m_updateRect);
- if (contentBounds().IsEmpty())
- return;
- if (visibleContentRect().IsEmpty())
- return;
-
- createUpdaterIfNeeded();
-
- gfx::Rect contentRect = scrollbarLayerRectToContentRect(gfx::Rect(m_scrollbar->location(), bounds()));
- updatePart(m_backTrackUpdater.get(), m_backTrack.get(), contentRect, queue, stats);
- if (m_foreTrack && m_foreTrackUpdater)
- updatePart(m_foreTrackUpdater.get(), m_foreTrack.get(), contentRect, queue, stats);
-
- // Consider the thumb to be at the origin when painting.
- gfx::Rect thumbRect = m_geometry->thumbRect(m_scrollbar.get());
- m_thumbSize = thumbRect.size();
- gfx::Rect originThumbRect = scrollbarLayerRectToContentRect(gfx::Rect(thumbRect.size()));
- if (!originThumbRect.IsEmpty())
- updatePart(m_thumbUpdater.get(), m_thumb.get(), originThumbRect, queue, stats);
+void ScrollbarLayer::setTexturePriorities(
+ const PriorityCalculator& priority_calc) {
+ if (layerTreeHost()->settings().solidColorScrollbars)
+ return;
+
+ if (contentBounds().IsEmpty())
+ return;
+ DCHECK_LE(contentBounds().width(), MaxTextureSize());
+ DCHECK_LE(contentBounds().height(), MaxTextureSize());
+
+ CreateUpdaterIfNeeded();
+
+ bool draws_to_root = !renderTarget()->parent();
+ if (back_track_) {
+ back_track_->texture()->setDimensions(contentBounds(), texture_format_);
+ back_track_->texture()->setRequestPriority(
+ PriorityCalculator::uiPriority(draws_to_root));
+ }
+ if (fore_track_) {
+ fore_track_->texture()->setDimensions(contentBounds(), texture_format_);
+ fore_track_->texture()->setRequestPriority(
+ PriorityCalculator::uiPriority(draws_to_root));
+ }
+ if (thumb_) {
+ gfx::Rect thumb_layer_rect = geometry_->thumbRect(scrollbar_.get());
+ gfx::Size thumb_size =
+ ScrollbarLayerRectToContentRect(thumb_layer_rect).size();
+ thumb_->texture()->setDimensions(thumb_size, texture_format_);
+ thumb_->texture()->setRequestPriority(
+ PriorityCalculator::uiPriority(draws_to_root));
+ }
+}
- m_dirtyRect = gfx::RectF();
+void ScrollbarLayer::update(ResourceUpdateQueue& queue,
+ const OcclusionTracker* occlusion,
+ RenderingStats* stats) {
+ ContentsScalingLayer::update(queue, occlusion, stats);
+
+ dirty_rect_.Union(m_updateRect);
+ if (contentBounds().IsEmpty())
+ return;
+ if (visibleContentRect().IsEmpty())
+ return;
+
+ CreateUpdaterIfNeeded();
+
+ gfx::Rect content_rect = ScrollbarLayerRectToContentRect(
+ gfx::Rect(scrollbar_->location(), bounds()));
+ UpdatePart(back_track_updater_.get(),
+ back_track_.get(),
+ content_rect,
+ &queue,
+ stats);
+ if (fore_track_ && fore_track_updater_) {
+ UpdatePart(fore_track_updater_.get(),
+ fore_track_.get(),
+ content_rect,
+ &queue,
+ stats);
+ }
+
+ // Consider the thumb to be at the origin when painting.
+ gfx::Rect thumb_rect = geometry_->thumbRect(scrollbar_.get());
+ thumb_size_ = thumb_rect.size();
+ gfx::Rect origin_thumb_rect =
+ ScrollbarLayerRectToContentRect(gfx::Rect(thumb_rect.size()));
+ if (!origin_thumb_rect.IsEmpty()) {
+ UpdatePart(thumb_updater_.get(),
+ thumb_.get(),
+ origin_thumb_rect,
+ &queue,
+ stats);
+ }
+
+ dirty_rect_ = gfx::RectF();
}
} // namespace cc
diff --git a/cc/scrollbar_layer.h b/cc/scrollbar_layer.h
index e26cbde..73d4075 100644
--- a/cc/scrollbar_layer.h
+++ b/cc/scrollbar_layer.h
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
#ifndef CC_SCROLLBAR_LAYER_H_
#define CC_SCROLLBAR_LAYER_H_
@@ -20,71 +19,79 @@ class Scrollbar;
class ScrollbarThemeComposite;
class CC_EXPORT ScrollbarLayer : public ContentsScalingLayer {
-public:
- virtual scoped_ptr<LayerImpl> createLayerImpl(LayerTreeImpl* treeImpl) OVERRIDE;
-
- static scoped_refptr<ScrollbarLayer> create(
- scoped_ptr<WebKit::WebScrollbar>,
- scoped_ptr<ScrollbarThemePainter>,
- scoped_ptr<WebKit::WebScrollbarThemeGeometry>,
- int scrollLayerId);
-
- int scrollLayerId() const { return m_scrollLayerId; }
- void setScrollLayerId(int id);
-
- WebKit::WebScrollbar::Orientation orientation() const;
-
- // Layer interface
- virtual void setTexturePriorities(const PriorityCalculator&) OVERRIDE;
- virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats*) OVERRIDE;
- virtual void setLayerTreeHost(LayerTreeHost*) OVERRIDE;
- virtual void pushPropertiesTo(LayerImpl*) OVERRIDE;
- virtual void calculateContentsScale(
- float idealContentsScale,
- bool animatingTransformToScreen,
- float* contentsScaleX,
- float* contentsScaleY,
- gfx::Size* contentBounds) OVERRIDE;
-
- virtual ScrollbarLayer* toScrollbarLayer() OVERRIDE;
-
-protected:
- ScrollbarLayer(
- scoped_ptr<WebKit::WebScrollbar>,
- scoped_ptr<ScrollbarThemePainter>,
- scoped_ptr<WebKit::WebScrollbarThemeGeometry>,
- int scrollLayerId);
- virtual ~ScrollbarLayer();
-
-private:
- void updatePart(CachingBitmapContentLayerUpdater*, LayerUpdater::Resource*, const gfx::Rect&, ResourceUpdateQueue&, RenderingStats*);
- void createUpdaterIfNeeded();
- gfx::Rect scrollbarLayerRectToContentRect(const gfx::Rect& layerRect) const;
-
- bool isDirty() const { return !m_dirtyRect.IsEmpty(); }
-
- int maxTextureSize();
- float clampScaleToMaxTextureSize(float scale);
-
- scoped_ptr<WebKit::WebScrollbar> m_scrollbar;
- scoped_ptr<ScrollbarThemePainter> m_painter;
- scoped_ptr<WebKit::WebScrollbarThemeGeometry> m_geometry;
- gfx::Size m_thumbSize;
- int m_scrollLayerId;
-
- unsigned m_textureFormat;
-
- gfx::RectF m_dirtyRect;
-
- scoped_refptr<CachingBitmapContentLayerUpdater> m_backTrackUpdater;
- scoped_refptr<CachingBitmapContentLayerUpdater> m_foreTrackUpdater;
- scoped_refptr<CachingBitmapContentLayerUpdater> m_thumbUpdater;
-
- // All the parts of the scrollbar except the thumb
- scoped_ptr<LayerUpdater::Resource> m_backTrack;
- scoped_ptr<LayerUpdater::Resource> m_foreTrack;
- scoped_ptr<LayerUpdater::Resource> m_thumb;
+ public:
+ virtual scoped_ptr<LayerImpl> createLayerImpl(LayerTreeImpl* tree_impl)
+ OVERRIDE;
+
+ static scoped_refptr<ScrollbarLayer> Create(
+ scoped_ptr<WebKit::WebScrollbar>,
+ scoped_ptr<ScrollbarThemePainter>,
+ scoped_ptr<WebKit::WebScrollbarThemeGeometry>,
+ int scrollLayerId);
+
+ int scroll_layer_id() const { return scroll_layer_id_; }
+ void SetScrollLayerId(int id);
+
+ WebKit::WebScrollbar::Orientation Orientation() const;
+
+ // Layer interface
+ virtual void setTexturePriorities(const PriorityCalculator& priority_calc)
+ OVERRIDE;
+ virtual void update(ResourceUpdateQueue& queue,
+ const OcclusionTracker* occlusion,
+ RenderingStats* stats) OVERRIDE;
+ virtual void setLayerTreeHost(LayerTreeHost* host) OVERRIDE;
+ virtual void pushPropertiesTo(LayerImpl* layer) OVERRIDE;
+ virtual void calculateContentsScale(float ideal_contents_scale,
+ bool animating_transform_to_screen,
+ float* contents_scale_x,
+ float* contents_scale_y,
+ gfx::Size* contentBounds) OVERRIDE;
+
+ virtual ScrollbarLayer* toScrollbarLayer() OVERRIDE;
+
+ protected:
+ ScrollbarLayer(
+ scoped_ptr<WebKit::WebScrollbar>,
+ scoped_ptr<ScrollbarThemePainter>,
+ scoped_ptr<WebKit::WebScrollbarThemeGeometry>,
+ int scrollLayerId);
+ virtual ~ScrollbarLayer();
+
+ private:
+ void UpdatePart(CachingBitmapContentLayerUpdater* painter,
+ LayerUpdater::Resource* resource,
+ gfx::Rect rect,
+ ResourceUpdateQueue* queue,
+ RenderingStats* stats);
+ void CreateUpdaterIfNeeded();
+ gfx::Rect ScrollbarLayerRectToContentRect(gfx::Rect layer_rect) const;
+
+ bool is_dirty() const { return !dirty_rect_.IsEmpty(); }
+
+ int MaxTextureSize();
+ float ClampScaleToMaxTextureSize(float scale);
+
+ scoped_ptr<WebKit::WebScrollbar> scrollbar_;
+ scoped_ptr<ScrollbarThemePainter> painter_;
+ scoped_ptr<WebKit::WebScrollbarThemeGeometry> geometry_;
+ gfx::Size thumb_size_;
+ int scroll_layer_id_;
+
+ unsigned texture_format_;
+
+ gfx::RectF dirty_rect_;
+
+ scoped_refptr<CachingBitmapContentLayerUpdater> back_track_updater_;
+ scoped_refptr<CachingBitmapContentLayerUpdater> fore_track_updater_;
+ scoped_refptr<CachingBitmapContentLayerUpdater> thumb_updater_;
+
+ // All the parts of the scrollbar except the thumb
+ scoped_ptr<LayerUpdater::Resource> back_track_;
+ scoped_ptr<LayerUpdater::Resource> fore_track_;
+ scoped_ptr<LayerUpdater::Resource> thumb_;
};
-}
+} // namespace cc
+
#endif // CC_SCROLLBAR_LAYER_H_
diff --git a/cc/scrollbar_layer_impl.cc b/cc/scrollbar_layer_impl.cc
index 976f4cb..8fd2b62 100644
--- a/cc/scrollbar_layer_impl.cc
+++ b/cc/scrollbar_layer_impl.cc
@@ -17,282 +17,299 @@ using WebKit::WebScrollbar;
namespace cc {
-scoped_ptr<ScrollbarLayerImpl> ScrollbarLayerImpl::create(LayerTreeImpl* treeImpl, int id, scoped_ptr<ScrollbarGeometryFixedThumb> geometry)
-{
- return make_scoped_ptr(new ScrollbarLayerImpl(treeImpl, id, geometry.Pass()));
-}
-
-ScrollbarLayerImpl::ScrollbarLayerImpl(LayerTreeImpl* treeImpl, int id, scoped_ptr<ScrollbarGeometryFixedThumb> geometry)
- : ScrollbarLayerImplBase(treeImpl, id)
- , m_scrollbar(this)
- , m_backTrackResourceId(0)
- , m_foreTrackResourceId(0)
- , m_thumbResourceId(0)
- , m_geometry(geometry.Pass())
- , m_currentPos(0)
- , m_totalSize(0)
- , m_maximum(0)
- , m_scrollLayerId(-1)
- , m_scrollbarOverlayStyle(WebScrollbar::ScrollbarOverlayStyleDefault)
- , m_orientation(WebScrollbar::Horizontal)
- , m_controlSize(WebScrollbar::RegularScrollbar)
- , m_pressedPart(WebScrollbar::NoPart)
- , m_hoveredPart(WebScrollbar::NoPart)
- , m_isScrollableAreaActive(false)
- , m_isScrollViewScrollbar(false)
- , m_enabled(false)
- , m_isCustomScrollbar(false)
- , m_isOverlayScrollbar(false)
-{
-}
+scoped_ptr<ScrollbarLayerImpl> ScrollbarLayerImpl::Create(
+ LayerTreeImpl* tree_impl,
+ int id,
+ scoped_ptr<ScrollbarGeometryFixedThumb> geometry) {
+ return make_scoped_ptr(new ScrollbarLayerImpl(tree_impl,
+ id,
+ geometry.Pass()));
+}
-ScrollbarLayerImpl::~ScrollbarLayerImpl()
-{
-}
+ScrollbarLayerImpl::ScrollbarLayerImpl(
+ LayerTreeImpl* tree_impl,
+ int id,
+ scoped_ptr<ScrollbarGeometryFixedThumb> geometry)
+ : ScrollbarLayerImplBase(tree_impl, id),
+ scrollbar_(this),
+ back_track_resource_id_(0),
+ fore_track_resource_id_(0),
+ thumb_resource_id_(0),
+ geometry_(geometry.Pass()),
+ current_pos_(0),
+ total_size_(0),
+ maximum_(0),
+ scroll_layer_id_(-1),
+ scrollbar_overlay_style_(WebScrollbar::ScrollbarOverlayStyleDefault),
+ orientation_(WebScrollbar::Horizontal),
+ control_size_(WebScrollbar::RegularScrollbar),
+ pressed_part_(WebScrollbar::NoPart),
+ hovered_part_(WebScrollbar::NoPart),
+ is_scrollable_area_active_(false),
+ is_scroll_view_scrollbar_(false),
+ enabled_(false),
+ is_custom_scrollbar_(false),
+ is_overlay_scrollbar_(false) {}
+
+ScrollbarLayerImpl::~ScrollbarLayerImpl() {}
+
+ScrollbarLayerImpl* ScrollbarLayerImpl::toScrollbarLayer() {
+ return this;
+}
+
+void ScrollbarLayerImpl::SetScrollbarData(WebScrollbar* scrollbar) {
+ scrollbar_overlay_style_ = scrollbar->scrollbarOverlayStyle();
+ orientation_ = scrollbar->orientation();
+ control_size_ = scrollbar->controlSize();
+ pressed_part_ = scrollbar->pressedPart();
+ hovered_part_ = scrollbar->hoveredPart();
+ is_scrollable_area_active_ = scrollbar->isScrollableAreaActive();
+ is_scroll_view_scrollbar_ = scrollbar->isScrollViewScrollbar();
+ enabled_ = scrollbar->enabled();
+ is_custom_scrollbar_ = scrollbar->isCustomScrollbar();
+ is_overlay_scrollbar_ = scrollbar->isOverlay();
+
+ scrollbar->getTickmarks(tickmarks_);
+}
+
+void ScrollbarLayerImpl::SetThumbSize(gfx::Size size) {
+ thumb_size_ = size;
+ if (!geometry_) {
+ // In impl-side painting, the ScrollbarLayerImpl in the pending tree
+ // simply holds properties that are later pushed to the active tree's
+ // layer, but it doesn't hold geometry or append quads.
+ DCHECK(layerTreeImpl()->IsPendingTree());
+ return;
+ }
+ geometry_->setThumbSize(size);
+}
+
+float ScrollbarLayerImpl::CurrentPos() const {
+ return current_pos_;
+}
+
+int ScrollbarLayerImpl::TotalSize() const {
+ return total_size_;
+}
+
+int ScrollbarLayerImpl::Maximum() const {
+ return maximum_;
+}
+
+WebKit::WebScrollbar::Orientation ScrollbarLayerImpl::Orientation() const {
+ return orientation_;
+}
+
+static gfx::RectF ToUVRect(gfx::Rect r, gfx::Rect bounds) {
+ return gfx::ScaleRect(r, 1.f / bounds.width(), 1.f / bounds.height());
+}
+
+gfx::Rect ScrollbarLayerImpl::ScrollbarLayerRectToContentRect(
+ gfx::Rect layer_rect) const {
+ // Don't intersect with the bounds as in layerRectToContentRect() because
+ // layer_rect here might be in coordinates of the containing layer.
+ gfx::RectF content_rect = gfx::ScaleRect(layer_rect,
+ contentsScaleX(),
+ contentsScaleY());
+ return gfx::ToEnclosingRect(content_rect);
+}
+
+scoped_ptr<LayerImpl> ScrollbarLayerImpl::createLayerImpl(
+ LayerTreeImpl* tree_impl) {
+ return ScrollbarLayerImpl::Create(tree_impl,
+ id(),
+ geometry_.Pass()).PassAs<LayerImpl>();
+}
+
+void ScrollbarLayerImpl::pushPropertiesTo(LayerImpl* layer) {
+ LayerImpl::pushPropertiesTo(layer);
+
+ ScrollbarLayerImpl* scrollbar_layer = static_cast<ScrollbarLayerImpl*>(layer);
+
+ scrollbar_layer->SetScrollbarData(&scrollbar_);
+ scrollbar_layer->SetThumbSize(thumb_size_);
+
+ scrollbar_layer->set_back_track_resource_id(back_track_resource_id_);
+ scrollbar_layer->set_fore_track_resource_id(fore_track_resource_id_);
+ scrollbar_layer->set_thumb_resource_id(thumb_resource_id_);
+}
+
+void ScrollbarLayerImpl::appendQuads(QuadSink& quad_sink,
+ AppendQuadsData& append_quads_data) {
+ bool premultipled_alpha = true;
+ bool flipped = false;
+ gfx::PointF uv_top_left(0.f, 0.f);
+ gfx::PointF uv_bottom_right(1.f, 1.f);
+ gfx::Rect boundsRect(gfx::Point(), bounds());
+ gfx::Rect contentBoundsRect(gfx::Point(), contentBounds());
-ScrollbarLayerImpl* ScrollbarLayerImpl::toScrollbarLayer()
-{
- return this;
-}
+ SharedQuadState* shared_quad_state =
+ quad_sink.useSharedQuadState(createSharedQuadState());
+ appendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data);
-void ScrollbarLayerImpl::setScrollbarData(WebScrollbar* scrollbar)
-{
- m_scrollbarOverlayStyle = scrollbar->scrollbarOverlayStyle();
- m_orientation = scrollbar->orientation();
- m_controlSize = scrollbar->controlSize();
- m_pressedPart = scrollbar->pressedPart();
- m_hoveredPart = scrollbar->hoveredPart();
- m_isScrollableAreaActive = scrollbar->isScrollableAreaActive();
- m_isScrollViewScrollbar = scrollbar->isScrollViewScrollbar();
- m_enabled = scrollbar->enabled();
- m_isCustomScrollbar = scrollbar->isCustomScrollbar();
- m_isOverlayScrollbar = scrollbar->isOverlay();
-
- scrollbar->getTickmarks(m_tickmarks);
-}
+ WebRect thumb_rect, back_track_rect, foreTrackRect;
+ geometry_->splitTrack(&scrollbar_,
+ geometry_->trackRect(&scrollbar_),
+ back_track_rect,
+ thumb_rect,
+ foreTrackRect);
+ if (!geometry_->hasThumb(&scrollbar_))
+ thumb_rect = WebRect();
-void ScrollbarLayerImpl::setThumbSize(gfx::Size size)
-{
- m_thumbSize = size;
- if (!m_geometry) {
- // In impl-side painting, the ScrollbarLayerImpl in the pending tree
- // simply holds properties that are later pushed to the active tree's
- // layer, but it doesn't hold geometry or append quads.
- DCHECK(layerTreeImpl()->IsPendingTree());
- return;
+ if (layerTreeImpl()->settings().solidColorScrollbars) {
+ int thickness_override =
+ layerTreeImpl()->settings().solidColorScrollbarThicknessDIP;
+ if (thickness_override != -1) {
+ if (scrollbar_.orientation() == WebScrollbar::Vertical)
+ thumb_rect.width = thickness_override;
+ else
+ thumb_rect.height = thickness_override;
}
- m_geometry->setThumbSize(size);
-}
-
-float ScrollbarLayerImpl::currentPos() const
-{
- return m_currentPos;
-}
-
-int ScrollbarLayerImpl::totalSize() const
-{
- return m_totalSize;
-}
-
-int ScrollbarLayerImpl::maximum() const
-{
- return m_maximum;
-}
+ gfx::Rect quad_rect(ScrollbarLayerRectToContentRect(thumb_rect));
+ scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create();
+ quad->SetNew(shared_quad_state,
+ quad_rect,
+ layerTreeImpl()->settings().solidColorScrollbarColor);
+ quad_sink.append(quad.PassAs<DrawQuad>(), append_quads_data);
+ return;
+ }
+
+ if (thumb_resource_id_ && !thumb_rect.isEmpty()) {
+ gfx::Rect quad_rect(ScrollbarLayerRectToContentRect(thumb_rect));
+ gfx::Rect opaque_rect;
+ const float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create();
+ quad->SetNew(shared_quad_state,
+ quad_rect,
+ opaque_rect,
+ thumb_resource_id_,
+ premultipled_alpha,
+ uv_top_left,
+ uv_bottom_right,
+ opacity,
+ flipped);
+ quad_sink.append(quad.PassAs<DrawQuad>(), append_quads_data);
+ }
-WebKit::WebScrollbar::Orientation ScrollbarLayerImpl::orientation() const
-{
- return m_orientation;
-}
+ if (!back_track_resource_id_)
+ return;
-static gfx::RectF toUVRect(const gfx::Rect& r, const gfx::Rect& bounds)
-{
- return gfx::ScaleRect(r, 1.0 / bounds.width(), 1.0 / bounds.height());
-}
+ // We only paint the track in two parts if we were given a texture for the
+ // forward track part.
+ if (fore_track_resource_id_ && !foreTrackRect.isEmpty()) {
+ gfx::Rect quad_rect(ScrollbarLayerRectToContentRect(foreTrackRect));
+ gfx::Rect opaque_rect(contentsOpaque() ? quad_rect : gfx::Rect());
+ gfx::RectF uv_rect(ToUVRect(foreTrackRect, boundsRect));
+ const float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create();
+ quad->SetNew(shared_quad_state,
+ quad_rect,
+ opaque_rect,
+ fore_track_resource_id_,
+ premultipled_alpha,
+ uv_rect.origin(),
+ uv_rect.bottom_right(),
+ opacity,
+ flipped);
+ quad_sink.append(quad.PassAs<DrawQuad>(), append_quads_data);
+ }
-gfx::Rect ScrollbarLayerImpl::scrollbarLayerRectToContentRect(const gfx::Rect& layerRect) const
-{
- // Don't intersect with the bounds as in layerRectToContentRect() because
- // layerRect here might be in coordinates of the containing layer.
- gfx::RectF contentRect = gfx::ScaleRect(layerRect, contentsScaleX(), contentsScaleY());
- return gfx::ToEnclosingRect(contentRect);
-}
-
-scoped_ptr<LayerImpl> ScrollbarLayerImpl::createLayerImpl(LayerTreeImpl* treeImpl)
-{
- return ScrollbarLayerImpl::create(treeImpl, id(), m_geometry.Pass()).PassAs<LayerImpl>();
-}
-
-void ScrollbarLayerImpl::pushPropertiesTo(LayerImpl* layer)
-{
- LayerImpl::pushPropertiesTo(layer);
-
- ScrollbarLayerImpl* scrollbarLayer = static_cast<ScrollbarLayerImpl*>(layer);
-
- scrollbarLayer->setScrollbarData(&m_scrollbar);
- scrollbarLayer->setThumbSize(m_thumbSize);
-
- scrollbarLayer->setBackTrackResourceId(m_backTrackResourceId);
- scrollbarLayer->setForeTrackResourceId(m_foreTrackResourceId);
- scrollbarLayer->setThumbResourceId(m_thumbResourceId);
-}
-
-void ScrollbarLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuadsData)
-{
- bool premultipledAlpha = true;
- bool flipped = false;
- gfx::PointF uvTopLeft(0.f, 0.f);
- gfx::PointF uvBottomRight(1.f, 1.f);
- gfx::Rect boundsRect(gfx::Point(), bounds());
- gfx::Rect contentBoundsRect(gfx::Point(), contentBounds());
-
- SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQuadState());
- appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData);
-
- WebRect thumbRect, backTrackRect, foreTrackRect;
- m_geometry->splitTrack(&m_scrollbar, m_geometry->trackRect(&m_scrollbar), backTrackRect, thumbRect, foreTrackRect);
- if (!m_geometry->hasThumb(&m_scrollbar))
- thumbRect = WebRect();
-
- if (layerTreeImpl()->settings().solidColorScrollbars) {
- int thicknessOverride = layerTreeImpl()->settings().solidColorScrollbarThicknessDIP;
- if (thicknessOverride != -1) {
- if (m_scrollbar.orientation() == WebScrollbar::Vertical)
- thumbRect.width = thicknessOverride;
- else
- thumbRect.height = thicknessOverride;
- }
- gfx::Rect quadRect(scrollbarLayerRectToContentRect(thumbRect));
- scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create();
- quad->SetNew(sharedQuadState, quadRect, layerTreeImpl()->settings().solidColorScrollbarColor);
- quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData);
- return;
- }
-
- if (m_thumbResourceId && !thumbRect.isEmpty()) {
- gfx::Rect quadRect(scrollbarLayerRectToContentRect(thumbRect));
- gfx::Rect opaqueRect;
- const float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f};
- scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create();
- quad->SetNew(sharedQuadState, quadRect, opaqueRect, m_thumbResourceId, premultipledAlpha, uvTopLeft, uvBottomRight, opacity, flipped);
- quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData);
- }
-
- if (!m_backTrackResourceId)
- return;
-
- // We only paint the track in two parts if we were given a texture for the forward track part.
- if (m_foreTrackResourceId && !foreTrackRect.isEmpty()) {
- gfx::Rect quadRect(scrollbarLayerRectToContentRect(foreTrackRect));
- gfx::Rect opaqueRect(contentsOpaque() ? quadRect : gfx::Rect());
- gfx::RectF uvRect(toUVRect(foreTrackRect, boundsRect));
- const float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f};
- scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create();
- quad->SetNew(sharedQuadState, quadRect, opaqueRect, m_foreTrackResourceId, premultipledAlpha, uvRect.origin(), uvRect.bottom_right(), opacity, flipped);
- quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData);
- }
-
- // Order matters here: since the back track texture is being drawn to the entire contents rect, we must append it after the thumb and
- // fore track quads. The back track texture contains (and displays) the buttons.
- if (!contentBoundsRect.IsEmpty()) {
- gfx::Rect quadRect(contentBoundsRect);
- gfx::Rect opaqueRect(contentsOpaque() ? quadRect : gfx::Rect());
- const float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f};
- scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create();
- quad->SetNew(sharedQuadState, quadRect, opaqueRect, m_backTrackResourceId, premultipledAlpha, uvTopLeft, uvBottomRight, opacity, flipped);
- quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData);
- }
+ // Order matters here: since the back track texture is being drawn to the
+ // entire contents rect, we must append it after the thumb and fore track
+ // quads. The back track texture contains (and displays) the buttons.
+ if (!contentBoundsRect.IsEmpty()) {
+ gfx::Rect quad_rect(contentBoundsRect);
+ gfx::Rect opaque_rect(contentsOpaque() ? quad_rect : gfx::Rect());
+ const float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create();
+ quad->SetNew(shared_quad_state,
+ quad_rect,
+ opaque_rect,
+ back_track_resource_id_,
+ premultipled_alpha,
+ uv_top_left,
+ uv_bottom_right,
+ opacity,
+ flipped);
+ quad_sink.append(quad.PassAs<DrawQuad>(), append_quads_data);
+ }
}
-void ScrollbarLayerImpl::didLoseOutputSurface()
-{
- m_backTrackResourceId = 0;
- m_foreTrackResourceId = 0;
- m_thumbResourceId = 0;
+void ScrollbarLayerImpl::didLoseOutputSurface() {
+ back_track_resource_id_ = 0;
+ fore_track_resource_id_ = 0;
+ thumb_resource_id_ = 0;
}
-bool ScrollbarLayerImpl::Scrollbar::isOverlay() const
-{
- return m_owner->m_isOverlayScrollbar;
+bool ScrollbarLayerImpl::Scrollbar::isOverlay() const {
+ return owner_->is_overlay_scrollbar_;
}
-int ScrollbarLayerImpl::Scrollbar::value() const
-{
- return m_owner->currentPos();
+int ScrollbarLayerImpl::Scrollbar::value() const {
+ return owner_->CurrentPos();
}
-WebKit::WebPoint ScrollbarLayerImpl::Scrollbar::location() const
-{
- return WebKit::WebPoint();
+WebKit::WebPoint ScrollbarLayerImpl::Scrollbar::location() const {
+ return WebKit::WebPoint();
}
-WebKit::WebSize ScrollbarLayerImpl::Scrollbar::size() const
-{
- return WebKit::WebSize(m_owner->bounds().width(), m_owner->bounds().height());
+WebKit::WebSize ScrollbarLayerImpl::Scrollbar::size() const {
+ return WebKit::WebSize(owner_->bounds().width(), owner_->bounds().height());
}
-bool ScrollbarLayerImpl::Scrollbar::enabled() const
-{
- return m_owner->m_enabled;
+bool ScrollbarLayerImpl::Scrollbar::enabled() const {
+ return owner_->enabled_;
}
-int ScrollbarLayerImpl::Scrollbar::maximum() const
-{
- return m_owner->maximum();
+int ScrollbarLayerImpl::Scrollbar::maximum() const {
+ return owner_->Maximum();
}
-int ScrollbarLayerImpl::Scrollbar::totalSize() const
-{
- return m_owner->totalSize();
+int ScrollbarLayerImpl::Scrollbar::totalSize() const {
+ return owner_->TotalSize();
}
-bool ScrollbarLayerImpl::Scrollbar::isScrollViewScrollbar() const
-{
- return m_owner->m_isScrollViewScrollbar;
+bool ScrollbarLayerImpl::Scrollbar::isScrollViewScrollbar() const {
+ return owner_->is_scroll_view_scrollbar_;
}
-bool ScrollbarLayerImpl::Scrollbar::isScrollableAreaActive() const
-{
- return m_owner->m_isScrollableAreaActive;
+bool ScrollbarLayerImpl::Scrollbar::isScrollableAreaActive() const {
+ return owner_->is_scrollable_area_active_;
}
-void ScrollbarLayerImpl::Scrollbar::getTickmarks(WebKit::WebVector<WebRect>& tickmarks) const
-{
- tickmarks = m_owner->m_tickmarks;
+void ScrollbarLayerImpl::Scrollbar::getTickmarks(
+ WebKit::WebVector<WebRect>& tickmarks) const {
+ tickmarks = owner_->tickmarks_;
}
-WebScrollbar::ScrollbarControlSize ScrollbarLayerImpl::Scrollbar::controlSize() const
-{
- return m_owner->m_controlSize;
+WebScrollbar::ScrollbarControlSize ScrollbarLayerImpl::Scrollbar::controlSize()
+ const {
+ return owner_->control_size_;
}
-WebScrollbar::ScrollbarPart ScrollbarLayerImpl::Scrollbar::pressedPart() const
-{
- return m_owner->m_pressedPart;
+WebScrollbar::ScrollbarPart ScrollbarLayerImpl::Scrollbar::pressedPart() const {
+ return owner_->pressed_part_;
}
-WebScrollbar::ScrollbarPart ScrollbarLayerImpl::Scrollbar::hoveredPart() const
-{
- return m_owner->m_hoveredPart;
+WebScrollbar::ScrollbarPart ScrollbarLayerImpl::Scrollbar::hoveredPart() const {
+ return owner_->hovered_part_;
}
-WebScrollbar::ScrollbarOverlayStyle ScrollbarLayerImpl::Scrollbar::scrollbarOverlayStyle() const
-{
- return m_owner->m_scrollbarOverlayStyle;
+WebScrollbar::ScrollbarOverlayStyle
+ScrollbarLayerImpl::Scrollbar::scrollbarOverlayStyle() const {
+ return owner_->scrollbar_overlay_style_;
}
-WebScrollbar::Orientation ScrollbarLayerImpl::Scrollbar::orientation() const
-{
- return m_owner->m_orientation;
+WebScrollbar::Orientation ScrollbarLayerImpl::Scrollbar::orientation() const {
+ return owner_->orientation_;
}
-bool ScrollbarLayerImpl::Scrollbar::isCustomScrollbar() const
-{
- return m_owner->m_isCustomScrollbar;
+bool ScrollbarLayerImpl::Scrollbar::isCustomScrollbar() const {
+ return owner_->is_custom_scrollbar_;
}
-const char* ScrollbarLayerImpl::layerTypeAsString() const
-{
- return "ScrollbarLayer";
+const char* ScrollbarLayerImpl::layerTypeAsString() const {
+ return "ScrollbarLayer";
}
} // namespace cc
diff --git a/cc/scrollbar_layer_impl.h b/cc/scrollbar_layer_impl.h
index f37dd05..6a34435 100644
--- a/cc/scrollbar_layer_impl.h
+++ b/cc/scrollbar_layer_impl.h
@@ -16,104 +16,118 @@ namespace cc {
class ScrollView;
class CC_EXPORT ScrollbarLayerImpl : public ScrollbarLayerImplBase {
-public:
- static scoped_ptr<ScrollbarLayerImpl> create(LayerTreeImpl* treeImpl, int id, scoped_ptr<ScrollbarGeometryFixedThumb> geometry);
- virtual ~ScrollbarLayerImpl();
-
- virtual ScrollbarLayerImpl* toScrollbarLayer() OVERRIDE;
- int scrollLayerId() const { return m_scrollLayerId; }
- void setScrollLayerId(int id) { m_scrollLayerId = id; }
-
- void setScrollbarData(WebKit::WebScrollbar*);
- void setThumbSize(gfx::Size size);
-
- void setBackTrackResourceId(ResourceProvider::ResourceId id) { m_backTrackResourceId = id; }
- void setForeTrackResourceId(ResourceProvider::ResourceId id) { m_foreTrackResourceId = id; }
- void setThumbResourceId(ResourceProvider::ResourceId id) { m_thumbResourceId = id; }
-
-
- // ScrollbarLayerImplBase implementation.
- virtual float currentPos() const OVERRIDE;
- virtual int totalSize() const OVERRIDE;
- virtual int maximum() const OVERRIDE;
-
- void setCurrentPos(float currentPos) { m_currentPos = currentPos; }
- void setTotalSize(int totalSize) { m_totalSize = totalSize; }
- void setMaximum(int maximum) { m_maximum = maximum; }
-
- virtual WebKit::WebScrollbar::Orientation orientation() const OVERRIDE;
-
- virtual scoped_ptr<LayerImpl> createLayerImpl(LayerTreeImpl*) OVERRIDE;
- virtual void pushPropertiesTo(LayerImpl*) OVERRIDE;
-
- virtual void appendQuads(QuadSink&, AppendQuadsData&) OVERRIDE;
-
- virtual void didLoseOutputSurface() OVERRIDE;
-
-protected:
- ScrollbarLayerImpl(LayerTreeImpl* treeImpl, int id, scoped_ptr<ScrollbarGeometryFixedThumb> geometry);
-
-private:
- // nested class only to avoid namespace problem
- class Scrollbar : public WebKit::WebScrollbar {
- public:
- explicit Scrollbar(ScrollbarLayerImpl* owner) : m_owner(owner) { }
-
- // WebScrollbar implementation
- virtual bool isOverlay() const;
- virtual int value() const;
- virtual WebKit::WebPoint location() const;
- virtual WebKit::WebSize size() const;
- virtual bool enabled() const;
- virtual int maximum() const;
- virtual int totalSize() const;
- virtual bool isScrollViewScrollbar() const;
- virtual bool isScrollableAreaActive() const;
- virtual void getTickmarks(WebKit::WebVector<WebKit::WebRect>& tickmarks) const;
- virtual WebScrollbar::ScrollbarControlSize controlSize() const;
- virtual WebScrollbar::ScrollbarPart pressedPart() const;
- virtual WebScrollbar::ScrollbarPart hoveredPart() const;
- virtual WebScrollbar::ScrollbarOverlayStyle scrollbarOverlayStyle() const;
- virtual WebScrollbar::Orientation orientation() const;
- virtual bool isCustomScrollbar() const;
-
- private:
- ScrollbarLayerImpl* m_owner;
-
- };
-
- virtual const char* layerTypeAsString() const OVERRIDE;
-
- gfx::Rect scrollbarLayerRectToContentRect(const gfx::Rect& layerRect) const;
-
- Scrollbar m_scrollbar;
-
- ResourceProvider::ResourceId m_backTrackResourceId;
- ResourceProvider::ResourceId m_foreTrackResourceId;
- ResourceProvider::ResourceId m_thumbResourceId;
-
- scoped_ptr<ScrollbarGeometryFixedThumb> m_geometry;
-
- float m_currentPos;
- int m_totalSize;
- int m_maximum;
- gfx::Size m_thumbSize;
-
- int m_scrollLayerId;
-
- // Data to implement Scrollbar
- WebKit::WebScrollbar::ScrollbarOverlayStyle m_scrollbarOverlayStyle;
- WebKit::WebVector<WebKit::WebRect> m_tickmarks;
- WebKit::WebScrollbar::Orientation m_orientation;
- WebKit::WebScrollbar::ScrollbarControlSize m_controlSize;
- WebKit::WebScrollbar::ScrollbarPart m_pressedPart;
- WebKit::WebScrollbar::ScrollbarPart m_hoveredPart;
-
- bool m_isScrollableAreaActive;
- bool m_isScrollViewScrollbar;
- bool m_enabled;
- bool m_isCustomScrollbar;
- bool m_isOverlayScrollbar;
+ public:
+ static scoped_ptr<ScrollbarLayerImpl> Create(
+ LayerTreeImpl* tree_impl,
+ int id,
+ scoped_ptr<ScrollbarGeometryFixedThumb> geometry);
+ virtual ~ScrollbarLayerImpl();
+
+ virtual ScrollbarLayerImpl* toScrollbarLayer() OVERRIDE;
+ int scroll_layer_id() const { return scroll_layer_id_; }
+ void set_scroll_layer_id(int id) { scroll_layer_id_ = id; }
+
+ void SetScrollbarData(WebKit::WebScrollbar* scrollbar);
+ void SetThumbSize(gfx::Size size);
+
+ void set_back_track_resource_id(ResourceProvider::ResourceId id) {
+ back_track_resource_id_ = id;
+ }
+ void set_fore_track_resource_id(ResourceProvider::ResourceId id) {
+ fore_track_resource_id_ = id;
+ }
+ void set_thumb_resource_id(ResourceProvider::ResourceId id) {
+ thumb_resource_id_ = id;
+ }
+
+
+ // ScrollbarLayerImplBase implementation.
+ virtual float CurrentPos() const OVERRIDE;
+ virtual int TotalSize() const OVERRIDE;
+ virtual int Maximum() const OVERRIDE;
+
+ void SetCurrentPos(float current_pos) { current_pos_ = current_pos; }
+ void SetTotalSize(int total_size) { total_size_ = total_size; }
+ void SetMaximum(int maximum) { maximum_ = maximum; }
+
+ virtual WebKit::WebScrollbar::Orientation Orientation() const OVERRIDE;
+
+ virtual scoped_ptr<LayerImpl> createLayerImpl(LayerTreeImpl* tree_impl)
+ OVERRIDE;
+ virtual void pushPropertiesTo(LayerImpl* layer) OVERRIDE;
+
+ virtual void appendQuads(QuadSink& quad_sink,
+ AppendQuadsData& append_quads_data) OVERRIDE;
+
+ virtual void didLoseOutputSurface() OVERRIDE;
+
+ protected:
+ ScrollbarLayerImpl(LayerTreeImpl* tree_impl,
+ int id,
+ scoped_ptr<ScrollbarGeometryFixedThumb> geometry);
+
+ private:
+ // nested class only to avoid namespace problem
+ class Scrollbar : public WebKit::WebScrollbar {
+ public:
+ explicit Scrollbar(ScrollbarLayerImpl* owner) : owner_(owner) {}
+
+ // WebScrollbar implementation
+ virtual bool isOverlay() const;
+ virtual int value() const;
+ virtual WebKit::WebPoint location() const;
+ virtual WebKit::WebSize size() const;
+ virtual bool enabled() const;
+ virtual int maximum() const;
+ virtual int totalSize() const;
+ virtual bool isScrollViewScrollbar() const;
+ virtual bool isScrollableAreaActive() const;
+ virtual void getTickmarks(WebKit::WebVector<WebKit::WebRect>& tickmarks)
+ const;
+ virtual WebScrollbar::ScrollbarControlSize controlSize() const;
+ virtual WebScrollbar::ScrollbarPart pressedPart() const;
+ virtual WebScrollbar::ScrollbarPart hoveredPart() const;
+ virtual WebScrollbar::ScrollbarOverlayStyle scrollbarOverlayStyle() const;
+ virtual WebScrollbar::Orientation orientation() const;
+ virtual bool isCustomScrollbar() const;
+
+ private:
+ ScrollbarLayerImpl* owner_;
+
+ };
+
+ virtual const char* layerTypeAsString() const OVERRIDE;
+
+ gfx::Rect ScrollbarLayerRectToContentRect(gfx::Rect layer_rect) const;
+
+ Scrollbar scrollbar_;
+
+ ResourceProvider::ResourceId back_track_resource_id_;
+ ResourceProvider::ResourceId fore_track_resource_id_;
+ ResourceProvider::ResourceId thumb_resource_id_;
+
+ scoped_ptr<ScrollbarGeometryFixedThumb> geometry_;
+
+ float current_pos_;
+ int total_size_;
+ int maximum_;
+ gfx::Size thumb_size_;
+
+ int scroll_layer_id_;
+
+ // Data to implement Scrollbar
+ WebKit::WebScrollbar::ScrollbarOverlayStyle scrollbar_overlay_style_;
+ WebKit::WebVector<WebKit::WebRect> tickmarks_;
+ WebKit::WebScrollbar::Orientation orientation_;
+ WebKit::WebScrollbar::ScrollbarControlSize control_size_;
+ WebKit::WebScrollbar::ScrollbarPart pressed_part_;
+ WebKit::WebScrollbar::ScrollbarPart hovered_part_;
+
+ bool is_scrollable_area_active_;
+ bool is_scroll_view_scrollbar_;
+ bool enabled_;
+ bool is_custom_scrollbar_;
+ bool is_overlay_scrollbar_;
};
}
diff --git a/cc/scrollbar_layer_impl_base.h b/cc/scrollbar_layer_impl_base.h
index c28c570..d4debdb 100644
--- a/cc/scrollbar_layer_impl_base.h
+++ b/cc/scrollbar_layer_impl_base.h
@@ -12,19 +12,19 @@
namespace cc {
class CC_EXPORT ScrollbarLayerImplBase : public LayerImpl {
-public:
- virtual ~ScrollbarLayerImplBase() { }
+ public:
+ virtual ~ScrollbarLayerImplBase() {}
- virtual float currentPos() const = 0;
- virtual int totalSize() const = 0;
- virtual int maximum() const = 0;
- virtual WebKit::WebScrollbar::Orientation orientation() const = 0;
-
-protected:
- ScrollbarLayerImplBase(LayerTreeImpl* treeImpl, int id)
- : LayerImpl(treeImpl, id) { }
+ virtual float CurrentPos() const = 0;
+ virtual int TotalSize() const = 0;
+ virtual int Maximum() const = 0;
+ virtual WebKit::WebScrollbar::Orientation Orientation() const = 0;
+ protected:
+ ScrollbarLayerImplBase(LayerTreeImpl* tree_impl, int id)
+ : LayerImpl(tree_impl, id) {}
};
} // namespace cc
+
#endif // CC_SCROLLBAR_LAYER_IMPL_BASE_H_
diff --git a/cc/scrollbar_layer_unittest.cc b/cc/scrollbar_layer_unittest.cc
index c7edef1..912a663 100644
--- a/cc/scrollbar_layer_unittest.cc
+++ b/cc/scrollbar_layer_unittest.cc
@@ -38,7 +38,7 @@ scoped_ptr<LayerImpl> layerImplForScrollAreaAndScrollbar(
{
scoped_refptr<Layer> layerTreeRoot = Layer::create();
scoped_refptr<Layer> child1 = Layer::create();
- scoped_refptr<Layer> child2 = ScrollbarLayer::create(scrollbar.Pass(), FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), FakeWebScrollbarThemeGeometry::create(true), child1->id());
+ scoped_refptr<Layer> child2 = ScrollbarLayer::Create(scrollbar.Pass(), FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), FakeWebScrollbarThemeGeometry::create(true), child1->id());
layerTreeRoot->addChild(child1);
layerTreeRoot->insertChild(child2, reverse_order ? 0 : 1);
scoped_ptr<LayerImpl> layerImpl = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), host_impl->activeTree());
@@ -52,7 +52,7 @@ TEST(ScrollbarLayerTest, resolveScrollLayerPointer)
FakeLayerTreeHostImpl hostImpl(&proxy);
{
- scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::create());
+ scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create());
scoped_ptr<LayerImpl> layerImplTreeRoot = layerImplForScrollAreaAndScrollbar(&hostImpl, scrollbar.Pass(), false);
LayerImpl* ccChild1 = layerImplTreeRoot->children()[0];
@@ -62,7 +62,7 @@ TEST(ScrollbarLayerTest, resolveScrollLayerPointer)
}
{ // another traverse order
- scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::create());
+ scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create());
scoped_ptr<LayerImpl> layerImplTreeRoot = layerImplForScrollAreaAndScrollbar(&hostImpl, scrollbar.Pass(), true);
ScrollbarLayerImpl* ccChild1 = static_cast<ScrollbarLayerImpl*>(layerImplTreeRoot->children()[0]);
@@ -78,7 +78,7 @@ TEST(ScrollbarLayerTest, shouldScrollNonOverlayOnMainThread)
FakeLayerTreeHostImpl hostImpl(&proxy);
// Create and attach a non-overlay scrollbar.
- scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::create());
+ scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create());
static_cast<FakeWebScrollbar*>(scrollbar.get())->setOverlay(false);
scoped_ptr<LayerImpl> layerImplTreeRoot = layerImplForScrollAreaAndScrollbar(&hostImpl, scrollbar.Pass(), false);
ScrollbarLayerImpl* scrollbarLayerImpl = static_cast<ScrollbarLayerImpl*>(layerImplTreeRoot->children()[1]);
@@ -89,7 +89,7 @@ TEST(ScrollbarLayerTest, shouldScrollNonOverlayOnMainThread)
EXPECT_EQ(InputHandlerClient::ScrollOnMainThread, scrollbarLayerImpl->tryScroll(gfx::Point(0, 0), InputHandlerClient::Gesture));
// Create and attach an overlay scrollbar.
- scrollbar = FakeWebScrollbar::create();
+ scrollbar = FakeWebScrollbar::Create();
static_cast<FakeWebScrollbar*>(scrollbar.get())->setOverlay(true);
layerImplTreeRoot = layerImplForScrollAreaAndScrollbar(&hostImpl, scrollbar.Pass(), false);
@@ -105,10 +105,10 @@ TEST(ScrollbarLayerTest, scrollOffsetSynchronization)
FakeImplProxy proxy;
FakeLayerTreeHostImpl hostImpl(&proxy);
- scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::create());
+ scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create());
scoped_refptr<Layer> layerTreeRoot = Layer::create();
scoped_refptr<Layer> contentLayer = Layer::create();
- scoped_refptr<Layer> scrollbarLayer = ScrollbarLayer::create(scrollbar.Pass(), FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), FakeWebScrollbarThemeGeometry::create(true), layerTreeRoot->id());
+ scoped_refptr<Layer> scrollbarLayer = ScrollbarLayer::Create(scrollbar.Pass(), FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), FakeWebScrollbarThemeGeometry::create(true), layerTreeRoot->id());
layerTreeRoot->addChild(contentLayer);
layerTreeRoot->addChild(scrollbarLayer);
@@ -122,9 +122,9 @@ TEST(ScrollbarLayerTest, scrollOffsetSynchronization)
ScrollbarLayerImpl* ccScrollbarLayer = static_cast<ScrollbarLayerImpl*>(layerImplTreeRoot->children()[1]);
- EXPECT_EQ(10, ccScrollbarLayer->currentPos());
- EXPECT_EQ(100, ccScrollbarLayer->totalSize());
- EXPECT_EQ(30, ccScrollbarLayer->maximum());
+ EXPECT_EQ(10, ccScrollbarLayer->CurrentPos());
+ EXPECT_EQ(100, ccScrollbarLayer->TotalSize());
+ EXPECT_EQ(30, ccScrollbarLayer->Maximum());
layerTreeRoot->setScrollOffset(gfx::Vector2d(100, 200));
layerTreeRoot->setMaxScrollOffset(gfx::Vector2d(300, 500));
@@ -136,15 +136,15 @@ TEST(ScrollbarLayerTest, scrollOffsetSynchronization)
TreeSynchronizer::pushProperties(layerTreeRoot.get(), layerImplTreeRoot.get());
EXPECT_EQ(scrollbarController, layerImplTreeRoot->scrollbarAnimationController());
- EXPECT_EQ(100, ccScrollbarLayer->currentPos());
- EXPECT_EQ(1000, ccScrollbarLayer->totalSize());
- EXPECT_EQ(300, ccScrollbarLayer->maximum());
+ EXPECT_EQ(100, ccScrollbarLayer->CurrentPos());
+ EXPECT_EQ(1000, ccScrollbarLayer->TotalSize());
+ EXPECT_EQ(300, ccScrollbarLayer->Maximum());
layerImplTreeRoot->scrollBy(gfx::Vector2d(12, 34));
- EXPECT_EQ(112, ccScrollbarLayer->currentPos());
- EXPECT_EQ(1000, ccScrollbarLayer->totalSize());
- EXPECT_EQ(300, ccScrollbarLayer->maximum());
+ EXPECT_EQ(112, ccScrollbarLayer->CurrentPos());
+ EXPECT_EQ(1000, ccScrollbarLayer->TotalSize());
+ EXPECT_EQ(300, ccScrollbarLayer->Maximum());
}
TEST(ScrollbarLayerTest, solidColorThicknessOverride)
@@ -155,11 +155,11 @@ TEST(ScrollbarLayerTest, solidColorThicknessOverride)
FakeImplProxy proxy;
FakeLayerTreeHostImpl hostImpl(layerTreeSettings, &proxy);
- scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::create());
+ scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create());
static_cast<FakeWebScrollbar*>(scrollbar.get())->setOverlay(true);
scoped_ptr<LayerImpl> layerImplTreeRoot = layerImplForScrollAreaAndScrollbar(&hostImpl, scrollbar.Pass(), false);
ScrollbarLayerImpl* scrollbarLayerImpl = static_cast<ScrollbarLayerImpl*>(layerImplTreeRoot->children()[1]);
- scrollbarLayerImpl->setThumbSize(gfx::Size(4, 4));
+ scrollbarLayerImpl->SetThumbSize(gfx::Size(4, 4));
// Thickness should be overridden to 3.
{
@@ -201,14 +201,14 @@ public:
{
m_layerTreeHost->initializeRendererIfNeeded();
- scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::create());
- m_scrollbarLayer = ScrollbarLayer::create(scrollbar.Pass(), FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), FakeWebScrollbarThemeGeometry::create(true), 1);
+ scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create());
+ m_scrollbarLayer = ScrollbarLayer::Create(scrollbar.Pass(), FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), FakeWebScrollbarThemeGeometry::create(true), 1);
m_scrollbarLayer->setLayerTreeHost(m_layerTreeHost.get());
m_scrollbarLayer->setBounds(m_bounds);
m_layerTreeHost->rootLayer()->addChild(m_scrollbarLayer);
m_scrollLayer = Layer::create();
- m_scrollbarLayer->setScrollLayerId(m_scrollLayer->id());
+ m_scrollbarLayer->SetScrollLayerId(m_scrollLayer->id());
m_layerTreeHost->rootLayer()->addChild(m_scrollLayer);
postSetNeedsCommitToMainThread();
@@ -268,10 +268,10 @@ public:
{
m_layerTreeHost.reset(new MockLayerTreeHost(m_layerTreeSettings));
- scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::create());
+ scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create());
scoped_refptr<Layer> layerTreeRoot = Layer::create();
scoped_refptr<Layer> contentLayer = Layer::create();
- scoped_refptr<Layer> scrollbarLayer = ScrollbarLayer::create(scrollbar.Pass(), FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), FakeWebScrollbarThemeGeometry::create(true), layerTreeRoot->id());
+ scoped_refptr<Layer> scrollbarLayer = ScrollbarLayer::Create(scrollbar.Pass(), FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), FakeWebScrollbarThemeGeometry::create(true), layerTreeRoot->id());
layerTreeRoot->addChild(contentLayer);
layerTreeRoot->addChild(scrollbarLayer);
diff --git a/cc/test/fake_scrollbar_layer.cc b/cc/test/fake_scrollbar_layer.cc
index eb4c38d..140ae0b 100644
--- a/cc/test/fake_scrollbar_layer.cc
+++ b/cc/test/fake_scrollbar_layer.cc
@@ -14,7 +14,7 @@ namespace cc {
FakeScrollbarLayer::FakeScrollbarLayer(
bool paint_during_update, bool has_thumb, int scrolling_layer_id)
: ScrollbarLayer(
- FakeWebScrollbar::create().PassAs<WebKit::WebScrollbar>(),
+ FakeWebScrollbar::Create().PassAs<WebKit::WebScrollbar>(),
FakeScrollbarThemePainter::Create(paint_during_update)
.PassAs<ScrollbarThemePainter>(),
FakeWebScrollbarThemeGeometry::create(has_thumb)
diff --git a/cc/test/fake_web_scrollbar.h b/cc/test/fake_web_scrollbar.h
index 89313d6..20565a3 100644
--- a/cc/test/fake_web_scrollbar.h
+++ b/cc/test/fake_web_scrollbar.h
@@ -12,7 +12,7 @@ namespace cc {
class FakeWebScrollbar : public WebKit::WebScrollbar {
public:
- static scoped_ptr<FakeWebScrollbar> create() {
+ static scoped_ptr<FakeWebScrollbar> Create() {
return make_scoped_ptr(new FakeWebScrollbar());
}
diff --git a/cc/tree_synchronizer.cc b/cc/tree_synchronizer.cc
index 8c3a370..1d4619d 100644
--- a/cc/tree_synchronizer.cc
+++ b/cc/tree_synchronizer.cc
@@ -120,13 +120,13 @@ void updateScrollbarLayerPointersRecursiveInternal(const RawPtrLayerImplMap& new
RawPtrLayerImplMap::const_iterator iter = newLayers.find(scrollbarLayer->id());
ScrollbarLayerImpl* scrollbarLayerImpl = iter != newLayers.end() ? static_cast<ScrollbarLayerImpl*>(iter->second) : NULL;
- iter = newLayers.find(scrollbarLayer->scrollLayerId());
+ iter = newLayers.find(scrollbarLayer->scroll_layer_id());
LayerImpl* scrollLayerImpl = iter != newLayers.end() ? iter->second : NULL;
DCHECK(scrollbarLayerImpl);
DCHECK(scrollLayerImpl);
- if (scrollbarLayer->orientation() == WebKit::WebScrollbar::Horizontal)
+ if (scrollbarLayer->Orientation() == WebKit::WebScrollbar::Horizontal)
scrollLayerImpl->setHorizontalScrollbarLayer(scrollbarLayerImpl);
else
scrollLayerImpl->setVerticalScrollbarLayer(scrollbarLayerImpl);
diff --git a/webkit/compositor_bindings/web_scrollbar_layer_impl.cc b/webkit/compositor_bindings/web_scrollbar_layer_impl.cc
index 4f23788..c015e04 100644
--- a/webkit/compositor_bindings/web_scrollbar_layer_impl.cc
+++ b/webkit/compositor_bindings/web_scrollbar_layer_impl.cc
@@ -17,7 +17,7 @@ WebScrollbarLayerImpl::WebScrollbarLayerImpl(
WebScrollbar* scrollbar,
WebScrollbarThemePainter painter,
WebScrollbarThemeGeometry* geometry)
- : layer_(new WebLayerImpl(ScrollbarLayer::create(
+ : layer_(new WebLayerImpl(ScrollbarLayer::Create(
make_scoped_ptr(scrollbar),
WebToCCScrollbarThemePainterAdapter::Create(
make_scoped_ptr(new WebScrollbarThemePainter(painter)))
@@ -31,7 +31,7 @@ WebLayer* WebScrollbarLayerImpl::layer() { return layer_.get(); }
void WebScrollbarLayerImpl::setScrollLayer(WebLayer* layer) {
int id = layer ? static_cast<WebLayerImpl*>(layer)->layer()->id() : 0;
- static_cast<ScrollbarLayer*>(layer_->layer())->setScrollLayerId(id);
+ static_cast<ScrollbarLayer*>(layer_->layer())->SetScrollLayerId(id);
}
} // namespace WebKit