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

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

Issue 2429173005: Mus+Ash: Replace (Server)WindowSurface with (Server)WindowCompositorFrameSink (Closed)
Patch Set: ui::CompositorFrameSink => ui::WindowCompositorFrameSink Created 4 years, 2 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 2015 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/window_surface.h"
6
7 #include "base/memory/ptr_util.h"
8 #include "services/ui/public/cpp/window_surface_client.h"
9
10 namespace ui {
11
12 // static
13 std::unique_ptr<WindowSurface> WindowSurface::Create(
14 std::unique_ptr<WindowSurfaceBinding>* surface_binding) {
15 cc::mojom::MojoCompositorFrameSinkPtr surface;
16 cc::mojom::MojoCompositorFrameSinkClientPtr surface_client;
17 mojo::InterfaceRequest<cc::mojom::MojoCompositorFrameSinkClient>
18 surface_client_request = GetProxy(&surface_client);
19
20 surface_binding->reset(new WindowSurfaceBinding(
21 GetProxy(&surface), surface_client.PassInterface()));
22 return base::WrapUnique(new WindowSurface(surface.PassInterface(),
23 std::move(surface_client_request)));
24 }
25
26 WindowSurface::~WindowSurface() {}
27
28 void WindowSurface::BindToThread() {
29 DCHECK(!thread_checker_);
30 thread_checker_.reset(new base::ThreadChecker());
31 surface_.Bind(std::move(surface_info_));
32 client_binding_.reset(
33 new mojo::Binding<cc::mojom::MojoCompositorFrameSinkClient>(
34 this, std::move(client_request_)));
35 }
36
37 void WindowSurface::SubmitCompositorFrame(cc::CompositorFrame frame) {
38 DCHECK(thread_checker_);
39 DCHECK(thread_checker_->CalledOnValidThread());
40 if (!surface_)
41 return;
42 surface_->SubmitCompositorFrame(std::move(frame));
43 }
44
45 WindowSurface::WindowSurface(
46 mojo::InterfacePtrInfo<cc::mojom::MojoCompositorFrameSink> surface_info,
47 mojo::InterfaceRequest<cc::mojom::MojoCompositorFrameSinkClient>
48 client_request)
49 : client_(nullptr),
50 surface_info_(std::move(surface_info)),
51 client_request_(std::move(client_request)) {}
52
53 void WindowSurface::DidReceiveCompositorFrameAck() {
54 DCHECK(thread_checker_);
55 DCHECK(thread_checker_->CalledOnValidThread());
56 if (!client_)
57 return;
58 client_->DidReceiveCompositorFrameAck();
59 }
60
61 void WindowSurface::ReclaimResources(
62 const cc::ReturnedResourceArray& resources) {
63 DCHECK(thread_checker_);
64 DCHECK(thread_checker_->CalledOnValidThread());
65 if (!client_)
66 return;
67 client_->ReclaimResources(std::move(resources));
68 }
69
70 WindowSurfaceBinding::~WindowSurfaceBinding() {}
71
72 WindowSurfaceBinding::WindowSurfaceBinding(
73 mojo::InterfaceRequest<cc::mojom::MojoCompositorFrameSink> surface_request,
74 mojo::InterfacePtrInfo<cc::mojom::MojoCompositorFrameSinkClient>
75 surface_client)
76 : surface_request_(std::move(surface_request)),
77 surface_client_(std::move(surface_client)) {}
78
79 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698