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

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

Issue 21567003: cc: Fix accelerated video freezing with commit aborts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add test; update comment 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/video_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"
11 #include "cc/animation/timing_function.h" 11 #include "cc/animation/timing_function.h"
12 #include "cc/debug/frame_rate_counter.h" 12 #include "cc/debug/frame_rate_counter.h"
13 #include "cc/layers/content_layer.h" 13 #include "cc/layers/content_layer.h"
14 #include "cc/layers/content_layer_client.h" 14 #include "cc/layers/content_layer_client.h"
15 #include "cc/layers/io_surface_layer.h" 15 #include "cc/layers/io_surface_layer.h"
16 #include "cc/layers/layer_impl.h" 16 #include "cc/layers/layer_impl.h"
17 #include "cc/layers/picture_layer.h" 17 #include "cc/layers/picture_layer.h"
18 #include "cc/layers/scrollbar_layer.h" 18 #include "cc/layers/scrollbar_layer.h"
19 #include "cc/layers/video_layer.h"
19 #include "cc/output/begin_frame_args.h" 20 #include "cc/output/begin_frame_args.h"
20 #include "cc/output/copy_output_request.h" 21 #include "cc/output/copy_output_request.h"
21 #include "cc/output/copy_output_result.h" 22 #include "cc/output/copy_output_result.h"
22 #include "cc/output/output_surface.h" 23 #include "cc/output/output_surface.h"
23 #include "cc/resources/prioritized_resource.h" 24 #include "cc/resources/prioritized_resource.h"
24 #include "cc/resources/prioritized_resource_manager.h" 25 #include "cc/resources/prioritized_resource_manager.h"
25 #include "cc/resources/resource_update_queue.h" 26 #include "cc/resources/resource_update_queue.h"
26 #include "cc/scheduler/frame_rate_controller.h" 27 #include "cc/scheduler/frame_rate_controller.h"
27 #include "cc/test/fake_content_layer.h" 28 #include "cc/test/fake_content_layer.h"
28 #include "cc/test/fake_content_layer_client.h" 29 #include "cc/test/fake_content_layer_client.h"
29 #include "cc/test/fake_layer_tree_host_client.h" 30 #include "cc/test/fake_layer_tree_host_client.h"
30 #include "cc/test/fake_output_surface.h" 31 #include "cc/test/fake_output_surface.h"
31 #include "cc/test/fake_picture_layer.h" 32 #include "cc/test/fake_picture_layer.h"
32 #include "cc/test/fake_picture_layer_impl.h" 33 #include "cc/test/fake_picture_layer_impl.h"
33 #include "cc/test/fake_proxy.h" 34 #include "cc/test/fake_proxy.h"
34 #include "cc/test/fake_scrollbar_layer.h" 35 #include "cc/test/fake_scrollbar_layer.h"
36 #include "cc/test/fake_video_frame_provider.h"
35 #include "cc/test/geometry_test_utils.h" 37 #include "cc/test/geometry_test_utils.h"
36 #include "cc/test/layer_tree_test.h" 38 #include "cc/test/layer_tree_test.h"
37 #include "cc/test/occlusion_tracker_test_common.h" 39 #include "cc/test/occlusion_tracker_test_common.h"
38 #include "cc/trees/layer_tree_host_impl.h" 40 #include "cc/trees/layer_tree_host_impl.h"
39 #include "cc/trees/layer_tree_impl.h" 41 #include "cc/trees/layer_tree_impl.h"
40 #include "cc/trees/single_thread_proxy.h" 42 #include "cc/trees/single_thread_proxy.h"
41 #include "cc/trees/thread_proxy.h" 43 #include "cc/trees/thread_proxy.h"
42 #include "gpu/GLES2/gl2extchromium.h" 44 #include "gpu/GLES2/gl2extchromium.h"
43 #include "skia/ext/refptr.h" 45 #include "skia/ext/refptr.h"
44 #include "testing/gmock/include/gmock/gmock.h" 46 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 3905 matching lines...) Expand 10 before | Expand all | Expand 10 after
3950 }; 3952 };
3951 3953
3952 TEST_F(LayerTreeHostTestTreeActivationCallback, DirectRenderer) { 3954 TEST_F(LayerTreeHostTestTreeActivationCallback, DirectRenderer) {
3953 RunTest(true, false, true); 3955 RunTest(true, false, true);
3954 } 3956 }
3955 3957
3956 TEST_F(LayerTreeHostTestTreeActivationCallback, DelegatingRenderer) { 3958 TEST_F(LayerTreeHostTestTreeActivationCallback, DelegatingRenderer) {
3957 RunTest(true, true, true); 3959 RunTest(true, true, true);
3958 } 3960 }
3959 3961
3962 // VideoLayer must support being invalidated and then passing that along
3963 // to the compositor thread, even though no resources are updated in
3964 // response to that invalidation.
3965 class LayerTreeHostTestVideoLayerInvalidate : public LayerTreeHostTest {
3966 public:
3967 LayerTreeHostTestVideoLayerInvalidate() : num_commits_(0), num_draws_(0) {}
3968
3969 virtual void SetupTree() OVERRIDE {
3970 LayerTreeHostTest::SetupTree();
3971 video_layer_ = VideoLayer::Create(&provider_);
3972 video_layer_->SetBounds(gfx::Size(10, 10));
3973 video_layer_->SetIsDrawable(true);
3974 layer_tree_host()->root_layer()->AddChild(video_layer_);
3975 }
3976
3977 virtual void BeginTest() OVERRIDE {
3978 // One initial commit.
3979 PostSetNeedsCommitToMainThread();
3980 }
3981
3982 virtual void DidCommitAndDrawFrame() OVERRIDE {
3983 // After commit, invalidate the video layer. This should cause a commit.
3984 if (layer_tree_host()->source_frame_number() == 1)
3985 video_layer_->SetNeedsDisplay();
3986 }
3987
3988 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
3989 num_draws_++;
3990 if (impl->active_tree()->source_frame_number() == 1)
3991 EndTest();
3992 }
3993
3994 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE {
3995 num_commits_++;
3996 }
3997
3998 virtual void AfterTest() OVERRIDE {
3999 EXPECT_GE(2, num_commits_);
4000 EXPECT_GE(2, num_draws_);
4001 }
4002
4003 private:
4004 FakeVideoFrameProvider provider_;
4005 scoped_refptr<VideoLayer> video_layer_;
4006 int num_commits_;
4007 int num_draws_;
4008 };
4009
4010 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestVideoLayerInvalidate);
4011
3960 } // namespace 4012 } // namespace
3961 } // namespace cc 4013 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/video_layer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698