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

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

Issue 23694031: Fix race conditions in window snapshot code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing further feedback, added stress test for snapshots Created 7 years, 2 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/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 629
630 if (sfn == kReadbackReplacementSourceFrameNumber) 630 if (sfn == kReadbackReplacementSourceFrameNumber)
631 EndTest(); 631 EndTest();
632 } 632 }
633 633
634 virtual void AfterTest() OVERRIDE {} 634 virtual void AfterTest() OVERRIDE {}
635 }; 635 };
636 636
637 MULTI_THREAD_TEST_F(LayerTreeHostTestCompositeAndReadbackAfterForcedDraw); 637 MULTI_THREAD_TEST_F(LayerTreeHostTestCompositeAndReadbackAfterForcedDraw);
638 638
639 class LayerTreeHostTestSetNextCommitForcesRedraw : public LayerTreeHostTest {
bajones 2013/09/26 22:27:23 @enne: Not being overly familiar with these tests
640 public:
641 LayerTreeHostTestSetNextCommitForcesRedraw()
642 : num_draws_(0),
643 bounds_(50, 50),
644 root_layer_(ContentLayer::Create(&client_)) {
645 }
646
647 virtual void BeginTest() OVERRIDE {
648 root_layer_->SetIsDrawable(true);
649 root_layer_->SetBounds(bounds_);
650 layer_tree_host()->SetRootLayer(root_layer_);
651 layer_tree_host()->SetViewportSize(bounds_);
652 PostSetNeedsCommitToMainThread();
653 }
654
655 virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
656 LayerTreeHostImpl::FrameData* frame_data,
657 bool result) OVERRIDE {
658 EXPECT_TRUE(result);
659
660 gfx::RectF root_damage_rect;
661 if (!frame_data->render_passes.empty())
662 root_damage_rect = frame_data->render_passes.back()->damage_rect;
663
664 // Both passes expect full frame damage
665 EXPECT_RECT_EQ(gfx::Rect(bounds_), root_damage_rect);
666
667 return result;
668 }
669
670 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
enne (OOO) 2013/09/27 19:59:07 This test is good, but I'd like to make more sure
671 if (!num_draws_) {
672 // Should force full frame damage on the next commit
673 PostSetNextCommitForcesRedrawToMainThread();
674 PostSetNeedsCommitToMainThread();
675 } else {
676 EndTest();
677 }
678 num_draws_++;
679 }
680
681 virtual void AfterTest() OVERRIDE {
682 EXPECT_EQ(2, num_draws_);
683 }
684
685 private:
686 int num_draws_;
687 const gfx::Size bounds_;
688 FakeContentLayerClient client_;
689 scoped_refptr<ContentLayer> root_layer_;
690 };
691
692 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNextCommitForcesRedraw);
693
639 // If the layerTreeHost says it can't draw, Then we should not try to draw. 694 // If the layerTreeHost says it can't draw, Then we should not try to draw.
640 class LayerTreeHostTestCanDrawBlocksDrawing : public LayerTreeHostTest { 695 class LayerTreeHostTestCanDrawBlocksDrawing : public LayerTreeHostTest {
641 public: 696 public:
642 LayerTreeHostTestCanDrawBlocksDrawing() : num_commits_(0), done_(false) {} 697 LayerTreeHostTestCanDrawBlocksDrawing() : num_commits_(0), done_(false) {}
643 698
644 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 699 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
645 700
646 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { 701 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
647 if (done_) 702 if (done_)
648 return; 703 return;
(...skipping 4126 matching lines...) Expand 10 before | Expand all | Expand 10 after
4775 4830
4776 private: 4831 private:
4777 int num_commits_; 4832 int num_commits_;
4778 }; 4833 };
4779 4834
4780 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestMemoryLimits); 4835 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestMemoryLimits);
4781 4836
4782 } // namespace 4837 } // namespace
4783 4838
4784 } // namespace cc 4839 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698