Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(676)

Unified Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 16211002: Skip drawing unsupported layers in forced software mode (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase on r203584 Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« cc/layers/video_layer_impl.cc ('K') | « cc/trees/layer_tree_host_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 6976087869b597287f5db6748b536a8f5ea0fa71..b2cc8160761dcda3e939f68d976800951d016fce 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -1057,27 +1057,44 @@ class DidDrawCheckLayer : public TiledLayerImpl {
return scoped_ptr<LayerImpl>(new DidDrawCheckLayer(tree_impl, id));
}
- virtual void DidDraw(ResourceProvider* provider) OVERRIDE {
- did_draw_called_ = true;
+ virtual bool WillDraw(DrawMode draw_mode, ResourceProvider* provider)
+ OVERRIDE {
+ will_draw_called_ = true;
+ if (will_draw_returns_false_)
+ return false;
+ return TiledLayerImpl::WillDraw(draw_mode, provider);
}
- virtual void WillDraw(ResourceProvider* provider) OVERRIDE {
- will_draw_called_ = true;
+ virtual void AppendQuads(QuadSink* quad_sink,
+ AppendQuadsData* append_quads_data) OVERRIDE {
+ append_quads_called_ = true;
+ TiledLayerImpl::AppendQuads(quad_sink, append_quads_data);
+ }
+
+ virtual void DidDraw(ResourceProvider* provider) OVERRIDE {
+ did_draw_called_ = true;
+ TiledLayerImpl::DidDraw(provider);
}
- bool did_draw_called() const { return did_draw_called_; }
bool will_draw_called() const { return will_draw_called_; }
+ bool append_quads_called() const { return append_quads_called_; }
+ bool did_draw_called() const { return did_draw_called_; }
+
+ void set_will_draw_returns_false() { will_draw_returns_false_ = true; }
void ClearDidDrawCheck() {
- did_draw_called_ = false;
will_draw_called_ = false;
+ append_quads_called_ = false;
+ did_draw_called_ = false;
}
protected:
DidDrawCheckLayer(LayerTreeImpl* tree_impl, int id)
: TiledLayerImpl(tree_impl, id),
- did_draw_called_(false),
- will_draw_called_(false) {
+ will_draw_returns_false_(false),
+ will_draw_called_(false),
+ append_quads_called_(false),
+ did_draw_called_(false) {
SetAnchorPoint(gfx::PointF());
SetBounds(gfx::Size(10, 10));
SetContentBounds(gfx::Size(10, 10));
@@ -1093,10 +1110,51 @@ class DidDrawCheckLayer : public TiledLayerImpl {
}
private:
- bool did_draw_called_;
+ bool will_draw_returns_false_;
bool will_draw_called_;
+ bool append_quads_called_;
+ bool did_draw_called_;
};
+TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) {
+ // The root layer is always drawn, so run this test on a child layer that
+ // will be masked out by the root layer's bounds.
+ host_impl_->active_tree()->SetRootLayer(
+ DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
+ DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(
+ host_impl_->active_tree()->root_layer());
+
+ root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2));
+ DidDrawCheckLayer* layer =
+ static_cast<DidDrawCheckLayer*>(root->children()[0]);
+
+ {
+ LayerTreeHostImpl::FrameData frame;
+ EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect(10, 10)));
+ host_impl_->DrawLayers(&frame, base::TimeTicks::Now());
+ host_impl_->DidDrawAllLayers(frame);
+
+ EXPECT_TRUE(layer->will_draw_called());
+ EXPECT_TRUE(layer->append_quads_called());
+ EXPECT_TRUE(layer->did_draw_called());
+ }
+
+ {
+ LayerTreeHostImpl::FrameData frame;
+
+ layer->set_will_draw_returns_false();
+ layer->ClearDidDrawCheck();
+
+ EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect(10, 10)));
+ host_impl_->DrawLayers(&frame, base::TimeTicks::Now());
+ host_impl_->DidDrawAllLayers(frame);
+
+ EXPECT_TRUE(layer->will_draw_called());
+ EXPECT_FALSE(layer->append_quads_called());
+ EXPECT_FALSE(layer->did_draw_called());
+ }
+}
+
TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) {
// The root layer is always drawn, so run this test on a child layer that
// will be masked out by the root layer's bounds.
@@ -5749,5 +5807,38 @@ TEST_F(LayerTreeHostImplTest, ForcedDrawToSoftwareDeviceBasicRender) {
EXPECT_TRUE(host_impl_->ActivationStateAsValue());
}
+TEST_F(LayerTreeHostImplTest,
+ ForcedDrawToSoftwareDeviceSkipsUnsupportedLayers) {
+ FakeOutputSurface* output_surface = FakeOutputSurface::CreateDeferredGL(
+ scoped_ptr<SoftwareOutputDevice>(new CountingSoftwareDevice())).release();
+ host_impl_->InitializeRenderer(
+ scoped_ptr<OutputSurface>(output_surface));
+
+ output_surface->set_forced_draw_to_software_device(true);
+ EXPECT_TRUE(output_surface->ForcedDrawToSoftwareDevice());
+
+ // SolidColorLayerImpl will be drawn.
+ scoped_ptr<SolidColorLayerImpl> root_layer =
+ SolidColorLayerImpl::Create(host_impl_->active_tree(), 1);
+
+ // VideoLayerImpl will not be drawn.
+ FakeVideoFrameProvider provider;
+ scoped_ptr<VideoLayerImpl> video_layer =
+ VideoLayerImpl::Create(host_impl_->active_tree(), 2, &provider);
+ video_layer->SetBounds(gfx::Size(10, 10));
+ video_layer->SetContentBounds(gfx::Size(10, 10));
+ video_layer->SetDrawsContent(true);
+ root_layer->AddChild(video_layer.PassAs<LayerImpl>());
+ SetupRootLayerImpl(root_layer.PassAs<LayerImpl>());
+
+ LayerTreeHostImpl::FrameData frame;
+ EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ host_impl_->DrawLayers(&frame, base::TimeTicks::Now());
+ host_impl_->DidDrawAllLayers(frame);
+
+ EXPECT_EQ(1u, frame.will_draw_layers.size());
+ EXPECT_EQ(host_impl_->active_tree()->root_layer(), frame.will_draw_layers[0]);
+}
+
} // namespace
} // namespace cc
« cc/layers/video_layer_impl.cc ('K') | « cc/trees/layer_tree_host_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698