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

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: addmissingfile 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
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 5115 matching lines...) Expand 10 before | Expand all | Expand 10 after
5126 { 5126 {
5127 LayerTreeHostImpl::FrameData frame; 5127 LayerTreeHostImpl::FrameData frame;
5128 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 5128 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5129 5129
5130 ASSERT_EQ(1u, frame.render_passes.size()); 5130 ASSERT_EQ(1u, frame.render_passes.size());
5131 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 5131 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
5132 ASSERT_EQ(DrawQuad::RENDER_PASS, 5132 ASSERT_EQ(DrawQuad::RENDER_PASS,
5133 frame.render_passes[0]->quad_list[1]->material); 5133 frame.render_passes[0]->quad_list[1]->material);
5134 const RenderPassDrawQuad* replica_quad = 5134 const RenderPassDrawQuad* replica_quad =
5135 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 5135 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
5136 EXPECT_TRUE(replica_quad->is_replica);
5137 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), 5136 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(),
5138 replica_quad->rect.ToString()); 5137 replica_quad->rect.ToString());
5139 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 5138 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
5140 replica_quad->mask_uv_rect.ToString()); 5139 replica_quad->mask_uv_rect.ToString());
5141 5140
5142 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5141 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5143 host_impl_->DidDrawAllLayers(frame); 5142 host_impl_->DidDrawAllLayers(frame);
5144 } 5143 }
5145 5144
5146 // Applying a DSF should change the render surface size, but won't affect 5145 // Applying a DSF should change the render surface size, but won't affect
5147 // which part of the mask is used. 5146 // which part of the mask is used.
5148 device_scale_factor = 2.f; 5147 device_scale_factor = 2.f;
5149 gfx::Size device_viewport = 5148 gfx::Size device_viewport =
5150 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); 5149 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor));
5151 host_impl_->SetViewportSize(device_viewport); 5150 host_impl_->SetViewportSize(device_viewport);
5152 host_impl_->SetDeviceScaleFactor(device_scale_factor); 5151 host_impl_->SetDeviceScaleFactor(device_scale_factor);
5153 host_impl_->active_tree()->set_needs_update_draw_properties(); 5152 host_impl_->active_tree()->set_needs_update_draw_properties();
5154 { 5153 {
5155 LayerTreeHostImpl::FrameData frame; 5154 LayerTreeHostImpl::FrameData frame;
5156 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 5155 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5157 5156
5158 ASSERT_EQ(1u, frame.render_passes.size()); 5157 ASSERT_EQ(1u, frame.render_passes.size());
5159 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 5158 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
5160 ASSERT_EQ(DrawQuad::RENDER_PASS, 5159 ASSERT_EQ(DrawQuad::RENDER_PASS,
5161 frame.render_passes[0]->quad_list[1]->material); 5160 frame.render_passes[0]->quad_list[1]->material);
5162 const RenderPassDrawQuad* replica_quad = 5161 const RenderPassDrawQuad* replica_quad =
5163 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 5162 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
5164 EXPECT_TRUE(replica_quad->is_replica);
5165 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 5163 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
5166 replica_quad->rect.ToString()); 5164 replica_quad->rect.ToString());
5167 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 5165 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
5168 replica_quad->mask_uv_rect.ToString()); 5166 replica_quad->mask_uv_rect.ToString());
5169 5167
5170 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5168 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5171 host_impl_->DidDrawAllLayers(frame); 5169 host_impl_->DidDrawAllLayers(frame);
5172 } 5170 }
5173 5171
5174 // Applying an equivalent content scale on the content layer and the mask 5172 // Applying an equivalent content scale on the content layer and the mask
(...skipping 10 matching lines...) Expand all
5185 { 5183 {
5186 LayerTreeHostImpl::FrameData frame; 5184 LayerTreeHostImpl::FrameData frame;
5187 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 5185 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5188 5186
5189 ASSERT_EQ(1u, frame.render_passes.size()); 5187 ASSERT_EQ(1u, frame.render_passes.size());
5190 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 5188 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
5191 ASSERT_EQ(DrawQuad::RENDER_PASS, 5189 ASSERT_EQ(DrawQuad::RENDER_PASS,
5192 frame.render_passes[0]->quad_list[1]->material); 5190 frame.render_passes[0]->quad_list[1]->material);
5193 const RenderPassDrawQuad* replica_quad = 5191 const RenderPassDrawQuad* replica_quad =
5194 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 5192 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
5195 EXPECT_TRUE(replica_quad->is_replica);
5196 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 5193 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
5197 replica_quad->rect.ToString()); 5194 replica_quad->rect.ToString());
5198 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 5195 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
5199 replica_quad->mask_uv_rect.ToString()); 5196 replica_quad->mask_uv_rect.ToString());
5200 5197
5201 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5198 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5202 host_impl_->DidDrawAllLayers(frame); 5199 host_impl_->DidDrawAllLayers(frame);
5203 } 5200 }
5204 5201
5205 // Applying a different contents scale to the mask layer means it will have 5202 // Applying a different contents scale to the mask layer means it will have
5206 // a larger texture, but it should use the same tex coords to cover the 5203 // a larger texture, but it should use the same tex coords to cover the
5207 // layer it masks. 5204 // layer it masks.
5208 mask_layer->SetContentBounds(mask_size); 5205 mask_layer->SetContentBounds(mask_size);
5209 mask_layer->SetContentsScale(1.f, 1.f); 5206 mask_layer->SetContentsScale(1.f, 1.f);
5210 host_impl_->active_tree()->set_needs_update_draw_properties(); 5207 host_impl_->active_tree()->set_needs_update_draw_properties();
5211 { 5208 {
5212 LayerTreeHostImpl::FrameData frame; 5209 LayerTreeHostImpl::FrameData frame;
5213 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 5210 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5214 5211
5215 ASSERT_EQ(1u, frame.render_passes.size()); 5212 ASSERT_EQ(1u, frame.render_passes.size());
5216 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 5213 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
5217 ASSERT_EQ(DrawQuad::RENDER_PASS, 5214 ASSERT_EQ(DrawQuad::RENDER_PASS,
5218 frame.render_passes[0]->quad_list[1]->material); 5215 frame.render_passes[0]->quad_list[1]->material);
5219 const RenderPassDrawQuad* replica_quad = 5216 const RenderPassDrawQuad* replica_quad =
5220 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 5217 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
5221 EXPECT_TRUE(replica_quad->is_replica);
5222 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 5218 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
5223 replica_quad->rect.ToString()); 5219 replica_quad->rect.ToString());
5224 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 5220 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
5225 replica_quad->mask_uv_rect.ToString()); 5221 replica_quad->mask_uv_rect.ToString());
5226 5222
5227 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5223 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5228 host_impl_->DidDrawAllLayers(frame); 5224 host_impl_->DidDrawAllLayers(frame);
5229 } 5225 }
5230 } 5226 }
5231 5227
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
5289 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 5285 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5290 5286
5291 ASSERT_EQ(1u, frame.render_passes.size()); 5287 ASSERT_EQ(1u, frame.render_passes.size());
5292 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 5288 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
5293 5289
5294 // The surface is 100x50. 5290 // The surface is 100x50.
5295 ASSERT_EQ(DrawQuad::RENDER_PASS, 5291 ASSERT_EQ(DrawQuad::RENDER_PASS,
5296 frame.render_passes[0]->quad_list[0]->material); 5292 frame.render_passes[0]->quad_list[0]->material);
5297 const RenderPassDrawQuad* render_pass_quad = 5293 const RenderPassDrawQuad* render_pass_quad =
5298 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 5294 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
5299 EXPECT_FALSE(render_pass_quad->is_replica);
5300 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), 5295 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(),
5301 render_pass_quad->rect.ToString()); 5296 render_pass_quad->rect.ToString());
5302 5297
5303 // The mask covers the owning layer only. 5298 // The mask covers the owning layer only.
5304 ASSERT_EQ(DrawQuad::RENDER_PASS, 5299 ASSERT_EQ(DrawQuad::RENDER_PASS,
5305 frame.render_passes[0]->quad_list[1]->material); 5300 frame.render_passes[0]->quad_list[1]->material);
5306 const RenderPassDrawQuad* replica_quad = 5301 const RenderPassDrawQuad* replica_quad =
5307 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 5302 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
5308 EXPECT_TRUE(replica_quad->is_replica);
5309 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), 5303 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(),
5310 replica_quad->rect.ToString()); 5304 replica_quad->rect.ToString());
5311 EXPECT_EQ(gfx::RectF(0.f, 0.f, 2.f, 1.f).ToString(), 5305 EXPECT_EQ(gfx::RectF(0.f, 0.f, 2.f, 1.f).ToString(),
5312 replica_quad->mask_uv_rect.ToString()); 5306 replica_quad->mask_uv_rect.ToString());
5313 5307
5314 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5308 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5315 host_impl_->DidDrawAllLayers(frame); 5309 host_impl_->DidDrawAllLayers(frame);
5316 } 5310 }
5317 5311
5318 // Move the child to (-50, 0) instead. Now the mask should be moved to still 5312 // Move the child to (-50, 0) instead. Now the mask should be moved to still
5319 // cover the layer being replicated. 5313 // cover the layer being replicated.
5320 content_child_layer->SetPosition(gfx::Point(-50, 0)); 5314 content_child_layer->SetPosition(gfx::Point(-50, 0));
5321 { 5315 {
5322 LayerTreeHostImpl::FrameData frame; 5316 LayerTreeHostImpl::FrameData frame;
5323 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 5317 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5324 5318
5325 ASSERT_EQ(1u, frame.render_passes.size()); 5319 ASSERT_EQ(1u, frame.render_passes.size());
5326 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 5320 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
5327 5321
5328 // The surface is 100x50 with its origin at (-50, 0). 5322 // The surface is 100x50 with its origin at (-50, 0).
5329 ASSERT_EQ(DrawQuad::RENDER_PASS, 5323 ASSERT_EQ(DrawQuad::RENDER_PASS,
5330 frame.render_passes[0]->quad_list[0]->material); 5324 frame.render_passes[0]->quad_list[0]->material);
5331 const RenderPassDrawQuad* render_pass_quad = 5325 const RenderPassDrawQuad* render_pass_quad =
5332 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 5326 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
5333 EXPECT_FALSE(render_pass_quad->is_replica);
5334 EXPECT_EQ(gfx::Rect(-50, 0, 100, 50).ToString(), 5327 EXPECT_EQ(gfx::Rect(-50, 0, 100, 50).ToString(),
5335 render_pass_quad->rect.ToString()); 5328 render_pass_quad->rect.ToString());
5336 5329
5337 // The mask covers the owning layer only. 5330 // The mask covers the owning layer only.
5338 ASSERT_EQ(DrawQuad::RENDER_PASS, 5331 ASSERT_EQ(DrawQuad::RENDER_PASS,
5339 frame.render_passes[0]->quad_list[1]->material); 5332 frame.render_passes[0]->quad_list[1]->material);
5340 const RenderPassDrawQuad* replica_quad = 5333 const RenderPassDrawQuad* replica_quad =
5341 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 5334 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
5342 EXPECT_TRUE(replica_quad->is_replica);
5343 EXPECT_EQ(gfx::Rect(-50, 0, 100, 50).ToString(), 5335 EXPECT_EQ(gfx::Rect(-50, 0, 100, 50).ToString(),
5344 replica_quad->rect.ToString()); 5336 replica_quad->rect.ToString());
5345 EXPECT_EQ(gfx::RectF(-1.f, 0.f, 2.f, 1.f).ToString(), 5337 EXPECT_EQ(gfx::RectF(-1.f, 0.f, 2.f, 1.f).ToString(),
5346 replica_quad->mask_uv_rect.ToString()); 5338 replica_quad->mask_uv_rect.ToString());
5347 5339
5348 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5340 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5349 host_impl_->DidDrawAllLayers(frame); 5341 host_impl_->DidDrawAllLayers(frame);
5350 } 5342 }
5351 } 5343 }
5352 5344
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
5417 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 5409 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5418 5410
5419 ASSERT_EQ(1u, frame.render_passes.size()); 5411 ASSERT_EQ(1u, frame.render_passes.size());
5420 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 5412 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
5421 5413
5422 // The surface is clipped to 10x20. 5414 // The surface is clipped to 10x20.
5423 ASSERT_EQ(DrawQuad::RENDER_PASS, 5415 ASSERT_EQ(DrawQuad::RENDER_PASS,
5424 frame.render_passes[0]->quad_list[0]->material); 5416 frame.render_passes[0]->quad_list[0]->material);
5425 const RenderPassDrawQuad* render_pass_quad = 5417 const RenderPassDrawQuad* render_pass_quad =
5426 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 5418 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
5427 EXPECT_FALSE(render_pass_quad->is_replica);
5428 EXPECT_EQ(gfx::Rect(20, 10, 10, 20).ToString(), 5419 EXPECT_EQ(gfx::Rect(20, 10, 10, 20).ToString(),
5429 render_pass_quad->rect.ToString()); 5420 render_pass_quad->rect.ToString());
5430 5421
5431 // The masked layer is 50x50, but the surface size is 10x20. So the texture 5422 // The masked layer is 50x50, but the surface size is 10x20. So the texture
5432 // coords in the mask are scaled by 10/50 and 20/50. 5423 // coords in the mask are scaled by 10/50 and 20/50.
5433 // The surface is clipped to (20,10) so the mask texture coords are offset 5424 // The surface is clipped to (20,10) so the mask texture coords are offset
5434 // by 20/50 and 10/50 5425 // by 20/50 and 10/50
5435 EXPECT_EQ(gfx::ScaleRect(gfx::RectF(20.f, 10.f, 10.f, 20.f), 5426 EXPECT_EQ(gfx::ScaleRect(gfx::RectF(20.f, 10.f, 10.f, 20.f),
5436 1.f / 50.f).ToString(), 5427 1.f / 50.f).ToString(),
5437 render_pass_quad->mask_uv_rect.ToString()); 5428 render_pass_quad->mask_uv_rect.ToString());
(...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after
6810 EXPECT_EQ(1u, raw_mask_layer->did_become_active_call_count()); 6801 EXPECT_EQ(1u, raw_mask_layer->did_become_active_call_count());
6811 EXPECT_EQ(0u, raw_replica_mask_layer->did_become_active_call_count()); 6802 EXPECT_EQ(0u, raw_replica_mask_layer->did_become_active_call_count());
6812 pending_tree->DidBecomeActive(); 6803 pending_tree->DidBecomeActive();
6813 EXPECT_EQ(3u, raw_pending_layer->did_become_active_call_count()); 6804 EXPECT_EQ(3u, raw_pending_layer->did_become_active_call_count());
6814 EXPECT_EQ(2u, raw_mask_layer->did_become_active_call_count()); 6805 EXPECT_EQ(2u, raw_mask_layer->did_become_active_call_count());
6815 EXPECT_EQ(1u, raw_replica_mask_layer->did_become_active_call_count()); 6806 EXPECT_EQ(1u, raw_replica_mask_layer->did_become_active_call_count());
6816 } 6807 }
6817 6808
6818 } // namespace 6809 } // namespace
6819 } // namespace cc 6810 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698