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

Side by Side Diff: services/ui/public/cpp/output_surface.cc

Issue 2337913003: Fork cc::OutputSurface into cc::CompositorFrameSink. (Closed)
Patch Set: cfsfork: android-vulkan Created 4 years, 3 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 "services/ui/public/cpp/output_surface.h"
6
7 #include "base/bind.h"
8 #include "cc/output/compositor_frame.h"
9 #include "cc/output/output_surface_client.h"
10 #include "gpu/ipc/client/gpu_channel_host.h"
11 #include "services/ui/public/cpp/context_provider.h"
12 #include "services/ui/public/cpp/gpu_service.h"
13 #include "services/ui/public/cpp/window_surface.h"
14
15 namespace ui {
16
17 OutputSurface::OutputSurface(
18 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host,
19 std::unique_ptr<ui::WindowSurface> surface)
20 : cc::OutputSurface(
21 make_scoped_refptr(new ContextProvider(std::move(gpu_channel_host))),
22 nullptr,
23 nullptr),
24 surface_(std::move(surface)) {
25 capabilities_.delegated_rendering = true;
26 }
27
28 OutputSurface::~OutputSurface() {}
29
30 bool OutputSurface::BindToClient(cc::OutputSurfaceClient* client) {
31 surface_->BindToThread();
32 surface_->set_client(this);
33
34 // TODO(enne): Get this from the WindowSurface via ServerWindowSurface.
35 begin_frame_source_.reset(new cc::DelayBasedBeginFrameSource(
36 base::MakeUnique<cc::DelayBasedTimeSource>(
37 base::ThreadTaskRunnerHandle::Get().get())));
38
39 client->SetBeginFrameSource(begin_frame_source_.get());
40 return cc::OutputSurface::BindToClient(client);
41 }
42
43 void OutputSurface::DetachFromClient() {
44 client_->SetBeginFrameSource(nullptr);
45 begin_frame_source_.reset();
46 surface_.reset();
47 cc::OutputSurface::DetachFromClient();
48 }
49
50 void OutputSurface::BindFramebuffer() {
51 // This is a delegating output surface, no framebuffer/direct drawing support.
52 NOTREACHED();
53 }
54
55 uint32_t OutputSurface::GetFramebufferCopyTextureFormat() {
56 // This is a delegating output surface, no framebuffer/direct drawing support.
57 NOTREACHED();
58 return 0;
59 }
60
61 void OutputSurface::SwapBuffers(cc::CompositorFrame frame) {
62 // OutputSurface owns WindowSurface, and so if OutputSurface is
63 // destroyed then SubmitCompositorFrame's callback will never get called.
64 // Thus, base::Unretained is safe here.
65 surface_->SubmitCompositorFrame(
66 std::move(frame),
67 base::Bind(&OutputSurface::SwapBuffersComplete, base::Unretained(this)));
68 }
69
70 void OutputSurface::OnResourcesReturned(
71 ui::WindowSurface* surface,
72 mojo::Array<cc::ReturnedResource> resources) {
73 client_->ReclaimResources(resources.To<cc::ReturnedResourceArray>());
74 }
75
76 void OutputSurface::SwapBuffersComplete() {
77 client_->DidSwapBuffersComplete();
78 }
79
80 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/public/cpp/output_surface.h ('k') | third_party/WebKit/Source/platform/graphics/CompositorMutableStateTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698