OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef COMPONENTS_MUS_GLES2_GL_SURFACE_ADAPTER_H_ | 5 #ifndef COMPONENTS_MUS_GLES2_GL_SURFACE_ADAPTER_H_ |
6 #define COMPONENTS_MUS_GLES2_GL_SURFACE_ADAPTER_H_ | 6 #define COMPONENTS_MUS_GLES2_GL_SURFACE_ADAPTER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "ui/gfx/swap_result.h" | 14 #include "ui/gfx/swap_result.h" |
15 #include "ui/gl/gl_surface.h" | 15 #include "ui/gl/gl_surface.h" |
16 | 16 |
17 namespace mus { | 17 namespace mus { |
18 | 18 |
19 // Wraps a GLSurface such that there is a real GLSurface instance acting as | 19 // Wraps a GLSurface such that there is a real GLSurface instance acting as |
20 // delegate. Implements the GLSurface interface. The |gfx::GLSurfaceAdapter| | 20 // delegate. Implements the GLSurface interface. The |gl::GLSurfaceAdapter| |
21 // superclass provides a default implementation that forwards all GLSurface | 21 // superclass provides a default implementation that forwards all GLSurface |
22 // methods to the provided delegate. |GLSurfaceAdapterMus| overrides only the | 22 // methods to the provided delegate. |GLSurfaceAdapterMus| overrides only the |
23 // necessary methods to augment the completion callback argument to | 23 // necessary methods to augment the completion callback argument to |
24 // |SwapBuffersAsync|, |PostSubBufferAsync| and |CommitOverlayPlanesAsync| with | 24 // |SwapBuffersAsync|, |PostSubBufferAsync| and |CommitOverlayPlanesAsync| with |
25 // a callback provided with the |SetGpuCompletedSwapBuffersCallback| method. | 25 // a callback provided with the |SetGpuCompletedSwapBuffersCallback| method. |
26 class GLSurfaceAdapterMus : public gfx::GLSurfaceAdapter { | 26 class GLSurfaceAdapterMus : public gl::GLSurfaceAdapter { |
27 public: | 27 public: |
28 // Creates a new |GLSurfaceAdapterMus| that delegates to |surface|. | 28 // Creates a new |GLSurfaceAdapterMus| that delegates to |surface|. |
29 explicit GLSurfaceAdapterMus(scoped_refptr<gfx::GLSurface> surface); | 29 explicit GLSurfaceAdapterMus(scoped_refptr<gl::GLSurface> surface); |
30 | 30 |
31 // gfx::GLSurfaceAdapter. | 31 // gl::GLSurfaceAdapter. |
32 void SwapBuffersAsync( | 32 void SwapBuffersAsync( |
33 const gfx::GLSurface::SwapCompletionCallback& callback) override; | 33 const gl::GLSurface::SwapCompletionCallback& callback) override; |
34 void PostSubBufferAsync( | 34 void PostSubBufferAsync( |
35 int x, | 35 int x, |
36 int y, | 36 int y, |
37 int width, | 37 int width, |
38 int height, | 38 int height, |
39 const gfx::GLSurface::SwapCompletionCallback& callback) override; | 39 const gl::GLSurface::SwapCompletionCallback& callback) override; |
40 void CommitOverlayPlanesAsync( | 40 void CommitOverlayPlanesAsync( |
41 const gfx::GLSurface::SwapCompletionCallback& callback) override; | 41 const gl::GLSurface::SwapCompletionCallback& callback) override; |
42 | 42 |
43 // Set an additional callback to run on SwapBuffers completion. | 43 // Set an additional callback to run on SwapBuffers completion. |
44 void SetGpuCompletedSwapBuffersCallback( | 44 void SetGpuCompletedSwapBuffersCallback( |
45 gfx::GLSurface::SwapCompletionCallback callback); | 45 gl::GLSurface::SwapCompletionCallback callback); |
46 | 46 |
47 private: | 47 private: |
48 ~GLSurfaceAdapterMus() override; | 48 ~GLSurfaceAdapterMus() override; |
49 | 49 |
50 // We wrap the callback given to the |gfx::GLSurfaceAdapter| overrides above | 50 // We wrap the callback given to the |gl::GLSurfaceAdapter| overrides above |
51 // with an invocation of this function. It invokes |adapter_callback_| and the | 51 // with an invocation of this function. It invokes |adapter_callback_| and the |
52 // original |original_callback| provided by the original invoker of | 52 // original |original_callback| provided by the original invoker of |
53 // |SwapBuffersAsync| etc. | 53 // |SwapBuffersAsync| etc. |
54 void WrappedCallbackForSwapBuffersAsync( | 54 void WrappedCallbackForSwapBuffersAsync( |
55 const gfx::GLSurface::SwapCompletionCallback& original_callback, | 55 const gl::GLSurface::SwapCompletionCallback& original_callback, |
56 gfx::SwapResult result); | 56 gfx::SwapResult result); |
57 | 57 |
58 gfx::GLSurface::SwapCompletionCallback adapter_callback_; | 58 gl::GLSurface::SwapCompletionCallback adapter_callback_; |
59 | 59 |
60 // gfx::GLSurfaceAdapter doesn't own the delegate surface so keep a reference | 60 // gl::GLSurfaceAdapter doesn't own the delegate surface so keep a reference |
61 // here. | 61 // here. |
62 scoped_refptr<gfx::GLSurface> surface_; | 62 scoped_refptr<gl::GLSurface> surface_; |
63 | 63 |
64 base::WeakPtrFactory<GLSurfaceAdapterMus> weak_ptr_factory_; | 64 base::WeakPtrFactory<GLSurfaceAdapterMus> weak_ptr_factory_; |
65 | 65 |
66 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapterMus); | 66 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapterMus); |
67 }; | 67 }; |
68 | 68 |
69 } // namespace mus | 69 } // namespace mus |
70 | 70 |
71 #endif // COMPONENTS_MUS_GLES2_GL_SURFACE_ADAPTER_H_ | 71 #endif // COMPONENTS_MUS_GLES2_GL_SURFACE_ADAPTER_H_ |
OLD | NEW |