| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 class DidDrawCheckLayer : public TiledLayerImpl { | 1054 class DidDrawCheckLayer : public TiledLayerImpl { |
| 1055 public: | 1055 public: |
| 1056 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { | 1056 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { |
| 1057 return scoped_ptr<LayerImpl>(new DidDrawCheckLayer(tree_impl, id)); | 1057 return scoped_ptr<LayerImpl>(new DidDrawCheckLayer(tree_impl, id)); |
| 1058 } | 1058 } |
| 1059 | 1059 |
| 1060 virtual void DidDraw(ResourceProvider* provider) OVERRIDE { | 1060 virtual void DidDraw(ResourceProvider* provider) OVERRIDE { |
| 1061 did_draw_called_ = true; | 1061 did_draw_called_ = true; |
| 1062 } | 1062 } |
| 1063 | 1063 |
| 1064 virtual void WillDraw(ResourceProvider* provider) OVERRIDE { | 1064 virtual bool WillDraw(DrawMode draw_mode, ResourceProvider* provider) |
| 1065 OVERRIDE { |
| 1065 will_draw_called_ = true; | 1066 will_draw_called_ = true; |
| 1067 return true; |
| 1066 } | 1068 } |
| 1067 | 1069 |
| 1068 bool did_draw_called() const { return did_draw_called_; } | 1070 bool did_draw_called() const { return did_draw_called_; } |
| 1069 bool will_draw_called() const { return will_draw_called_; } | 1071 bool will_draw_called() const { return will_draw_called_; } |
| 1070 | 1072 |
| 1071 void ClearDidDrawCheck() { | 1073 void ClearDidDrawCheck() { |
| 1072 did_draw_called_ = false; | 1074 did_draw_called_ = false; |
| 1073 will_draw_called_ = false; | 1075 will_draw_called_ = false; |
| 1074 } | 1076 } |
| 1075 | 1077 |
| (...skipping 4666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5742 DrawFrame(); | 5744 DrawFrame(); |
| 5743 | 5745 |
| 5744 EXPECT_EQ(1, software_device->frames_began_); | 5746 EXPECT_EQ(1, software_device->frames_began_); |
| 5745 EXPECT_EQ(1, software_device->frames_ended_); | 5747 EXPECT_EQ(1, software_device->frames_ended_); |
| 5746 | 5748 |
| 5747 // Call other API methods that are likely to hit NULL pointer in this mode. | 5749 // Call other API methods that are likely to hit NULL pointer in this mode. |
| 5748 EXPECT_TRUE(host_impl_->AsValue()); | 5750 EXPECT_TRUE(host_impl_->AsValue()); |
| 5749 EXPECT_TRUE(host_impl_->ActivationStateAsValue()); | 5751 EXPECT_TRUE(host_impl_->ActivationStateAsValue()); |
| 5750 } | 5752 } |
| 5751 | 5753 |
| 5754 TEST_F(LayerTreeHostImplTest, |
| 5755 ForcedDrawToSoftwareDeviceSkipsUnsupportedLayers) { |
| 5756 FakeOutputSurface* output_surface = FakeOutputSurface::CreateDeferredGL( |
| 5757 scoped_ptr<SoftwareOutputDevice>(new CountingSoftwareDevice())).release(); |
| 5758 host_impl_->InitializeRenderer( |
| 5759 scoped_ptr<OutputSurface>(output_surface)); |
| 5760 |
| 5761 output_surface->set_forced_draw_to_software_device(true); |
| 5762 EXPECT_TRUE(output_surface->ForcedDrawToSoftwareDevice()); |
| 5763 |
| 5764 // SolidColorLayerImpl will be drawn. |
| 5765 scoped_ptr<SolidColorLayerImpl> root_layer = |
| 5766 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
| 5767 |
| 5768 // VideoLayerImpl will not be drawn. |
| 5769 FakeVideoFrameProvider provider; |
| 5770 scoped_ptr<VideoLayerImpl> video_layer = |
| 5771 VideoLayerImpl::Create(host_impl_->active_tree(), 2, &provider); |
| 5772 video_layer->SetBounds(gfx::Size(10, 10)); |
| 5773 video_layer->SetContentBounds(gfx::Size(10, 10)); |
| 5774 video_layer->SetDrawsContent(true); |
| 5775 root_layer->AddChild(video_layer.PassAs<LayerImpl>()); |
| 5776 SetupRootLayerImpl(root_layer.PassAs<LayerImpl>()); |
| 5777 |
| 5778 LayerTreeHostImpl::FrameData frame; |
| 5779 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 5780 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); |
| 5781 host_impl_->DidDrawAllLayers(frame); |
| 5782 |
| 5783 EXPECT_EQ(1u, frame.will_draw_layers.size()); |
| 5784 EXPECT_EQ(host_impl_->active_tree()->root_layer(), frame.will_draw_layers[0]); |
| 5785 } |
| 5786 |
| 5752 } // namespace | 5787 } // namespace |
| 5753 } // namespace cc | 5788 } // namespace cc |
| OLD | NEW |