OLD | NEW |
---|---|
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 "blimp/client/support/compositor/blimp_embedder_compositor.h" | 5 #include "blimp/client/support/compositor/blimp_embedder_compositor.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 explicit DisplayOutputSurface( | 44 explicit DisplayOutputSurface( |
45 scoped_refptr<cc::ContextProvider> context_provider, | 45 scoped_refptr<cc::ContextProvider> context_provider, |
46 scoped_refptr<base::SingleThreadTaskRunner> task_runner) | 46 scoped_refptr<base::SingleThreadTaskRunner> task_runner) |
47 : cc::OutputSurface(std::move(context_provider)), | 47 : cc::OutputSurface(std::move(context_provider)), |
48 task_runner_(std::move(task_runner)), | 48 task_runner_(std::move(task_runner)), |
49 weak_ptr_factory_(this) {} | 49 weak_ptr_factory_(this) {} |
50 | 50 |
51 ~DisplayOutputSurface() override = default; | 51 ~DisplayOutputSurface() override = default; |
52 | 52 |
53 // cc::OutputSurface implementation | 53 // cc::OutputSurface implementation |
54 void BindToClient(cc::OutputSurfaceClient* client) override { | |
55 client_ = client; | |
56 } | |
54 void EnsureBackbuffer() override {} | 57 void EnsureBackbuffer() override {} |
55 void DiscardBackbuffer() override { | 58 void DiscardBackbuffer() override { |
56 context_provider()->ContextGL()->DiscardBackbufferCHROMIUM(); | 59 context_provider()->ContextGL()->DiscardBackbufferCHROMIUM(); |
57 } | 60 } |
58 void BindFramebuffer() override { | 61 void BindFramebuffer() override { |
59 context_provider()->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, 0); | 62 context_provider()->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, 0); |
60 } | 63 } |
61 void Reshape(const gfx::Size& size, | 64 void Reshape(const gfx::Size& size, |
62 float device_scale_factor, | 65 float device_scale_factor, |
63 const gfx::ColorSpace& color_space, | 66 const gfx::ColorSpace& color_space, |
(...skipping 19 matching lines...) Expand all Loading... | |
83 // We assume we have an alpha channel from the BlimpContextProvider, so use | 86 // We assume we have an alpha channel from the BlimpContextProvider, so use |
84 // GL_RGBA here. | 87 // GL_RGBA here. |
85 return GL_RGBA; | 88 return GL_RGBA; |
86 } | 89 } |
87 bool HasExternalStencilTest() const override { return false; } | 90 bool HasExternalStencilTest() const override { return false; } |
88 void ApplyExternalStencil() override {} | 91 void ApplyExternalStencil() override {} |
89 | 92 |
90 private: | 93 private: |
91 void SwapBuffersCallback() { client_->DidReceiveSwapBuffersAck(); } | 94 void SwapBuffersCallback() { client_->DidReceiveSwapBuffersAck(); } |
92 | 95 |
96 cc::OutputSurfaceClient* client_ = nullptr; | |
93 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 97 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
94 base::WeakPtrFactory<DisplayOutputSurface> weak_ptr_factory_; | 98 base::WeakPtrFactory<DisplayOutputSurface> weak_ptr_factory_; |
95 | 99 |
96 DISALLOW_COPY_AND_ASSIGN(DisplayOutputSurface); | 100 DISALLOW_COPY_AND_ASSIGN(DisplayOutputSurface); |
97 }; | 101 }; |
98 | 102 |
99 base::LazyInstance<SimpleTaskGraphRunner> g_task_graph_runner = | 103 base::LazyInstance<SimpleTaskGraphRunner> g_task_graph_runner = |
100 LAZY_INSTANCE_INITIALIZER; | 104 LAZY_INSTANCE_INITIALIZER; |
101 | 105 |
102 } // namespace | 106 } // namespace |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 NOTREACHED() << "Can't fail to initialize the CompositorFrameSink here"; | 190 NOTREACHED() << "Can't fail to initialize the CompositorFrameSink here"; |
187 } | 191 } |
188 | 192 |
189 void BlimpEmbedderCompositor::HandlePendingCompositorFrameSinkRequest() { | 193 void BlimpEmbedderCompositor::HandlePendingCompositorFrameSinkRequest() { |
190 DCHECK(compositor_frame_sink_request_pending_); | 194 DCHECK(compositor_frame_sink_request_pending_); |
191 | 195 |
192 // Can't handle the request right now since we don't have a widget. | 196 // Can't handle the request right now since we don't have a widget. |
193 if (!host_->IsVisible()) | 197 if (!host_->IsVisible()) |
194 return; | 198 return; |
195 | 199 |
196 DCHECK(context_provider_); | 200 DCHECK(context_provider_); |
Khushal
2016/10/25 01:10:02
Should we context_provider_->BindToCurrentThread()
danakj
2016/10/25 18:58:38
No this is for the layer compositor's context it w
danakj
2016/10/25 19:00:00
I lied, I guess this is shared. Blimp is single th
Khushal
2016/10/25 20:45:06
I actually got confused about whether it was neede
danakj
2016/10/25 20:47:23
Ya, Display will no longer (double) bind the conte
| |
197 | 201 |
198 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = | 202 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = |
199 compositor_dependencies_->GetGpuMemoryBufferManager(); | 203 compositor_dependencies_->GetGpuMemoryBufferManager(); |
200 | 204 |
201 auto task_runner = base::ThreadTaskRunnerHandle::Get(); | 205 auto task_runner = base::ThreadTaskRunnerHandle::Get(); |
202 auto display_output_surface = | 206 auto display_output_surface = |
203 base::MakeUnique<DisplayOutputSurface>(context_provider_, task_runner); | 207 base::MakeUnique<DisplayOutputSurface>(context_provider_, task_runner); |
204 | 208 |
205 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source( | 209 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source( |
206 new cc::DelayBasedBeginFrameSource( | 210 new cc::DelayBasedBeginFrameSource( |
(...skipping 13 matching lines...) Expand all Loading... | |
220 // The Browser compositor and display share the same context provider. | 224 // The Browser compositor and display share the same context provider. |
221 auto compositor_frame_sink = base::MakeUnique<cc::DirectCompositorFrameSink>( | 225 auto compositor_frame_sink = base::MakeUnique<cc::DirectCompositorFrameSink>( |
222 frame_sink_id_, compositor_dependencies_->GetSurfaceManager(), | 226 frame_sink_id_, compositor_dependencies_->GetSurfaceManager(), |
223 display_.get(), context_provider_, nullptr); | 227 display_.get(), context_provider_, nullptr); |
224 | 228 |
225 host_->SetCompositorFrameSink(std::move(compositor_frame_sink)); | 229 host_->SetCompositorFrameSink(std::move(compositor_frame_sink)); |
226 } | 230 } |
227 | 231 |
228 } // namespace client | 232 } // namespace client |
229 } // namespace blimp | 233 } // namespace blimp |
OLD | NEW |