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

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

Issue 2382873002: Replace usage of SurfaceId's client_id with 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/surfaces_pixeltest.cc ('k') | cc/trees/layer_tree_host.h » ('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 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 uint32_t kCompositorClientId = 1;
18 static constexpr uint32_t kCompositorSinkId = 1;
18 19
19 namespace cc { 20 namespace cc {
20 21
21 TestCompositorFrameSink::TestCompositorFrameSink( 22 TestCompositorFrameSink::TestCompositorFrameSink(
22 scoped_refptr<ContextProvider> compositor_context_provider, 23 scoped_refptr<ContextProvider> compositor_context_provider,
23 scoped_refptr<ContextProvider> worker_context_provider, 24 scoped_refptr<ContextProvider> worker_context_provider,
24 std::unique_ptr<OutputSurface> display_output_surface, 25 std::unique_ptr<OutputSurface> display_output_surface,
25 SharedBitmapManager* shared_bitmap_manager, 26 SharedBitmapManager* shared_bitmap_manager,
26 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, 27 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
27 const RendererSettings& renderer_settings, 28 const RendererSettings& renderer_settings,
28 base::SingleThreadTaskRunner* task_runner, 29 base::SingleThreadTaskRunner* task_runner,
29 bool synchronous_composite, 30 bool synchronous_composite,
30 bool force_disable_reclaim_resources) 31 bool force_disable_reclaim_resources)
31 : CompositorFrameSink(std::move(compositor_context_provider), 32 : CompositorFrameSink(std::move(compositor_context_provider),
32 std::move(worker_context_provider)), 33 std::move(worker_context_provider)),
33 surface_manager_(new SurfaceManager), 34 surface_manager_(new SurfaceManager),
34 surface_id_allocator_(new SurfaceIdAllocator(kCompositorClientId)), 35 surface_id_allocator_(new SurfaceIdAllocator(
36 FrameSinkId(kCompositorClientId, kCompositorSinkId))),
35 surface_factory_(new SurfaceFactory(surface_manager_.get(), this)) { 37 surface_factory_(new SurfaceFactory(surface_manager_.get(), this)) {
36 std::unique_ptr<SyntheticBeginFrameSource> begin_frame_source; 38 std::unique_ptr<SyntheticBeginFrameSource> begin_frame_source;
37 std::unique_ptr<DisplayScheduler> scheduler; 39 std::unique_ptr<DisplayScheduler> scheduler;
38 if (!synchronous_composite) { 40 if (!synchronous_composite) {
39 if (renderer_settings.disable_display_vsync) { 41 if (renderer_settings.disable_display_vsync) {
40 begin_frame_source.reset(new BackToBackBeginFrameSource( 42 begin_frame_source.reset(new BackToBackBeginFrameSource(
41 base::MakeUnique<DelayBasedTimeSource>(task_runner))); 43 base::MakeUnique<DelayBasedTimeSource>(task_runner)));
42 } else { 44 } else {
43 begin_frame_source.reset(new DelayBasedBeginFrameSource( 45 begin_frame_source.reset(new DelayBasedBeginFrameSource(
44 base::MakeUnique<DelayBasedTimeSource>(task_runner))); 46 base::MakeUnique<DelayBasedTimeSource>(task_runner)));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 if (!CompositorFrameSink::BindToClient(client)) 82 if (!CompositorFrameSink::BindToClient(client))
81 return false; 83 return false;
82 84
83 // 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
84 // 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
85 // 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
86 // context here. 88 // context here.
87 if (!capabilities_.delegated_sync_points_required && context_provider()) 89 if (!capabilities_.delegated_sync_points_required && context_provider())
88 context_provider()->SetLostContextCallback(base::Closure()); 90 context_provider()->SetLostContextCallback(base::Closure());
89 91
90 surface_manager_->RegisterSurfaceClientId(surface_id_allocator_->client_id()); 92 surface_manager_->RegisterFrameSinkId(surface_id_allocator_->frame_sink_id());
91 surface_manager_->RegisterSurfaceFactoryClient( 93 surface_manager_->RegisterSurfaceFactoryClient(
92 surface_id_allocator_->client_id(), this); 94 surface_id_allocator_->frame_sink_id(), this);
93 display_->Initialize(this, surface_manager_.get(), 95 display_->Initialize(this, surface_manager_.get(),
94 surface_id_allocator_->client_id()); 96 surface_id_allocator_->frame_sink_id());
95 display_->renderer_for_testing()->SetEnlargePassTextureAmountForTesting( 97 display_->renderer_for_testing()->SetEnlargePassTextureAmountForTesting(
96 enlarge_pass_texture_amount_); 98 enlarge_pass_texture_amount_);
97 display_->SetVisible(true); 99 display_->SetVisible(true);
98 bound_ = true; 100 bound_ = true;
99 return true; 101 return true;
100 } 102 }
101 103
102 void TestCompositorFrameSink::DetachFromClient() { 104 void TestCompositorFrameSink::DetachFromClient() {
103 // Some tests make BindToClient fail on purpose. ^__^ 105 // Some tests make BindToClient fail on purpose. ^__^
104 if (bound_) { 106 if (bound_) {
105 if (!delegated_surface_id_.is_null()) 107 if (!delegated_surface_id_.is_null())
106 surface_factory_->Destroy(delegated_surface_id_); 108 surface_factory_->Destroy(delegated_surface_id_);
107 surface_manager_->UnregisterSurfaceFactoryClient( 109 surface_manager_->UnregisterSurfaceFactoryClient(
108 surface_id_allocator_->client_id()); 110 surface_id_allocator_->frame_sink_id());
109 surface_manager_->InvalidateSurfaceClientId( 111 surface_manager_->InvalidateFrameSinkId(
110 surface_id_allocator_->client_id()); 112 surface_id_allocator_->frame_sink_id());
111 bound_ = false; 113 bound_ = false;
112 } 114 }
113 display_ = nullptr; 115 display_ = nullptr;
114 surface_factory_ = nullptr; 116 surface_factory_ = nullptr;
115 surface_id_allocator_ = nullptr; 117 surface_id_allocator_ = nullptr;
116 surface_manager_ = nullptr; 118 surface_manager_ = nullptr;
117 CompositorFrameSink::DetachFromClient(); 119 CompositorFrameSink::DetachFromClient();
118 } 120 }
119 121
120 void TestCompositorFrameSink::SwapBuffers(CompositorFrame frame) { 122 void TestCompositorFrameSink::SwapBuffers(CompositorFrame frame) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 if (test_client_) 185 if (test_client_)
184 test_client_->DisplayWillDrawAndSwap(will_draw_and_swap, render_passes); 186 test_client_->DisplayWillDrawAndSwap(will_draw_and_swap, render_passes);
185 } 187 }
186 188
187 void TestCompositorFrameSink::DisplayDidDrawAndSwap() { 189 void TestCompositorFrameSink::DisplayDidDrawAndSwap() {
188 if (test_client_) 190 if (test_client_)
189 test_client_->DisplayDidDrawAndSwap(); 191 test_client_->DisplayDidDrawAndSwap();
190 } 192 }
191 193
192 } // namespace cc 194 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surfaces_pixeltest.cc ('k') | cc/trees/layer_tree_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698