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

Side by Side Diff: cc/surfaces/direct_compositor_frame_sink_unittest.cc

Issue 2383373002: Reduce SurfaceIdAllocator usage and tie SurfaceFactory to a single FrameSinkId (Closed)
Patch Set: Rebased Created 4 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
« no previous file with comments | « cc/surfaces/direct_compositor_frame_sink.cc ('k') | cc/surfaces/display_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/surfaces/direct_compositor_frame_sink.h" 5 #include "cc/surfaces/direct_compositor_frame_sink.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "cc/output/renderer_settings.h" 9 #include "cc/output/renderer_settings.h"
10 #include "cc/output/texture_mailbox_deleter.h" 10 #include "cc/output/texture_mailbox_deleter.h"
(...skipping 15 matching lines...) Expand all
26 namespace cc { 26 namespace cc {
27 namespace { 27 namespace {
28 28
29 static constexpr FrameSinkId kArbitraryFrameSinkId(1, 1); 29 static constexpr FrameSinkId kArbitraryFrameSinkId(1, 1);
30 30
31 class DirectCompositorFrameSinkTest : public testing::Test { 31 class DirectCompositorFrameSinkTest : public testing::Test {
32 public: 32 public:
33 DirectCompositorFrameSinkTest() 33 DirectCompositorFrameSinkTest()
34 : now_src_(new base::SimpleTestTickClock()), 34 : now_src_(new base::SimpleTestTickClock()),
35 task_runner_(new OrderedSimpleTaskRunner(now_src_.get(), true)), 35 task_runner_(new OrderedSimpleTaskRunner(now_src_.get(), true)),
36 allocator_(kArbitraryFrameSinkId),
37 display_size_(1920, 1080), 36 display_size_(1920, 1080),
38 display_rect_(display_size_), 37 display_rect_(display_size_),
39 context_provider_(TestContextProvider::Create()) { 38 context_provider_(TestContextProvider::Create()) {
40 surface_manager_.RegisterFrameSinkId(allocator_.frame_sink_id()); 39 surface_manager_.RegisterFrameSinkId(kArbitraryFrameSinkId);
41 40
42 std::unique_ptr<FakeOutputSurface> display_output_surface = 41 std::unique_ptr<FakeOutputSurface> display_output_surface =
43 FakeOutputSurface::Create3d(); 42 FakeOutputSurface::Create3d();
44 display_output_surface_ = display_output_surface.get(); 43 display_output_surface_ = display_output_surface.get();
45 44
46 std::unique_ptr<BeginFrameSource> begin_frame_source( 45 std::unique_ptr<BeginFrameSource> begin_frame_source(
47 new BackToBackBeginFrameSource( 46 new BackToBackBeginFrameSource(
48 base::MakeUnique<DelayBasedTimeSource>(task_runner_.get()))); 47 base::MakeUnique<DelayBasedTimeSource>(task_runner_.get())));
49 48
50 int max_frames_pending = 2; 49 int max_frames_pending = 2;
51 std::unique_ptr<DisplayScheduler> scheduler(new DisplayScheduler( 50 std::unique_ptr<DisplayScheduler> scheduler(new DisplayScheduler(
52 begin_frame_source.get(), task_runner_.get(), max_frames_pending)); 51 begin_frame_source.get(), task_runner_.get(), max_frames_pending));
53 52
54 display_.reset(new Display( 53 display_.reset(new Display(
55 &bitmap_manager_, &gpu_memory_buffer_manager_, RendererSettings(), 54 &bitmap_manager_, &gpu_memory_buffer_manager_, RendererSettings(),
56 std::move(begin_frame_source), std::move(display_output_surface), 55 std::move(begin_frame_source), std::move(display_output_surface),
57 std::move(scheduler), 56 std::move(scheduler),
58 base::MakeUnique<TextureMailboxDeleter>(task_runner_.get()))); 57 base::MakeUnique<TextureMailboxDeleter>(task_runner_.get())));
59 compositor_frame_sink_.reset(new DirectCompositorFrameSink( 58 compositor_frame_sink_.reset(new DirectCompositorFrameSink(
60 &surface_manager_, &allocator_, display_.get(), context_provider_, 59 kArbitraryFrameSinkId, &surface_manager_, display_.get(),
61 nullptr)); 60 context_provider_, nullptr));
62 61
63 compositor_frame_sink_->BindToClient(&compositor_frame_sink_client_); 62 compositor_frame_sink_->BindToClient(&compositor_frame_sink_client_);
64 display_->Resize(display_size_); 63 display_->Resize(display_size_);
65 display_->SetVisible(true); 64 display_->SetVisible(true);
66 65
67 EXPECT_FALSE( 66 EXPECT_FALSE(
68 compositor_frame_sink_client_.did_lose_compositor_frame_sink_called()); 67 compositor_frame_sink_client_.did_lose_compositor_frame_sink_called());
69 } 68 }
70 69
71 ~DirectCompositorFrameSinkTest() override {} 70 ~DirectCompositorFrameSinkTest() override {}
(...skipping 17 matching lines...) Expand all
89 SwapBuffersWithDamage(display_rect_); 88 SwapBuffersWithDamage(display_rect_);
90 89
91 EXPECT_EQ(0u, display_output_surface_->num_sent_frames()); 90 EXPECT_EQ(0u, display_output_surface_->num_sent_frames());
92 task_runner_->RunUntilIdle(); 91 task_runner_->RunUntilIdle();
93 EXPECT_EQ(1u, display_output_surface_->num_sent_frames()); 92 EXPECT_EQ(1u, display_output_surface_->num_sent_frames());
94 } 93 }
95 94
96 protected: 95 protected:
97 std::unique_ptr<base::SimpleTestTickClock> now_src_; 96 std::unique_ptr<base::SimpleTestTickClock> now_src_;
98 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; 97 scoped_refptr<OrderedSimpleTaskRunner> task_runner_;
99 SurfaceIdAllocator allocator_;
100 98
101 const gfx::Size display_size_; 99 const gfx::Size display_size_;
102 const gfx::Rect display_rect_; 100 const gfx::Rect display_rect_;
103 SurfaceManager surface_manager_; 101 SurfaceManager surface_manager_;
104 TestSharedBitmapManager bitmap_manager_; 102 TestSharedBitmapManager bitmap_manager_;
105 TestGpuMemoryBufferManager gpu_memory_buffer_manager_; 103 TestGpuMemoryBufferManager gpu_memory_buffer_manager_;
106 104
107 scoped_refptr<TestContextProvider> context_provider_; 105 scoped_refptr<TestContextProvider> context_provider_;
108 FakeOutputSurface* display_output_surface_ = nullptr; 106 FakeOutputSurface* display_output_surface_ = nullptr;
109 std::unique_ptr<Display> display_; 107 std::unique_ptr<Display> display_;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 EXPECT_EQ(1u, display_output_surface_->num_sent_frames()); 146 EXPECT_EQ(1u, display_output_surface_->num_sent_frames());
149 147
150 SwapBuffersWithDamage(gfx::Rect()); 148 SwapBuffersWithDamage(gfx::Rect());
151 EXPECT_EQ(1u, display_output_surface_->num_sent_frames()); 149 EXPECT_EQ(1u, display_output_surface_->num_sent_frames());
152 task_runner_->RunUntilIdle(); 150 task_runner_->RunUntilIdle();
153 EXPECT_EQ(1u, display_output_surface_->num_sent_frames()); 151 EXPECT_EQ(1u, display_output_surface_->num_sent_frames());
154 } 152 }
155 153
156 } // namespace 154 } // namespace
157 } // namespace cc 155 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/direct_compositor_frame_sink.cc ('k') | cc/surfaces/display_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698