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

Side by Side Diff: blimp/client/support/compositor/blimp_embedder_compositor.cc

Issue 2402173002: cc: Get rid of PostSwapBuffersComplete. (Closed)
Patch Set: postswap: fix-blimp-unittest-post-swap-acks 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 "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/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
10 #include "blimp/client/public/compositor/compositor_dependencies.h" 11 #include "blimp/client/public/compositor/compositor_dependencies.h"
11 #include "blimp/client/support/compositor/blimp_context_provider.h" 12 #include "blimp/client/support/compositor/blimp_context_provider.h"
12 #include "cc/animation/animation_host.h" 13 #include "cc/animation/animation_host.h"
13 #include "cc/layers/layer.h" 14 #include "cc/layers/layer.h"
14 #include "cc/output/output_surface.h" 15 #include "cc/output/output_surface.h"
15 #include "cc/output/output_surface_frame.h" 16 #include "cc/output/output_surface_frame.h"
16 #include "cc/output/texture_mailbox_deleter.h" 17 #include "cc/output/texture_mailbox_deleter.h"
17 #include "cc/raster/single_thread_task_graph_runner.h" 18 #include "cc/raster/single_thread_task_graph_runner.h"
18 #include "cc/surfaces/direct_compositor_frame_sink.h" 19 #include "cc/surfaces/direct_compositor_frame_sink.h"
(...skipping 15 matching lines...) Expand all
34 Start("BlimpBrowserCompositorWorker", 35 Start("BlimpBrowserCompositorWorker",
35 base::SimpleThread::Options(base::ThreadPriority::BACKGROUND)); 36 base::SimpleThread::Options(base::ThreadPriority::BACKGROUND));
36 } 37 }
37 38
38 ~SimpleTaskGraphRunner() override { Shutdown(); } 39 ~SimpleTaskGraphRunner() override { Shutdown(); }
39 }; 40 };
40 41
41 class DisplayOutputSurface : public cc::OutputSurface { 42 class DisplayOutputSurface : public cc::OutputSurface {
42 public: 43 public:
43 explicit DisplayOutputSurface( 44 explicit DisplayOutputSurface(
44 scoped_refptr<cc::ContextProvider> context_provider) 45 scoped_refptr<cc::ContextProvider> context_provider,
45 : cc::OutputSurface(std::move(context_provider)) {} 46 scoped_refptr<base::SingleThreadTaskRunner> task_runner)
47 : cc::OutputSurface(std::move(context_provider)),
48 task_runner_(std::move(task_runner)),
49 weak_ptr_factory_(this) {}
46 50
47 ~DisplayOutputSurface() override = default; 51 ~DisplayOutputSurface() override = default;
48 52
49 // cc::OutputSurface implementation 53 // cc::OutputSurface implementation
50 void EnsureBackbuffer() override {} 54 void EnsureBackbuffer() override {}
51 void DiscardBackbuffer() override { 55 void DiscardBackbuffer() override {
52 context_provider()->ContextGL()->DiscardBackbufferCHROMIUM(); 56 context_provider()->ContextGL()->DiscardBackbufferCHROMIUM();
53 } 57 }
54 void BindFramebuffer() override { 58 void BindFramebuffer() override {
55 context_provider()->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, 0); 59 context_provider()->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, 0);
56 } 60 }
57 void Reshape(const gfx::Size& size, 61 void Reshape(const gfx::Size& size,
58 float device_scale_factor, 62 float device_scale_factor,
59 const gfx::ColorSpace& color_space, 63 const gfx::ColorSpace& color_space,
60 bool has_alpha) override { 64 bool has_alpha) override {
61 context_provider()->ContextGL()->ResizeCHROMIUM( 65 context_provider()->ContextGL()->ResizeCHROMIUM(
62 size.width(), size.height(), device_scale_factor, has_alpha); 66 size.width(), size.height(), device_scale_factor, has_alpha);
63 } 67 }
64 void SwapBuffers(cc::OutputSurfaceFrame frame) override { 68 void SwapBuffers(cc::OutputSurfaceFrame frame) override {
65 // See cc::OutputSurface::SwapBuffers() comment for details.
66 context_provider_->ContextSupport()->Swap(); 69 context_provider_->ContextSupport()->Swap();
67 cc::OutputSurface::PostSwapBuffersComplete(); 70 // The ack for SwapBuffers must be run asynchronously, that will be
71 // satisfied since we will go through a PostTask here.
72 task_runner_->PostTask(
73 FROM_HERE, base::Bind(&DisplayOutputSurface::SwapBuffersCallback,
74 weak_ptr_factory_.GetWeakPtr()));
68 } 75 }
69 cc::OverlayCandidateValidator* GetOverlayCandidateValidator() const override { 76 cc::OverlayCandidateValidator* GetOverlayCandidateValidator() const override {
70 return nullptr; 77 return nullptr;
71 } 78 }
72 bool IsDisplayedAsOverlayPlane() const override { return false; } 79 bool IsDisplayedAsOverlayPlane() const override { return false; }
73 unsigned GetOverlayTextureId() const override { return 0; } 80 unsigned GetOverlayTextureId() const override { return 0; }
74 bool SurfaceIsSuspendForRecycle() const override { return false; } 81 bool SurfaceIsSuspendForRecycle() const override { return false; }
75 uint32_t GetFramebufferCopyTextureFormat() override { 82 uint32_t GetFramebufferCopyTextureFormat() override {
76 // We assume we have an alpha channel from the BlimpContextProvider, so use 83 // We assume we have an alpha channel from the BlimpContextProvider, so use
77 // GL_RGBA here. 84 // GL_RGBA here.
78 return GL_RGBA; 85 return GL_RGBA;
79 } 86 }
80 bool HasExternalStencilTest() const override { return false; } 87 bool HasExternalStencilTest() const override { return false; }
81 void ApplyExternalStencil() override {} 88 void ApplyExternalStencil() override {}
82 89
83 private: 90 private:
91 void SwapBuffersCallback() { client_->DidSwapBuffersComplete(); }
92
93 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
94 base::WeakPtrFactory<DisplayOutputSurface> weak_ptr_factory_;
95
84 DISALLOW_COPY_AND_ASSIGN(DisplayOutputSurface); 96 DISALLOW_COPY_AND_ASSIGN(DisplayOutputSurface);
85 }; 97 };
86 98
87 base::LazyInstance<SimpleTaskGraphRunner> g_task_graph_runner = 99 base::LazyInstance<SimpleTaskGraphRunner> g_task_graph_runner =
88 LAZY_INSTANCE_INITIALIZER; 100 LAZY_INSTANCE_INITIALIZER;
89 101
90 } // namespace 102 } // namespace
91 103
92 BlimpEmbedderCompositor::BlimpEmbedderCompositor( 104 BlimpEmbedderCompositor::BlimpEmbedderCompositor(
93 CompositorDependencies* compositor_dependencies) 105 CompositorDependencies* compositor_dependencies)
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 191
180 // Can't handle the request right now since we don't have a widget. 192 // Can't handle the request right now since we don't have a widget.
181 if (!host_->IsVisible()) 193 if (!host_->IsVisible())
182 return; 194 return;
183 195
184 DCHECK(context_provider_); 196 DCHECK(context_provider_);
185 197
186 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = 198 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager =
187 compositor_dependencies_->GetGpuMemoryBufferManager(); 199 compositor_dependencies_->GetGpuMemoryBufferManager();
188 200
201 auto task_runner = base::ThreadTaskRunnerHandle::Get();
189 auto display_output_surface = 202 auto display_output_surface =
190 base::MakeUnique<DisplayOutputSurface>(context_provider_); 203 base::MakeUnique<DisplayOutputSurface>(context_provider_, task_runner);
191 204
192 auto* task_runner = base::ThreadTaskRunnerHandle::Get().get();
193 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source( 205 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source(
194 new cc::DelayBasedBeginFrameSource( 206 new cc::DelayBasedBeginFrameSource(
195 base::MakeUnique<cc::DelayBasedTimeSource>(task_runner))); 207 base::MakeUnique<cc::DelayBasedTimeSource>(task_runner.get())));
196 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( 208 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler(
197 begin_frame_source.get(), task_runner, 209 begin_frame_source.get(), task_runner.get(),
198 display_output_surface->capabilities().max_frames_pending)); 210 display_output_surface->capabilities().max_frames_pending));
199 211
200 display_ = base::MakeUnique<cc::Display>( 212 display_ = base::MakeUnique<cc::Display>(
201 nullptr /*shared_bitmap_manager*/, gpu_memory_buffer_manager, 213 nullptr /*shared_bitmap_manager*/, gpu_memory_buffer_manager,
202 host_->GetSettings().renderer_settings, std::move(begin_frame_source), 214 host_->GetSettings().renderer_settings, std::move(begin_frame_source),
203 std::move(display_output_surface), std::move(scheduler), 215 std::move(display_output_surface), std::move(scheduler),
204 base::MakeUnique<cc::TextureMailboxDeleter>(task_runner)); 216 base::MakeUnique<cc::TextureMailboxDeleter>(task_runner.get()));
205 display_->SetVisible(true); 217 display_->SetVisible(true);
206 display_->Resize(viewport_size_in_px_); 218 display_->Resize(viewport_size_in_px_);
207 219
208 // The Browser compositor and display share the same context provider. 220 // The Browser compositor and display share the same context provider.
209 auto compositor_frame_sink = base::MakeUnique<cc::DirectCompositorFrameSink>( 221 auto compositor_frame_sink = base::MakeUnique<cc::DirectCompositorFrameSink>(
210 frame_sink_id_, compositor_dependencies_->GetSurfaceManager(), 222 frame_sink_id_, compositor_dependencies_->GetSurfaceManager(),
211 display_.get(), context_provider_, nullptr); 223 display_.get(), context_provider_, nullptr);
212 224
213 host_->SetCompositorFrameSink(std::move(compositor_frame_sink)); 225 host_->SetCompositorFrameSink(std::move(compositor_frame_sink));
214 } 226 }
215 227
216 } // namespace client 228 } // namespace client
217 } // namespace blimp 229 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/client/core/compositor/blimp_compositor_frame_sink_unittest.cc ('k') | cc/output/compositor_frame_sink.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698