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

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

Issue 1024633002: cc: Keep tilings texture size in sync (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address vmp's comments Created 5 years, 9 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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 private: 468 private:
469 int num_draws_; 469 int num_draws_;
470 const gfx::Size bounds_; 470 const gfx::Size bounds_;
471 const gfx::Rect invalid_rect_; 471 const gfx::Rect invalid_rect_;
472 FakeContentLayerClient client_; 472 FakeContentLayerClient client_;
473 scoped_refptr<Layer> root_layer_; 473 scoped_refptr<Layer> root_layer_;
474 }; 474 };
475 475
476 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsRedrawRect); 476 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsRedrawRect);
477 477
478 // Ensure the texture size of the pending and active trees are identical when a
479 // layer is not in the viewport and a resize happens on the viewport
480 class LayerTreeHostTestGpuRasterDeviceSizeChanged : public LayerTreeHostTest {
481 public:
482 LayerTreeHostTestGpuRasterDeviceSizeChanged()
483 : num_draws_(0), bounds_(500, 64), invalid_rect_(10, 10, 20, 20) {}
484
485 void BeginTest() override {
486 client_.set_fill_with_nonsolid_color(true);
487 root_layer_ = FakePictureLayer::Create(&client_);
488 root_layer_->SetIsDrawable(true);
489 gfx::Transform transform;
490 // Translate the layer out of the viewport to force it to not update its
491 // tile size via PushProperties.
492 transform.Translate(10000.0, 10000.0);
493 root_layer_->SetTransform(transform);
494 root_layer_->SetBounds(bounds_);
495 layer_tree_host()->SetRootLayer(root_layer_);
496 layer_tree_host()->SetViewportSize(bounds_);
497
498 PostSetNeedsCommitToMainThread();
499 }
500
501 void InitializeSettings(LayerTreeSettings* settings) override {
502 settings->gpu_rasterization_enabled = true;
503 settings->gpu_rasterization_forced = true;
504 }
505
506 void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
507 // Perform 2 commits.
508 if (!num_draws_) {
509 PostSetNeedsRedrawRectToMainThread(invalid_rect_);
510 } else {
511 EndTest();
512 }
513 num_draws_++;
514 }
515
516 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
517 if (num_draws_ == 2) {
518 auto pending_tree = host_impl->pending_tree();
519 auto pending_layer_impl =
520 static_cast<FakePictureLayerImpl*>(pending_tree->root_layer());
521 EXPECT_NE(pending_layer_impl, nullptr);
522
523 auto active_tree = host_impl->pending_tree();
524 auto active_layer_impl =
525 static_cast<FakePictureLayerImpl*>(active_tree->root_layer());
526 EXPECT_NE(pending_layer_impl, nullptr);
527
528 auto active_tiling_set = active_layer_impl->picture_layer_tiling_set();
529 auto active_tiling = active_tiling_set->tiling_at(0);
530 auto pending_tiling_set = pending_layer_impl->picture_layer_tiling_set();
531 auto pending_tiling = pending_tiling_set->tiling_at(0);
532 EXPECT_EQ(
533 pending_tiling->TilingDataForTesting().max_texture_size().width(),
534 active_tiling->TilingDataForTesting().max_texture_size().width());
535 }
536 }
537
538 void DidCommitAndDrawFrame() override {
539 // On the second commit, resize the viewport.
540 if (num_draws_ == 1) {
541 layer_tree_host()->SetViewportSize(gfx::Size(400, 64));
542 }
543 }
544
545 void AfterTest() override {}
546
547 private:
548 int num_draws_;
549 const gfx::Size bounds_;
550 const gfx::Rect invalid_rect_;
551 FakeContentLayerClient client_;
552 scoped_refptr<FakePictureLayer> root_layer_;
553 };
554
555 SINGLE_AND_MULTI_THREAD_IMPL_TEST_F(
556 LayerTreeHostTestGpuRasterDeviceSizeChanged);
557
478 class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest { 558 class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest {
479 public: 559 public:
480 void InitializeSettings(LayerTreeSettings* settings) override { 560 void InitializeSettings(LayerTreeSettings* settings) override {
481 settings->layer_transforms_should_scale_layer_contents = true; 561 settings->layer_transforms_should_scale_layer_contents = true;
482 } 562 }
483 563
484 void SetupTree() override { 564 void SetupTree() override {
485 root_layer_ = Layer::Create(); 565 root_layer_ = Layer::Create();
486 root_layer_->SetBounds(gfx::Size(10, 20)); 566 root_layer_->SetBounds(gfx::Size(10, 20));
487 root_layer_->CreateRenderSurface(); 567 root_layer_->CreateRenderSurface();
(...skipping 5873 matching lines...) Expand 10 before | Expand all | Expand 10 after
6361 6441
6362 void AfterTest() override {} 6442 void AfterTest() override {}
6363 6443
6364 private: 6444 private:
6365 scoped_refptr<Layer> child_; 6445 scoped_refptr<Layer> child_;
6366 }; 6446 };
6367 6447
6368 SINGLE_AND_MULTI_THREAD_TEST_F(LayerPreserveRenderSurfaceFromOutputRequests); 6448 SINGLE_AND_MULTI_THREAD_TEST_F(LayerPreserveRenderSurfaceFromOutputRequests);
6369 6449
6370 } // namespace cc 6450 } // namespace cc
OLDNEW
« cc/layers/picture_layer_impl.h ('K') | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698