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

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

Issue 2529703002: Mus: Install SwapBuffersCompleted/VSync callbacks to DirectOutputSurface(Ozone) (Closed)
Patch Set: Grab capabilities from the InProcessCommandBuffer instead of making them up Created 4 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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.h" 5 #include "services/ui/surfaces/direct_output_surface.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
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 "base/threading/thread_task_runner_handle.h"
11 #include "cc/output/context_provider.h" 12 #include "cc/output/context_provider.h"
12 #include "cc/output/output_surface_client.h" 13 #include "cc/output/output_surface_client.h"
13 #include "cc/output/output_surface_frame.h" 14 #include "cc/output/output_surface_frame.h"
14 #include "cc/scheduler/begin_frame_source.h" 15 #include "cc/scheduler/begin_frame_source.h"
15 #include "gpu/command_buffer/client/context_support.h" 16 #include "gpu/command_buffer/client/context_support.h"
16 #include "gpu/command_buffer/client/gles2_interface.h" 17 #include "gpu/command_buffer/client/gles2_interface.h"
17 18
18 namespace ui { 19 namespace ui {
19 20
20 DirectOutputSurface::DirectOutputSurface( 21 DirectOutputSurface::DirectOutputSurface(
21 scoped_refptr<cc::InProcessContextProvider> context_provider, 22 scoped_refptr<cc::InProcessContextProvider> context_provider,
22 cc::SyntheticBeginFrameSource* synthetic_begin_frame_source) 23 cc::SyntheticBeginFrameSource* synthetic_begin_frame_source)
23 : cc::OutputSurface(context_provider), 24 : cc::OutputSurface(context_provider),
24 synthetic_begin_frame_source_(synthetic_begin_frame_source), 25 synthetic_begin_frame_source_(synthetic_begin_frame_source),
25 weak_ptr_factory_(this) { 26 weak_ptr_factory_(this) {
26 capabilities_.flipped_output_surface = 27 capabilities_.flipped_output_surface =
27 context_provider->ContextCapabilities().flips_vertically; 28 context_provider->ContextCapabilities().flips_vertically;
29 context_provider->SetSwapBuffersCompletionCallback(
30 base::Bind(&DirectOutputSurface::OnGpuSwapBuffersCompleted,
31 weak_ptr_factory_.GetWeakPtr()));
32 context_provider->SetUpdateVSyncParametersCallback(
33 base::Bind(&DirectOutputSurface::OnVSyncParametersUpdated,
34 weak_ptr_factory_.GetWeakPtr()));
28 } 35 }
29 36
30 DirectOutputSurface::~DirectOutputSurface() {} 37 DirectOutputSurface::~DirectOutputSurface() {}
31 38
32 void DirectOutputSurface::BindToClient(cc::OutputSurfaceClient* client) { 39 void DirectOutputSurface::BindToClient(cc::OutputSurfaceClient* client) {
33 DCHECK(client); 40 DCHECK(client);
34 DCHECK(!client_); 41 DCHECK(!client_);
35 client_ = client; 42 client_ = client;
36 } 43 }
37 44
(...skipping 16 matching lines...) Expand all
54 } 61 }
55 62
56 void DirectOutputSurface::SwapBuffers(cc::OutputSurfaceFrame frame) { 63 void DirectOutputSurface::SwapBuffers(cc::OutputSurfaceFrame frame) {
57 DCHECK(context_provider_); 64 DCHECK(context_provider_);
58 if (frame.sub_buffer_rect == gfx::Rect(frame.size)) { 65 if (frame.sub_buffer_rect == gfx::Rect(frame.size)) {
59 context_provider_->ContextSupport()->Swap(); 66 context_provider_->ContextSupport()->Swap();
60 } else { 67 } else {
61 context_provider_->ContextSupport()->PartialSwapBuffers( 68 context_provider_->ContextSupport()->PartialSwapBuffers(
62 frame.sub_buffer_rect); 69 frame.sub_buffer_rect);
63 } 70 }
64
65 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL();
66 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM();
67 gl->ShallowFlushCHROMIUM();
68
69 gpu::SyncToken sync_token;
70 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData());
71
72 context_provider_->ContextSupport()->SignalSyncToken(
73 sync_token, base::Bind(&DirectOutputSurface::OnSwapBuffersComplete,
74 weak_ptr_factory_.GetWeakPtr()));
75 } 71 }
76 72
77 uint32_t DirectOutputSurface::GetFramebufferCopyTextureFormat() { 73 uint32_t DirectOutputSurface::GetFramebufferCopyTextureFormat() {
78 // TODO(danakj): What attributes are used for the default framebuffer here? 74 // TODO(danakj): What attributes are used for the default framebuffer here?
79 // Can it have alpha? cc::InProcessContextProvider doesn't take any 75 // Can it have alpha? cc::InProcessContextProvider doesn't take any
80 // attributes. 76 // attributes.
81 return GL_RGB; 77 return GL_RGB;
82 } 78 }
83 79
84 cc::OverlayCandidateValidator* 80 cc::OverlayCandidateValidator*
(...skipping 12 matching lines...) Expand all
97 bool DirectOutputSurface::SurfaceIsSuspendForRecycle() const { 93 bool DirectOutputSurface::SurfaceIsSuspendForRecycle() const {
98 return false; 94 return false;
99 } 95 }
100 96
101 bool DirectOutputSurface::HasExternalStencilTest() const { 97 bool DirectOutputSurface::HasExternalStencilTest() const {
102 return false; 98 return false;
103 } 99 }
104 100
105 void DirectOutputSurface::ApplyExternalStencil() {} 101 void DirectOutputSurface::ApplyExternalStencil() {}
106 102
107 void DirectOutputSurface::OnVSyncParametersUpdated( 103 void DirectOutputSurface::OnGpuSwapBuffersCompleted(
108 const base::TimeTicks& timebase, 104 const std::vector<ui::LatencyInfo>& latency_info,
109 const base::TimeDelta& interval) { 105 gfx::SwapResult result,
106 const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) {
107 client_->DidReceiveSwapBuffersAck();
108 }
109
110 void DirectOutputSurface::OnVSyncParametersUpdated(base::TimeTicks timebase,
111 base::TimeDelta interval) {
110 // TODO(brianderson): We should not be receiving 0 intervals. 112 // TODO(brianderson): We should not be receiving 0 intervals.
111 synthetic_begin_frame_source_->OnUpdateVSyncParameters( 113 synthetic_begin_frame_source_->OnUpdateVSyncParameters(
112 timebase, 114 timebase,
113 interval.is_zero() ? cc::BeginFrameArgs::DefaultInterval() : interval); 115 interval.is_zero() ? cc::BeginFrameArgs::DefaultInterval() : interval);
114 } 116 }
115 117
116 void DirectOutputSurface::OnSwapBuffersComplete() {
117 client_->DidReceiveSwapBuffersAck();
118 }
119 118
120 } // namespace ui 119 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/surfaces/direct_output_surface.h ('k') | services/ui/surfaces/direct_output_surface_ozone.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698