Index: cc/trees/layer_tree_host_impl_unittest.cc |
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc |
index 45d533b5fb883c173067cdc4d549d793a819fb77..43047ffb818aae832e6db1ac2e4bad7f07e1c7e5 100644 |
--- a/cc/trees/layer_tree_host_impl_unittest.cc |
+++ b/cc/trees/layer_tree_host_impl_unittest.cc |
@@ -1641,8 +1641,7 @@ TEST_F(LayerTreeHostImplTest, CompositorFrameMetadata) { |
} |
} |
-// TODO(enne): Convert this to PictureLayerImpl |
-class DidDrawCheckLayer : public TiledLayerImpl { |
+class DidDrawCheckLayer : public LayerImpl { |
public: |
static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { |
return scoped_ptr<LayerImpl>(new DidDrawCheckLayer(tree_impl, id)); |
@@ -1653,18 +1652,18 @@ class DidDrawCheckLayer : public TiledLayerImpl { |
will_draw_called_ = true; |
if (will_draw_returns_false_) |
return false; |
- return TiledLayerImpl::WillDraw(draw_mode, provider); |
+ return LayerImpl::WillDraw(draw_mode, provider); |
} |
virtual void AppendQuads(QuadSink* quad_sink, |
AppendQuadsData* append_quads_data) OVERRIDE { |
append_quads_called_ = true; |
- TiledLayerImpl::AppendQuads(quad_sink, append_quads_data); |
+ LayerImpl::AppendQuads(quad_sink, append_quads_data); |
} |
virtual void DidDraw(ResourceProvider* provider) OVERRIDE { |
did_draw_called_ = true; |
- TiledLayerImpl::DidDraw(provider); |
+ LayerImpl::DidDraw(provider); |
} |
bool will_draw_called() const { return will_draw_called_; } |
@@ -1681,7 +1680,7 @@ class DidDrawCheckLayer : public TiledLayerImpl { |
protected: |
DidDrawCheckLayer(LayerTreeImpl* tree_impl, int id) |
- : TiledLayerImpl(tree_impl, id), |
+ : LayerImpl(tree_impl, id), |
will_draw_returns_false_(false), |
will_draw_called_(false), |
append_quads_called_(false), |
@@ -1689,14 +1688,7 @@ class DidDrawCheckLayer : public TiledLayerImpl { |
SetBounds(gfx::Size(10, 10)); |
SetContentBounds(gfx::Size(10, 10)); |
SetDrawsContent(true); |
- set_skips_draw(false); |
draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10); |
- |
- scoped_ptr<LayerTilingData> tiler = |
- LayerTilingData::Create(gfx::Size(100, 100), |
- LayerTilingData::HAS_BORDER_TEXELS); |
- tiler->SetTilingRect(gfx::Rect(content_bounds())); |
- SetTilingData(*tiler.get()); |
} |
private: |
@@ -1872,69 +1864,93 @@ class MissingTextureAnimatingLayer : public DidDrawCheckLayer { |
static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, |
int id, |
bool tile_missing, |
- bool skips_draw, |
+ bool had_incomplete_tile, |
bool animating, |
ResourceProvider* resource_provider) { |
- return scoped_ptr<LayerImpl>(new MissingTextureAnimatingLayer( |
- tree_impl, |
- id, |
- tile_missing, |
- skips_draw, |
- animating, |
- resource_provider)); |
+ return scoped_ptr<LayerImpl>( |
+ new MissingTextureAnimatingLayer(tree_impl, |
+ id, |
+ tile_missing, |
+ had_incomplete_tile, |
+ animating, |
+ resource_provider)); |
} |
virtual void AppendQuads(QuadSink* quad_sink, |
AppendQuadsData* append_quads_data) OVERRIDE { |
- TiledLayerImpl::AppendQuads(quad_sink, append_quads_data); |
- if (tile_missing_) |
+ LayerImpl::AppendQuads(quad_sink, append_quads_data); |
+ if (had_incomplete_tile_) |
append_quads_data->had_incomplete_tile = true; |
+ if (tile_missing_) |
+ append_quads_data->num_missing_tiles++; |
} |
private: |
MissingTextureAnimatingLayer(LayerTreeImpl* tree_impl, |
int id, |
bool tile_missing, |
- bool skips_draw, |
+ bool had_incomplete_tile, |
bool animating, |
ResourceProvider* resource_provider) |
- : DidDrawCheckLayer(tree_impl, id), tile_missing_(tile_missing) { |
- scoped_ptr<LayerTilingData> tiling_data = |
- LayerTilingData::Create(gfx::Size(10, 10), |
- LayerTilingData::NO_BORDER_TEXELS); |
- tiling_data->SetTilingRect(gfx::Rect(bounds())); |
- SetTilingData(*tiling_data.get()); |
- set_skips_draw(skips_draw); |
- if (!tile_missing) { |
+ : DidDrawCheckLayer(tree_impl, id), |
+ tile_missing_(tile_missing), |
+ had_incomplete_tile_(had_incomplete_tile) { |
+ if (!tile_missing || !had_incomplete_tile_) { |
ResourceProvider::ResourceId resource = |
danakj
2014/06/10 19:41:51
we don't use this resource anymore, it can go away
sohanjg
2014/06/11 10:53:16
Done.
|
resource_provider->CreateResource(gfx::Size(1, 1), |
GL_CLAMP_TO_EDGE, |
ResourceProvider::TextureUsageAny, |
RGBA_8888); |
resource_provider->AllocateForTesting(resource); |
- PushTileProperties(0, 0, resource, gfx::Rect(), false); |
} |
if (animating) |
AddAnimatedTransformToLayer(this, 10.0, 3, 0); |
} |
bool tile_missing_; |
+ bool had_incomplete_tile_; |
}; |
-TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenNoTexturesMissing) { |
+TEST_F(LayerTreeHostImplTest, |
+ PrepareToDrawSucceedsWhenNoTexturesMissingAndNoIncompleteTile) { |
+ host_impl_->active_tree()->SetRootLayer( |
+ DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
+ DidDrawCheckLayer* root = |
+ static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
+ |
+ bool tile_missing = false; |
+ bool had_incomplete_tile = false; |
+ bool is_animating = false; |
+ root->AddChild( |
+ MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
+ 2, |
+ tile_missing, |
+ had_incomplete_tile, |
+ is_animating, |
+ host_impl_->resource_provider())); |
+ |
+ LayerTreeHostImpl::FrameData frame; |
+ |
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
+ host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
+ host_impl_->DidDrawAllLayers(frame); |
+} |
+ |
+TEST_F(LayerTreeHostImplTest, |
+ PrepareToDrawSucceedsWhenNoTexturesMissingAndIncompleteTile) { |
danakj
2014/06/10 19:41:51
This is the same test as PrepareToDrawSucceedsWith
sohanjg
2014/06/11 10:53:16
Done.
|
host_impl_->active_tree()->SetRootLayer( |
DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
DidDrawCheckLayer* root = |
static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
bool tile_missing = false; |
- bool skips_draw = false; |
+ bool had_incomplete_tile = true; |
bool is_animating = false; |
root->AddChild( |
MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
2, |
tile_missing, |
- skips_draw, |
+ had_incomplete_tile, |
is_animating, |
host_impl_->resource_provider())); |
@@ -1951,13 +1967,13 @@ TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) { |
DidDrawCheckLayer* root = |
static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
bool tile_missing = false; |
- bool skips_draw = false; |
+ bool had_incomplete_tile = false; |
bool is_animating = true; |
root->AddChild( |
MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
2, |
tile_missing, |
- skips_draw, |
+ had_incomplete_tile, |
is_animating, |
host_impl_->resource_provider())); |
@@ -1969,7 +1985,7 @@ TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) { |
} |
TEST_F(LayerTreeHostImplTest, |
- PrepareToDrawSucceedsWithNonAnimatedMissingTexture) { |
+ PrepareToDrawSucceedsWithNonAnimatedMissingTextureAndNoIncompleteTile) { |
// When a texture is missing and we're not animating, we draw as usual with |
// checkerboarding. |
host_impl_->active_tree()->SetRootLayer( |
@@ -1978,13 +1994,38 @@ TEST_F(LayerTreeHostImplTest, |
static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
bool tile_missing = true; |
- bool skips_draw = false; |
+ bool had_incomplete_tile = false; |
+ bool is_animating = false; |
+ root->AddChild( |
+ MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
+ 4, |
+ tile_missing, |
+ had_incomplete_tile, |
+ is_animating, |
+ host_impl_->resource_provider())); |
+ LayerTreeHostImpl::FrameData frame; |
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
+ host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
+ host_impl_->DidDrawAllLayers(frame); |
+} |
+ |
+TEST_F(LayerTreeHostImplTest, |
+ PrepareToDrawSucceedsWithNonAnimatedIncompleteTile) { |
+ // When a texture is missing and we're not animating, we draw as usual with |
+ // checkerboarding. |
+ host_impl_->active_tree()->SetRootLayer( |
+ DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
+ DidDrawCheckLayer* root = |
+ static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
+ |
+ bool tile_missing = false; |
+ bool had_incomplete_tile = true; |
bool is_animating = false; |
root->AddChild( |
MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
4, |
tile_missing, |
- skips_draw, |
+ had_incomplete_tile, |
is_animating, |
host_impl_->resource_provider())); |
LayerTreeHostImpl::FrameData frame; |
@@ -2001,13 +2042,13 @@ TEST_F(LayerTreeHostImplTest, PrepareToDrawFailsWhenAnimationUsesCheckerboard) { |
DidDrawCheckLayer* root = |
static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
bool tile_missing = true; |
- bool skips_draw = false; |
+ bool had_incomplete_tile = true; |
danakj
2014/06/10 19:41:51
add a case for this being false please
sohanjg
2014/06/11 10:53:16
Done.
|
bool is_animating = true; |
root->AddChild( |
MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
6, |
tile_missing, |
- skips_draw, |
+ had_incomplete_tile, |
is_animating, |
host_impl_->resource_provider())); |
LayerTreeHostImpl::FrameData frame; |
@@ -2017,21 +2058,22 @@ TEST_F(LayerTreeHostImplTest, PrepareToDrawFailsWhenAnimationUsesCheckerboard) { |
host_impl_->DidDrawAllLayers(frame); |
} |
-TEST_F(LayerTreeHostImplTest, |
- PrepareToDrawSucceedsWithMissingSkippedAnimatedLayer) { |
- // When the layer skips draw and we're animating, we still draw the frame. |
+TEST_F( |
+ LayerTreeHostImplTest, |
+ PrepareToDrawSucceedsWithAnimationAndNoMissingTextureAndNoIncompleteTile) { |
danakj
2014/06/10 19:41:51
This is the same as PrepareToDrawSucceedsWithAnima
sohanjg
2014/06/11 10:53:16
Done.
|
+ // When we're animating, we draw the frame. |
host_impl_->active_tree()->SetRootLayer( |
DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
DidDrawCheckLayer* root = |
static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
bool tile_missing = false; |
- bool skips_draw = true; |
+ bool had_incomplete_tile = false; |
bool is_animating = true; |
root->AddChild( |
MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
8, |
tile_missing, |
- skips_draw, |
+ had_incomplete_tile, |
is_animating, |
host_impl_->resource_provider())); |
LayerTreeHostImpl::FrameData frame; |
@@ -2040,21 +2082,22 @@ TEST_F(LayerTreeHostImplTest, |
host_impl_->DidDrawAllLayers(frame); |
} |
-TEST_F(LayerTreeHostImplTest, |
- PrepareToDrawSucceedsWhenHighResRequiredButNoMissingTextures) { |
- // When the layer skips draw and we're animating, we still draw the frame. |
+TEST_F( |
+ LayerTreeHostImplTest, |
+ PrepareToDrawFailsWhenHighResRequiredButNoMissingTexturesAndIncompleteTile) { |
danakj
2014/06/10 19:41:51
This says fails, but the draw is succeeding. And t
sohanjg
2014/06/11 10:53:16
Done.
|
+ // When we're not animating, we draw the frame. |
host_impl_->active_tree()->SetRootLayer( |
DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
DidDrawCheckLayer* root = |
static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
bool tile_missing = false; |
- bool skips_draw = false; |
+ bool had_incomplete_tile = false; |
bool is_animating = false; |
root->AddChild( |
MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
8, |
tile_missing, |
- skips_draw, |
+ had_incomplete_tile, |
is_animating, |
host_impl_->resource_provider())); |
host_impl_->active_tree()->SetRequiresHighResToDraw(); |
@@ -2065,20 +2108,20 @@ TEST_F(LayerTreeHostImplTest, |
} |
TEST_F(LayerTreeHostImplTest, |
- PrepareToDrawFailsWhenHighResRequiredAndMissingTextures) { |
- // When the layer skips draw and we're animating, we still draw the frame. |
+ PrepareToDrawFailsWhenHighResRequiredAndIncompleteTile) { |
+ // When we're not animating, we draw the frame. |
host_impl_->active_tree()->SetRootLayer( |
DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
DidDrawCheckLayer* root = |
static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
- bool tile_missing = true; |
- bool skips_draw = false; |
+ bool tile_missing = false; |
+ bool had_incomplete_tile = true; |
bool is_animating = false; |
root->AddChild( |
MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
8, |
tile_missing, |
- skips_draw, |
+ had_incomplete_tile, |
is_animating, |
host_impl_->resource_provider())); |
host_impl_->active_tree()->SetRequiresHighResToDraw(); |
@@ -2089,6 +2132,32 @@ TEST_F(LayerTreeHostImplTest, |
host_impl_->DidDrawAllLayers(frame); |
} |
+TEST_F( |
+ LayerTreeHostImplTest, |
+ PrepareToDrawFailsWhenHighResRequiredAndMissingTexturesButNoIncompleteTile) { |
+ // When a texture is missing and we're not animating, we dont draw the frame |
+ // if we Set RequiresHighResToDraw. |
+ host_impl_->active_tree()->SetRootLayer( |
+ DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
+ DidDrawCheckLayer* root = |
+ static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
+ bool tile_missing = true; |
+ bool had_incomplete_tile = false; |
+ bool is_animating = false; |
+ root->AddChild( |
+ MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
+ 8, |
+ tile_missing, |
+ had_incomplete_tile, |
+ is_animating, |
+ host_impl_->resource_provider())); |
+ host_impl_->active_tree()->SetRequiresHighResToDraw(); |
+ LayerTreeHostImpl::FrameData frame; |
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
enne (OOO)
2014/06/10 18:35:09
The comment above does not agree with this asserti
danakj
2014/06/10 19:41:51
Ya, we do draw when we're missing a tile entirely,
sohanjg
2014/06/11 10:53:16
Done.
|
+ host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
+ host_impl_->DidDrawAllLayers(frame); |
+} |
+ |
TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { |
scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
root->SetScrollClipLayer(Layer::INVALID_ID); |