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

Side by Side Diff: content/browser/compositor/reflector_impl_unittest.cc

Issue 2511273002: Decouple BrowserCompositorOutputSurface from BeginFrameSource. (Closed)
Patch Set: Another attempt to fix the crash Created 4 years, 1 month 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 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 "base/memory/ptr_util.h" 5 #include "base/memory/ptr_util.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "base/single_thread_task_runner.h" 7 #include "base/single_thread_task_runner.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "cc/output/output_surface_frame.h" 9 #include "cc/output/output_surface_frame.h"
10 #include "cc/scheduler/begin_frame_source.h" 10 #include "cc/scheduler/begin_frame_source.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 new TestOverlayCandidatesOzone()), 70 new TestOverlayCandidatesOzone()),
71 false)); 71 false));
72 #else 72 #else
73 return nullptr; 73 return nullptr;
74 #endif // defined(USE_OZONE) 74 #endif // defined(USE_OZONE)
75 } 75 }
76 76
77 class TestOutputSurface : public BrowserCompositorOutputSurface { 77 class TestOutputSurface : public BrowserCompositorOutputSurface {
78 public: 78 public:
79 TestOutputSurface(scoped_refptr<cc::ContextProvider> context_provider, 79 TestOutputSurface(scoped_refptr<cc::ContextProvider> context_provider,
80 scoped_refptr<ui::CompositorVSyncManager> vsync_manager, 80 scoped_refptr<ui::CompositorVSyncManager> vsync_manager)
81 cc::SyntheticBeginFrameSource* begin_frame_source)
82 : BrowserCompositorOutputSurface(std::move(context_provider), 81 : BrowserCompositorOutputSurface(std::move(context_provider),
83 std::move(vsync_manager), 82 std::move(vsync_manager),
84 begin_frame_source, 83 CreateTestValidatorOzone()) {}
85 CreateTestValidatorOzone()) {
86 }
87 84
88 void SetFlip(bool flip) { capabilities_.flipped_output_surface = flip; } 85 void SetFlip(bool flip) { capabilities_.flipped_output_surface = flip; }
89 86
90 void BindToClient(cc::OutputSurfaceClient* client) override {} 87 void BindToClient(cc::OutputSurfaceClient* client) override {}
91 void EnsureBackbuffer() override {} 88 void EnsureBackbuffer() override {}
92 void DiscardBackbuffer() override {} 89 void DiscardBackbuffer() override {}
93 void BindFramebuffer() override {} 90 void BindFramebuffer() override {}
94 void Reshape(const gfx::Size& size, 91 void Reshape(const gfx::Size& size,
95 float device_scale_factor, 92 float device_scale_factor,
96 const gfx::ColorSpace& color_space, 93 const gfx::ColorSpace& color_space,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 new NoTransportImageTransportFactory)); 131 new NoTransportImageTransportFactory));
135 message_loop_.reset(new base::MessageLoop()); 132 message_loop_.reset(new base::MessageLoop());
136 task_runner_ = message_loop_->task_runner(); 133 task_runner_ = message_loop_->task_runner();
137 compositor_task_runner_ = new FakeTaskRunner(); 134 compositor_task_runner_ = new FakeTaskRunner();
138 begin_frame_source_.reset(new cc::DelayBasedBeginFrameSource( 135 begin_frame_source_.reset(new cc::DelayBasedBeginFrameSource(
139 base::MakeUnique<cc::DelayBasedTimeSource>( 136 base::MakeUnique<cc::DelayBasedTimeSource>(
140 compositor_task_runner_.get()))); 137 compositor_task_runner_.get())));
141 compositor_.reset( 138 compositor_.reset(
142 new ui::Compositor(context_factory, compositor_task_runner_.get())); 139 new ui::Compositor(context_factory, compositor_task_runner_.get()));
143 compositor_->SetAcceleratedWidget(gfx::kNullAcceleratedWidget); 140 compositor_->SetAcceleratedWidget(gfx::kNullAcceleratedWidget);
141 compositor_->vsync_manager()->AddObserver(begin_frame_source_.get());
144 142
145 auto context_provider = cc::TestContextProvider::Create(); 143 auto context_provider = cc::TestContextProvider::Create();
146 context_provider->BindToCurrentThread(); 144 context_provider->BindToCurrentThread();
147 output_surface_ = base::MakeUnique<TestOutputSurface>( 145 output_surface_ = base::MakeUnique<TestOutputSurface>(
148 std::move(context_provider), compositor_->vsync_manager(), 146 std::move(context_provider), compositor_->vsync_manager());
149 begin_frame_source_.get());
150 147
151 root_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); 148 root_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR));
152 compositor_->SetRootLayer(root_layer_.get()); 149 compositor_->SetRootLayer(root_layer_.get());
153 mirroring_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); 150 mirroring_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR));
154 compositor_->root_layer()->Add(mirroring_layer_.get()); 151 compositor_->root_layer()->Add(mirroring_layer_.get());
155 output_surface_->Reshape(kSurfaceSize, 1.f, gfx::ColorSpace(), false); 152 output_surface_->Reshape(kSurfaceSize, 1.f, gfx::ColorSpace(), false);
156 mirroring_layer_->SetBounds(gfx::Rect(kSurfaceSize)); 153 mirroring_layer_->SetBounds(gfx::Rect(kSurfaceSize));
157 } 154 }
158 155
159 void SetUpReflector() { 156 void SetUpReflector() {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 plane_2.plane_z_order = 1; 227 plane_2.plane_z_order = 1;
231 list.push_back(plane_1); 228 list.push_back(plane_1);
232 list.push_back(plane_2); 229 list.push_back(plane_2);
233 output_surface_->GetOverlayCandidateValidator()->CheckOverlaySupport(&list); 230 output_surface_->GetOverlayCandidateValidator()->CheckOverlaySupport(&list);
234 EXPECT_FALSE(list[0].overlay_handled); 231 EXPECT_FALSE(list[0].overlay_handled);
235 } 232 }
236 #endif // defined(USE_OZONE) 233 #endif // defined(USE_OZONE)
237 234
238 } // namespace 235 } // namespace
239 } // namespace content 236 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698