OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 "components/mus/public/cpp/window_surface.h" | 5 #include "components/mus/public/cpp/window_surface.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "components/mus/public/cpp/surfaces/surfaces_type_converters.h" | |
9 #include "components/mus/public/cpp/window_surface_client.h" | 8 #include "components/mus/public/cpp/window_surface_client.h" |
10 | 9 |
11 namespace mus { | 10 namespace mus { |
12 | 11 |
13 // static | 12 // static |
14 std::unique_ptr<WindowSurface> WindowSurface::Create( | 13 std::unique_ptr<WindowSurface> WindowSurface::Create( |
15 std::unique_ptr<WindowSurfaceBinding>* surface_binding) { | 14 std::unique_ptr<WindowSurfaceBinding>* surface_binding) { |
16 mojom::SurfacePtr surface; | 15 mojom::SurfacePtr surface; |
17 mojom::SurfaceClientPtr surface_client; | 16 mojom::SurfaceClientPtr surface_client; |
18 mojo::InterfaceRequest<mojom::SurfaceClient> surface_client_request = | 17 mojo::InterfaceRequest<mojom::SurfaceClient> surface_client_request = |
19 GetProxy(&surface_client); | 18 GetProxy(&surface_client); |
20 | 19 |
21 surface_binding->reset(new WindowSurfaceBinding( | 20 surface_binding->reset(new WindowSurfaceBinding( |
22 GetProxy(&surface), surface_client.PassInterface())); | 21 GetProxy(&surface), surface_client.PassInterface())); |
23 return base::WrapUnique(new WindowSurface(surface.PassInterface(), | 22 return base::WrapUnique(new WindowSurface(surface.PassInterface(), |
24 std::move(surface_client_request))); | 23 std::move(surface_client_request))); |
25 } | 24 } |
26 | 25 |
27 WindowSurface::~WindowSurface() {} | 26 WindowSurface::~WindowSurface() {} |
28 | 27 |
29 void WindowSurface::BindToThread() { | 28 void WindowSurface::BindToThread() { |
30 DCHECK(!thread_checker_); | 29 DCHECK(!thread_checker_); |
31 thread_checker_.reset(new base::ThreadChecker()); | 30 thread_checker_.reset(new base::ThreadChecker()); |
32 surface_.Bind(std::move(surface_info_)); | 31 surface_.Bind(std::move(surface_info_)); |
33 client_binding_.reset(new mojo::Binding<mojom::SurfaceClient>( | 32 client_binding_.reset(new mojo::Binding<mojom::SurfaceClient>( |
34 this, std::move(client_request_))); | 33 this, std::move(client_request_))); |
35 } | 34 } |
36 | 35 |
37 void WindowSurface::SubmitCompositorFrame(cc::mojom::CompositorFramePtr frame, | 36 void WindowSurface::SubmitCompositorFrame(cc::CompositorFrame frame, |
38 const base::Closure& callback) { | 37 const base::Closure& callback) { |
39 DCHECK(thread_checker_); | 38 DCHECK(thread_checker_); |
40 DCHECK(thread_checker_->CalledOnValidThread()); | 39 DCHECK(thread_checker_->CalledOnValidThread()); |
41 if (!surface_) | 40 if (!surface_) |
42 return; | 41 return; |
43 surface_->SubmitCompositorFrame(std::move(frame), callback); | 42 surface_->SubmitCompositorFrame(std::move(frame), callback); |
44 } | 43 } |
45 | 44 |
46 WindowSurface::WindowSurface( | 45 WindowSurface::WindowSurface( |
47 mojo::InterfacePtrInfo<mojom::Surface> surface_info, | 46 mojo::InterfacePtrInfo<mojom::Surface> surface_info, |
(...skipping 13 matching lines...) Expand all Loading... |
61 | 60 |
62 WindowSurfaceBinding::~WindowSurfaceBinding() {} | 61 WindowSurfaceBinding::~WindowSurfaceBinding() {} |
63 | 62 |
64 WindowSurfaceBinding::WindowSurfaceBinding( | 63 WindowSurfaceBinding::WindowSurfaceBinding( |
65 mojo::InterfaceRequest<mojom::Surface> surface_request, | 64 mojo::InterfaceRequest<mojom::Surface> surface_request, |
66 mojo::InterfacePtrInfo<mojom::SurfaceClient> surface_client) | 65 mojo::InterfacePtrInfo<mojom::SurfaceClient> surface_client) |
67 : surface_request_(std::move(surface_request)), | 66 : surface_request_(std::move(surface_request)), |
68 surface_client_(std::move(surface_client)) {} | 67 surface_client_(std::move(surface_client)) {} |
69 | 68 |
70 } // namespace mus | 69 } // namespace mus |
OLD | NEW |