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/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/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 } | 460 } |
461 | 461 |
462 protected: | 462 protected: |
463 int num_activates_; | 463 int num_activates_; |
464 int num_output_surfaces_initialized_; | 464 int num_output_surfaces_initialized_; |
465 }; | 465 }; |
466 | 466 |
467 SINGLE_AND_MULTI_THREAD_TEST_F( | 467 SINGLE_AND_MULTI_THREAD_TEST_F( |
468 LayerTreeHostDelegatedTestInvalidFrameAfterContextLost); | 468 LayerTreeHostDelegatedTestInvalidFrameAfterContextLost); |
469 | 469 |
470 class LayerTreeHostDelegatedTestOffscreenContext_NoFilters | |
471 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { | |
472 protected: | |
473 virtual void BeginTest() OVERRIDE { | |
474 scoped_ptr<DelegatedFrameData> frame = | |
475 CreateFrameData(gfx::Rect(0, 0, 1, 1), | |
476 gfx::Rect(0, 0, 1, 1)); | |
477 SetFrameData(frame.Pass()); | |
478 | |
479 PostSetNeedsCommitToMainThread(); | |
480 } | |
481 | |
482 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | |
483 EXPECT_FALSE(host_impl->offscreen_context_provider()); | |
484 EndTest(); | |
485 } | |
486 }; | |
487 | |
488 SINGLE_AND_MULTI_THREAD_TEST_F( | |
489 LayerTreeHostDelegatedTestOffscreenContext_NoFilters); | |
490 | |
491 class LayerTreeHostDelegatedTestOffscreenContext_Filters | |
492 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { | |
493 protected: | |
494 virtual void BeginTest() OVERRIDE { | |
495 scoped_ptr<DelegatedFrameData> frame = | |
496 CreateFrameData(gfx::Rect(0, 0, 1, 1), | |
497 gfx::Rect(0, 0, 1, 1)); | |
498 | |
499 FilterOperations filters; | |
500 filters.Append(FilterOperation::CreateGrayscaleFilter(0.5f)); | |
501 AddRenderPass(frame.get(), | |
502 RenderPass::Id(2, 1), | |
503 gfx::Rect(0, 0, 1, 1), | |
504 gfx::Rect(0, 0, 1, 1), | |
505 filters, | |
506 FilterOperations()); | |
507 SetFrameData(frame.Pass()); | |
508 | |
509 PostSetNeedsCommitToMainThread(); | |
510 } | |
511 | |
512 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | |
513 bool expect_context = !delegating_renderer(); | |
514 EXPECT_EQ(expect_context, !!host_impl->offscreen_context_provider()); | |
515 EndTest(); | |
516 } | |
517 }; | |
518 | |
519 SINGLE_AND_MULTI_THREAD_TEST_F( | |
520 LayerTreeHostDelegatedTestOffscreenContext_Filters); | |
521 | |
522 class LayerTreeHostDelegatedTestOffscreenContext_BackgroundFilters | |
523 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { | |
524 protected: | |
525 virtual void BeginTest() OVERRIDE { | |
526 scoped_ptr<DelegatedFrameData> frame = | |
527 CreateFrameData(gfx::Rect(0, 0, 1, 1), | |
528 gfx::Rect(0, 0, 1, 1)); | |
529 | |
530 FilterOperations filters; | |
531 filters.Append(FilterOperation::CreateGrayscaleFilter(0.5f)); | |
532 AddRenderPass(frame.get(), | |
533 RenderPass::Id(2, 1), | |
534 gfx::Rect(0, 0, 1, 1), | |
535 gfx::Rect(0, 0, 1, 1), | |
536 FilterOperations(), | |
537 filters); | |
538 SetFrameData(frame.Pass()); | |
539 | |
540 PostSetNeedsCommitToMainThread(); | |
541 } | |
542 | |
543 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | |
544 bool expect_context = !delegating_renderer(); | |
545 EXPECT_EQ(expect_context, !!host_impl->offscreen_context_provider()); | |
546 EndTest(); | |
547 } | |
548 }; | |
549 | |
550 SINGLE_AND_MULTI_THREAD_TEST_F( | |
551 LayerTreeHostDelegatedTestOffscreenContext_BackgroundFilters); | |
552 | |
553 class LayerTreeHostDelegatedTestOffscreenContext_Filters_AddedToTree | |
554 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { | |
555 protected: | |
556 virtual void BeginTest() OVERRIDE { | |
557 scoped_ptr<DelegatedFrameData> frame_no_filters = | |
558 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | |
559 | |
560 scoped_ptr<DelegatedFrameData> frame_with_filters = | |
561 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | |
562 | |
563 FilterOperations filters; | |
564 filters.Append(FilterOperation::CreateGrayscaleFilter(0.5f)); | |
565 AddRenderPass(frame_with_filters.get(), | |
566 RenderPass::Id(2, 1), | |
567 gfx::Rect(0, 0, 1, 1), | |
568 gfx::Rect(0, 0, 1, 1), | |
569 filters, | |
570 FilterOperations()); | |
571 | |
572 SetFrameData(frame_no_filters.Pass()); | |
573 delegated_->RemoveFromParent(); | |
574 SetFrameData(frame_with_filters.Pass()); | |
575 layer_tree_host()->root_layer()->AddChild(delegated_); | |
576 | |
577 PostSetNeedsCommitToMainThread(); | |
578 } | |
579 | |
580 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | |
581 bool expect_context = !delegating_renderer(); | |
582 EXPECT_EQ(expect_context, !!host_impl->offscreen_context_provider()); | |
583 EndTest(); | |
584 } | |
585 }; | |
586 | |
587 SINGLE_AND_MULTI_THREAD_TEST_F( | |
588 LayerTreeHostDelegatedTestOffscreenContext_Filters_AddedToTree); | |
589 | |
590 class LayerTreeHostDelegatedTestLayerUsesFrameDamage | 470 class LayerTreeHostDelegatedTestLayerUsesFrameDamage |
591 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { | 471 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { |
592 public: | 472 public: |
593 LayerTreeHostDelegatedTestLayerUsesFrameDamage() | 473 LayerTreeHostDelegatedTestLayerUsesFrameDamage() |
594 : LayerTreeHostDelegatedTestCaseSingleDelegatedLayer(), | 474 : LayerTreeHostDelegatedTestCaseSingleDelegatedLayer(), |
595 first_draw_for_source_frame_(true) {} | 475 first_draw_for_source_frame_(true) {} |
596 | 476 |
597 virtual void DidCommit() OVERRIDE { | 477 virtual void DidCommit() OVERRIDE { |
598 int next_source_frame_number = layer_tree_host()->source_frame_number(); | 478 int next_source_frame_number = layer_tree_host()->source_frame_number(); |
599 switch (next_source_frame_number) { | 479 switch (next_source_frame_number) { |
(...skipping 1716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2316 } | 2196 } |
2317 | 2197 |
2318 scoped_refptr<DelegatedRendererLayer> delegated_thief_; | 2198 scoped_refptr<DelegatedRendererLayer> delegated_thief_; |
2319 }; | 2199 }; |
2320 | 2200 |
2321 SINGLE_AND_MULTI_THREAD_TEST_F( | 2201 SINGLE_AND_MULTI_THREAD_TEST_F( |
2322 LayerTreeHostDelegatedTestRemoveAndChangeResources); | 2202 LayerTreeHostDelegatedTestRemoveAndChangeResources); |
2323 | 2203 |
2324 } // namespace | 2204 } // namespace |
2325 } // namespace cc | 2205 } // namespace cc |
OLD | NEW |