Index: cc/layer_tree_host_unittest.cc |
diff --git a/cc/layer_tree_host_unittest.cc b/cc/layer_tree_host_unittest.cc |
index b8d79d9cf42289d77aa64fdbe7401c96fc173fa7..9e9d8588f5d239561b2e660d4099b4829016e82b 100644 |
--- a/cc/layer_tree_host_unittest.cc |
+++ b/cc/layer_tree_host_unittest.cc |
@@ -11,11 +11,15 @@ |
#include "cc/layer_tree_host_impl.h" |
#include "cc/layer_tree_impl.h" |
#include "cc/output_surface.h" |
+#include "cc/scrollbar_layer.h" |
#include "cc/single_thread_proxy.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_theme_painter.h" |
+#include "cc/test/fake_web_scrollbar.h" |
+#include "cc/test/fake_web_scrollbar_theme_geometry.h" |
#include "cc/test/geometry_test_utils.h" |
#include "cc/test/layer_tree_test_common.h" |
#include "cc/test/occlusion_tracker_test_common.h" |
@@ -1172,6 +1176,42 @@ private: |
int m_paintContentsCount; |
}; |
+class ScrollbarLayerWithUpdateTracking : public ScrollbarLayer { |
+public: |
+ static scoped_refptr<ScrollbarLayerWithUpdateTracking> create(int scrollLayerId, bool paintContentsDuringUpdate) |
+ { |
+ return make_scoped_refptr(new ScrollbarLayerWithUpdateTracking(scrollLayerId, paintContentsDuringUpdate)); |
+ } |
+ |
+ int updateCount() { return m_updateCount; } |
+ void resetUpdateCount() { m_updateCount = 0; } |
+ |
+ virtual void update(ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats& stats) OVERRIDE |
+ { |
+ ScrollbarLayer::update(queue, occlusion, stats); |
+ m_updateCount++; |
+ } |
+ |
+private: |
+ explicit ScrollbarLayerWithUpdateTracking(int scrollLayerId, bool paintContentsDuringUpdate) |
+ : ScrollbarLayer( |
+ FakeWebScrollbar::create().PassAs<WebKit::WebScrollbar>(), |
+ FakeScrollbarThemePainter::Create(paintContentsDuringUpdate).PassAs<ScrollbarThemePainter>(), |
+ FakeWebScrollbarThemeGeometry::create().PassAs<WebKit::WebScrollbarThemeGeometry>(), |
+ scrollLayerId) |
+ , m_updateCount(0) |
+ { |
+ setAnchorPoint(gfx::PointF(0, 0)); |
+ setBounds(gfx::Size(10, 10)); |
+ setIsDrawable(true); |
+ } |
+ virtual ~ScrollbarLayerWithUpdateTracking() |
+ { |
+ } |
+ |
+ int m_updateCount; |
+}; |
+ |
// Layer opacity change during paint should not prevent compositor resources from being updated during commit. |
class LayerTreeHostTestOpacityChange : public LayerTreeHostTest { |
public: |
@@ -1398,6 +1438,7 @@ class LayerTreeHostTestAtomicCommit : public LayerTreeHostTest { |
public: |
LayerTreeHostTestAtomicCommit() |
: m_layer(ContentLayerWithUpdateTracking::create(&m_client)) |
+ , m_scrollbar(ScrollbarLayerWithUpdateTracking::create(m_layer->id(), true)) |
{ |
// Make sure partial texture updates are turned off. |
m_settings.maxPartialTextureUpdates = 0; |
@@ -1405,6 +1446,7 @@ public: |
virtual void beginTest() OVERRIDE |
{ |
+ m_layer->addChild(m_scrollbar); |
m_layerTreeHost->setRootLayer(m_layer); |
m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
@@ -1421,25 +1463,28 @@ public: |
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->texture(0))); |
+ EXPECT_TRUE(context->usedTexture(context->texture(1))); |
context->resetUsedTextures(); |
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->texture(0))); |
- // New texture should have been used. |
- EXPECT_TRUE(context->usedTexture(context->texture(1))); |
+ EXPECT_FALSE(context->usedTexture(context->texture(1))); |
+ // New textures should have been used. |
+ EXPECT_TRUE(context->usedTexture(context->texture(2))); |
+ EXPECT_TRUE(context->usedTexture(context->texture(3))); |
context->resetUsedTextures(); |
break; |
@@ -1453,8 +1498,8 @@ public: |
{ |
CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(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()); |
if (impl->activeTree()->source_frame_number() < 1) { |
context->resetUsedTextures(); |
@@ -1467,6 +1512,7 @@ public: |
virtual void layout() OVERRIDE |
{ |
m_layer->setNeedsDisplay(); |
+ m_scrollbar->setNeedsDisplay(); |
} |
virtual void afterTest() OVERRIDE |
@@ -1476,6 +1522,7 @@ public: |
private: |
FakeContentLayerClient m_client; |
scoped_refptr<ContentLayerWithUpdateTracking> m_layer; |
+ scoped_refptr<ScrollbarLayerWithUpdateTracking> m_scrollbar; |
}; |
TEST_F(LayerTreeHostTestAtomicCommit, runMultiThread) |
@@ -1500,6 +1547,8 @@ public: |
LayerTreeHostTestAtomicCommitWithPartialUpdate() |
: m_parent(ContentLayerWithUpdateTracking::create(&m_client)) |
, m_child(ContentLayerWithUpdateTracking::create(&m_client)) |
+ , m_scrollbarWithPaints(ScrollbarLayerWithUpdateTracking::create(m_parent->id(), true)) |
+ , m_scrollbarWithoutPaints(ScrollbarLayerWithUpdateTracking::create(m_parent->id(), false)) |
, m_numCommits(0) |
{ |
// Allow one partial texture update. |
@@ -1514,6 +1563,8 @@ public: |
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); |
+ setLayerPropertiesForTesting(m_scrollbarWithPaints.get(), m_parent.get(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 10), gfx::Size(10, 10), false); |
+ setLayerPropertiesForTesting(m_scrollbarWithoutPaints.get(), m_parent.get(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 10), gfx::Size(10, 10), false); |
ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); |
ResourceUpdateQueue queue; |
@@ -1528,31 +1579,54 @@ public: |
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->texture(0))); |
EXPECT_TRUE(context->usedTexture(context->texture(1))); |
+ EXPECT_TRUE(context->usedTexture(context->texture(2))); |
+ EXPECT_TRUE(context->usedTexture(context->texture(3))); |
context->resetUsedTextures(); |
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->texture(0))); |
EXPECT_FALSE(context->usedTexture(context->texture(1))); |
- // New textures should have been used. |
- EXPECT_TRUE(context->usedTexture(context->texture(2))); |
+ // The non-painting scrollbar's texture wasn't updated. |
+ EXPECT_FALSE(context->usedTexture(context->texture(2))); |
+ // The painting scrollbar's partial update texture was used. |
EXPECT_TRUE(context->usedTexture(context->texture(3))); |
+ // New textures should have been used. |
+ EXPECT_TRUE(context->usedTexture(context->texture(4))); |
+ EXPECT_TRUE(context->usedTexture(context->texture(5))); |
context->resetUsedTextures(); |
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->texture(2))); |
+ // The painting scrollbar does a partial update. |
+ EXPECT_TRUE(context->usedTexture(context->texture(3))); |
+ // One content layer does a partial update also. |
+ EXPECT_TRUE(context->usedTexture(context->texture(4))); |
+ EXPECT_FALSE(context->usedTexture(context->texture(5))); |
context->resetUsedTextures(); |
break; |
@@ -1563,8 +1637,10 @@ public: |
context->resetUsedTextures(); |
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(); |
break; |
@@ -1578,12 +1654,12 @@ public: |
{ |
CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(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()); |
if (impl->activeTree()->source_frame_number() < 4) { |
context->resetUsedTextures(); |
@@ -1600,14 +1676,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: |
@@ -1627,6 +1709,8 @@ private: |
FakeContentLayerClient m_client; |
scoped_refptr<ContentLayerWithUpdateTracking> m_parent; |
scoped_refptr<ContentLayerWithUpdateTracking> m_child; |
+ scoped_refptr<ScrollbarLayerWithUpdateTracking> m_scrollbarWithPaints; |
+ scoped_refptr<ScrollbarLayerWithUpdateTracking> m_scrollbarWithoutPaints; |
int m_numCommits; |
}; |