OLD | NEW |
---|---|
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/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
10 #include "cc/animation/timing_function.h" | 10 #include "cc/animation/timing_function.h" |
11 #include "cc/debug/frame_rate_counter.h" | 11 #include "cc/debug/frame_rate_counter.h" |
12 #include "cc/layers/content_layer.h" | 12 #include "cc/layers/content_layer.h" |
13 #include "cc/layers/content_layer_client.h" | 13 #include "cc/layers/content_layer_client.h" |
14 #include "cc/layers/io_surface_layer.h" | 14 #include "cc/layers/io_surface_layer.h" |
15 #include "cc/layers/layer_impl.h" | 15 #include "cc/layers/layer_impl.h" |
16 #include "cc/layers/picture_layer.h" | 16 #include "cc/layers/picture_layer.h" |
17 #include "cc/layers/scrollbar_layer.h" | 17 #include "cc/layers/scrollbar_layer.h" |
18 #include "cc/output/copy_output_request.h" | 18 #include "cc/output/copy_output_request.h" |
19 #include "cc/output/output_surface.h" | 19 #include "cc/output/output_surface.h" |
20 #include "cc/resources/prioritized_resource.h" | 20 #include "cc/resources/prioritized_resource.h" |
21 #include "cc/resources/prioritized_resource_manager.h" | 21 #include "cc/resources/prioritized_resource_manager.h" |
22 #include "cc/resources/resource_update_queue.h" | 22 #include "cc/resources/resource_update_queue.h" |
23 #include "cc/scheduler/frame_rate_controller.h" | 23 #include "cc/scheduler/frame_rate_controller.h" |
24 #include "cc/test/fake_content_layer.h" | 24 #include "cc/test/fake_content_layer.h" |
25 #include "cc/test/fake_content_layer_client.h" | 25 #include "cc/test/fake_content_layer_client.h" |
26 #include "cc/test/fake_layer_tree_host_client.h" | 26 #include "cc/test/fake_layer_tree_host_client.h" |
27 #include "cc/test/fake_output_surface.h" | 27 #include "cc/test/fake_output_surface.h" |
28 #include "cc/test/fake_picture_layer.h" | |
29 #include "cc/test/fake_picture_layer_impl.h" | |
28 #include "cc/test/fake_proxy.h" | 30 #include "cc/test/fake_proxy.h" |
29 #include "cc/test/fake_scrollbar_layer.h" | 31 #include "cc/test/fake_scrollbar_layer.h" |
30 #include "cc/test/geometry_test_utils.h" | 32 #include "cc/test/geometry_test_utils.h" |
31 #include "cc/test/layer_tree_test.h" | 33 #include "cc/test/layer_tree_test.h" |
32 #include "cc/test/occlusion_tracker_test_common.h" | 34 #include "cc/test/occlusion_tracker_test_common.h" |
33 #include "cc/trees/layer_tree_host_impl.h" | 35 #include "cc/trees/layer_tree_host_impl.h" |
34 #include "cc/trees/layer_tree_impl.h" | 36 #include "cc/trees/layer_tree_impl.h" |
35 #include "cc/trees/single_thread_proxy.h" | 37 #include "cc/trees/single_thread_proxy.h" |
36 #include "cc/trees/thread_proxy.h" | 38 #include "cc/trees/thread_proxy.h" |
37 #include "gpu/GLES2/gl2extchromium.h" | 39 #include "gpu/GLES2/gl2extchromium.h" |
(...skipping 2833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2871 }; | 2873 }; |
2872 | 2874 |
2873 TEST_F(LayerTreeHostTestNumFramesPending, DelegatingRenderer) { | 2875 TEST_F(LayerTreeHostTestNumFramesPending, DelegatingRenderer) { |
2874 RunTest(true, true, true); | 2876 RunTest(true, true, true); |
2875 } | 2877 } |
2876 | 2878 |
2877 TEST_F(LayerTreeHostTestNumFramesPending, GLRenderer) { | 2879 TEST_F(LayerTreeHostTestNumFramesPending, GLRenderer) { |
2878 RunTest(true, false, true); | 2880 RunTest(true, false, true); |
2879 } | 2881 } |
2880 | 2882 |
2883 class LayerTreeHostTestDeferredInitialize : public LayerTreeHostTest { | |
2884 public: | |
2885 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | |
2886 // PictureLayer can only be used with impl side painting enabled. | |
2887 settings->impl_side_painting = true; | |
2888 } | |
2889 | |
2890 virtual void SetupTree() OVERRIDE { | |
2891 layer_ = FakePictureLayer::Create(&client_); | |
2892 layer_tree_host()->SetRootLayer(layer_); | |
2893 LayerTreeHostTest::SetupTree(); | |
2894 } | |
2895 | |
2896 virtual void BeginTest() OVERRIDE { | |
2897 initialized_gl_ = false; | |
2898 PostSetNeedsCommitToMainThread(); | |
2899 } | |
2900 | |
2901 virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE { | |
2902 return FakeOutputSurface::CreateDeferredGL( | |
2903 scoped_ptr<WebKit::WebGraphicsContext3D>( | |
2904 TestWebGraphicsContext3D::Create()), | |
2905 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice)) | |
2906 .PassAs<OutputSurface>(); | |
2907 } | |
2908 | |
2909 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | |
2910 ASSERT_TRUE(host_impl->RootLayer()); | |
2911 FakePictureLayerImpl* layer_impl = | |
2912 static_cast<FakePictureLayerImpl*>(host_impl->RootLayer()); | |
2913 if (!initialized_gl_) { | |
2914 EXPECT_EQ(1u, layer_impl->append_quads_count()); | |
2915 EXPECT_TRUE( | |
2916 host_impl->DeferredInitialize(scoped_refptr<ContextProvider>())); | |
2917 initialized_gl_ = true; | |
2918 | |
2919 // Force redraw again. | |
2920 host_impl->SetNeedsRedrawRect(gfx::Rect(1, 1)); | |
danakj
2013/06/06 14:49:31
Why do you need this if you are causing a second c
boliu
2013/06/06 17:39:25
Removed PostSetNeedsCommitToMainThread below, and
| |
2921 } else { | |
2922 EXPECT_EQ(2u, layer_impl->append_quads_count()); | |
2923 } | |
2924 } | |
2925 | |
2926 virtual void DidCommitAndDrawFrame() OVERRIDE { | |
2927 if (layer_->update_count() == 1) { | |
2928 // Commit and draw again in hardware. | |
2929 PostSetNeedsCommitToMainThread(); | |
2930 } else { | |
2931 EndTest(); | |
2932 } | |
2933 } | |
2934 | |
2935 virtual void AfterTest() OVERRIDE { | |
2936 EXPECT_TRUE(initialized_gl_); | |
2937 EXPECT_EQ(2u, layer_->update_count()); | |
2938 } | |
2939 | |
2940 private: | |
2941 FakeContentLayerClient client_; | |
2942 scoped_refptr<FakePictureLayer> layer_; | |
2943 bool initialized_gl_; | |
2944 }; | |
2945 | |
2946 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitialize); | |
2947 | |
2881 } // namespace | 2948 } // namespace |
2882 } // namespace cc | 2949 } // namespace cc |
OLD | NEW |