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

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 1175113010: cc: Rename visible_content_rect and content stuff on quads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rename-visible-content-rect: moreandroid Created 5 years, 6 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 unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 // Set the BeginFrameArgs so that methods which use it are able to. 181 // Set the BeginFrameArgs so that methods which use it are able to.
182 host_impl_->WillBeginImplFrame( 182 host_impl_->WillBeginImplFrame(
183 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); 183 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE));
184 return init; 184 return init;
185 } 185 }
186 186
187 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) { 187 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) {
188 root->SetPosition(gfx::PointF()); 188 root->SetPosition(gfx::PointF());
189 root->SetBounds(gfx::Size(10, 10)); 189 root->SetBounds(gfx::Size(10, 10));
190 root->SetDrawsContent(true); 190 root->SetDrawsContent(true);
191 root->draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10); 191 root->draw_properties().visible_layer_rect = gfx::Rect(0, 0, 10, 10);
192 root->SetHasRenderSurface(true); 192 root->SetHasRenderSurface(true);
193 host_impl_->active_tree()->SetRootLayer(root.Pass()); 193 host_impl_->active_tree()->SetRootLayer(root.Pass());
194 } 194 }
195 195
196 static void ExpectClearedScrollDeltasRecursive(LayerImpl* layer) { 196 static void ExpectClearedScrollDeltasRecursive(LayerImpl* layer) {
197 ASSERT_EQ(layer->ScrollDelta(), gfx::Vector2d()); 197 ASSERT_EQ(layer->ScrollDelta(), gfx::Vector2d());
198 for (size_t i = 0; i < layer->children().size(); ++i) 198 for (size_t i = 0; i < layer->children().size(); ++i)
199 ExpectClearedScrollDeltasRecursive(layer->children()[i]); 199 ExpectClearedScrollDeltasRecursive(layer->children()[i]);
200 } 200 }
201 201
(...skipping 1943 matching lines...) Expand 10 before | Expand all | Expand 10 after
2145 2145
2146 protected: 2146 protected:
2147 DidDrawCheckLayer(LayerTreeImpl* tree_impl, int id) 2147 DidDrawCheckLayer(LayerTreeImpl* tree_impl, int id)
2148 : LayerImpl(tree_impl, id), 2148 : LayerImpl(tree_impl, id),
2149 will_draw_returns_false_(false), 2149 will_draw_returns_false_(false),
2150 will_draw_called_(false), 2150 will_draw_called_(false),
2151 append_quads_called_(false), 2151 append_quads_called_(false),
2152 did_draw_called_(false) { 2152 did_draw_called_(false) {
2153 SetBounds(gfx::Size(10, 10)); 2153 SetBounds(gfx::Size(10, 10));
2154 SetDrawsContent(true); 2154 SetDrawsContent(true);
2155 draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10); 2155 draw_properties().visible_layer_rect = gfx::Rect(0, 0, 10, 10);
2156 } 2156 }
2157 2157
2158 private: 2158 private:
2159 bool will_draw_returns_false_; 2159 bool will_draw_returns_false_;
2160 bool will_draw_called_; 2160 bool will_draw_called_;
2161 bool append_quads_called_; 2161 bool append_quads_called_;
2162 bool did_draw_called_; 2162 bool did_draw_called_;
2163 }; 2163 };
2164 2164
2165 TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) { 2165 TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2209 // will be masked out by the root layer's bounds. 2209 // will be masked out by the root layer's bounds.
2210 host_impl_->active_tree()->SetRootLayer( 2210 host_impl_->active_tree()->SetRootLayer(
2211 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); 2211 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
2212 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( 2212 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(
2213 host_impl_->active_tree()->root_layer()); 2213 host_impl_->active_tree()->root_layer());
2214 root->SetMasksToBounds(true); 2214 root->SetMasksToBounds(true);
2215 root->SetHasRenderSurface(true); 2215 root->SetHasRenderSurface(true);
2216 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); 2216 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2));
2217 DidDrawCheckLayer* layer = 2217 DidDrawCheckLayer* layer =
2218 static_cast<DidDrawCheckLayer*>(root->children()[0]); 2218 static_cast<DidDrawCheckLayer*>(root->children()[0]);
2219 // Ensure visible_content_rect for layer is empty. 2219 // Ensure visible_layer_rect for layer is empty.
2220 layer->SetPosition(gfx::PointF(100.f, 100.f)); 2220 layer->SetPosition(gfx::PointF(100.f, 100.f));
2221 layer->SetBounds(gfx::Size(10, 10)); 2221 layer->SetBounds(gfx::Size(10, 10));
2222 2222
2223 LayerTreeHostImpl::FrameData frame; 2223 LayerTreeHostImpl::FrameData frame;
2224 2224
2225 EXPECT_FALSE(layer->will_draw_called()); 2225 EXPECT_FALSE(layer->will_draw_called());
2226 EXPECT_FALSE(layer->did_draw_called()); 2226 EXPECT_FALSE(layer->did_draw_called());
2227 2227
2228 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 2228 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
2229 host_impl_->DrawLayers(&frame); 2229 host_impl_->DrawLayers(&frame);
2230 host_impl_->DidDrawAllLayers(frame); 2230 host_impl_->DidDrawAllLayers(frame);
2231 2231
2232 EXPECT_FALSE(layer->will_draw_called()); 2232 EXPECT_FALSE(layer->will_draw_called());
2233 EXPECT_FALSE(layer->did_draw_called()); 2233 EXPECT_FALSE(layer->did_draw_called());
2234 2234
2235 EXPECT_TRUE(layer->visible_content_rect().IsEmpty()); 2235 EXPECT_TRUE(layer->visible_layer_rect().IsEmpty());
2236 2236
2237 // Ensure visible_content_rect for layer is not empty 2237 // Ensure visible_layer_rect for layer is not empty
2238 layer->SetPosition(gfx::PointF()); 2238 layer->SetPosition(gfx::PointF());
2239 2239
2240 EXPECT_FALSE(layer->will_draw_called()); 2240 EXPECT_FALSE(layer->will_draw_called());
2241 EXPECT_FALSE(layer->did_draw_called()); 2241 EXPECT_FALSE(layer->did_draw_called());
2242 2242
2243 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 2243 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
2244 host_impl_->DrawLayers(&frame); 2244 host_impl_->DrawLayers(&frame);
2245 host_impl_->DidDrawAllLayers(frame); 2245 host_impl_->DidDrawAllLayers(frame);
2246 2246
2247 EXPECT_TRUE(layer->will_draw_called()); 2247 EXPECT_TRUE(layer->will_draw_called());
2248 EXPECT_TRUE(layer->did_draw_called()); 2248 EXPECT_TRUE(layer->did_draw_called());
2249 2249
2250 EXPECT_FALSE(layer->visible_content_rect().IsEmpty()); 2250 EXPECT_FALSE(layer->visible_layer_rect().IsEmpty());
2251 } 2251 }
2252 2252
2253 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) { 2253 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) {
2254 gfx::Size big_size(1000, 1000); 2254 gfx::Size big_size(1000, 1000);
2255 host_impl_->SetViewportSize(big_size); 2255 host_impl_->SetViewportSize(big_size);
2256 2256
2257 host_impl_->active_tree()->SetRootLayer( 2257 host_impl_->active_tree()->SetRootLayer(
2258 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); 2258 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
2259 DidDrawCheckLayer* root = 2259 DidDrawCheckLayer* root =
2260 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 2260 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
(...skipping 3261 matching lines...) Expand 10 before | Expand all | Expand 10 after
5522 scoped_ptr<LayerImpl> grand_child = 5522 scoped_ptr<LayerImpl> grand_child =
5523 FakeLayerWithQuads::Create(my_host_impl->active_tree(), 3); 5523 FakeLayerWithQuads::Create(my_host_impl->active_tree(), 3);
5524 5524
5525 gfx::Rect root_rect(0, 0, 100, 100); 5525 gfx::Rect root_rect(0, 0, 100, 100);
5526 gfx::Rect child_rect(10, 10, 50, 50); 5526 gfx::Rect child_rect(10, 10, 50, 50);
5527 gfx::Rect grand_child_rect(5, 5, 150, 150); 5527 gfx::Rect grand_child_rect(5, 5, 150, 150);
5528 5528
5529 root->SetHasRenderSurface(true); 5529 root->SetHasRenderSurface(true);
5530 root->SetPosition(root_rect.origin()); 5530 root->SetPosition(root_rect.origin());
5531 root->SetBounds(root_rect.size()); 5531 root->SetBounds(root_rect.size());
5532 root->draw_properties().visible_content_rect = root_rect; 5532 root->draw_properties().visible_layer_rect = root_rect;
5533 root->SetDrawsContent(false); 5533 root->SetDrawsContent(false);
5534 root->render_surface()->SetContentRect(gfx::Rect(root_rect.size())); 5534 root->render_surface()->SetContentRect(gfx::Rect(root_rect.size()));
5535 5535
5536 child->SetPosition(gfx::PointF(child_rect.x(), child_rect.y())); 5536 child->SetPosition(gfx::PointF(child_rect.x(), child_rect.y()));
5537 child->SetOpacity(0.5f); 5537 child->SetOpacity(0.5f);
5538 child->SetBounds(gfx::Size(child_rect.width(), child_rect.height())); 5538 child->SetBounds(gfx::Size(child_rect.width(), child_rect.height()));
5539 child->draw_properties().visible_content_rect = child_rect; 5539 child->draw_properties().visible_layer_rect = child_rect;
5540 child->SetDrawsContent(false); 5540 child->SetDrawsContent(false);
5541 child->SetHasRenderSurface(true); 5541 child->SetHasRenderSurface(true);
5542 5542
5543 grand_child->SetPosition(grand_child_rect.origin()); 5543 grand_child->SetPosition(grand_child_rect.origin());
5544 grand_child->SetBounds(grand_child_rect.size()); 5544 grand_child->SetBounds(grand_child_rect.size());
5545 grand_child->draw_properties().visible_content_rect = grand_child_rect; 5545 grand_child->draw_properties().visible_layer_rect = grand_child_rect;
5546 grand_child->SetDrawsContent(true); 5546 grand_child->SetDrawsContent(true);
5547 5547
5548 child->AddChild(grand_child.Pass()); 5548 child->AddChild(grand_child.Pass());
5549 root->AddChild(child.Pass()); 5549 root->AddChild(child.Pass());
5550 5550
5551 my_host_impl->active_tree()->SetRootLayer(root.Pass()); 5551 my_host_impl->active_tree()->SetRootLayer(root.Pass());
5552 return my_host_impl.Pass(); 5552 return my_host_impl.Pass();
5553 } 5553 }
5554 5554
5555 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) { 5555 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) {
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
5893 5893
5894 LayerTreeHostImpl::FrameData frame; 5894 LayerTreeHostImpl::FrameData frame;
5895 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 5895 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5896 5896
5897 ASSERT_EQ(1u, frame.render_passes.size()); 5897 ASSERT_EQ(1u, frame.render_passes.size());
5898 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size()); 5898 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size());
5899 const DrawQuad* quad = frame.render_passes[0]->quad_list.front(); 5899 const DrawQuad* quad = frame.render_passes[0]->quad_list.front();
5900 5900
5901 bool clipped = false, force_aa = false; 5901 bool clipped = false, force_aa = false;
5902 gfx::QuadF device_layer_quad = MathUtil::MapQuad( 5902 gfx::QuadF device_layer_quad = MathUtil::MapQuad(
5903 quad->shared_quad_state->content_to_target_transform, 5903 quad->shared_quad_state->quad_to_target_transform,
5904 gfx::QuadF(quad->shared_quad_state->visible_content_rect), &clipped); 5904 gfx::QuadF(quad->shared_quad_state->visible_quad_layer_rect), &clipped);
5905 EXPECT_FALSE(clipped); 5905 EXPECT_FALSE(clipped);
5906 bool antialiased = 5906 bool antialiased =
5907 GLRendererWithSetupQuadForAntialiasing::ShouldAntialiasQuad( 5907 GLRendererWithSetupQuadForAntialiasing::ShouldAntialiasQuad(
5908 device_layer_quad, clipped, force_aa); 5908 device_layer_quad, clipped, force_aa);
5909 EXPECT_FALSE(antialiased); 5909 EXPECT_FALSE(antialiased);
5910 5910
5911 host_impl_->DrawLayers(&frame); 5911 host_impl_->DrawLayers(&frame);
5912 host_impl_->DidDrawAllLayers(frame); 5912 host_impl_->DidDrawAllLayers(frame);
5913 } 5913 }
5914 5914
(...skipping 2055 matching lines...) Expand 10 before | Expand all | Expand 10 after
7970 // Hold an unowned pointer to the output surface to use for mock expectations. 7970 // Hold an unowned pointer to the output surface to use for mock expectations.
7971 MockReclaimResourcesOutputSurface* mock_output_surface = output_surface.get(); 7971 MockReclaimResourcesOutputSurface* mock_output_surface = output_surface.get();
7972 7972
7973 CreateHostImpl(DefaultSettings(), output_surface.Pass()); 7973 CreateHostImpl(DefaultSettings(), output_surface.Pass());
7974 EXPECT_CALL(*mock_output_surface, ForceReclaimResources()).Times(1); 7974 EXPECT_CALL(*mock_output_surface, ForceReclaimResources()).Times(1);
7975 host_impl_->BeginCommit(); 7975 host_impl_->BeginCommit();
7976 } 7976 }
7977 7977
7978 } // namespace 7978 } // namespace
7979 } // namespace cc 7979 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698