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

Side by Side Diff: components/mus/surfaces/direct_output_surface.cc

Issue 2119963002: Move mus to //services/ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/mus/surfaces/direct_output_surface.h"
6
7 #include <stdint.h>
8
9 #include "base/bind.h"
10 #include "base/memory/ptr_util.h"
11 #include "cc/output/compositor_frame.h"
12 #include "cc/output/context_provider.h"
13 #include "cc/output/output_surface_client.h"
14 #include "cc/scheduler/begin_frame_source.h"
15 #include "gpu/command_buffer/client/context_support.h"
16 #include "gpu/command_buffer/client/gles2_interface.h"
17
18 namespace mus {
19
20 DirectOutputSurface::DirectOutputSurface(
21 scoped_refptr<SurfacesContextProvider> context_provider,
22 cc::SyntheticBeginFrameSource* synthetic_begin_frame_source)
23 : cc::OutputSurface(context_provider, nullptr, nullptr),
24 synthetic_begin_frame_source_(synthetic_begin_frame_source),
25 weak_ptr_factory_(this) {
26 context_provider->SetDelegate(this);
27 }
28
29 DirectOutputSurface::~DirectOutputSurface() = default;
30
31 bool DirectOutputSurface::BindToClient(cc::OutputSurfaceClient* client) {
32 if (!cc::OutputSurface::BindToClient(client))
33 return false;
34
35 if (capabilities_.uses_default_gl_framebuffer) {
36 capabilities_.flipped_output_surface =
37 context_provider()->ContextCapabilities().flips_vertically;
38 }
39 return true;
40 }
41
42 void DirectOutputSurface::OnVSyncParametersUpdated(
43 const base::TimeTicks& timebase,
44 const base::TimeDelta& interval) {
45 // TODO(brianderson): We should not be receiving 0 intervals.
46 synthetic_begin_frame_source_->OnUpdateVSyncParameters(
47 timebase,
48 interval.is_zero() ? cc::BeginFrameArgs::DefaultInterval() : interval);
49 }
50
51 void DirectOutputSurface::SwapBuffers(cc::CompositorFrame frame) {
52 DCHECK(context_provider_);
53 DCHECK(frame.gl_frame_data);
54 if (frame.gl_frame_data->sub_buffer_rect ==
55 gfx::Rect(frame.gl_frame_data->size)) {
56 context_provider_->ContextSupport()->Swap();
57 } else {
58 context_provider_->ContextSupport()->PartialSwapBuffers(
59 frame.gl_frame_data->sub_buffer_rect);
60 }
61
62 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL();
63 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM();
64 gl->ShallowFlushCHROMIUM();
65
66 gpu::SyncToken sync_token;
67 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData());
68
69 context_provider_->ContextSupport()->SignalSyncToken(
70 sync_token, base::Bind(&OutputSurface::OnSwapBuffersComplete,
71 weak_ptr_factory_.GetWeakPtr()));
72 client_->DidSwapBuffers();
73 }
74
75 uint32_t DirectOutputSurface::GetFramebufferCopyTextureFormat() {
76 // TODO(danakj): What attributes are used for the default framebuffer here?
77 // Can it have alpha? SurfacesContextProvider doesn't take any attributes.
78 return GL_RGB;
79 }
80
81 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/surfaces/direct_output_surface.h ('k') | components/mus/surfaces/direct_output_surface_ozone.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698