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