Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/layers/layer_iterator.h" |
| 6 #include "cc/output/copy_output_request.h" | 6 #include "cc/output/copy_output_request.h" |
| 7 #include "cc/output/copy_output_result.h" | 7 #include "cc/output/copy_output_result.h" |
| 8 #include "cc/test/fake_content_layer_client.h" | 8 #include "cc/test/fake_content_layer_client.h" |
| 9 #include "cc/test/fake_output_surface.h" | 9 #include "cc/test/fake_output_surface.h" |
| 10 #include "cc/test/fake_picture_layer.h" | 10 #include "cc/test/fake_picture_layer.h" |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 use_gl_renderer_ = false; | 168 use_gl_renderer_ = false; |
| 169 RunTest(false, false); | 169 RunTest(false, false); |
| 170 } | 170 } |
| 171 | 171 |
| 172 TEST_F(LayerTreeHostCopyRequestTestMultipleRequests, | 172 TEST_F(LayerTreeHostCopyRequestTestMultipleRequests, |
| 173 SoftwareRenderer_RunMultiThread) { | 173 SoftwareRenderer_RunMultiThread) { |
| 174 use_gl_renderer_ = false; | 174 use_gl_renderer_ = false; |
| 175 RunTest(true, false); | 175 RunTest(true, false); |
| 176 } | 176 } |
| 177 | 177 |
| 178 class LayerTreeHostCopyRequestCompletionCausesCommit | |
|
danakj
2015/12/02 23:07:52
can you leave a comment to the bug here too so it'
| |
| 179 : public LayerTreeHostCopyRequestTest { | |
| 180 protected: | |
| 181 void SetupTree() override { | |
| 182 root_ = FakePictureLayer::Create(layer_settings(), &client_); | |
| 183 root_->SetBounds(gfx::Size(20, 20)); | |
| 184 | |
| 185 layer_ = FakePictureLayer::Create(layer_settings(), &client_); | |
| 186 layer_->SetBounds(gfx::Size(15, 15)); | |
| 187 root_->AddChild(layer_); | |
| 188 | |
| 189 layer_tree_host()->SetRootLayer(root_); | |
| 190 LayerTreeHostCopyRequestTest::SetupTree(); | |
| 191 client_.set_bounds(root_->bounds()); | |
| 192 } | |
| 193 | |
| 194 void BeginTest() override { | |
| 195 callback_count_ = 0; | |
| 196 PostSetNeedsCommitToMainThread(); | |
| 197 } | |
| 198 | |
| 199 void DidCommit() override { | |
| 200 int frame = layer_tree_host()->source_frame_number(); | |
| 201 switch (frame) { | |
| 202 case 1: | |
| 203 layer_->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( | |
| 204 base::Bind(&LayerTreeHostCopyRequestCompletionCausesCommit:: | |
| 205 CopyOutputCallback, | |
| 206 base::Unretained(this)))); | |
| 207 EXPECT_EQ(0, callback_count_); | |
| 208 break; | |
| 209 case 2: | |
| 210 // This commit was triggered by the copy request. | |
| 211 break; | |
| 212 case 3: | |
| 213 // This commit was triggered by the completion of the copy request. | |
| 214 EXPECT_EQ(1, callback_count_); | |
| 215 EndTest(); | |
| 216 break; | |
| 217 } | |
| 218 } | |
| 219 | |
| 220 void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) { | |
| 221 EXPECT_FALSE(result->IsEmpty()); | |
| 222 ++callback_count_; | |
| 223 } | |
| 224 | |
| 225 void AfterTest() override {} | |
| 226 | |
| 227 int callback_count_; | |
| 228 FakeContentLayerClient client_; | |
| 229 scoped_refptr<FakePictureLayer> root_; | |
| 230 scoped_refptr<FakePictureLayer> layer_; | |
| 231 }; | |
| 232 | |
| 233 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | |
| 234 LayerTreeHostCopyRequestCompletionCausesCommit); | |
| 235 | |
| 178 class LayerTreeHostCopyRequestTestLayerDestroyed | 236 class LayerTreeHostCopyRequestTestLayerDestroyed |
| 179 : public LayerTreeHostCopyRequestTest { | 237 : public LayerTreeHostCopyRequestTest { |
| 180 protected: | 238 protected: |
| 181 void SetupTree() override { | 239 void SetupTree() override { |
| 182 root_ = FakePictureLayer::Create(layer_settings(), &client_); | 240 root_ = FakePictureLayer::Create(layer_settings(), &client_); |
| 183 root_->SetBounds(gfx::Size(20, 20)); | 241 root_->SetBounds(gfx::Size(20, 20)); |
| 184 | 242 |
| 185 main_destroyed_ = FakePictureLayer::Create(layer_settings(), &client_); | 243 main_destroyed_ = FakePictureLayer::Create(layer_settings(), &client_); |
| 186 main_destroyed_->SetBounds(gfx::Size(15, 15)); | 244 main_destroyed_->SetBounds(gfx::Size(15, 15)); |
| 187 root_->AddChild(main_destroyed_); | 245 root_->AddChild(main_destroyed_); |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 420 LayerImpl* parent = grand_parent->children()[0].get(); | 478 LayerImpl* parent = grand_parent->children()[0].get(); |
| 421 LayerImpl* copy_layer = parent->children()[0].get(); | 479 LayerImpl* copy_layer = parent->children()[0].get(); |
| 422 | 480 |
| 423 // |parent| owns a surface, but it was hidden and not part of the copy | 481 // |parent| owns a surface, but it was hidden and not part of the copy |
| 424 // request so it should not allocate any resource. | 482 // request so it should not allocate any resource. |
| 425 EXPECT_FALSE(renderer->HasAllocatedResourcesForTesting( | 483 EXPECT_FALSE(renderer->HasAllocatedResourcesForTesting( |
| 426 parent->render_surface()->GetRenderPassId())); | 484 parent->render_surface()->GetRenderPassId())); |
| 427 | 485 |
| 428 // |copy_layer| should have been rendered to a texture since it was needed | 486 // |copy_layer| should have been rendered to a texture since it was needed |
| 429 // for a copy request. | 487 // for a copy request. |
| 430 EXPECT_TRUE(renderer->HasAllocatedResourcesForTesting( | 488 if (did_draw_) { |
| 431 copy_layer->render_surface()->GetRenderPassId())); | 489 // Ignore the extra frame that occurs due to copy completion. |
| 490 EXPECT_FALSE(copy_layer->render_surface()); | |
| 491 } else { | |
| 492 EXPECT_TRUE(renderer->HasAllocatedResourcesForTesting( | |
| 493 copy_layer->render_surface()->GetRenderPassId())); | |
| 494 } | |
| 432 | 495 |
| 433 did_draw_ = true; | 496 did_draw_ = true; |
| 434 } | 497 } |
| 435 | 498 |
| 436 void AfterTest() override { EXPECT_TRUE(did_draw_); } | 499 void AfterTest() override { EXPECT_TRUE(did_draw_); } |
| 437 | 500 |
| 438 FakeContentLayerClient client_; | 501 FakeContentLayerClient client_; |
| 439 bool did_draw_; | 502 bool did_draw_; |
| 440 scoped_refptr<FakePictureLayer> root_; | 503 scoped_refptr<FakePictureLayer> root_; |
| 441 scoped_refptr<FakePictureLayer> grand_parent_layer_; | 504 scoped_refptr<FakePictureLayer> grand_parent_layer_; |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1187 int num_draws_; | 1250 int num_draws_; |
| 1188 bool copy_happened_; | 1251 bool copy_happened_; |
| 1189 bool draw_happened_; | 1252 bool draw_happened_; |
| 1190 }; | 1253 }; |
| 1191 | 1254 |
| 1192 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 1255 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
| 1193 LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest); | 1256 LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest); |
| 1194 | 1257 |
| 1195 } // namespace | 1258 } // namespace |
| 1196 } // namespace cc | 1259 } // namespace cc |
| OLD | NEW |