Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Side by Side Diff: components/mus/gles2/gl_surface_adapter.h

Issue 2119963002: Move mus to //services/ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 such that there is a real GLSurface instance acting as
20 // delegate. Implements the GLSurface interface. The |gl::GLSurfaceAdapter|
21 // superclass provides a default implementation that forwards all GLSurface
22 // methods to the provided delegate. |GLSurfaceAdapterMus| overrides only the
23 // necessary methods to augment the completion callback argument to
24 // |SwapBuffersAsync|, |PostSubBufferAsync| and |CommitOverlayPlanesAsync| with
25 // a callback provided with the |SetGpuCompletedSwapBuffersCallback| method.
26 class GLSurfaceAdapterMus : public gl::GLSurfaceAdapter {
27 public:
28 // Creates a new |GLSurfaceAdapterMus| that delegates to |surface|.
29 explicit GLSurfaceAdapterMus(scoped_refptr<gl::GLSurface> surface);
30
31 // gl::GLSurfaceAdapter.
32 void SwapBuffersAsync(
33 const gl::GLSurface::SwapCompletionCallback& callback) override;
34 void PostSubBufferAsync(
35 int x,
36 int y,
37 int width,
38 int height,
39 const gl::GLSurface::SwapCompletionCallback& callback) override;
40 void CommitOverlayPlanesAsync(
41 const gl::GLSurface::SwapCompletionCallback& callback) override;
42
43 // Set an additional callback to run on SwapBuffers completion.
44 void SetGpuCompletedSwapBuffersCallback(
45 gl::GLSurface::SwapCompletionCallback callback);
46
47 private:
48 ~GLSurfaceAdapterMus() override;
49
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
52 // original |original_callback| provided by the original invoker of
53 // |SwapBuffersAsync| etc.
54 void WrappedCallbackForSwapBuffersAsync(
55 const gl::GLSurface::SwapCompletionCallback& original_callback,
56 gfx::SwapResult result);
57
58 gl::GLSurface::SwapCompletionCallback adapter_callback_;
59
60 // gl::GLSurfaceAdapter doesn't own the delegate surface so keep a reference
61 // here.
62 scoped_refptr<gl::GLSurface> surface_;
63
64 base::WeakPtrFactory<GLSurfaceAdapterMus> weak_ptr_factory_;
65
66 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapterMus);
67 };
68
69 } // namespace mus
70
71 #endif // COMPONENTS_MUS_GLES2_GL_SURFACE_ADAPTER_H_
OLDNEW
« no previous file with comments | « components/mus/gles2/command_buffer_task_runner.cc ('k') | components/mus/gles2/gl_surface_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698