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

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

Issue 2102833002: cc: Fixup cc to not use auto to deduce a raw pointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 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
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.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 : did_notify_ready_to_activate_(false), 232 : did_notify_ready_to_activate_(false),
233 all_tiles_required_for_activation_are_ready_to_draw_(false), 233 all_tiles_required_for_activation_are_ready_to_draw_(false),
234 required_for_activation_count_(0) {} 234 required_for_activation_count_(0) {}
235 235
236 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 236 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
237 237
238 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { 238 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override {
239 const std::vector<PictureLayerImpl*>& layers = 239 const std::vector<PictureLayerImpl*>& layers =
240 impl->sync_tree()->picture_layers(); 240 impl->sync_tree()->picture_layers();
241 required_for_activation_count_ = 0; 241 required_for_activation_count_ = 0;
242 for (const auto& layer : layers) { 242 for (auto* layer : layers) {
243 FakePictureLayerImpl* fake_layer = 243 FakePictureLayerImpl* fake_layer =
244 static_cast<FakePictureLayerImpl*>(layer); 244 static_cast<FakePictureLayerImpl*>(layer);
245 required_for_activation_count_ += 245 required_for_activation_count_ +=
246 fake_layer->CountTilesRequiredForActivation(); 246 fake_layer->CountTilesRequiredForActivation();
247 } 247 }
248 } 248 }
249 249
250 void NotifyReadyToActivateOnThread(LayerTreeHostImpl* impl) override { 250 void NotifyReadyToActivateOnThread(LayerTreeHostImpl* impl) override {
251 did_notify_ready_to_activate_ = true; 251 did_notify_ready_to_activate_ = true;
252 all_tiles_required_for_activation_are_ready_to_draw_ = 252 all_tiles_required_for_activation_are_ready_to_draw_ =
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 required_for_draw_count_(0) {} 309 required_for_draw_count_(0) {}
310 310
311 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 311 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
312 312
313 void NotifyReadyToDrawOnThread(LayerTreeHostImpl* impl) override { 313 void NotifyReadyToDrawOnThread(LayerTreeHostImpl* impl) override {
314 did_notify_ready_to_draw_ = true; 314 did_notify_ready_to_draw_ = true;
315 const std::vector<PictureLayerImpl*>& layers = 315 const std::vector<PictureLayerImpl*>& layers =
316 impl->active_tree()->picture_layers(); 316 impl->active_tree()->picture_layers();
317 all_tiles_required_for_draw_are_ready_to_draw_ = 317 all_tiles_required_for_draw_are_ready_to_draw_ =
318 impl->tile_manager()->IsReadyToDraw(); 318 impl->tile_manager()->IsReadyToDraw();
319 for (const auto& layer : layers) { 319 for (auto* layer : layers) {
320 FakePictureLayerImpl* fake_layer = 320 FakePictureLayerImpl* fake_layer =
321 static_cast<FakePictureLayerImpl*>(layer); 321 static_cast<FakePictureLayerImpl*>(layer);
322 required_for_draw_count_ += fake_layer->CountTilesRequiredForDraw(); 322 required_for_draw_count_ += fake_layer->CountTilesRequiredForDraw();
323 } 323 }
324 324
325 EndTest(); 325 EndTest();
326 } 326 }
327 327
328 void AfterTest() override { 328 void AfterTest() override {
329 EXPECT_TRUE(did_notify_ready_to_draw_); 329 EXPECT_TRUE(did_notify_ready_to_draw_);
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 1375
1376 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { 1376 void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
1377 if (num_draws_ < 2) { 1377 if (num_draws_ < 2) {
1378 PostSetNeedsRedrawRectToMainThread(invalid_rect_); 1378 PostSetNeedsRedrawRectToMainThread(invalid_rect_);
1379 num_draws_++; 1379 num_draws_++;
1380 } 1380 }
1381 } 1381 }
1382 1382
1383 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { 1383 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
1384 if (num_draws_ == 2) { 1384 if (num_draws_ == 2) {
1385 auto pending_tree = host_impl->pending_tree(); 1385 auto* pending_tree = host_impl->pending_tree();
1386 auto pending_layer_impl = static_cast<FakePictureLayerImpl*>( 1386 auto* pending_layer_impl = static_cast<FakePictureLayerImpl*>(
1387 pending_tree->root_layer_for_testing()); 1387 pending_tree->root_layer_for_testing());
1388 EXPECT_NE(pending_layer_impl, nullptr); 1388 EXPECT_NE(pending_layer_impl, nullptr);
1389 1389
1390 auto active_tree = host_impl->pending_tree(); 1390 auto* active_tree = host_impl->pending_tree();
1391 auto active_layer_impl = static_cast<FakePictureLayerImpl*>( 1391 auto* active_layer_impl = static_cast<FakePictureLayerImpl*>(
1392 active_tree->root_layer_for_testing()); 1392 active_tree->root_layer_for_testing());
1393 EXPECT_NE(pending_layer_impl, nullptr); 1393 EXPECT_NE(pending_layer_impl, nullptr);
1394 1394
1395 auto active_tiling_set = active_layer_impl->picture_layer_tiling_set(); 1395 auto* active_tiling_set = active_layer_impl->picture_layer_tiling_set();
1396 auto active_tiling = active_tiling_set->tiling_at(0); 1396 auto* active_tiling = active_tiling_set->tiling_at(0);
1397 auto pending_tiling_set = pending_layer_impl->picture_layer_tiling_set(); 1397 auto* pending_tiling_set = pending_layer_impl->picture_layer_tiling_set();
1398 auto pending_tiling = pending_tiling_set->tiling_at(0); 1398 auto* pending_tiling = pending_tiling_set->tiling_at(0);
1399 EXPECT_EQ( 1399 EXPECT_EQ(
1400 pending_tiling->TilingDataForTesting().max_texture_size().width(), 1400 pending_tiling->TilingDataForTesting().max_texture_size().width(),
1401 active_tiling->TilingDataForTesting().max_texture_size().width()); 1401 active_tiling->TilingDataForTesting().max_texture_size().width());
1402 EndTest(); 1402 EndTest();
1403 } 1403 }
1404 } 1404 }
1405 1405
1406 void DidCommitAndDrawFrame() override { 1406 void DidCommitAndDrawFrame() override {
1407 // On the second commit, resize the viewport. 1407 // On the second commit, resize the viewport.
1408 if (num_draws_ == 1) { 1408 if (num_draws_ == 1) {
(...skipping 4100 matching lines...) Expand 10 before | Expand all | Expand 10 after
5509 client_.set_bounds(root_clip->bounds()); 5509 client_.set_bounds(root_clip->bounds());
5510 } 5510 }
5511 5511
5512 // Returns the delta scale of all quads in the frame's root pass from their 5512 // Returns the delta scale of all quads in the frame's root pass from their
5513 // ideal, or 0 if they are not all the same. 5513 // ideal, or 0 if they are not all the same.
5514 float FrameQuadScaleDeltaFromIdeal(LayerTreeHostImpl::FrameData* frame_data) { 5514 float FrameQuadScaleDeltaFromIdeal(LayerTreeHostImpl::FrameData* frame_data) {
5515 if (frame_data->has_no_damage) 5515 if (frame_data->has_no_damage)
5516 return 0.f; 5516 return 0.f;
5517 float frame_scale = 0.f; 5517 float frame_scale = 0.f;
5518 RenderPass* root_pass = frame_data->render_passes.back().get(); 5518 RenderPass* root_pass = frame_data->render_passes.back().get();
5519 for (const auto& draw_quad : root_pass->quad_list) { 5519 for (auto* draw_quad : root_pass->quad_list) {
5520 // Checkerboards mean an incomplete frame. 5520 // Checkerboards mean an incomplete frame.
5521 if (draw_quad->material != DrawQuad::TILED_CONTENT) 5521 if (draw_quad->material != DrawQuad::TILED_CONTENT)
5522 return 0.f; 5522 return 0.f;
5523 const TileDrawQuad* quad = TileDrawQuad::MaterialCast(draw_quad); 5523 const TileDrawQuad* quad = TileDrawQuad::MaterialCast(draw_quad);
5524 float quad_scale = 5524 float quad_scale =
5525 quad->tex_coord_rect.width() / static_cast<float>(quad->rect.width()); 5525 quad->tex_coord_rect.width() / static_cast<float>(quad->rect.width());
5526 float transform_scale = SkMScalarToFloat( 5526 float transform_scale = SkMScalarToFloat(
5527 quad->shared_quad_state->quad_to_target_transform.matrix().get(0, 0)); 5527 quad->shared_quad_state->quad_to_target_transform.matrix().get(0, 0));
5528 float scale = quad_scale / transform_scale; 5528 float scale = quad_scale / transform_scale;
5529 if (frame_scale != 0.f && frame_scale != scale) 5529 if (frame_scale != 0.f && frame_scale != scale)
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
5812 client_.set_bounds(root_clip->bounds()); 5812 client_.set_bounds(root_clip->bounds());
5813 } 5813 }
5814 5814
5815 // Returns the delta scale of all quads in the frame's root pass from their 5815 // Returns the delta scale of all quads in the frame's root pass from their
5816 // ideal, or 0 if they are not all the same. 5816 // ideal, or 0 if they are not all the same.
5817 float FrameQuadScaleDeltaFromIdeal(LayerTreeHostImpl::FrameData* frame_data) { 5817 float FrameQuadScaleDeltaFromIdeal(LayerTreeHostImpl::FrameData* frame_data) {
5818 if (frame_data->has_no_damage) 5818 if (frame_data->has_no_damage)
5819 return 0.f; 5819 return 0.f;
5820 float frame_scale = 0.f; 5820 float frame_scale = 0.f;
5821 RenderPass* root_pass = frame_data->render_passes.back().get(); 5821 RenderPass* root_pass = frame_data->render_passes.back().get();
5822 for (const auto& draw_quad : root_pass->quad_list) { 5822 for (auto* draw_quad : root_pass->quad_list) {
5823 const TileDrawQuad* quad = TileDrawQuad::MaterialCast(draw_quad); 5823 const TileDrawQuad* quad = TileDrawQuad::MaterialCast(draw_quad);
5824 float quad_scale = 5824 float quad_scale =
5825 quad->tex_coord_rect.width() / static_cast<float>(quad->rect.width()); 5825 quad->tex_coord_rect.width() / static_cast<float>(quad->rect.width());
5826 float transform_scale = SkMScalarToFloat( 5826 float transform_scale = SkMScalarToFloat(
5827 quad->shared_quad_state->quad_to_target_transform.matrix().get(0, 0)); 5827 quad->shared_quad_state->quad_to_target_transform.matrix().get(0, 0));
5828 float scale = quad_scale / transform_scale; 5828 float scale = quad_scale / transform_scale;
5829 if (frame_scale != 0.f && frame_scale != scale) 5829 if (frame_scale != 0.f && frame_scale != scale)
5830 return 0.f; 5830 return 0.f;
5831 frame_scale = scale; 5831 frame_scale = scale;
5832 } 5832 }
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after
6873 private: 6873 private:
6874 FakeContentLayerClient client_; 6874 FakeContentLayerClient client_;
6875 const gfx::Size viewport_size_; 6875 const gfx::Size viewport_size_;
6876 const gfx::Size large_image_size_; 6876 const gfx::Size large_image_size_;
6877 }; 6877 };
6878 6878
6879 SINGLE_AND_MULTI_THREAD_TEST_F(GpuRasterizationSucceedsWithLargeImage); 6879 SINGLE_AND_MULTI_THREAD_TEST_F(GpuRasterizationSucceedsWithLargeImage);
6880 6880
6881 } // namespace 6881 } // namespace
6882 } // namespace cc 6882 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | cc/trees/layer_tree_host_unittest_serialization.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698