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

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

Issue 1013463003: Update from https://crrev.com/320931 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: 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
« no previous file with comments | « cc/trees/layer_tree_host_pixeltest_masks.cc ('k') | cc/trees/layer_tree_impl.h » ('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.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"
11 #include "cc/animation/timing_function.h" 11 #include "cc/animation/timing_function.h"
12 #include "cc/base/swap_promise.h"
13 #include "cc/debug/frame_rate_counter.h" 12 #include "cc/debug/frame_rate_counter.h"
14 #include "cc/layers/content_layer.h" 13 #include "cc/layers/content_layer.h"
15 #include "cc/layers/content_layer_client.h" 14 #include "cc/layers/content_layer_client.h"
16 #include "cc/layers/io_surface_layer.h" 15 #include "cc/layers/io_surface_layer.h"
17 #include "cc/layers/layer_impl.h" 16 #include "cc/layers/layer_impl.h"
18 #include "cc/layers/painted_scrollbar_layer.h" 17 #include "cc/layers/painted_scrollbar_layer.h"
19 #include "cc/layers/picture_layer.h" 18 #include "cc/layers/picture_layer.h"
20 #include "cc/layers/solid_color_layer.h" 19 #include "cc/layers/solid_color_layer.h"
21 #include "cc/output/begin_frame_args.h" 20 #include "cc/output/begin_frame_args.h"
22 #include "cc/output/compositor_frame_ack.h" 21 #include "cc/output/compositor_frame_ack.h"
23 #include "cc/output/copy_output_request.h" 22 #include "cc/output/copy_output_request.h"
24 #include "cc/output/copy_output_result.h" 23 #include "cc/output/copy_output_result.h"
25 #include "cc/output/output_surface.h" 24 #include "cc/output/output_surface.h"
25 #include "cc/output/swap_promise.h"
26 #include "cc/quads/draw_quad.h" 26 #include "cc/quads/draw_quad.h"
27 #include "cc/quads/io_surface_draw_quad.h" 27 #include "cc/quads/io_surface_draw_quad.h"
28 #include "cc/quads/tile_draw_quad.h" 28 #include "cc/quads/tile_draw_quad.h"
29 #include "cc/resources/prioritized_resource.h" 29 #include "cc/resources/prioritized_resource.h"
30 #include "cc/resources/prioritized_resource_manager.h" 30 #include "cc/resources/prioritized_resource_manager.h"
31 #include "cc/resources/resource_update_queue.h" 31 #include "cc/resources/resource_update_queue.h"
32 #include "cc/test/fake_content_layer.h" 32 #include "cc/test/fake_content_layer.h"
33 #include "cc/test/fake_content_layer_client.h" 33 #include "cc/test/fake_content_layer_client.h"
34 #include "cc/test/fake_content_layer_impl.h" 34 #include "cc/test/fake_content_layer_impl.h"
35 #include "cc/test/fake_layer_tree_host_client.h" 35 #include "cc/test/fake_layer_tree_host_client.h"
(...skipping 2915 matching lines...) Expand 10 before | Expand all | Expand 10 after
2951 private: 2951 private:
2952 FakeContentLayerClient client_; 2952 FakeContentLayerClient client_;
2953 scoped_refptr<FakePictureLayer> layer_; 2953 scoped_refptr<FakePictureLayer> layer_;
2954 bool did_initialize_gl_; 2954 bool did_initialize_gl_;
2955 bool did_release_gl_; 2955 bool did_release_gl_;
2956 int last_source_frame_number_drawn_; 2956 int last_source_frame_number_drawn_;
2957 }; 2957 };
2958 2958
2959 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitialize); 2959 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitialize);
2960 2960
2961 class LayerTreeHostTestResourcelessSoftwareDraw : public LayerTreeHostTest {
2962 public:
2963 void SetupTree() override {
2964 root_layer_ = FakePictureLayer::Create(&client_);
2965 root_layer_->SetIsDrawable(true);
2966 root_layer_->SetBounds(gfx::Size(50, 50));
2967
2968 parent_layer_ = FakePictureLayer::Create(&client_);
2969 parent_layer_->SetIsDrawable(true);
2970 parent_layer_->SetBounds(gfx::Size(50, 50));
2971 parent_layer_->SetForceRenderSurface(true);
2972
2973 child_layer_ = FakePictureLayer::Create(&client_);
2974 child_layer_->SetIsDrawable(true);
2975 child_layer_->SetBounds(gfx::Size(50, 50));
2976
2977 root_layer_->AddChild(parent_layer_);
2978 parent_layer_->AddChild(child_layer_);
2979 layer_tree_host()->SetRootLayer(root_layer_);
2980
2981 LayerTreeHostTest::SetupTree();
2982 }
2983
2984 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override {
2985 return FakeOutputSurface::CreateDeferredGL(
2986 make_scoped_ptr(new SoftwareOutputDevice), delegating_renderer());
2987 }
2988
2989 void BeginTest() override {
2990 PostSetNeedsCommitToMainThread();
2991 swap_count_ = 0;
2992 }
2993
2994 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
2995 LayerTreeHostImpl::FrameData* frame_data,
2996 DrawResult draw_result) override {
2997 if (host_impl->GetDrawMode() == DRAW_MODE_RESOURCELESS_SOFTWARE) {
2998 EXPECT_EQ(1u, frame_data->render_passes.size());
2999 // Has at least 3 quads for each layer.
3000 RenderPass* render_pass = frame_data->render_passes[0];
3001 EXPECT_GE(render_pass->quad_list.size(), 3u);
3002 } else {
3003 EXPECT_EQ(2u, frame_data->render_passes.size());
3004
3005 // At least root layer quad in root render pass.
3006 EXPECT_GE(frame_data->render_passes[0]->quad_list.size(), 1u);
3007 // At least parent and child layer quads in parent render pass.
3008 EXPECT_GE(frame_data->render_passes[1]->quad_list.size(), 2u);
3009 }
3010 return draw_result;
3011 }
3012
3013 void SwapBuffersCompleteOnThread(LayerTreeHostImpl* host_impl) override {
3014 swap_count_++;
3015 switch (swap_count_) {
3016 case 1: {
3017 gfx::Transform identity;
3018 gfx::Rect empty_rect;
3019 bool resourceless_software_draw = true;
3020 host_impl->SetExternalDrawConstraints(identity, empty_rect, empty_rect,
3021 empty_rect, identity,
3022 resourceless_software_draw);
3023 host_impl->SetFullRootLayerDamage();
3024 host_impl->SetNeedsRedraw();
3025 break;
3026 }
3027 case 2:
3028 EndTest();
3029 break;
3030 default:
3031 NOTREACHED();
3032 }
3033 }
3034
3035 void AfterTest() override {}
3036
3037 private:
3038 FakeContentLayerClient client_;
3039 scoped_refptr<Layer> root_layer_;
3040 scoped_refptr<Layer> parent_layer_;
3041 scoped_refptr<Layer> child_layer_;
3042 int swap_count_;
3043 };
3044
3045 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestResourcelessSoftwareDraw);
3046
2961 class LayerTreeHostTestDeferredInitializeWithGpuRasterization 3047 class LayerTreeHostTestDeferredInitializeWithGpuRasterization
2962 : public LayerTreeHostTestDeferredInitialize { 3048 : public LayerTreeHostTestDeferredInitialize {
2963 void InitializeSettings(LayerTreeSettings* settings) override { 3049 void InitializeSettings(LayerTreeSettings* settings) override {
2964 // PictureLayer can only be used with impl side painting enabled. 3050 // PictureLayer can only be used with impl side painting enabled.
2965 settings->impl_side_painting = true; 3051 settings->impl_side_painting = true;
2966 settings->gpu_rasterization_enabled = true; 3052 settings->gpu_rasterization_enabled = true;
2967 settings->gpu_rasterization_forced = true; 3053 settings->gpu_rasterization_forced = true;
2968 } 3054 }
2969 }; 3055 };
2970 3056
(...skipping 2284 matching lines...) Expand 10 before | Expand all | Expand 10 after
5255 }; 5341 };
5256 5342
5257 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); 5343 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting);
5258 5344
5259 class LayerTreeHostTestSendBeginFramesToChildren : public LayerTreeHostTest { 5345 class LayerTreeHostTestSendBeginFramesToChildren : public LayerTreeHostTest {
5260 public: 5346 public:
5261 LayerTreeHostTestSendBeginFramesToChildren() 5347 LayerTreeHostTestSendBeginFramesToChildren()
5262 : begin_frame_sent_to_children_(false) { 5348 : begin_frame_sent_to_children_(false) {
5263 } 5349 }
5264 5350
5265 void InitializeSettings(LayerTreeSettings* settings) override {
5266 settings->forward_begin_frames_to_children = true;
5267 }
5268
5269 void BeginTest() override { 5351 void BeginTest() override {
5270 // Kick off the test with a commit. 5352 // Kick off the test with a commit.
5271 PostSetNeedsCommitToMainThread(); 5353 PostSetNeedsCommitToMainThread();
5272 } 5354 }
5273 5355
5274 void SendBeginFramesToChildren(const BeginFrameArgs& args) override { 5356 void SendBeginFramesToChildren(const BeginFrameArgs& args) override {
5275 begin_frame_sent_to_children_ = true; 5357 begin_frame_sent_to_children_ = true;
5276 EndTest(); 5358 EndTest();
5277 } 5359 }
5278 5360
(...skipping 16 matching lines...) Expand all
5295 5377
5296 class LayerTreeHostTestSendBeginFramesToChildrenWithExternalBFS 5378 class LayerTreeHostTestSendBeginFramesToChildrenWithExternalBFS
5297 : public LayerTreeHostTest { 5379 : public LayerTreeHostTest {
5298 public: 5380 public:
5299 LayerTreeHostTestSendBeginFramesToChildrenWithExternalBFS() 5381 LayerTreeHostTestSendBeginFramesToChildrenWithExternalBFS()
5300 : begin_frame_sent_to_children_(false) { 5382 : begin_frame_sent_to_children_(false) {
5301 } 5383 }
5302 5384
5303 void InitializeSettings(LayerTreeSettings* settings) override { 5385 void InitializeSettings(LayerTreeSettings* settings) override {
5304 settings->use_external_begin_frame_source = true; 5386 settings->use_external_begin_frame_source = true;
5305 settings->forward_begin_frames_to_children = true;
5306 } 5387 }
5307 5388
5308 void BeginTest() override { 5389 void BeginTest() override {
5309 // Kick off the test with a commit. 5390 // Kick off the test with a commit.
5310 PostSetNeedsCommitToMainThread(); 5391 PostSetNeedsCommitToMainThread();
5311 } 5392 }
5312 5393
5313 void SendBeginFramesToChildren(const BeginFrameArgs& args) override { 5394 void SendBeginFramesToChildren(const BeginFrameArgs& args) override {
5314 begin_frame_sent_to_children_ = true; 5395 begin_frame_sent_to_children_ = true;
5315 EndTest(); 5396 EndTest();
(...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after
6337 6418
6338 void AfterTest() override {} 6419 void AfterTest() override {}
6339 6420
6340 private: 6421 private:
6341 scoped_refptr<Layer> child_; 6422 scoped_refptr<Layer> child_;
6342 }; 6423 };
6343 6424
6344 SINGLE_AND_MULTI_THREAD_TEST_F(LayerPreserveRenderSurfaceFromOutputRequests); 6425 SINGLE_AND_MULTI_THREAD_TEST_F(LayerPreserveRenderSurfaceFromOutputRequests);
6345 6426
6346 } // namespace cc 6427 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_pixeltest_masks.cc ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698