diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-22 07:04:58 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-22 07:04:58 +0000 |
commit | 924fb87c53e80cb0f958b090b654e92fe910bf57 (patch) | |
tree | 381fd214b32ad4a32ba22601d48b8969aab4a9e4 /cc | |
parent | 508754793c2d869126d8749b16686d2e49017413 (diff) | |
download | chromium_src-924fb87c53e80cb0f958b090b654e92fe910bf57.zip chromium_src-924fb87c53e80cb0f958b090b654e92fe910bf57.tar.gz chromium_src-924fb87c53e80cb0f958b090b654e92fe910bf57.tar.bz2 |
cc: Don't use partial updates for scrollbars when they are not allowed.
Scrollbars always use partial updates, without claiming a partial update
slot from the LayerTreeHost, unlike content layers. However, when partial
updates are not allowed at all (under ubercomp), then the Scrollbar layer
should not do partial updates at all.
Tests:
LayerTreeHostTestAtomicCommit.runMultiThread
LayerTreeHostTestAtomicCommitWithPartialUpdate.runMultiThread
NOTRY=true
BUG=123444
Depends on: https://codereview.chromium.org/11609002
Review URL: https://chromiumcodereview.appspot.com/11464041
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174503 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/cc_tests.gyp | 2 | ||||
-rw-r--r-- | cc/layer_impl.cc | 12 | ||||
-rw-r--r-- | cc/layer_tree_host_unittest.cc | 173 | ||||
-rw-r--r-- | cc/layer_tree_settings.cc | 11 | ||||
-rw-r--r-- | cc/layer_tree_settings.h | 1 | ||||
-rw-r--r-- | cc/resource_update_controller.cc | 4 | ||||
-rw-r--r-- | cc/scrollbar_animation_controller.cc | 13 | ||||
-rw-r--r-- | cc/scrollbar_layer.cc | 19 | ||||
-rw-r--r-- | cc/scrollbar_layer.h | 4 | ||||
-rw-r--r-- | cc/test/fake_scrollbar_layer.cc | 38 | ||||
-rw-r--r-- | cc/test/fake_scrollbar_layer.h | 38 |
11 files changed, 241 insertions, 74 deletions
diff --git a/cc/cc_tests.gyp b/cc/cc_tests.gyp index b5b57e3..77647105 100644 --- a/cc/cc_tests.gyp +++ b/cc/cc_tests.gyp @@ -82,6 +82,8 @@ 'test/fake_picture_layer_tiling_client.h', 'test/fake_proxy.cc', 'test/fake_proxy.h', + 'test/fake_scrollbar_layer.cc', + 'test/fake_scrollbar_layer.h', 'test/fake_scrollbar_theme_painter.h', 'test/fake_scrollbar_theme_painter.cc', 'test/fake_tile_manager_client.h', diff --git a/cc/layer_impl.cc b/cc/layer_impl.cc index 09c1fa0..1f6e21a 100644 --- a/cc/layer_impl.cc +++ b/cc/layer_impl.cc @@ -17,6 +17,7 @@ #include "cc/proxy.h" #include "cc/quad_sink.h" #include "cc/scrollbar_animation_controller.h" +#include "cc/scrollbar_animation_controller_linear_fade.h" #include "ui/gfx/point_conversions.h" #include "ui/gfx/rect_conversions.h" @@ -790,8 +791,15 @@ const ScrollbarLayerImpl* LayerImpl::horizontalScrollbarLayer() const void LayerImpl::setHorizontalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) { - if (!m_scrollbarAnimationController) - m_scrollbarAnimationController = ScrollbarAnimationController::create(this); + if (!m_scrollbarAnimationController) { + if (m_layerTreeImpl->settings().useLinearFadeScrollbarAnimator) { + double fadeoutDelay = 0.3; + double fadeoutLength = 0.3; + m_scrollbarAnimationController = ScrollbarAnimationControllerLinearFade::create(this, fadeoutDelay, fadeoutLength).PassAs<ScrollbarAnimationController>(); + } else { + m_scrollbarAnimationController = ScrollbarAnimationController::create(this); + } + } m_scrollbarAnimationController->setHorizontalScrollbarLayer(scrollbarLayer); m_scrollbarAnimationController->updateScrollOffset(this); } diff --git a/cc/layer_tree_host_unittest.cc b/cc/layer_tree_host_unittest.cc index 331de3b..1e1334d 100644 --- a/cc/layer_tree_host_unittest.cc +++ b/cc/layer_tree_host_unittest.cc @@ -12,10 +12,12 @@ #include "cc/layer_tree_impl.h" #include "cc/output_surface.h" #include "cc/single_thread_proxy.h" +#include "cc/test/fake_content_layer.h" #include "cc/test/fake_content_layer_client.h" #include "cc/test/fake_layer_tree_host_client.h" #include "cc/test/fake_output_surface.h" #include "cc/test/fake_proxy.h" +#include "cc/test/fake_scrollbar_layer.h" #include "cc/test/geometry_test_utils.h" #include "cc/test/layer_tree_test_common.h" #include "cc/resource_update_queue.h" @@ -995,49 +997,64 @@ TEST_F(LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers, runMultiThread class LayerTreeHostTestAtomicCommit : public LayerTreeHostTest { public: LayerTreeHostTestAtomicCommit() - : m_layer(ContentLayerWithUpdateTracking::create(&m_client)) { // Make sure partial texture updates are turned off. m_settings.maxPartialTextureUpdates = 0; + // Linear fade animator prevents scrollbars from drawing immediately. + m_settings.useLinearFadeScrollbarAnimator = false; } - virtual void beginTest() OVERRIDE + virtual void setupTree() OVERRIDE { + m_layer = FakeContentLayer::Create(&m_client); + m_layer->setBounds(gfx::Size(10, 20)); + + m_scrollbar = FakeScrollbarLayer::Create(true, m_layer->id()); + m_scrollbar->setPosition(gfx::Point(0, 10)); + m_scrollbar->setBounds(gfx::Size(10, 10)); + + m_layer->addChild(m_scrollbar); + m_layerTreeHost->setRootLayer(m_layer); - m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); + LayerTreeHostTest::setupTree(); + } - ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); - ResourceUpdateQueue queue; - m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()); + virtual void beginTest() OVERRIDE + { postSetNeedsCommitToMainThread(); } virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { + ASSERT_EQ(0u, m_layerTreeHost->settings().maxPartialTextureUpdates); + FakeWebGraphicsContext3D* context = static_cast<FakeWebGraphicsContext3D*>(impl->outputSurface()->Context3D()); switch (impl->activeTree()->source_frame_number()) { case 0: - // Number of textures should be one. - ASSERT_EQ(1, context->NumTextures()); - // Number of textures used for commit should be one. - EXPECT_EQ(1, context->NumUsedTextures()); + // Number of textures should be one for each layer + ASSERT_EQ(2, context->NumTextures()); + // Number of textures used for commit should be one for each layer. + EXPECT_EQ(2, context->NumUsedTextures()); // Verify that used texture is correct. EXPECT_TRUE(context->UsedTexture(context->TextureAt(0))); + EXPECT_TRUE(context->UsedTexture(context->TextureAt(1))); context->ResetUsedTextures(); postSetNeedsCommitToMainThread(); break; case 1: - // Number of textures should be two as the first texture - // is used by impl thread and cannot by used for update. - ASSERT_EQ(2, context->NumTextures()); - // Number of textures used for commit should still be one. - EXPECT_EQ(1, context->NumUsedTextures()); - // First texture should not have been used. + // Number of textures should be doubled as the first textures + // are used by impl thread and cannot by used for update. + ASSERT_EQ(4, context->NumTextures()); + // Number of textures used for commit should still be one for each layer. + EXPECT_EQ(2, context->NumUsedTextures()); + // First textures should not have been used. EXPECT_FALSE(context->UsedTexture(context->TextureAt(0))); - // New texture should have been used. - EXPECT_TRUE(context->UsedTexture(context->TextureAt(1))); + EXPECT_FALSE(context->UsedTexture(context->TextureAt(1))); + // New textures should have been used. + EXPECT_TRUE(context->UsedTexture(context->TextureAt(2))); + EXPECT_TRUE(context->UsedTexture(context->TextureAt(3))); context->ResetUsedTextures(); postSetNeedsCommitToMainThread(); @@ -1055,14 +1072,15 @@ public: { FakeWebGraphicsContext3D* context = static_cast<FakeWebGraphicsContext3D*>(impl->outputSurface()->Context3D()); - // Number of textures used for draw should always be one. - EXPECT_EQ(1, context->NumUsedTextures()); + // Number of textures used for draw should always be one for each layer. + EXPECT_EQ(2, context->NumUsedTextures()); context->ResetUsedTextures(); } virtual void layout() OVERRIDE { m_layer->setNeedsDisplay(); + m_scrollbar->setNeedsDisplay(); } virtual void afterTest() OVERRIDE @@ -1071,7 +1089,8 @@ public: private: FakeContentLayerClient m_client; - scoped_refptr<ContentLayerWithUpdateTracking> m_layer; + scoped_refptr<FakeContentLayer> m_layer; + scoped_refptr<FakeScrollbarLayer> m_scrollbar; }; TEST_F(LayerTreeHostTestAtomicCommit, runMultiThread) @@ -1094,62 +1113,104 @@ static void setLayerPropertiesForTesting(Layer* layer, Layer* parent, const gfx: class LayerTreeHostTestAtomicCommitWithPartialUpdate : public LayerTreeHostTest { public: LayerTreeHostTestAtomicCommitWithPartialUpdate() - : m_parent(ContentLayerWithUpdateTracking::create(&m_client)) - , m_child(ContentLayerWithUpdateTracking::create(&m_client)) - , m_numCommits(0) + : m_numCommits(0) { // Allow one partial texture update. m_settings.maxPartialTextureUpdates = 1; + // Linear fade animator prevents scrollbars from drawing immediately. + m_settings.useLinearFadeScrollbarAnimator = false; } - virtual void beginTest() OVERRIDE + virtual void setupTree() OVERRIDE { - m_layerTreeHost->setRootLayer(m_parent); - m_layerTreeHost->setViewportSize(gfx::Size(10, 20), gfx::Size(10, 20)); + m_parent = FakeContentLayer::Create(&m_client); + m_parent->setBounds(gfx::Size(10, 20)); - gfx::Transform identityMatrix; - setLayerPropertiesForTesting(m_parent.get(), 0, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 20), true); - setLayerPropertiesForTesting(m_child.get(), m_parent.get(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 10), gfx::Size(10, 10), false); + m_child = FakeContentLayer::Create(&m_client); + m_child->setPosition(gfx::Point(0, 10)); + m_child->setBounds(gfx::Size(3, 10)); - ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); - ResourceUpdateQueue queue; - m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()); + m_scrollbarWithPaints = + FakeScrollbarLayer::Create(true, m_parent->id()); + m_scrollbarWithPaints->setPosition(gfx::Point(3, 10)); + m_scrollbarWithPaints->setBounds(gfx::Size(3, 10)); + + m_scrollbarWithoutPaints = + FakeScrollbarLayer::Create(false, m_parent->id()); + m_scrollbarWithoutPaints->setPosition(gfx::Point(6, 10)); + m_scrollbarWithoutPaints->setBounds(gfx::Size(3, 10)); + + m_parent->addChild(m_child); + m_parent->addChild(m_scrollbarWithPaints); + m_parent->addChild(m_scrollbarWithoutPaints); + + m_layerTreeHost->setRootLayer(m_parent); + LayerTreeHostTest::setupTree(); + } + + virtual void beginTest() OVERRIDE + { postSetNeedsCommitToMainThread(); } virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { + ASSERT_EQ(1u, m_layerTreeHost->settings().maxPartialTextureUpdates); + FakeWebGraphicsContext3D* context = static_cast<FakeWebGraphicsContext3D*>(impl->outputSurface()->Context3D()); switch (impl->activeTree()->source_frame_number()) { case 0: - // Number of textures should be two. - ASSERT_EQ(2, context->NumTextures()); - // Number of textures used for commit should be two. - EXPECT_EQ(2, context->NumUsedTextures()); + // Number of textures should be one for each layer. + ASSERT_EQ(4, context->NumTextures()); + // Number of textures used for commit should be one for each layer. + EXPECT_EQ(4, context->NumUsedTextures()); // Verify that used textures are correct. EXPECT_TRUE(context->UsedTexture(context->TextureAt(0))); EXPECT_TRUE(context->UsedTexture(context->TextureAt(1))); + EXPECT_TRUE(context->UsedTexture(context->TextureAt(2))); + EXPECT_TRUE(context->UsedTexture(context->TextureAt(3))); context->ResetUsedTextures(); postSetNeedsCommitToMainThread(); break; case 1: - // Number of textures used for commit should still be two. - EXPECT_EQ(2, context->NumUsedTextures()); - // First two textures should not have been used. + // Number of textures should be two for each content layer and one + // for each scrollbar, since they always do a partial update. + ASSERT_EQ(6, context->NumTextures()); + // Number of textures used for commit should be one for each content + // layer, and one for the scrollbar layer that paints. + EXPECT_EQ(3, context->NumUsedTextures()); + + // First content textures should not have been used. EXPECT_FALSE(context->UsedTexture(context->TextureAt(0))); EXPECT_FALSE(context->UsedTexture(context->TextureAt(1))); - // New textures should have been used. - EXPECT_TRUE(context->UsedTexture(context->TextureAt(2))); + // The non-painting scrollbar's texture wasn't updated. + EXPECT_FALSE(context->UsedTexture(context->TextureAt(2))); + // The painting scrollbar's partial update texture was used. EXPECT_TRUE(context->UsedTexture(context->TextureAt(3))); + // New textures should have been used. + EXPECT_TRUE(context->UsedTexture(context->TextureAt(4))); + EXPECT_TRUE(context->UsedTexture(context->TextureAt(5))); context->ResetUsedTextures(); postSetNeedsCommitToMainThread(); break; case 2: - // Number of textures used for commit should still be two. - EXPECT_EQ(2, context->NumUsedTextures()); + // Number of textures should be two for each content layer and one + // for each scrollbar, since they always do a partial update. + ASSERT_EQ(6, context->NumTextures()); + // Number of textures used for commit should be one for each content + // layer, and one for the scrollbar layer that paints. + EXPECT_EQ(3, context->NumUsedTextures()); + + // The non-painting scrollbar's texture wasn't updated. + EXPECT_FALSE(context->UsedTexture(context->TextureAt(2))); + // The painting scrollbar does a partial update. + EXPECT_TRUE(context->UsedTexture(context->TextureAt(3))); + // One content layer does a partial update also. + EXPECT_TRUE(context->UsedTexture(context->TextureAt(4))); + EXPECT_FALSE(context->UsedTexture(context->TextureAt(5))); context->ResetUsedTextures(); postSetNeedsCommitToMainThread(); @@ -1162,8 +1223,10 @@ public: postSetNeedsCommitToMainThread(); break; case 4: - // Number of textures used for commit should be one. - EXPECT_EQ(1, context->NumUsedTextures()); + // Number of textures used for commit should be two. One for the + // content layer, and one for the painting scrollbar. The + // non-painting scrollbar doesn't update its texture. + EXPECT_EQ(2, context->NumUsedTextures()); context->ResetUsedTextures(); postSetNeedsCommitToMainThread(); @@ -1181,12 +1244,12 @@ public: { FakeWebGraphicsContext3D* context = static_cast<FakeWebGraphicsContext3D*>(impl->outputSurface()->Context3D()); - // Number of textures used for drawing should two except for frame 4 - // where the viewport only contains one layer. + // Number of textures used for drawing should one per layer except for + // frame 3 where the viewport only contains one layer. if (impl->activeTree()->source_frame_number() == 3) EXPECT_EQ(1, context->NumUsedTextures()); else - EXPECT_EQ(2, context->NumUsedTextures()); + EXPECT_EQ(4, context->NumUsedTextures()); context->ResetUsedTextures(); } @@ -1198,14 +1261,20 @@ public: case 1: m_parent->setNeedsDisplay(); m_child->setNeedsDisplay(); + m_scrollbarWithPaints->setNeedsDisplay(); + m_scrollbarWithoutPaints->setNeedsDisplay(); break; case 2: // Damage part of layers. m_parent->setNeedsDisplayRect(gfx::RectF(0, 0, 5, 5)); m_child->setNeedsDisplayRect(gfx::RectF(0, 0, 5, 5)); + m_scrollbarWithPaints->setNeedsDisplayRect(gfx::RectF(0, 0, 5, 5)); + m_scrollbarWithoutPaints->setNeedsDisplayRect(gfx::RectF(0, 0, 5, 5)); break; case 3: m_child->setNeedsDisplay(); + m_scrollbarWithPaints->setNeedsDisplay(); + m_scrollbarWithoutPaints->setNeedsDisplay(); m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); break; case 4: @@ -1225,8 +1294,10 @@ public: private: FakeContentLayerClient m_client; - scoped_refptr<ContentLayerWithUpdateTracking> m_parent; - scoped_refptr<ContentLayerWithUpdateTracking> m_child; + scoped_refptr<FakeContentLayer> m_parent; + scoped_refptr<FakeContentLayer> m_child; + scoped_refptr<FakeScrollbarLayer> m_scrollbarWithPaints; + scoped_refptr<FakeScrollbarLayer> m_scrollbarWithoutPaints; int m_numCommits; }; diff --git a/cc/layer_tree_settings.cc b/cc/layer_tree_settings.cc index 4221167..f8b9643 100644 --- a/cc/layer_tree_settings.cc +++ b/cc/layer_tree_settings.cc @@ -26,6 +26,7 @@ LayerTreeSettings::LayerTreeSettings() , showOverdrawInTracing(false) , canUseLCDText(true) , shouldClearRootRenderPass(true) + , useLinearFadeScrollbarAnimator(false) , refreshRate(0) , maxPartialTextureUpdates(std::numeric_limits<size_t>::max()) , numRasterThreads(1) @@ -46,6 +47,16 @@ LayerTreeSettings::LayerTreeSettings() canUseLCDText = false; #endif +#if defined(OS_ANDROID) + // TODO(danakj): Move this out to the android code. + maxPartialTextureUpdates = 0; +#endif + +#if defined(OS_ANDROID) + // TODO(danakj): Move this out to the android code. + useLinearFadeScrollbarAnimator = true; +#endif + initialDebugState.showPropertyChangedRects = CommandLine::ForCurrentProcess()->HasSwitch(cc::switches::kShowPropertyChangedRects); initialDebugState.showSurfaceDamageRects = CommandLine::ForCurrentProcess()->HasSwitch(cc::switches::kShowSurfaceDamageRects); initialDebugState.showScreenSpaceRects = CommandLine::ForCurrentProcess()->HasSwitch(cc::switches::kShowScreenSpaceRects); diff --git a/cc/layer_tree_settings.h b/cc/layer_tree_settings.h index 847795f..6f0f7be 100644 --- a/cc/layer_tree_settings.h +++ b/cc/layer_tree_settings.h @@ -29,6 +29,7 @@ class CC_EXPORT LayerTreeSettings { bool showOverdrawInTracing; bool canUseLCDText; bool shouldClearRootRenderPass; + bool useLinearFadeScrollbarAnimator; double refreshRate; size_t maxPartialTextureUpdates; size_t numRasterThreads; diff --git a/cc/resource_update_controller.cc b/cc/resource_update_controller.cc index d1ba4cf..9c35f8b 100644 --- a/cc/resource_update_controller.cc +++ b/cc/resource_update_controller.cc @@ -23,11 +23,7 @@ using WebKit::WebSharedGraphicsContext3D; namespace { // Number of partial updates we allow. -#if defined(OS_ANDROID) -const size_t partialTextureUpdatesMax = 0; -#else const size_t partialTextureUpdatesMax = 12; -#endif // Measured in seconds. const double textureUpdateTickRate = 0.004; diff --git a/cc/scrollbar_animation_controller.cc b/cc/scrollbar_animation_controller.cc index 1d9151b..f2e471c 100644 --- a/cc/scrollbar_animation_controller.cc +++ b/cc/scrollbar_animation_controller.cc @@ -9,25 +9,12 @@ #include "build/build_config.h" #include "cc/scrollbar_layer_impl.h" -#if defined(OS_ANDROID) -#include "cc/scrollbar_animation_controller_linear_fade.h" -#endif - namespace cc { -#if defined(OS_ANDROID) -scoped_ptr<ScrollbarAnimationController> ScrollbarAnimationController::create(LayerImpl* scrollLayer) -{ - static const double fadeoutDelay = 0.3; - static const double fadeoutLength = 0.3; - return ScrollbarAnimationControllerLinearFade::create(scrollLayer, fadeoutDelay, fadeoutLength).PassAs<ScrollbarAnimationController>(); -} -#else scoped_ptr<ScrollbarAnimationController> ScrollbarAnimationController::create(LayerImpl* scrollLayer) { return make_scoped_ptr(new ScrollbarAnimationController(scrollLayer)); } -#endif ScrollbarAnimationController::ScrollbarAnimationController(LayerImpl* scrollLayer) : m_horizontalScrollbarLayer(0) diff --git a/cc/scrollbar_layer.cc b/cc/scrollbar_layer.cc index f35b865..c6ca1b1 100644 --- a/cc/scrollbar_layer.cc +++ b/cc/scrollbar_layer.cc @@ -249,7 +249,7 @@ void ScrollbarLayer::updatePart(CachingBitmapContentLayerUpdater* painter, Layer // we already have valid texture data. if (resource->texture()->haveBackingTexture() && resource->texture()->size() == rect.size() && - m_updateRect.IsEmpty()) + !isDirty()) return; // We should always have enough memory for UI. @@ -265,8 +265,12 @@ void ScrollbarLayer::updatePart(CachingBitmapContentLayerUpdater* painter, Layer return; } + bool partialUpdatesAllowed = layerTreeHost()->settings().maxPartialTextureUpdates > 0; + if (!partialUpdatesAllowed) + resource->texture()->returnBackingTexture(); + gfx::Vector2d destOffset(0, 0); - resource->update(queue, rect, destOffset, false, stats); + resource->update(queue, rect, destOffset, partialUpdatesAllowed, stats); } gfx::Rect ScrollbarLayer::scrollbarLayerRectToContentRect(const gfx::Rect& layerRect) const @@ -306,8 +310,13 @@ void ScrollbarLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker* { ContentsScalingLayer::update(queue, occlusion, stats); + m_dirtyRect.Union(m_updateRect); if (contentBounds().IsEmpty()) return; + if (visibleContentRect().IsEmpty()) + return; + if (!isDirty()) + return; createUpdaterIfNeeded(); @@ -317,10 +326,12 @@ void ScrollbarLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker* updatePart(m_foreTrackUpdater.get(), m_foreTrack.get(), contentRect, queue, stats); // Consider the thumb to be at the origin when painting. - WebKit::WebRect thumbRect = m_geometry->thumbRect(m_scrollbar.get()); - gfx::Rect originThumbRect = scrollbarLayerRectToContentRect(gfx::Rect(0, 0, thumbRect.width, thumbRect.height)); + gfx::Rect thumbRect = m_geometry->thumbRect(m_scrollbar.get()); + gfx::Rect originThumbRect = scrollbarLayerRectToContentRect(gfx::Rect(thumbRect.size())); if (!originThumbRect.IsEmpty()) updatePart(m_thumbUpdater.get(), m_thumb.get(), originThumbRect, queue, stats); + + m_dirtyRect = gfx::RectF(); } } // namespace cc diff --git a/cc/scrollbar_layer.h b/cc/scrollbar_layer.h index 2ddbad7..1816f51 100644 --- a/cc/scrollbar_layer.h +++ b/cc/scrollbar_layer.h @@ -58,6 +58,8 @@ private: void createUpdaterIfNeeded(); gfx::Rect scrollbarLayerRectToContentRect(const gfx::Rect& layerRect) const; + bool isDirty() const { return !m_dirtyRect.IsEmpty(); } + int maxTextureSize(); float clampScaleToMaxTextureSize(float scale); @@ -68,6 +70,8 @@ private: GLenum m_textureFormat; + gfx::RectF m_dirtyRect; + scoped_refptr<CachingBitmapContentLayerUpdater> m_backTrackUpdater; scoped_refptr<CachingBitmapContentLayerUpdater> m_foreTrackUpdater; scoped_refptr<CachingBitmapContentLayerUpdater> m_thumbUpdater; diff --git a/cc/test/fake_scrollbar_layer.cc b/cc/test/fake_scrollbar_layer.cc new file mode 100644 index 0000000..7d5d968 --- /dev/null +++ b/cc/test/fake_scrollbar_layer.cc @@ -0,0 +1,38 @@ +// Copyright 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "cc/test/fake_scrollbar_layer.h" + +#include "cc/test/fake_scrollbar_theme_painter.h" +#include "cc/test/fake_web_scrollbar.h" +#include "cc/test/fake_web_scrollbar_theme_geometry.h" + +namespace cc { + +FakeScrollbarLayer::FakeScrollbarLayer( + bool paint_during_update, int scrolling_layer_id) + : ScrollbarLayer( + FakeWebScrollbar::create().PassAs<WebKit::WebScrollbar>(), + FakeScrollbarThemePainter::Create(paint_during_update) + .PassAs<ScrollbarThemePainter>(), + FakeWebScrollbarThemeGeometry::create() + .PassAs<WebKit::WebScrollbarThemeGeometry>(), + scrolling_layer_id), + update_count_(0) { + setAnchorPoint(gfx::PointF(0, 0)); + setBounds(gfx::Size(1, 1)); + setIsDrawable(true); +} + +FakeScrollbarLayer::~FakeScrollbarLayer() {} + +void FakeScrollbarLayer::update( + ResourceUpdateQueue& queue, + const OcclusionTracker* occlusion, + RenderingStats& stats) { + ScrollbarLayer::update(queue, occlusion, stats); + update_count_++; +} + +} // namespace cc diff --git a/cc/test/fake_scrollbar_layer.h b/cc/test/fake_scrollbar_layer.h new file mode 100644 index 0000000..354cf8b --- /dev/null +++ b/cc/test/fake_scrollbar_layer.h @@ -0,0 +1,38 @@ +// Copyright 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CC_TEST_FAKE_SCROLLBAR_LAYER_H_ +#define CC_TEST_FAKE_SCROLLBAR_LAYER_H_ + +#include "base/memory/scoped_ptr.h" +#include "cc/scrollbar_layer.h" + +namespace cc { + +class FakeScrollbarLayer : public ScrollbarLayer { +public: + static scoped_refptr<FakeScrollbarLayer> Create( + bool paint_during_update, int scrolling_layer_id) { + return make_scoped_refptr(new FakeScrollbarLayer( + paint_during_update, scrolling_layer_id)); + } + + int update_count() { return update_count_; } + void reset_update_count() { update_count_ = 0; } + + virtual void update( + ResourceUpdateQueue& queue, + const OcclusionTracker* occlusion, + RenderingStats& stats) OVERRIDE; + +private: + FakeScrollbarLayer(bool paint_during_update, int scrolling_layer_id); + virtual ~FakeScrollbarLayer(); + + int update_count_; +}; + +} // namespace cc + +#endif // CC_TEST_FAKE_SCROLLBAR_LAYER_H_ |