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/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 2929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2940 FakeContentLayerClient client_; | 2940 FakeContentLayerClient client_; |
2941 scoped_refptr<FakeContentLayer> root_; | 2941 scoped_refptr<FakeContentLayer> root_; |
2942 scoped_refptr<FakeContentLayer> parent_layer_; | 2942 scoped_refptr<FakeContentLayer> parent_layer_; |
2943 scoped_refptr<FakeContentLayer> copy_layer_; | 2943 scoped_refptr<FakeContentLayer> copy_layer_; |
2944 }; | 2944 }; |
2945 | 2945 |
2946 // No output to copy for delegated renderers. | 2946 // No output to copy for delegated renderers. |
2947 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 2947 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
2948 LayerTreeHostTestAsyncReadbackClippedOut); | 2948 LayerTreeHostTestAsyncReadbackClippedOut); |
2949 | 2949 |
| 2950 class LayerTreeHostTestAsyncTwoReadbacksWithoutDraw : public LayerTreeHostTest { |
| 2951 protected: |
| 2952 virtual void SetupTree() OVERRIDE { |
| 2953 root_ = FakeContentLayer::Create(&client_); |
| 2954 root_->SetBounds(gfx::Size(20, 20)); |
| 2955 |
| 2956 copy_layer_ = FakeContentLayer::Create(&client_); |
| 2957 copy_layer_->SetBounds(gfx::Size(10, 10)); |
| 2958 root_->AddChild(copy_layer_); |
| 2959 |
| 2960 layer_tree_host()->SetRootLayer(root_); |
| 2961 LayerTreeHostTest::SetupTree(); |
| 2962 } |
| 2963 |
| 2964 void AddCopyRequest(Layer* layer) { |
| 2965 layer->RequestCopyOfOutput( |
| 2966 CopyOutputRequest::CreateBitmapRequest(base::Bind( |
| 2967 &LayerTreeHostTestAsyncTwoReadbacksWithoutDraw::CopyOutputCallback, |
| 2968 base::Unretained(this)))); |
| 2969 } |
| 2970 |
| 2971 virtual void BeginTest() OVERRIDE { |
| 2972 saw_copy_request_ = false; |
| 2973 callback_count_ = 0; |
| 2974 PostSetNeedsCommitToMainThread(); |
| 2975 |
| 2976 // Prevent drawing. |
| 2977 layer_tree_host()->SetViewportSize(gfx::Size(0, 0)); |
| 2978 |
| 2979 AddCopyRequest(copy_layer_.get()); |
| 2980 } |
| 2981 |
| 2982 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 2983 if (impl->active_tree()->source_frame_number() == 0) { |
| 2984 LayerImpl* root = impl->active_tree()->root_layer(); |
| 2985 EXPECT_TRUE(root->children()[0]->HasCopyRequest()); |
| 2986 saw_copy_request_ = true; |
| 2987 } |
| 2988 } |
| 2989 |
| 2990 virtual void DidCommit() OVERRIDE { |
| 2991 if (layer_tree_host()->commit_number() == 1) { |
| 2992 // Allow drawing. |
| 2993 layer_tree_host()->SetViewportSize(gfx::Size(root_->bounds())); |
| 2994 |
| 2995 AddCopyRequest(copy_layer_.get()); |
| 2996 } |
| 2997 } |
| 2998 |
| 2999 void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) { |
| 3000 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread()); |
| 3001 EXPECT_EQ(copy_layer_->bounds().ToString(), result->size().ToString()); |
| 3002 ++callback_count_; |
| 3003 |
| 3004 if (callback_count_ == 2) |
| 3005 EndTest(); |
| 3006 } |
| 3007 |
| 3008 virtual void AfterTest() OVERRIDE { EXPECT_TRUE(saw_copy_request_); } |
| 3009 |
| 3010 bool saw_copy_request_; |
| 3011 int callback_count_; |
| 3012 FakeContentLayerClient client_; |
| 3013 scoped_refptr<FakeContentLayer> root_; |
| 3014 scoped_refptr<FakeContentLayer> copy_layer_; |
| 3015 }; |
| 3016 |
| 3017 // No output to copy for delegated renderers. |
| 3018 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
| 3019 LayerTreeHostTestAsyncTwoReadbacksWithoutDraw); |
| 3020 |
2950 class LayerTreeHostTestNumFramesPending : public LayerTreeHostTest { | 3021 class LayerTreeHostTestNumFramesPending : public LayerTreeHostTest { |
2951 public: | 3022 public: |
2952 virtual void BeginTest() OVERRIDE { | 3023 virtual void BeginTest() OVERRIDE { |
2953 frame_ = 0; | 3024 frame_ = 0; |
2954 PostSetNeedsCommitToMainThread(); | 3025 PostSetNeedsCommitToMainThread(); |
2955 } | 3026 } |
2956 | 3027 |
2957 // Round 1: commit + draw | 3028 // Round 1: commit + draw |
2958 // Round 2: commit only (no draw/swap) | 3029 // Round 2: commit only (no draw/swap) |
2959 // Round 3: draw only (no commit) | 3030 // Round 3: draw only (no commit) |
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3894 TEST_F(LayerTreeHostTestTreeActivationCallback, DirectRenderer) { | 3965 TEST_F(LayerTreeHostTestTreeActivationCallback, DirectRenderer) { |
3895 RunTest(true, false, true); | 3966 RunTest(true, false, true); |
3896 } | 3967 } |
3897 | 3968 |
3898 TEST_F(LayerTreeHostTestTreeActivationCallback, DelegatingRenderer) { | 3969 TEST_F(LayerTreeHostTestTreeActivationCallback, DelegatingRenderer) { |
3899 RunTest(true, true, true); | 3970 RunTest(true, true, true); |
3900 } | 3971 } |
3901 | 3972 |
3902 } // namespace | 3973 } // namespace |
3903 } // namespace cc | 3974 } // namespace cc |
OLD | NEW |