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

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

Issue 1007623002: Fix resourceless software draw (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: EXPECT_GE 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_common_unittest.cc ('k') | no next file » | 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"
(...skipping 2942 matching lines...) Expand 10 before | Expand all | Expand 10 after
2953 private: 2953 private:
2954 FakeContentLayerClient client_; 2954 FakeContentLayerClient client_;
2955 scoped_refptr<FakePictureLayer> layer_; 2955 scoped_refptr<FakePictureLayer> layer_;
2956 bool did_initialize_gl_; 2956 bool did_initialize_gl_;
2957 bool did_release_gl_; 2957 bool did_release_gl_;
2958 int last_source_frame_number_drawn_; 2958 int last_source_frame_number_drawn_;
2959 }; 2959 };
2960 2960
2961 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitialize); 2961 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitialize);
2962 2962
2963 class LayerTreeHostTestResourcelessSoftwareDraw : public LayerTreeHostTest {
2964 public:
2965 void SetupTree() override {
2966 root_layer_ = FakePictureLayer::Create(&client_);
2967 root_layer_->SetIsDrawable(true);
2968 root_layer_->SetBounds(gfx::Size(50, 50));
2969
2970 parent_layer_ = FakePictureLayer::Create(&client_);
2971 parent_layer_->SetIsDrawable(true);
2972 parent_layer_->SetBounds(gfx::Size(50, 50));
2973 parent_layer_->SetForceRenderSurface(true);
2974
2975 child_layer_ = FakePictureLayer::Create(&client_);
2976 child_layer_->SetIsDrawable(true);
2977 child_layer_->SetBounds(gfx::Size(50, 50));
2978
2979 root_layer_->AddChild(parent_layer_);
2980 parent_layer_->AddChild(child_layer_);
2981 layer_tree_host()->SetRootLayer(root_layer_);
2982
2983 LayerTreeHostTest::SetupTree();
2984 }
2985
2986 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override {
2987 return FakeOutputSurface::CreateDeferredGL(
2988 make_scoped_ptr(new SoftwareOutputDevice), delegating_renderer());
2989 }
2990
2991 void BeginTest() override {
2992 PostSetNeedsCommitToMainThread();
2993 swap_count_ = 0;
2994 }
2995
2996 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
2997 LayerTreeHostImpl::FrameData* frame_data,
2998 DrawResult draw_result) override {
2999 if (host_impl->GetDrawMode() == DRAW_MODE_RESOURCELESS_SOFTWARE) {
3000 EXPECT_EQ(1u, frame_data->render_passes.size());
3001 // Has at least 3 quads for each layer.
3002 RenderPass* render_pass = frame_data->render_passes[0];
3003 EXPECT_GE(render_pass->quad_list.size(), 3u);
3004 } else {
3005 EXPECT_EQ(2u, frame_data->render_passes.size());
3006
3007 // At least root layer quad in root render pass.
3008 EXPECT_GE(frame_data->render_passes[0]->quad_list.size(), 1u);
3009 // At least parent and child layer quads in parent render pass.
3010 EXPECT_GE(frame_data->render_passes[1]->quad_list.size(), 2u);
3011 }
3012 return draw_result;
3013 }
3014
3015 void SwapBuffersCompleteOnThread(LayerTreeHostImpl* host_impl) override {
3016 swap_count_++;
3017 switch (swap_count_) {
3018 case 1: {
3019 gfx::Transform identity;
3020 gfx::Rect empty_rect;
3021 bool resourceless_software_draw = true;
3022 host_impl->SetExternalDrawConstraints(identity, empty_rect, empty_rect,
3023 empty_rect, identity,
3024 resourceless_software_draw);
3025 host_impl->SetFullRootLayerDamage();
3026 host_impl->SetNeedsRedraw();
3027 break;
3028 }
3029 case 2:
3030 EndTest();
3031 break;
3032 default:
3033 NOTREACHED();
3034 }
3035 }
3036
3037 void AfterTest() override {}
3038
3039 private:
3040 FakeContentLayerClient client_;
3041 scoped_refptr<Layer> root_layer_;
3042 scoped_refptr<Layer> parent_layer_;
3043 scoped_refptr<Layer> child_layer_;
3044 int swap_count_;
3045 };
3046
3047 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestResourcelessSoftwareDraw);
3048
2963 class LayerTreeHostTestDeferredInitializeWithGpuRasterization 3049 class LayerTreeHostTestDeferredInitializeWithGpuRasterization
2964 : public LayerTreeHostTestDeferredInitialize { 3050 : public LayerTreeHostTestDeferredInitialize {
2965 void InitializeSettings(LayerTreeSettings* settings) override { 3051 void InitializeSettings(LayerTreeSettings* settings) override {
2966 // PictureLayer can only be used with impl side painting enabled. 3052 // PictureLayer can only be used with impl side painting enabled.
2967 settings->impl_side_painting = true; 3053 settings->impl_side_painting = true;
2968 settings->gpu_rasterization_enabled = true; 3054 settings->gpu_rasterization_enabled = true;
2969 settings->gpu_rasterization_forced = true; 3055 settings->gpu_rasterization_forced = true;
2970 } 3056 }
2971 }; 3057 };
2972 3058
(...skipping 3383 matching lines...) Expand 10 before | Expand all | Expand 10 after
6356 6442
6357 void AfterTest() override {} 6443 void AfterTest() override {}
6358 6444
6359 private: 6445 private:
6360 scoped_refptr<Layer> child_; 6446 scoped_refptr<Layer> child_;
6361 }; 6447 };
6362 6448
6363 SINGLE_AND_MULTI_THREAD_TEST_F(LayerPreserveRenderSurfaceFromOutputRequests); 6449 SINGLE_AND_MULTI_THREAD_TEST_F(LayerPreserveRenderSurfaceFromOutputRequests);
6364 6450
6365 } // namespace cc 6451 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698