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

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

Issue 640203002: [C++11 Allowed Features] Declares a type-safe null pointer converting from NULL to nullptr [part-… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "cc/layers/content_layer.h" 8 #include "cc/layers/content_layer.h"
9 #include "cc/layers/delegated_frame_provider.h" 9 #include "cc/layers/delegated_frame_provider.h"
10 #include "cc/layers/delegated_frame_resource_collection.h" 10 #include "cc/layers/delegated_frame_resource_collection.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 using media::VideoFrame; 47 using media::VideoFrame;
48 48
49 namespace cc { 49 namespace cc {
50 namespace { 50 namespace {
51 51
52 // These tests deal with losing the 3d graphics context. 52 // These tests deal with losing the 3d graphics context.
53 class LayerTreeHostContextTest : public LayerTreeTest { 53 class LayerTreeHostContextTest : public LayerTreeTest {
54 public: 54 public:
55 LayerTreeHostContextTest() 55 LayerTreeHostContextTest()
56 : LayerTreeTest(), 56 : LayerTreeTest(),
57 context3d_(NULL), 57 context3d_(nullptr),
58 times_to_fail_create_(0), 58 times_to_fail_create_(0),
59 times_to_lose_during_commit_(0), 59 times_to_lose_during_commit_(0),
60 times_to_lose_during_draw_(0), 60 times_to_lose_during_draw_(0),
61 times_to_fail_recreate_(0), 61 times_to_fail_recreate_(0),
62 times_to_expect_create_failed_(0), 62 times_to_expect_create_failed_(0),
63 times_create_failed_(0), 63 times_create_failed_(0),
64 committed_at_least_once_(false), 64 committed_at_least_once_(false),
65 context_should_support_io_surface_(false), 65 context_should_support_io_surface_(false),
66 fallback_context_works_(false), 66 fallback_context_works_(false),
67 async_output_surface_creation_(false) { 67 async_output_surface_creation_(false) {
68 media::InitializeMediaLibraryForTesting(); 68 media::InitializeMediaLibraryForTesting();
69 } 69 }
70 70
71 void LoseContext() { 71 void LoseContext() {
72 // For sanity-checking tests, they should only call this when the 72 // For sanity-checking tests, they should only call this when the
73 // context is not lost. 73 // context is not lost.
74 CHECK(context3d_); 74 CHECK(context3d_);
75 context3d_->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, 75 context3d_->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
76 GL_INNOCENT_CONTEXT_RESET_ARB); 76 GL_INNOCENT_CONTEXT_RESET_ARB);
77 context3d_ = NULL; 77 context3d_ = nullptr;
78 } 78 }
79 79
80 virtual scoped_ptr<TestWebGraphicsContext3D> CreateContext3d() { 80 virtual scoped_ptr<TestWebGraphicsContext3D> CreateContext3d() {
81 return TestWebGraphicsContext3D::Create(); 81 return TestWebGraphicsContext3D::Create();
82 } 82 }
83 83
84 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback) 84 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback)
85 override { 85 override {
86 if (times_to_fail_create_) { 86 if (times_to_fail_create_) {
87 --times_to_fail_create_; 87 --times_to_fail_create_;
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 756
757 layer_tree_host()->SetRootLayer(root_); 757 layer_tree_host()->SetRootLayer(root_);
758 LayerTreeHostContextTest::SetupTree(); 758 LayerTreeHostContextTest::SetupTree();
759 } 759 }
760 760
761 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); } 761 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
762 762
763 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { 763 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
764 LayerTreeHostContextTest::DidActivateTreeOnThread(host_impl); 764 LayerTreeHostContextTest::DidActivateTreeOnThread(host_impl);
765 765
766 FakePictureLayerImpl* root_picture = NULL; 766 FakePictureLayerImpl* root_picture = nullptr;
767 FakePictureLayerImpl* child_picture = NULL; 767 FakePictureLayerImpl* child_picture = nullptr;
768 FakePictureLayerImpl* grandchild_picture = NULL; 768 FakePictureLayerImpl* grandchild_picture = nullptr;
769 FakeContentLayerImpl* root_content = NULL; 769 FakeContentLayerImpl* root_content = nullptr;
770 FakeContentLayerImpl* child_content = NULL; 770 FakeContentLayerImpl* child_content = nullptr;
771 FakeContentLayerImpl* grandchild_content = NULL; 771 FakeContentLayerImpl* grandchild_content = nullptr;
772 772
773 if (layer_tree_host()->settings().impl_side_painting) { 773 if (layer_tree_host()->settings().impl_side_painting) {
774 root_picture = static_cast<FakePictureLayerImpl*>( 774 root_picture = static_cast<FakePictureLayerImpl*>(
775 host_impl->active_tree()->root_layer()); 775 host_impl->active_tree()->root_layer());
776 child_picture = 776 child_picture =
777 static_cast<FakePictureLayerImpl*>(root_picture->children()[0]); 777 static_cast<FakePictureLayerImpl*>(root_picture->children()[0]);
778 grandchild_picture = 778 grandchild_picture =
779 static_cast<FakePictureLayerImpl*>(child_picture->children()[0]); 779 static_cast<FakePictureLayerImpl*>(child_picture->children()[0]);
780 780
781 } else { 781 } else {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 public: 840 public:
841 LayerTreeHostContextTestDontUseLostResources() : lost_context_(false) { 841 LayerTreeHostContextTestDontUseLostResources() : lost_context_(false) {
842 context_should_support_io_surface_ = true; 842 context_should_support_io_surface_ = true;
843 843
844 child_output_surface_ = FakeOutputSurface::Create3d(); 844 child_output_surface_ = FakeOutputSurface::Create3d();
845 child_output_surface_->BindToClient(&output_surface_client_); 845 child_output_surface_->BindToClient(&output_surface_client_);
846 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); 846 shared_bitmap_manager_.reset(new TestSharedBitmapManager());
847 child_resource_provider_ = 847 child_resource_provider_ =
848 ResourceProvider::Create(child_output_surface_.get(), 848 ResourceProvider::Create(child_output_surface_.get(),
849 shared_bitmap_manager_.get(), 849 shared_bitmap_manager_.get(),
850 NULL, 850 nullptr,
851 0, 851 0,
852 false, 852 false,
853 1, 853 1,
854 false); 854 false);
855 } 855 }
856 856
857 static void EmptyReleaseCallback(unsigned sync_point, bool lost) {} 857 static void EmptyReleaseCallback(unsigned sync_point, bool lost) {}
858 858
859 virtual void SetupTree() override { 859 virtual void SetupTree() override {
860 gpu::gles2::GLES2Interface* gl = 860 gpu::gles2::GLES2Interface* gl =
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 910
911 scoped_refptr<Layer> layer; 911 scoped_refptr<Layer> layer;
912 if (layer_tree_host()->settings().impl_side_painting) 912 if (layer_tree_host()->settings().impl_side_painting)
913 layer = PictureLayer::Create(&client_); 913 layer = PictureLayer::Create(&client_);
914 else 914 else
915 layer = ContentLayer::Create(&client_); 915 layer = ContentLayer::Create(&client_);
916 layer->SetBounds(gfx::Size(10, 10)); 916 layer->SetBounds(gfx::Size(10, 10));
917 layer->SetIsDrawable(true); 917 layer->SetIsDrawable(true);
918 root->AddChild(layer); 918 root->AddChild(layer);
919 919
920 scoped_refptr<TextureLayer> texture = TextureLayer::CreateForMailbox(NULL); 920 scoped_refptr<TextureLayer> texture = TextureLayer::CreateForMailbox(nullptr );
danakj 2014/10/09 16:00:53 and here..
921 texture->SetBounds(gfx::Size(10, 10)); 921 texture->SetBounds(gfx::Size(10, 10));
922 texture->SetIsDrawable(true); 922 texture->SetIsDrawable(true);
923 texture->SetTextureMailbox( 923 texture->SetTextureMailbox(
924 TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point), 924 TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point),
925 SingleReleaseCallback::Create( 925 SingleReleaseCallback::Create(
926 base::Bind(&LayerTreeHostContextTestDontUseLostResources:: 926 base::Bind(&LayerTreeHostContextTestDontUseLostResources::
927 EmptyReleaseCallback))); 927 EmptyReleaseCallback)));
928 root->AddChild(texture); 928 root->AddChild(texture);
929 929
930 scoped_refptr<Layer> mask; 930 scoped_refptr<Layer> mask;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 1014
1015 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1015 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1016 1016
1017 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { 1017 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
1018 LayerTreeHostContextTest::CommitCompleteOnThread(host_impl); 1018 LayerTreeHostContextTest::CommitCompleteOnThread(host_impl);
1019 1019
1020 if (host_impl->active_tree()->source_frame_number() == 3) { 1020 if (host_impl->active_tree()->source_frame_number() == 3) {
1021 // On the third commit we're recovering from context loss. Hardware 1021 // On the third commit we're recovering from context loss. Hardware
1022 // video frames should not be reused by the VideoFrameProvider, but 1022 // video frames should not be reused by the VideoFrameProvider, but
1023 // software frames can be. 1023 // software frames can be.
1024 hw_frame_provider_.set_frame(NULL); 1024 hw_frame_provider_.set_frame(nullptr);
1025 scaled_hw_frame_provider_.set_frame(NULL); 1025 scaled_hw_frame_provider_.set_frame(nullptr);
1026 } 1026 }
1027 } 1027 }
1028 1028
1029 virtual DrawResult PrepareToDrawOnThread( 1029 virtual DrawResult PrepareToDrawOnThread(
1030 LayerTreeHostImpl* host_impl, 1030 LayerTreeHostImpl* host_impl,
1031 LayerTreeHostImpl::FrameData* frame, 1031 LayerTreeHostImpl::FrameData* frame,
1032 DrawResult draw_result) override { 1032 DrawResult draw_result) override {
1033 if (host_impl->active_tree()->source_frame_number() == 2) { 1033 if (host_impl->active_tree()->source_frame_number() == 2) {
1034 // Lose the context during draw on the second commit. This will cause 1034 // Lose the context during draw on the second commit. This will cause
1035 // a third commit to recover. 1035 // a third commit to recover.
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
1706 virtual void AfterTest() override {} 1706 virtual void AfterTest() override {}
1707 1707
1708 bool deferred_; 1708 bool deferred_;
1709 }; 1709 };
1710 1710
1711 SINGLE_AND_MULTI_THREAD_TEST_F( 1711 SINGLE_AND_MULTI_THREAD_TEST_F(
1712 LayerTreeHostContextTestLoseAfterSendingBeginMainFrame); 1712 LayerTreeHostContextTestLoseAfterSendingBeginMainFrame);
1713 1713
1714 } // namespace 1714 } // namespace
1715 } // namespace cc 1715 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698