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

Side by Side Diff: cc/test/test_compositor_frame_sink.cc

Issue 2383373002: Reduce SurfaceIdAllocator usage and tie SurfaceFactory to a single FrameSinkId (Closed)
Patch Set: Fix TestRenderViewHost + Mac 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/test/test_compositor_frame_sink.h" 5 #include "cc/test/test_compositor_frame_sink.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "cc/output/begin_frame_args.h" 10 #include "cc/output/begin_frame_args.h"
11 #include "cc/output/compositor_frame_sink_client.h" 11 #include "cc/output/compositor_frame_sink_client.h"
12 #include "cc/output/copy_output_request.h" 12 #include "cc/output/copy_output_request.h"
13 #include "cc/output/direct_renderer.h" 13 #include "cc/output/direct_renderer.h"
14 #include "cc/output/output_surface.h" 14 #include "cc/output/output_surface.h"
15 #include "cc/output/texture_mailbox_deleter.h" 15 #include "cc/output/texture_mailbox_deleter.h"
16 16
17 static constexpr uint32_t kCompositorClientId = 1; 17 static constexpr cc::FrameSinkId kCompositorFrameSinkId(1, 1);
18 static constexpr uint32_t kCompositorSinkId = 1;
19 18
20 namespace cc { 19 namespace cc {
21 20
22 TestCompositorFrameSink::TestCompositorFrameSink( 21 TestCompositorFrameSink::TestCompositorFrameSink(
23 scoped_refptr<ContextProvider> compositor_context_provider, 22 scoped_refptr<ContextProvider> compositor_context_provider,
24 scoped_refptr<ContextProvider> worker_context_provider, 23 scoped_refptr<ContextProvider> worker_context_provider,
25 std::unique_ptr<OutputSurface> display_output_surface, 24 std::unique_ptr<OutputSurface> display_output_surface,
26 SharedBitmapManager* shared_bitmap_manager, 25 SharedBitmapManager* shared_bitmap_manager,
27 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, 26 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
28 const RendererSettings& renderer_settings, 27 const RendererSettings& renderer_settings,
29 base::SingleThreadTaskRunner* task_runner, 28 base::SingleThreadTaskRunner* task_runner,
30 bool synchronous_composite, 29 bool synchronous_composite,
31 bool force_disable_reclaim_resources) 30 bool force_disable_reclaim_resources)
32 : CompositorFrameSink(std::move(compositor_context_provider), 31 : CompositorFrameSink(std::move(compositor_context_provider),
33 std::move(worker_context_provider)), 32 std::move(worker_context_provider)),
33 frame_sink_id_(kCompositorFrameSinkId),
34 surface_manager_(new SurfaceManager), 34 surface_manager_(new SurfaceManager),
35 surface_id_allocator_(new SurfaceIdAllocator( 35 surface_id_allocator_(new SurfaceIdAllocator(frame_sink_id_)),
36 FrameSinkId(kCompositorClientId, kCompositorSinkId))), 36 surface_factory_(
37 surface_factory_(new SurfaceFactory(surface_manager_.get(), this)) { 37 new SurfaceFactory(frame_sink_id_, surface_manager_.get(), this)) {
38 std::unique_ptr<SyntheticBeginFrameSource> begin_frame_source; 38 std::unique_ptr<SyntheticBeginFrameSource> begin_frame_source;
39 std::unique_ptr<DisplayScheduler> scheduler; 39 std::unique_ptr<DisplayScheduler> scheduler;
40 if (!synchronous_composite) { 40 if (!synchronous_composite) {
41 if (renderer_settings.disable_display_vsync) { 41 if (renderer_settings.disable_display_vsync) {
42 begin_frame_source.reset(new BackToBackBeginFrameSource( 42 begin_frame_source.reset(new BackToBackBeginFrameSource(
43 base::MakeUnique<DelayBasedTimeSource>(task_runner))); 43 base::MakeUnique<DelayBasedTimeSource>(task_runner)));
44 } else { 44 } else {
45 begin_frame_source.reset(new DelayBasedBeginFrameSource( 45 begin_frame_source.reset(new DelayBasedBeginFrameSource(
46 base::MakeUnique<DelayBasedTimeSource>(task_runner))); 46 base::MakeUnique<DelayBasedTimeSource>(task_runner)));
47 begin_frame_source->SetAuthoritativeVSyncInterval( 47 begin_frame_source->SetAuthoritativeVSyncInterval(
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 if (!CompositorFrameSink::BindToClient(client)) 82 if (!CompositorFrameSink::BindToClient(client))
83 return false; 83 return false;
84 84
85 // We want the Display's OutputSurface to hear about lost context, and since 85 // We want the Display's OutputSurface to hear about lost context, and since
86 // this shares a context with it (when delegated_sync_points_required is 86 // this shares a context with it (when delegated_sync_points_required is
87 // false), we should not be listening for lost context callbacks on the 87 // false), we should not be listening for lost context callbacks on the
88 // context here. 88 // context here.
89 if (!capabilities_.delegated_sync_points_required && context_provider()) 89 if (!capabilities_.delegated_sync_points_required && context_provider())
90 context_provider()->SetLostContextCallback(base::Closure()); 90 context_provider()->SetLostContextCallback(base::Closure());
91 91
92 surface_manager_->RegisterFrameSinkId(surface_id_allocator_->frame_sink_id()); 92 surface_manager_->RegisterFrameSinkId(frame_sink_id_);
93 surface_manager_->RegisterSurfaceFactoryClient( 93 surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this);
94 surface_id_allocator_->frame_sink_id(), this); 94 display_->Initialize(this, surface_manager_.get(), frame_sink_id_);
95 display_->Initialize(this, surface_manager_.get(),
96 surface_id_allocator_->frame_sink_id());
97 display_->renderer_for_testing()->SetEnlargePassTextureAmountForTesting( 95 display_->renderer_for_testing()->SetEnlargePassTextureAmountForTesting(
98 enlarge_pass_texture_amount_); 96 enlarge_pass_texture_amount_);
99 display_->SetVisible(true); 97 display_->SetVisible(true);
100 bound_ = true; 98 bound_ = true;
101 return true; 99 return true;
102 } 100 }
103 101
104 void TestCompositorFrameSink::DetachFromClient() { 102 void TestCompositorFrameSink::DetachFromClient() {
105 // Some tests make BindToClient fail on purpose. ^__^ 103 // Some tests make BindToClient fail on purpose. ^__^
106 if (bound_) { 104 if (bound_) {
107 if (!delegated_surface_id_.is_null()) 105 if (!delegated_surface_id_.is_null())
108 surface_factory_->Destroy(delegated_surface_id_); 106 surface_factory_->Destroy(delegated_surface_id_);
109 surface_manager_->UnregisterSurfaceFactoryClient( 107 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_);
110 surface_id_allocator_->frame_sink_id()); 108 surface_manager_->InvalidateFrameSinkId(frame_sink_id_);
111 surface_manager_->InvalidateFrameSinkId(
112 surface_id_allocator_->frame_sink_id());
113 bound_ = false; 109 bound_ = false;
114 } 110 }
115 display_ = nullptr; 111 display_ = nullptr;
116 surface_factory_ = nullptr; 112 surface_factory_ = nullptr;
117 surface_id_allocator_ = nullptr; 113 surface_id_allocator_ = nullptr;
118 surface_manager_ = nullptr; 114 surface_manager_ = nullptr;
119 CompositorFrameSink::DetachFromClient(); 115 CompositorFrameSink::DetachFromClient();
120 } 116 }
121 117
122 void TestCompositorFrameSink::SwapBuffers(CompositorFrame frame) { 118 void TestCompositorFrameSink::SwapBuffers(CompositorFrame frame) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 if (test_client_) 181 if (test_client_)
186 test_client_->DisplayWillDrawAndSwap(will_draw_and_swap, render_passes); 182 test_client_->DisplayWillDrawAndSwap(will_draw_and_swap, render_passes);
187 } 183 }
188 184
189 void TestCompositorFrameSink::DisplayDidDrawAndSwap() { 185 void TestCompositorFrameSink::DisplayDidDrawAndSwap() {
190 if (test_client_) 186 if (test_client_)
191 test_client_->DisplayDidDrawAndSwap(); 187 test_client_->DisplayDidDrawAndSwap();
192 } 188 }
193 189
194 } // namespace cc 190 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698