OLD | NEW |
| (Empty) |
1 // Copyright (c) 2016 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/gles2/gl_surface_adapter.h" | |
6 | |
7 #include "base/bind.h" | |
8 | |
9 namespace mus { | |
10 | |
11 GLSurfaceAdapterMus::GLSurfaceAdapterMus(scoped_refptr<gl::GLSurface> surface) | |
12 : gl::GLSurfaceAdapter(surface.get()), | |
13 surface_(surface), | |
14 weak_ptr_factory_(this) {} | |
15 | |
16 GLSurfaceAdapterMus::~GLSurfaceAdapterMus() {} | |
17 | |
18 void GLSurfaceAdapterMus::SwapBuffersAsync( | |
19 const GLSurface::SwapCompletionCallback& callback) { | |
20 gl::GLSurfaceAdapter::SwapBuffersAsync( | |
21 base::Bind(&GLSurfaceAdapterMus::WrappedCallbackForSwapBuffersAsync, | |
22 weak_ptr_factory_.GetWeakPtr(), callback)); | |
23 } | |
24 | |
25 void GLSurfaceAdapterMus::PostSubBufferAsync( | |
26 int x, | |
27 int y, | |
28 int width, | |
29 int height, | |
30 const GLSurface::SwapCompletionCallback& callback) { | |
31 gl::GLSurfaceAdapter::PostSubBufferAsync( | |
32 x, y, width, height, | |
33 base::Bind(&GLSurfaceAdapterMus::WrappedCallbackForSwapBuffersAsync, | |
34 weak_ptr_factory_.GetWeakPtr(), callback)); | |
35 } | |
36 | |
37 void GLSurfaceAdapterMus::CommitOverlayPlanesAsync( | |
38 const GLSurface::SwapCompletionCallback& callback) { | |
39 gl::GLSurfaceAdapter::CommitOverlayPlanesAsync( | |
40 base::Bind(&GLSurfaceAdapterMus::WrappedCallbackForSwapBuffersAsync, | |
41 weak_ptr_factory_.GetWeakPtr(), callback)); | |
42 } | |
43 | |
44 void GLSurfaceAdapterMus::WrappedCallbackForSwapBuffersAsync( | |
45 const gl::GLSurface::SwapCompletionCallback& original_callback, | |
46 gfx::SwapResult result) { | |
47 if (!adapter_callback_.is_null()) | |
48 adapter_callback_.Run(result); | |
49 original_callback.Run(result); | |
50 } | |
51 | |
52 void GLSurfaceAdapterMus::SetGpuCompletedSwapBuffersCallback( | |
53 gl::GLSurface::SwapCompletionCallback callback) { | |
54 adapter_callback_ = std::move(callback); | |
55 } | |
56 | |
57 } // namespace mus | |
OLD | NEW |