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 } |
| 57 |
54 void EnsureBackbuffer() override {} | 58 void EnsureBackbuffer() override {} |
55 void DiscardBackbuffer() override { | 59 void DiscardBackbuffer() override { |
56 context_provider()->ContextGL()->DiscardBackbufferCHROMIUM(); | 60 context_provider()->ContextGL()->DiscardBackbufferCHROMIUM(); |
57 } | 61 } |
58 void BindFramebuffer() override { | 62 void BindFramebuffer() override { |
59 context_provider()->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, 0); | 63 context_provider()->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, 0); |
60 } | 64 } |
61 void Reshape(const gfx::Size& size, | 65 void Reshape(const gfx::Size& size, |
62 float device_scale_factor, | 66 float device_scale_factor, |
63 const gfx::ColorSpace& color_space, | 67 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 | 87 // We assume we have an alpha channel from the BlimpContextProvider, so use |
84 // GL_RGBA here. | 88 // GL_RGBA here. |
85 return GL_RGBA; | 89 return GL_RGBA; |
86 } | 90 } |
87 bool HasExternalStencilTest() const override { return false; } | 91 bool HasExternalStencilTest() const override { return false; } |
88 void ApplyExternalStencil() override {} | 92 void ApplyExternalStencil() override {} |
89 | 93 |
90 private: | 94 private: |
91 void SwapBuffersCallback() { client_->DidReceiveSwapBuffersAck(); } | 95 void SwapBuffersCallback() { client_->DidReceiveSwapBuffersAck(); } |
92 | 96 |
| 97 cc::OutputSurfaceClient* client_ = nullptr; |
93 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 98 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
94 base::WeakPtrFactory<DisplayOutputSurface> weak_ptr_factory_; | 99 base::WeakPtrFactory<DisplayOutputSurface> weak_ptr_factory_; |
95 | 100 |
96 DISALLOW_COPY_AND_ASSIGN(DisplayOutputSurface); | 101 DISALLOW_COPY_AND_ASSIGN(DisplayOutputSurface); |
97 }; | 102 }; |
98 | 103 |
99 base::LazyInstance<SimpleTaskGraphRunner> g_task_graph_runner = | 104 base::LazyInstance<SimpleTaskGraphRunner> g_task_graph_runner = |
100 LAZY_INSTANCE_INITIALIZER; | 105 LAZY_INSTANCE_INITIALIZER; |
101 | 106 |
102 } // namespace | 107 } // namespace |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 } | 192 } |
188 | 193 |
189 void BlimpEmbedderCompositor::HandlePendingCompositorFrameSinkRequest() { | 194 void BlimpEmbedderCompositor::HandlePendingCompositorFrameSinkRequest() { |
190 DCHECK(compositor_frame_sink_request_pending_); | 195 DCHECK(compositor_frame_sink_request_pending_); |
191 | 196 |
192 // Can't handle the request right now since we don't have a widget. | 197 // Can't handle the request right now since we don't have a widget. |
193 if (!host_->IsVisible()) | 198 if (!host_->IsVisible()) |
194 return; | 199 return; |
195 | 200 |
196 DCHECK(context_provider_); | 201 DCHECK(context_provider_); |
| 202 context_provider_->BindToCurrentThread(); |
197 | 203 |
198 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = | 204 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = |
199 compositor_dependencies_->GetGpuMemoryBufferManager(); | 205 compositor_dependencies_->GetGpuMemoryBufferManager(); |
200 | 206 |
201 auto task_runner = base::ThreadTaskRunnerHandle::Get(); | 207 auto task_runner = base::ThreadTaskRunnerHandle::Get(); |
202 auto display_output_surface = | 208 auto display_output_surface = |
203 base::MakeUnique<DisplayOutputSurface>(context_provider_, task_runner); | 209 base::MakeUnique<DisplayOutputSurface>(context_provider_, task_runner); |
204 | 210 |
205 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source( | 211 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source( |
206 new cc::DelayBasedBeginFrameSource( | 212 new cc::DelayBasedBeginFrameSource( |
(...skipping 13 matching lines...) Expand all Loading... |
220 // The Browser compositor and display share the same context provider. | 226 // The Browser compositor and display share the same context provider. |
221 auto compositor_frame_sink = base::MakeUnique<cc::DirectCompositorFrameSink>( | 227 auto compositor_frame_sink = base::MakeUnique<cc::DirectCompositorFrameSink>( |
222 frame_sink_id_, compositor_dependencies_->GetSurfaceManager(), | 228 frame_sink_id_, compositor_dependencies_->GetSurfaceManager(), |
223 display_.get(), context_provider_, nullptr); | 229 display_.get(), context_provider_, nullptr); |
224 | 230 |
225 host_->SetCompositorFrameSink(std::move(compositor_frame_sink)); | 231 host_->SetCompositorFrameSink(std::move(compositor_frame_sink)); |
226 } | 232 } |
227 | 233 |
228 } // namespace client | 234 } // namespace client |
229 } // namespace blimp | 235 } // namespace blimp |
OLD | NEW |