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

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

Issue 22314002: cc: Fix IOSurfaceLayer freezing during aborts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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
« no previous file with comments | « cc/layers/io_surface_layer.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 4007 matching lines...) Expand 10 before | Expand all | Expand 10 after
4018 }; 4018 };
4019 4019
4020 TEST_F(LayerTreeHostTestTreeActivationCallback, DirectRenderer) { 4020 TEST_F(LayerTreeHostTestTreeActivationCallback, DirectRenderer) {
4021 RunTest(true, false, true); 4021 RunTest(true, false, true);
4022 } 4022 }
4023 4023
4024 TEST_F(LayerTreeHostTestTreeActivationCallback, DelegatingRenderer) { 4024 TEST_F(LayerTreeHostTestTreeActivationCallback, DelegatingRenderer) {
4025 RunTest(true, true, true); 4025 RunTest(true, true, true);
4026 } 4026 }
4027 4027
4028 // VideoLayer must support being invalidated and then passing that along 4028 class LayerInvalidateCausesDraw : public LayerTreeHostTest {
4029 // to the compositor thread, even though no resources are updated in
4030 // response to that invalidation.
4031 class LayerTreeHostTestVideoLayerInvalidate : public LayerTreeHostTest {
4032 public: 4029 public:
4033 LayerTreeHostTestVideoLayerInvalidate() : num_commits_(0), num_draws_(0) {} 4030 LayerInvalidateCausesDraw() : num_commits_(0), num_draws_(0) {}
4034
4035 virtual void SetupTree() OVERRIDE {
4036 LayerTreeHostTest::SetupTree();
4037 video_layer_ = VideoLayer::Create(&provider_);
4038 video_layer_->SetBounds(gfx::Size(10, 10));
4039 video_layer_->SetIsDrawable(true);
4040 layer_tree_host()->root_layer()->AddChild(video_layer_);
4041 }
4042 4031
4043 virtual void BeginTest() OVERRIDE { 4032 virtual void BeginTest() OVERRIDE {
4033 ASSERT_TRUE(!!invalidate_layer_)
4034 << "Derived tests must set this in SetupTree";
4035
4044 // One initial commit. 4036 // One initial commit.
4045 PostSetNeedsCommitToMainThread(); 4037 PostSetNeedsCommitToMainThread();
4046 } 4038 }
4047 4039
4048 virtual void DidCommitAndDrawFrame() OVERRIDE { 4040 virtual void DidCommitAndDrawFrame() OVERRIDE {
4049 // After commit, invalidate the video layer. This should cause a commit. 4041 // After commit, invalidate the layer. This should cause a commit.
4050 if (layer_tree_host()->source_frame_number() == 1) 4042 if (layer_tree_host()->source_frame_number() == 1)
4051 video_layer_->SetNeedsDisplay(); 4043 invalidate_layer_->SetNeedsDisplay();
4052 } 4044 }
4053 4045
4054 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { 4046 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
4055 num_draws_++; 4047 num_draws_++;
4056 if (impl->active_tree()->source_frame_number() == 1) 4048 if (impl->active_tree()->source_frame_number() == 1)
4057 EndTest(); 4049 EndTest();
4058 } 4050 }
4059 4051
4060 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { 4052 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE {
4061 num_commits_++; 4053 num_commits_++;
4062 } 4054 }
4063 4055
4064 virtual void AfterTest() OVERRIDE { 4056 virtual void AfterTest() OVERRIDE {
4065 EXPECT_GE(2, num_commits_); 4057 EXPECT_GE(2, num_commits_);
4066 EXPECT_GE(2, num_draws_); 4058 EXPECT_GE(2, num_draws_);
4067 } 4059 }
4068 4060
4061 protected:
4062 scoped_refptr<Layer> invalidate_layer_;
4063
4064 private:
4065 int num_commits_;
4066 int num_draws_;
4067 };
4068
4069 // VideoLayer must support being invalidated and then passing that along
4070 // to the compositor thread, even though no resources are updated in
4071 // response to that invalidation.
4072 class LayerTreeHostTestVideoLayerInvalidate : public LayerInvalidateCausesDraw {
4073 public:
4074 virtual void SetupTree() OVERRIDE {
4075 LayerTreeHostTest::SetupTree();
4076 scoped_refptr<VideoLayer> video_layer = VideoLayer::Create(&provider_);
4077 video_layer->SetBounds(gfx::Size(10, 10));
4078 video_layer->SetIsDrawable(true);
4079 layer_tree_host()->root_layer()->AddChild(video_layer);
4080
4081 invalidate_layer_ = video_layer;
4082 }
4083
4069 private: 4084 private:
4070 FakeVideoFrameProvider provider_; 4085 FakeVideoFrameProvider provider_;
4071 scoped_refptr<VideoLayer> video_layer_;
4072 int num_commits_;
4073 int num_draws_;
4074 }; 4086 };
4075 4087
4076 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestVideoLayerInvalidate); 4088 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestVideoLayerInvalidate);
4077 4089
4090 // IOSurfaceLayer must support being invalidated and then passing that along
4091 // to the compositor thread, even though no resources are updated in
4092 // response to that invalidation.
4093 class LayerTreeHostTestIOSurfaceLayerInvalidate
4094 : public LayerInvalidateCausesDraw {
4095 public:
4096 virtual void SetupTree() OVERRIDE {
4097 LayerTreeHostTest::SetupTree();
4098 scoped_refptr<IOSurfaceLayer> layer = IOSurfaceLayer::Create();
4099 layer->SetBounds(gfx::Size(10, 10));
4100 uint32_t fake_io_surface_id = 7;
4101 layer->SetIOSurfaceProperties(fake_io_surface_id, layer->bounds());
4102 layer->SetIsDrawable(true);
4103 layer_tree_host()->root_layer()->AddChild(layer);
4104
4105 invalidate_layer_ = layer;
4106 }
4107 };
4108
4109 // TODO(danakj): IOSurface layer can not be transported. crbug.com/239335
4110 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
4111 LayerTreeHostTestIOSurfaceLayerInvalidate);
4112
4078 class LayerTreeHostTestPushHiddenLayer : public LayerTreeHostTest { 4113 class LayerTreeHostTestPushHiddenLayer : public LayerTreeHostTest {
4079 protected: 4114 protected:
4080 virtual void SetupTree() OVERRIDE { 4115 virtual void SetupTree() OVERRIDE {
4081 root_layer_ = Layer::Create(); 4116 root_layer_ = Layer::Create();
4082 root_layer_->SetAnchorPoint(gfx::PointF()); 4117 root_layer_->SetAnchorPoint(gfx::PointF());
4083 root_layer_->SetPosition(gfx::Point()); 4118 root_layer_->SetPosition(gfx::Point());
4084 root_layer_->SetBounds(gfx::Size(10, 10)); 4119 root_layer_->SetBounds(gfx::Size(10, 10));
4085 4120
4086 parent_layer_ = SolidColorLayer::Create(); 4121 parent_layer_ = SolidColorLayer::Create();
4087 parent_layer_->SetAnchorPoint(gfx::PointF()); 4122 parent_layer_->SetAnchorPoint(gfx::PointF());
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
4176 virtual void AfterTest() OVERRIDE {} 4211 virtual void AfterTest() OVERRIDE {}
4177 4212
4178 FakeContentLayerClient client_; 4213 FakeContentLayerClient client_;
4179 scoped_refptr<FakePictureLayer> root_layer_; 4214 scoped_refptr<FakePictureLayer> root_layer_;
4180 }; 4215 };
4181 4216
4182 MULTI_THREAD_TEST_F(LayerTreeHostTestUpdateLayerInEmptyViewport); 4217 MULTI_THREAD_TEST_F(LayerTreeHostTestUpdateLayerInEmptyViewport);
4183 4218
4184 } // namespace 4219 } // namespace
4185 } // namespace cc 4220 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/io_surface_layer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698