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

Side by Side Diff: services/ui/surfaces/direct_output_surface_ozone.cc

Issue 2471503002: Mus+Ash: Unify CompositorFrameSinks (Closed)
Patch Set: Updated deps 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 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 "services/ui/surfaces/direct_output_surface_ozone.h" 5 #include "services/ui/surfaces/direct_output_surface_ozone.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "cc/output/context_provider.h" 11 #include "cc/output/context_provider.h"
12 #include "cc/output/output_surface_client.h" 12 #include "cc/output/output_surface_client.h"
13 #include "cc/output/output_surface_frame.h" 13 #include "cc/output/output_surface_frame.h"
14 #include "cc/scheduler/begin_frame_source.h" 14 #include "cc/scheduler/begin_frame_source.h"
15 #include "components/display_compositor/buffer_queue.h" 15 #include "components/display_compositor/buffer_queue.h"
16 #include "gpu/command_buffer/client/context_support.h" 16 #include "gpu/command_buffer/client/context_support.h"
17 #include "gpu/command_buffer/client/gles2_interface.h" 17 #include "gpu/command_buffer/client/gles2_interface.h"
18 #include "services/ui/surfaces/surfaces_context_provider.h" 18 #include "services/ui/surfaces/surfaces_context_provider.h"
19 #include "ui/display/types/display_snapshot.h" 19 #include "ui/display/types/display_snapshot.h"
20 20
21 using display_compositor::BufferQueue; 21 using display_compositor::BufferQueue;
22 22
23 namespace ui { 23 namespace ui {
24 24
25 DirectOutputSurfaceOzone::DirectOutputSurfaceOzone( 25 DirectOutputSurfaceOzone::DirectOutputSurfaceOzone(
26 scoped_refptr<SurfacesContextProvider> context_provider, 26 scoped_refptr<cc::ContextProvider> context_provider,
27 gfx::AcceleratedWidget widget, 27 gfx::AcceleratedWidget widget,
28 cc::SyntheticBeginFrameSource* synthetic_begin_frame_source, 28 cc::SyntheticBeginFrameSource* synthetic_begin_frame_source,
29 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, 29 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
30 uint32_t target, 30 uint32_t target,
31 uint32_t internalformat) 31 uint32_t internalformat)
32 : cc::OutputSurface(context_provider), 32 : cc::OutputSurface(context_provider),
33 gl_helper_(context_provider->ContextGL(), 33 gl_helper_(context_provider->ContextGL(),
34 context_provider->ContextSupport()), 34 context_provider->ContextSupport()),
35 synthetic_begin_frame_source_(synthetic_begin_frame_source), 35 synthetic_begin_frame_source_(synthetic_begin_frame_source),
36 weak_ptr_factory_(this) { 36 weak_ptr_factory_(this) {
37 buffer_queue_.reset( 37 buffer_queue_.reset(
38 new BufferQueue(context_provider->ContextGL(), target, internalformat, 38 new BufferQueue(context_provider->ContextGL(), target, internalformat,
39 ui::DisplaySnapshot::PrimaryFormat(), &gl_helper_, 39 ui::DisplaySnapshot::PrimaryFormat(), &gl_helper_,
40 gpu_memory_buffer_manager, widget)); 40 gpu_memory_buffer_manager, widget));
41 41
42 capabilities_.uses_default_gl_framebuffer = false; 42 capabilities_.uses_default_gl_framebuffer = false;
43 capabilities_.flipped_output_surface = true; 43 capabilities_.flipped_output_surface = true;
44 // Set |max_frames_pending| to 2 for surfaceless, which aligns scheduling 44 // Set |max_frames_pending| to 2 for surfaceless, which aligns scheduling
45 // more closely with the previous surfaced behavior. 45 // more closely with the previous surfaced behavior.
46 // With a surface, swap buffer ack used to return early, before actually 46 // With a surface, swap buffer ack used to return early, before actually
47 // presenting the back buffer, enabling the browser compositor to run ahead. 47 // presenting the back buffer, enabling the browser compositor to run ahead.
48 // Surfaceless implementation acks at the time of actual buffer swap, which 48 // Surfaceless implementation acks at the time of actual buffer swap, which
49 // shifts the start of the new frame forward relative to the old 49 // shifts the start of the new frame forward relative to the old
50 // implementation. 50 // implementation.
51 capabilities_.max_frames_pending = 2; 51 capabilities_.max_frames_pending = 2;
52 52
53 buffer_queue_->Initialize(); 53 buffer_queue_->Initialize();
54 54
55 context_provider->SetSwapBuffersCompletionCallback( 55 static_cast<SurfacesContextProvider*>(context_provider.get())
kylechar 2016/11/02 03:37:24 Ditto.
Fady Samuel 2016/11/02 04:31:22 Done.
56 base::Bind(&DirectOutputSurfaceOzone::OnGpuSwapBuffersCompleted, 56 ->SetSwapBuffersCompletionCallback(
57 base::Unretained(this))); 57 base::Bind(&DirectOutputSurfaceOzone::OnGpuSwapBuffersCompleted,
58 base::Unretained(this)));
58 } 59 }
59 60
60 DirectOutputSurfaceOzone::~DirectOutputSurfaceOzone() { 61 DirectOutputSurfaceOzone::~DirectOutputSurfaceOzone() {
61 // TODO(rjkroege): Support cleanup. 62 // TODO(rjkroege): Support cleanup.
62 } 63 }
63 64
64 void DirectOutputSurfaceOzone::BindToClient(cc::OutputSurfaceClient* client) { 65 void DirectOutputSurfaceOzone::BindToClient(cc::OutputSurfaceClient* client) {
65 DCHECK(client); 66 DCHECK(client);
66 DCHECK(!client_); 67 DCHECK(!client_);
67 client_ = client; 68 client_ = client;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 } 168 }
168 169
169 buffer_queue_->PageFlipComplete(); 170 buffer_queue_->PageFlipComplete();
170 client_->DidReceiveSwapBuffersAck(); 171 client_->DidReceiveSwapBuffersAck();
171 172
172 if (force_swap) 173 if (force_swap)
173 client_->SetNeedsRedrawRect(gfx::Rect(swap_size_)); 174 client_->SetNeedsRedrawRect(gfx::Rect(swap_size_));
174 } 175 }
175 176
176 } // namespace ui 177 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698