| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 6929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6940 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 6940 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 6941 host_impl_->DrawLayers(&frame); | 6941 host_impl_->DrawLayers(&frame); |
| 6942 EXPECT_TRUE(layer1->quads_appended()); | 6942 EXPECT_TRUE(layer1->quads_appended()); |
| 6943 host_impl_->DidDrawAllLayers(frame); | 6943 host_impl_->DidDrawAllLayers(frame); |
| 6944 | 6944 |
| 6945 // Layer with translucent content and painting, so drawn with blending. | 6945 // Layer with translucent content and painting, so drawn with blending. |
| 6946 layer1->SetContentsOpaque(false); | 6946 layer1->SetContentsOpaque(false); |
| 6947 layer1->SetExpectation(true, false); | 6947 layer1->SetExpectation(true, false); |
| 6948 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6948 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 6949 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 6949 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6950 host_impl_->active_tree()->set_needs_update_draw_properties(); |
| 6950 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 6951 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 6951 host_impl_->DrawLayers(&frame); | 6952 host_impl_->DrawLayers(&frame); |
| 6952 EXPECT_TRUE(layer1->quads_appended()); | 6953 EXPECT_TRUE(layer1->quads_appended()); |
| 6953 host_impl_->DidDrawAllLayers(frame); | 6954 host_impl_->DidDrawAllLayers(frame); |
| 6954 | 6955 |
| 6955 // Layer with translucent opacity, drawn with blending. | 6956 // Layer with translucent opacity, drawn with blending. |
| 6956 layer1->SetContentsOpaque(true); | 6957 layer1->SetContentsOpaque(true); |
| 6957 layer1->test_properties()->opacity = 0.5f; | 6958 layer1->test_properties()->opacity = 0.5f; |
| 6958 layer1->NoteLayerPropertyChanged(); | 6959 layer1->NoteLayerPropertyChanged(); |
| 6959 layer1->SetExpectation(true, false); | 6960 layer1->SetExpectation(true, false); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7001 host_impl_->DidDrawAllLayers(frame); | 7002 host_impl_->DidDrawAllLayers(frame); |
| 7002 | 7003 |
| 7003 // Parent layer with translucent content, drawn with blending. | 7004 // Parent layer with translucent content, drawn with blending. |
| 7004 // Child layer with opaque content, drawn without blending. | 7005 // Child layer with opaque content, drawn without blending. |
| 7005 layer1->SetContentsOpaque(false); | 7006 layer1->SetContentsOpaque(false); |
| 7006 layer1->SetExpectation(true, false); | 7007 layer1->SetExpectation(true, false); |
| 7007 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 7008 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 7008 layer2->SetExpectation(false, false); | 7009 layer2->SetExpectation(false, false); |
| 7009 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); | 7010 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 7010 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 7011 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 7012 host_impl_->active_tree()->set_needs_update_draw_properties(); |
| 7011 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 7013 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 7012 host_impl_->DrawLayers(&frame); | 7014 host_impl_->DrawLayers(&frame); |
| 7013 EXPECT_TRUE(layer1->quads_appended()); | 7015 EXPECT_TRUE(layer1->quads_appended()); |
| 7014 EXPECT_TRUE(layer2->quads_appended()); | 7016 EXPECT_TRUE(layer2->quads_appended()); |
| 7015 host_impl_->DidDrawAllLayers(frame); | 7017 host_impl_->DidDrawAllLayers(frame); |
| 7016 | 7018 |
| 7017 // Parent layer with translucent content but opaque painting, drawn without | 7019 // Parent layer with translucent content but opaque painting, drawn without |
| 7018 // blending. | 7020 // blending. |
| 7019 // Child layer with opaque content, drawn without blending. | 7021 // Child layer with opaque content, drawn without blending. |
| 7020 layer1->SetContentsOpaque(true); | 7022 layer1->SetContentsOpaque(true); |
| 7021 layer1->SetExpectation(false, false); | 7023 layer1->SetExpectation(false, false); |
| 7022 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 7024 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 7023 layer2->SetExpectation(false, false); | 7025 layer2->SetExpectation(false, false); |
| 7024 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); | 7026 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 7025 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 7027 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 7028 host_impl_->active_tree()->set_needs_update_draw_properties(); |
| 7026 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 7029 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 7027 host_impl_->DrawLayers(&frame); | 7030 host_impl_->DrawLayers(&frame); |
| 7028 EXPECT_TRUE(layer1->quads_appended()); | 7031 EXPECT_TRUE(layer1->quads_appended()); |
| 7029 EXPECT_TRUE(layer2->quads_appended()); | 7032 EXPECT_TRUE(layer2->quads_appended()); |
| 7030 host_impl_->DidDrawAllLayers(frame); | 7033 host_impl_->DidDrawAllLayers(frame); |
| 7031 | 7034 |
| 7032 // Parent layer with translucent opacity and opaque content. Since it has a | 7035 // Parent layer with translucent opacity and opaque content. Since it has a |
| 7033 // drawing child, it's drawn to a render surface which carries the opacity, | 7036 // drawing child, it's drawn to a render surface which carries the opacity, |
| 7034 // so it's itself drawn without blending. | 7037 // so it's itself drawn without blending. |
| 7035 // Child layer with opaque content, drawn without blending (parent surface | 7038 // Child layer with opaque content, drawn without blending (parent surface |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7109 host_impl_->DidDrawAllLayers(frame); | 7112 host_impl_->DidDrawAllLayers(frame); |
| 7110 | 7113 |
| 7111 // Layer with partially opaque contents, drawn with blending. | 7114 // Layer with partially opaque contents, drawn with blending. |
| 7112 layer1->SetContentsOpaque(false); | 7115 layer1->SetContentsOpaque(false); |
| 7113 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); | 7116 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); |
| 7114 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5)); | 7117 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5)); |
| 7115 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); | 7118 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
| 7116 layer1->SetExpectation(true, false); | 7119 layer1->SetExpectation(true, false); |
| 7117 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 7120 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 7118 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 7121 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 7122 host_impl_->active_tree()->set_needs_update_draw_properties(); |
| 7119 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 7123 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 7120 host_impl_->DrawLayers(&frame); | 7124 host_impl_->DrawLayers(&frame); |
| 7121 EXPECT_TRUE(layer1->quads_appended()); | 7125 EXPECT_TRUE(layer1->quads_appended()); |
| 7122 host_impl_->DidDrawAllLayers(frame); | 7126 host_impl_->DidDrawAllLayers(frame); |
| 7123 | 7127 |
| 7124 // Layer with partially opaque contents partially culled, drawn with blending. | 7128 // Layer with partially opaque contents partially culled, drawn with blending. |
| 7125 layer1->SetContentsOpaque(false); | 7129 layer1->SetContentsOpaque(false); |
| 7126 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); | 7130 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); |
| 7127 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2)); | 7131 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2)); |
| 7128 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); | 7132 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
| 7129 layer1->SetExpectation(true, false); | 7133 layer1->SetExpectation(true, false); |
| 7130 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 7134 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 7131 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 7135 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 7136 host_impl_->active_tree()->set_needs_update_draw_properties(); |
| 7132 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 7137 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 7133 host_impl_->DrawLayers(&frame); | 7138 host_impl_->DrawLayers(&frame); |
| 7134 EXPECT_TRUE(layer1->quads_appended()); | 7139 EXPECT_TRUE(layer1->quads_appended()); |
| 7135 host_impl_->DidDrawAllLayers(frame); | 7140 host_impl_->DidDrawAllLayers(frame); |
| 7136 | 7141 |
| 7137 // Layer with partially opaque contents culled, drawn with blending. | 7142 // Layer with partially opaque contents culled, drawn with blending. |
| 7138 layer1->SetContentsOpaque(false); | 7143 layer1->SetContentsOpaque(false); |
| 7139 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); | 7144 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); |
| 7140 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5)); | 7145 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5)); |
| 7141 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); | 7146 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
| 7142 layer1->SetExpectation(true, false); | 7147 layer1->SetExpectation(true, false); |
| 7143 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 7148 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 7144 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 7149 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 7150 host_impl_->active_tree()->set_needs_update_draw_properties(); |
| 7145 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 7151 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 7146 host_impl_->DrawLayers(&frame); | 7152 host_impl_->DrawLayers(&frame); |
| 7147 EXPECT_TRUE(layer1->quads_appended()); | 7153 EXPECT_TRUE(layer1->quads_appended()); |
| 7148 host_impl_->DidDrawAllLayers(frame); | 7154 host_impl_->DidDrawAllLayers(frame); |
| 7149 | 7155 |
| 7150 // Layer with partially opaque contents and translucent contents culled, drawn | 7156 // Layer with partially opaque contents and translucent contents culled, drawn |
| 7151 // without blending. | 7157 // without blending. |
| 7152 layer1->SetContentsOpaque(false); | 7158 layer1->SetContentsOpaque(false); |
| 7153 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); | 7159 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); |
| 7154 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5)); | 7160 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5)); |
| 7155 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); | 7161 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
| 7156 layer1->SetExpectation(false, false); | 7162 layer1->SetExpectation(false, false); |
| 7157 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 7163 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 7158 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 7164 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 7165 host_impl_->active_tree()->set_needs_update_draw_properties(); |
| 7159 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 7166 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 7160 host_impl_->DrawLayers(&frame); | 7167 host_impl_->DrawLayers(&frame); |
| 7161 EXPECT_TRUE(layer1->quads_appended()); | 7168 EXPECT_TRUE(layer1->quads_appended()); |
| 7162 host_impl_->DidDrawAllLayers(frame); | 7169 host_impl_->DidDrawAllLayers(frame); |
| 7163 } | 7170 } |
| 7164 | 7171 |
| 7165 static bool MayContainVideoBitSetOnFrameData(LayerTreeHostImpl* host_impl) { | 7172 static bool MayContainVideoBitSetOnFrameData(LayerTreeHostImpl* host_impl) { |
| 7166 host_impl->active_tree()->BuildPropertyTreesForTesting(); | 7173 host_impl->active_tree()->BuildPropertyTreesForTesting(); |
| 7174 host_impl->active_tree()->set_needs_update_draw_properties(); |
| 7167 LayerTreeHostImpl::FrameData frame; | 7175 LayerTreeHostImpl::FrameData frame; |
| 7168 EXPECT_EQ(DRAW_SUCCESS, host_impl->PrepareToDraw(&frame)); | 7176 EXPECT_EQ(DRAW_SUCCESS, host_impl->PrepareToDraw(&frame)); |
| 7169 host_impl->DrawLayers(&frame); | 7177 host_impl->DrawLayers(&frame); |
| 7170 host_impl->DidDrawAllLayers(frame); | 7178 host_impl->DidDrawAllLayers(frame); |
| 7171 return frame.may_contain_video; | 7179 return frame.may_contain_video; |
| 7172 } | 7180 } |
| 7173 | 7181 |
| 7174 TEST_F(LayerTreeHostImplTest, MayContainVideo) { | 7182 TEST_F(LayerTreeHostImplTest, MayContainVideo) { |
| 7175 gfx::Size big_size(1000, 1000); | 7183 gfx::Size big_size(1000, 1000); |
| 7176 host_impl_->SetViewportSize(big_size); | 7184 host_impl_->SetViewportSize(big_size); |
| (...skipping 4557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11734 SetupMouseMoveAtTestScrollbarStates(true); | 11742 SetupMouseMoveAtTestScrollbarStates(true); |
| 11735 } | 11743 } |
| 11736 | 11744 |
| 11737 TEST_F(LayerTreeHostImplTest, | 11745 TEST_F(LayerTreeHostImplTest, |
| 11738 LayerTreeHostImplTestScrollbarStatesInNotMainThreadScorlling) { | 11746 LayerTreeHostImplTestScrollbarStatesInNotMainThreadScorlling) { |
| 11739 SetupMouseMoveAtTestScrollbarStates(false); | 11747 SetupMouseMoveAtTestScrollbarStates(false); |
| 11740 } | 11748 } |
| 11741 | 11749 |
| 11742 } // namespace | 11750 } // namespace |
| 11743 } // namespace cc | 11751 } // namespace cc |
| OLD | NEW |