Chromium Code Reviews| Index: components/mus/gles2/gl_surface_adapter.h |
| diff --git a/components/mus/gles2/gl_surface_adapter.h b/components/mus/gles2/gl_surface_adapter.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3b447ae8fe479116d96a7be42cf607670d945509 |
| --- /dev/null |
| +++ b/components/mus/gles2/gl_surface_adapter.h |
| @@ -0,0 +1,64 @@ |
| +// Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef COMPONENTS_MUS_GLES2_GL_SURFACE_ADAPTER_H_ |
| +#define COMPONENTS_MUS_GLES2_GL_SURFACE_ADAPTER_H_ |
| + |
| +#include <stdint.h> |
| + |
| +#include <vector> |
| + |
| +#include "base/callback.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "ui/gfx/swap_result.h" |
| +#include "ui/gl/gl_surface.h" |
| + |
| +namespace mus { |
| + |
| +// Wraps a GLSurface using gfx::GLSurfaceAdapter. |
|
Fady Samuel
2016/04/01 23:24:42
nit: Better class level comments please. I'm not v
rjkroege
2016/04/01 23:58:44
Done.
|
| +class GLSurfaceAdapterMus : public gfx::GLSurfaceAdapter { |
| + public: |
| + explicit GLSurfaceAdapterMus(scoped_refptr<gfx::GLSurface> surface); |
| + // GLSurfaceAdapterMus replaces the necessary entry points to observe the end |
| + // of |
| + // SwapBuffers. |
| + void SwapBuffersAsync( |
| + const gfx::GLSurface::SwapCompletionCallback& callback) override; |
| + void PostSubBufferAsync( |
| + int x, |
| + int y, |
| + int width, |
| + int height, |
| + const gfx::GLSurface::SwapCompletionCallback& callback) override; |
| + void CommitOverlayPlanesAsync( |
| + const gfx::GLSurface::SwapCompletionCallback& callback) override; |
| + |
| + // Additional callback to run on SwapBuffers completion. |
| + void SetGpuCompletedSwapBuffersCallback( |
| + gfx::GLSurface::SwapCompletionCallback callback); |
| + |
| + private: |
| + ~GLSurfaceAdapterMus() override; |
| + |
| + // We wrap the callback given to the GLSurface entry points above with an |
| + // invocation of this function. It invokes |adapter_callback_| and the |
| + // provided original |original_callback| |
| + void WrappedCallbackForSwapBuffersAsync( |
| + const gfx::GLSurface::SwapCompletionCallback& original_callback, |
| + gfx::SwapResult result); |
| + |
| + gfx::GLSurface::SwapCompletionCallback adapter_callback_; |
| + |
| + // gfx::GLSurfaceAdapter doesn't own the delegate surface so keep a reference |
| + // here. |
| + scoped_refptr<gfx::GLSurface> surface_; |
| + |
| + base::WeakPtrFactory<GLSurfaceAdapterMus> weak_ptr_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapterMus); |
| +}; |
| + |
| +} // namespace mus |
| + |
| +#endif // COMPONENTS_MUS_GLES2_GL_SURFACE_ADAPTER_H_ |