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

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

Issue 14772021: cc::OutputSurfaceClient::InitializeForGL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Do not update caps in DidTryInitializeRendererOnImplThread Created 7 years, 6 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
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/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 2796 matching lines...) Expand 10 before | Expand all | Expand 10 after
2834 }; 2836 };
2835 2837
2836 TEST_F(LayerTreeHostTestNumFramesPending, DelegatingRenderer) { 2838 TEST_F(LayerTreeHostTestNumFramesPending, DelegatingRenderer) {
2837 RunTest(true, true, true); 2839 RunTest(true, true, true);
2838 } 2840 }
2839 2841
2840 TEST_F(LayerTreeHostTestNumFramesPending, GLRenderer) { 2842 TEST_F(LayerTreeHostTestNumFramesPending, GLRenderer) {
2841 RunTest(true, false, true); 2843 RunTest(true, false, true);
2842 } 2844 }
2843 2845
2846 class LayerTreeHostTestDeferredInitialize : public LayerTreeHostTest {
2847 public:
2848 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
2849 // PictureLayer can only be used with impl side painting enabled.
2850 settings->impl_side_painting = true;
2851 }
2852
2853 virtual void SetupTree() OVERRIDE {
2854 layer_ = FakePictureLayer::Create(&client_);
2855 layer_tree_host()->SetRootLayer(layer_);
2856 LayerTreeHostTest::SetupTree();
2857 }
2858
2859 virtual void BeginTest() OVERRIDE {
2860 initialized_gl_ = false;
2861 PostSetNeedsCommitToMainThread();
2862 }
2863
2864 virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE {
2865 return FakeOutputSurface::CreateDeferredGL(
2866 scoped_ptr<WebKit::WebGraphicsContext3D>(
2867 TestWebGraphicsContext3D::Create()),
2868 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice))
2869 .PassAs<OutputSurface>();
2870 }
2871
2872 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
2873 ASSERT_TRUE(host_impl->RootLayer());
2874 FakePictureLayerImpl* layer_impl =
2875 static_cast<FakePictureLayerImpl*>(host_impl->RootLayer());
2876 if (!initialized_gl_) {
2877 EXPECT_EQ(1u, layer_impl->append_quads_count());
2878 ImplThread()->PostTask(base::Bind(
2879 &LayerTreeHostTestDeferredInitialize::DeferredInitializeAndRedraw,
2880 base::Unretained(this),
2881 base::Unretained(host_impl)));
2882 } else {
2883 EXPECT_EQ(2u, layer_impl->append_quads_count());
2884 EndTest();
2885 }
2886 }
2887
2888 void DeferredInitializeAndRedraw(LayerTreeHostImpl* host_impl) {
2889 EXPECT_TRUE(
2890 host_impl->DeferredInitialize(scoped_refptr<ContextProvider>()));
2891 initialized_gl_ = true;
2892
2893 // Force redraw again.
2894 host_impl->SetNeedsRedrawRect(gfx::Rect(1, 1));
boliu 2013/06/06 19:27:14 And of course, test did not pass when enabled, so
danakj 2013/06/06 19:36:13 Note you could also SetNeedsDisplay() on the main
boliu 2013/06/06 20:18:13 Yep you are right. I misunderstood next_frame_is_n
2895 // PostSetNeedsCommitToMainThread();
boliu 2013/06/06 19:27:14 Arg...going to remove this in next PS.
2896 }
2897
2898 virtual void AfterTest() OVERRIDE {}
danakj 2013/06/06 19:36:13 It'd be nice to test initialized_gl_ = true here s
boliu 2013/06/06 20:18:13 Done.
2899
2900 private:
2901 FakeContentLayerClient client_;
2902 scoped_refptr<FakePictureLayer> layer_;
2903 bool initialized_gl_;
2904 };
2905
2906 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitialize);
2907
2844 } // namespace 2908 } // namespace
2845 } // namespace cc 2909 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698