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

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

Issue 883123003: cc: Dirty the RenderSurfaceLayerList when taking copy requests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « cc/test/layer_tree_test.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/layers/layer_iterator.h"
5 #include "cc/output/copy_output_request.h" 6 #include "cc/output/copy_output_request.h"
6 #include "cc/output/copy_output_result.h" 7 #include "cc/output/copy_output_result.h"
7 #include "cc/test/fake_content_layer.h" 8 #include "cc/test/fake_content_layer.h"
8 #include "cc/test/fake_content_layer_client.h" 9 #include "cc/test/fake_content_layer_client.h"
9 #include "cc/test/fake_output_surface.h" 10 #include "cc/test/fake_output_surface.h"
10 #include "cc/test/layer_tree_test.h" 11 #include "cc/test/layer_tree_test.h"
11 #include "cc/trees/layer_tree_impl.h" 12 #include "cc/trees/layer_tree_impl.h"
12 #include "gpu/GLES2/gl2extchromium.h" 13 #include "gpu/GLES2/gl2extchromium.h"
13 14
14 namespace cc { 15 namespace cc {
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 960
960 int callback_count_; 961 int callback_count_;
961 FakeContentLayerClient client_; 962 FakeContentLayerClient client_;
962 scoped_refptr<FakeContentLayer> root_; 963 scoped_refptr<FakeContentLayer> root_;
963 scoped_refptr<FakeContentLayer> copy_layer_; 964 scoped_refptr<FakeContentLayer> copy_layer_;
964 }; 965 };
965 966
966 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( 967 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
967 LayerTreeHostCopyRequestTestShutdownBeforeCopy); 968 LayerTreeHostCopyRequestTestShutdownBeforeCopy);
968 969
970 class LayerTreeHostCopyRequestTestMultipleDrawsWithHiddenCopyRequest
971 : public LayerTreeHostCopyRequestTest {
972 protected:
973 void SetupTree() override {
974 scoped_refptr<FakeContentLayer> root = FakeContentLayer::Create(&client_);
975 root->SetBounds(gfx::Size(20, 20));
976
977 child_ = FakeContentLayer::Create(&client_);
978 child_->SetBounds(gfx::Size(10, 10));
979 root->AddChild(child_);
980 child_->SetHideLayerAndSubtree(true);
981
982 layer_tree_host()->SetRootLayer(root);
983 LayerTreeHostCopyRequestTest::SetupTree();
984 }
985
986 void BeginTest() override {
987 num_draws_ = 0;
988 copy_happened_ = false;
989 PostSetNeedsCommitToMainThread();
990 }
991
992 void DidCommitAndDrawFrame() override {
993 // Send a copy request after the first commit.
994 if (layer_tree_host()->source_frame_number() == 1) {
995 child_->RequestCopyOfOutput(
996 CopyOutputRequest::CreateBitmapRequest(base::Bind(
997 &LayerTreeHostCopyRequestTestMultipleDrawsWithHiddenCopyRequest::
998 CopyOutputCallback,
999 base::Unretained(this))));
1000 }
1001 }
1002
1003 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
1004 LayerTreeHostImpl::FrameData* frame_data,
1005 DrawResult draw_result) override {
1006 LayerImpl* root = host_impl->active_tree()->root_layer();
1007 LayerImpl* child = root->children()[0];
1008
1009 bool saw_root = false;
1010 bool saw_child = false;
1011 for (LayerIterator<LayerImpl> it = LayerIterator<LayerImpl>::Begin(
1012 frame_data->render_surface_layer_list);
1013 it != LayerIterator<LayerImpl>::End(
1014 frame_data->render_surface_layer_list);
1015 ++it) {
1016 if (it.represents_itself()) {
1017 if (*it == root)
1018 saw_root = true;
1019 else if (*it == child)
1020 saw_child = true;
1021 else
1022 NOTREACHED();
1023 }
1024 }
1025
1026 ++num_draws_;
1027 // The first draw has no copy request. The 2nd draw has a copy request, the
1028 // 3rd should not again.
1029 switch (num_draws_) {
1030 case 1:
1031 // Only the root layer draws, the child is hidden.
1032 EXPECT_TRUE(saw_root);
1033 EXPECT_FALSE(saw_child);
1034 break;
1035 case 2:
1036 // Copy happening here, the child will draw.
1037 EXPECT_TRUE(saw_root);
1038 EXPECT_TRUE(saw_child);
1039 // Make another draw happen after doing the copy request.
1040 host_impl->SetNeedsRedrawRect(gfx::Rect(1, 1));
1041 break;
1042 case 3:
1043 // If LayerTreeHostImpl does the wrong thing, it will try to draw the
1044 // layer which had a copy request. But only the root should draw.
1045 EXPECT_TRUE(saw_root);
1046 EXPECT_FALSE(saw_child);
1047
1048 // End the test! Don't race with copy request callbacks, so post the end
1049 // to the main thread.
1050 EXPECT_TRUE(copy_happened_);
1051 PostEndTestToMainThread();
1052 break;
1053 }
1054 return draw_result;
1055 }
1056
1057 void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) {
1058 EXPECT_FALSE(TestEnded());
1059 copy_happened_ = true;
1060 }
1061
1062 void AfterTest() override {}
1063
1064 scoped_refptr<FakeContentLayer> child_;
1065 FakeContentLayerClient client_;
1066 int num_draws_;
1067 bool copy_happened_;
1068 };
1069
1070 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_NOIMPL_TEST_F(
1071 LayerTreeHostCopyRequestTestMultipleDrawsWithHiddenCopyRequest);
1072
969 } // namespace 1073 } // namespace
970 } // namespace cc 1074 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/layer_tree_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698