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

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

Issue 448133002: Remove unused RenderPassDrawQuad fields (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rpdqdamage: win64 Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « cc/test/render_pass_test_utils.cc ('k') | cc/trees/layer_tree_host_unittest_delegated.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 <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 5119 matching lines...) Expand 10 before | Expand all | Expand 10 after
5130 { 5130 {
5131 LayerTreeHostImpl::FrameData frame; 5131 LayerTreeHostImpl::FrameData frame;
5132 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 5132 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5133 5133
5134 ASSERT_EQ(1u, frame.render_passes.size()); 5134 ASSERT_EQ(1u, frame.render_passes.size());
5135 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 5135 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
5136 ASSERT_EQ(DrawQuad::RENDER_PASS, 5136 ASSERT_EQ(DrawQuad::RENDER_PASS,
5137 frame.render_passes[0]->quad_list[1]->material); 5137 frame.render_passes[0]->quad_list[1]->material);
5138 const RenderPassDrawQuad* replica_quad = 5138 const RenderPassDrawQuad* replica_quad =
5139 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 5139 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
5140 EXPECT_TRUE(replica_quad->is_replica);
5141 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), 5140 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(),
5142 replica_quad->rect.ToString()); 5141 replica_quad->rect.ToString());
5143 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 5142 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
5144 replica_quad->mask_uv_rect.ToString()); 5143 replica_quad->mask_uv_rect.ToString());
5145 5144
5146 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5145 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5147 host_impl_->DidDrawAllLayers(frame); 5146 host_impl_->DidDrawAllLayers(frame);
5148 } 5147 }
5149 5148
5150 // Applying a DSF should change the render surface size, but won't affect 5149 // Applying a DSF should change the render surface size, but won't affect
5151 // which part of the mask is used. 5150 // which part of the mask is used.
5152 device_scale_factor = 2.f; 5151 device_scale_factor = 2.f;
5153 gfx::Size device_viewport = 5152 gfx::Size device_viewport =
5154 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); 5153 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor));
5155 host_impl_->SetViewportSize(device_viewport); 5154 host_impl_->SetViewportSize(device_viewport);
5156 host_impl_->SetDeviceScaleFactor(device_scale_factor); 5155 host_impl_->SetDeviceScaleFactor(device_scale_factor);
5157 host_impl_->active_tree()->set_needs_update_draw_properties(); 5156 host_impl_->active_tree()->set_needs_update_draw_properties();
5158 { 5157 {
5159 LayerTreeHostImpl::FrameData frame; 5158 LayerTreeHostImpl::FrameData frame;
5160 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 5159 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5161 5160
5162 ASSERT_EQ(1u, frame.render_passes.size()); 5161 ASSERT_EQ(1u, frame.render_passes.size());
5163 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 5162 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
5164 ASSERT_EQ(DrawQuad::RENDER_PASS, 5163 ASSERT_EQ(DrawQuad::RENDER_PASS,
5165 frame.render_passes[0]->quad_list[1]->material); 5164 frame.render_passes[0]->quad_list[1]->material);
5166 const RenderPassDrawQuad* replica_quad = 5165 const RenderPassDrawQuad* replica_quad =
5167 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 5166 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
5168 EXPECT_TRUE(replica_quad->is_replica);
5169 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 5167 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
5170 replica_quad->rect.ToString()); 5168 replica_quad->rect.ToString());
5171 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 5169 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
5172 replica_quad->mask_uv_rect.ToString()); 5170 replica_quad->mask_uv_rect.ToString());
5173 5171
5174 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5172 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5175 host_impl_->DidDrawAllLayers(frame); 5173 host_impl_->DidDrawAllLayers(frame);
5176 } 5174 }
5177 5175
5178 // Applying an equivalent content scale on the content layer and the mask 5176 // Applying an equivalent content scale on the content layer and the mask
(...skipping 10 matching lines...) Expand all
5189 { 5187 {
5190 LayerTreeHostImpl::FrameData frame; 5188 LayerTreeHostImpl::FrameData frame;
5191 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 5189 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5192 5190
5193 ASSERT_EQ(1u, frame.render_passes.size()); 5191 ASSERT_EQ(1u, frame.render_passes.size());
5194 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 5192 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
5195 ASSERT_EQ(DrawQuad::RENDER_PASS, 5193 ASSERT_EQ(DrawQuad::RENDER_PASS,
5196 frame.render_passes[0]->quad_list[1]->material); 5194 frame.render_passes[0]->quad_list[1]->material);
5197 const RenderPassDrawQuad* replica_quad = 5195 const RenderPassDrawQuad* replica_quad =
5198 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 5196 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
5199 EXPECT_TRUE(replica_quad->is_replica);
5200 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 5197 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
5201 replica_quad->rect.ToString()); 5198 replica_quad->rect.ToString());
5202 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 5199 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
5203 replica_quad->mask_uv_rect.ToString()); 5200 replica_quad->mask_uv_rect.ToString());
5204 5201
5205 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5202 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5206 host_impl_->DidDrawAllLayers(frame); 5203 host_impl_->DidDrawAllLayers(frame);
5207 } 5204 }
5208 5205
5209 // Applying a different contents scale to the mask layer means it will have 5206 // Applying a different contents scale to the mask layer means it will have
5210 // a larger texture, but it should use the same tex coords to cover the 5207 // a larger texture, but it should use the same tex coords to cover the
5211 // layer it masks. 5208 // layer it masks.
5212 mask_layer->SetContentBounds(mask_size); 5209 mask_layer->SetContentBounds(mask_size);
5213 mask_layer->SetContentsScale(1.f, 1.f); 5210 mask_layer->SetContentsScale(1.f, 1.f);
5214 host_impl_->active_tree()->set_needs_update_draw_properties(); 5211 host_impl_->active_tree()->set_needs_update_draw_properties();
5215 { 5212 {
5216 LayerTreeHostImpl::FrameData frame; 5213 LayerTreeHostImpl::FrameData frame;
5217 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 5214 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5218 5215
5219 ASSERT_EQ(1u, frame.render_passes.size()); 5216 ASSERT_EQ(1u, frame.render_passes.size());
5220 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 5217 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
5221 ASSERT_EQ(DrawQuad::RENDER_PASS, 5218 ASSERT_EQ(DrawQuad::RENDER_PASS,
5222 frame.render_passes[0]->quad_list[1]->material); 5219 frame.render_passes[0]->quad_list[1]->material);
5223 const RenderPassDrawQuad* replica_quad = 5220 const RenderPassDrawQuad* replica_quad =
5224 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 5221 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
5225 EXPECT_TRUE(replica_quad->is_replica);
5226 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 5222 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
5227 replica_quad->rect.ToString()); 5223 replica_quad->rect.ToString());
5228 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 5224 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
5229 replica_quad->mask_uv_rect.ToString()); 5225 replica_quad->mask_uv_rect.ToString());
5230 5226
5231 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5227 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5232 host_impl_->DidDrawAllLayers(frame); 5228 host_impl_->DidDrawAllLayers(frame);
5233 } 5229 }
5234 } 5230 }
5235 5231
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
5293 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 5289 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5294 5290
5295 ASSERT_EQ(1u, frame.render_passes.size()); 5291 ASSERT_EQ(1u, frame.render_passes.size());
5296 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 5292 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
5297 5293
5298 // The surface is 100x50. 5294 // The surface is 100x50.
5299 ASSERT_EQ(DrawQuad::RENDER_PASS, 5295 ASSERT_EQ(DrawQuad::RENDER_PASS,
5300 frame.render_passes[0]->quad_list[0]->material); 5296 frame.render_passes[0]->quad_list[0]->material);
5301 const RenderPassDrawQuad* render_pass_quad = 5297 const RenderPassDrawQuad* render_pass_quad =
5302 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 5298 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
5303 EXPECT_FALSE(render_pass_quad->is_replica);
5304 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), 5299 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(),
5305 render_pass_quad->rect.ToString()); 5300 render_pass_quad->rect.ToString());
5306 5301
5307 // The mask covers the owning layer only. 5302 // The mask covers the owning layer only.
5308 ASSERT_EQ(DrawQuad::RENDER_PASS, 5303 ASSERT_EQ(DrawQuad::RENDER_PASS,
5309 frame.render_passes[0]->quad_list[1]->material); 5304 frame.render_passes[0]->quad_list[1]->material);
5310 const RenderPassDrawQuad* replica_quad = 5305 const RenderPassDrawQuad* replica_quad =
5311 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 5306 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
5312 EXPECT_TRUE(replica_quad->is_replica);
5313 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), 5307 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(),
5314 replica_quad->rect.ToString()); 5308 replica_quad->rect.ToString());
5315 EXPECT_EQ(gfx::RectF(0.f, 0.f, 2.f, 1.f).ToString(), 5309 EXPECT_EQ(gfx::RectF(0.f, 0.f, 2.f, 1.f).ToString(),
5316 replica_quad->mask_uv_rect.ToString()); 5310 replica_quad->mask_uv_rect.ToString());
5317 5311
5318 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5312 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5319 host_impl_->DidDrawAllLayers(frame); 5313 host_impl_->DidDrawAllLayers(frame);
5320 } 5314 }
5321 5315
5322 // Move the child to (-50, 0) instead. Now the mask should be moved to still 5316 // Move the child to (-50, 0) instead. Now the mask should be moved to still
5323 // cover the layer being replicated. 5317 // cover the layer being replicated.
5324 content_child_layer->SetPosition(gfx::Point(-50, 0)); 5318 content_child_layer->SetPosition(gfx::Point(-50, 0));
5325 { 5319 {
5326 LayerTreeHostImpl::FrameData frame; 5320 LayerTreeHostImpl::FrameData frame;
5327 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 5321 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5328 5322
5329 ASSERT_EQ(1u, frame.render_passes.size()); 5323 ASSERT_EQ(1u, frame.render_passes.size());
5330 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 5324 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
5331 5325
5332 // The surface is 100x50 with its origin at (-50, 0). 5326 // The surface is 100x50 with its origin at (-50, 0).
5333 ASSERT_EQ(DrawQuad::RENDER_PASS, 5327 ASSERT_EQ(DrawQuad::RENDER_PASS,
5334 frame.render_passes[0]->quad_list[0]->material); 5328 frame.render_passes[0]->quad_list[0]->material);
5335 const RenderPassDrawQuad* render_pass_quad = 5329 const RenderPassDrawQuad* render_pass_quad =
5336 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 5330 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
5337 EXPECT_FALSE(render_pass_quad->is_replica);
5338 EXPECT_EQ(gfx::Rect(-50, 0, 100, 50).ToString(), 5331 EXPECT_EQ(gfx::Rect(-50, 0, 100, 50).ToString(),
5339 render_pass_quad->rect.ToString()); 5332 render_pass_quad->rect.ToString());
5340 5333
5341 // The mask covers the owning layer only. 5334 // The mask covers the owning layer only.
5342 ASSERT_EQ(DrawQuad::RENDER_PASS, 5335 ASSERT_EQ(DrawQuad::RENDER_PASS,
5343 frame.render_passes[0]->quad_list[1]->material); 5336 frame.render_passes[0]->quad_list[1]->material);
5344 const RenderPassDrawQuad* replica_quad = 5337 const RenderPassDrawQuad* replica_quad =
5345 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 5338 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
5346 EXPECT_TRUE(replica_quad->is_replica);
5347 EXPECT_EQ(gfx::Rect(-50, 0, 100, 50).ToString(), 5339 EXPECT_EQ(gfx::Rect(-50, 0, 100, 50).ToString(),
5348 replica_quad->rect.ToString()); 5340 replica_quad->rect.ToString());
5349 EXPECT_EQ(gfx::RectF(-1.f, 0.f, 2.f, 1.f).ToString(), 5341 EXPECT_EQ(gfx::RectF(-1.f, 0.f, 2.f, 1.f).ToString(),
5350 replica_quad->mask_uv_rect.ToString()); 5342 replica_quad->mask_uv_rect.ToString());
5351 5343
5352 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5344 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5353 host_impl_->DidDrawAllLayers(frame); 5345 host_impl_->DidDrawAllLayers(frame);
5354 } 5346 }
5355 } 5347 }
5356 5348
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
5421 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 5413 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5422 5414
5423 ASSERT_EQ(1u, frame.render_passes.size()); 5415 ASSERT_EQ(1u, frame.render_passes.size());
5424 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 5416 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
5425 5417
5426 // The surface is clipped to 10x20. 5418 // The surface is clipped to 10x20.
5427 ASSERT_EQ(DrawQuad::RENDER_PASS, 5419 ASSERT_EQ(DrawQuad::RENDER_PASS,
5428 frame.render_passes[0]->quad_list[0]->material); 5420 frame.render_passes[0]->quad_list[0]->material);
5429 const RenderPassDrawQuad* render_pass_quad = 5421 const RenderPassDrawQuad* render_pass_quad =
5430 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 5422 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
5431 EXPECT_FALSE(render_pass_quad->is_replica);
5432 EXPECT_EQ(gfx::Rect(20, 10, 10, 20).ToString(), 5423 EXPECT_EQ(gfx::Rect(20, 10, 10, 20).ToString(),
5433 render_pass_quad->rect.ToString()); 5424 render_pass_quad->rect.ToString());
5434 5425
5435 // The masked layer is 50x50, but the surface size is 10x20. So the texture 5426 // The masked layer is 50x50, but the surface size is 10x20. So the texture
5436 // coords in the mask are scaled by 10/50 and 20/50. 5427 // coords in the mask are scaled by 10/50 and 20/50.
5437 // The surface is clipped to (20,10) so the mask texture coords are offset 5428 // The surface is clipped to (20,10) so the mask texture coords are offset
5438 // by 20/50 and 10/50 5429 // by 20/50 and 10/50
5439 EXPECT_EQ(gfx::ScaleRect(gfx::RectF(20.f, 10.f, 10.f, 20.f), 5430 EXPECT_EQ(gfx::ScaleRect(gfx::RectF(20.f, 10.f, 10.f, 20.f),
5440 1.f / 50.f).ToString(), 5431 1.f / 50.f).ToString(),
5441 render_pass_quad->mask_uv_rect.ToString()); 5432 render_pass_quad->mask_uv_rect.ToString());
(...skipping 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after
6845 host_impl_->DidLoseOutputSurface(); 6836 host_impl_->DidLoseOutputSurface();
6846 EXPECT_TRUE(host_impl_->IsContextLost()); 6837 EXPECT_TRUE(host_impl_->IsContextLost());
6847 EXPECT_EQ(1, num_lost_surfaces_); 6838 EXPECT_EQ(1, num_lost_surfaces_);
6848 host_impl_->DidLoseOutputSurface(); 6839 host_impl_->DidLoseOutputSurface();
6849 EXPECT_TRUE(host_impl_->IsContextLost()); 6840 EXPECT_TRUE(host_impl_->IsContextLost());
6850 EXPECT_EQ(1, num_lost_surfaces_); 6841 EXPECT_EQ(1, num_lost_surfaces_);
6851 } 6842 }
6852 6843
6853 } // namespace 6844 } // namespace
6854 } // namespace cc 6845 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/render_pass_test_utils.cc ('k') | cc/trees/layer_tree_host_unittest_delegated.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698