Chromium Code Reviews| 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 #ifndef COMPONENTS_MUS_GLES2_GL_SURFACE_ADAPTER_H_ | |
| 6 #define COMPONENTS_MUS_GLES2_GL_SURFACE_ADAPTER_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/callback.h" | |
| 13 #include "base/memory/weak_ptr.h" | |
| 14 #include "ui/gfx/swap_result.h" | |
| 15 #include "ui/gl/gl_surface.h" | |
| 16 | |
| 17 namespace mus { | |
| 18 | |
| 19 // 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.
| |
| 20 class GLSurfaceAdapterMus : public gfx::GLSurfaceAdapter { | |
| 21 public: | |
| 22 explicit GLSurfaceAdapterMus(scoped_refptr<gfx::GLSurface> surface); | |
| 23 // GLSurfaceAdapterMus replaces the necessary entry points to observe the end | |
| 24 // of | |
| 25 // SwapBuffers. | |
| 26 void SwapBuffersAsync( | |
| 27 const gfx::GLSurface::SwapCompletionCallback& callback) override; | |
| 28 void PostSubBufferAsync( | |
| 29 int x, | |
| 30 int y, | |
| 31 int width, | |
| 32 int height, | |
| 33 const gfx::GLSurface::SwapCompletionCallback& callback) override; | |
| 34 void CommitOverlayPlanesAsync( | |
| 35 const gfx::GLSurface::SwapCompletionCallback& callback) override; | |
| 36 | |
| 37 // Additional callback to run on SwapBuffers completion. | |
| 38 void SetGpuCompletedSwapBuffersCallback( | |
| 39 gfx::GLSurface::SwapCompletionCallback callback); | |
| 40 | |
| 41 private: | |
| 42 ~GLSurfaceAdapterMus() override; | |
| 43 | |
| 44 // We wrap the callback given to the GLSurface entry points above with an | |
| 45 // invocation of this function. It invokes |adapter_callback_| and the | |
| 46 // provided original |original_callback| | |
| 47 void WrappedCallbackForSwapBuffersAsync( | |
| 48 const gfx::GLSurface::SwapCompletionCallback& original_callback, | |
| 49 gfx::SwapResult result); | |
| 50 | |
| 51 gfx::GLSurface::SwapCompletionCallback adapter_callback_; | |
| 52 | |
| 53 // gfx::GLSurfaceAdapter doesn't own the delegate surface so keep a reference | |
| 54 // here. | |
| 55 scoped_refptr<gfx::GLSurface> surface_; | |
| 56 | |
| 57 base::WeakPtrFactory<GLSurfaceAdapterMus> weak_ptr_factory_; | |
| 58 | |
| 59 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapterMus); | |
| 60 }; | |
| 61 | |
| 62 } // namespace mus | |
| 63 | |
| 64 #endif // COMPONENTS_MUS_GLES2_GL_SURFACE_ADAPTER_H_ | |
| OLD | NEW |