Flutter Windows Embedder
surface.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter 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 FLUTTER_SHELL_PLATFORM_WINDOWS_EGL_SURFACE_H_
6 #define FLUTTER_SHELL_PLATFORM_WINDOWS_EGL_SURFACE_H_
7 
8 #include <EGL/egl.h>
9 
10 #include "flutter/fml/macros.h"
11 
12 namespace flutter {
13 namespace egl {
14 
15 // An EGL surface. This can be window surface or an off-screen buffer.
16 //
17 // This enables automatic error logging and mocking.
18 class Surface {
19  public:
20  Surface(EGLDisplay display, EGLContext context, EGLSurface surface);
21 
22  virtual ~Surface();
23 
24  // Destroy the EGL surface and invalidate this object.
25  //
26  // This also unbinds the current context from the thread.
27  virtual bool Destroy();
28 
29  // Check whether the EGL surface is valid.
30  virtual bool IsValid() const;
31 
32  // Check whether the EGL display, context, and surface are bound
33  // to the current thread.
34  virtual bool IsCurrent() const;
35 
36  // Bind the EGL surface's context and read and draw surfaces to the
37  // current thread. Returns true on success.
38  virtual bool MakeCurrent() const;
39 
40  // Swap the surface's front the and back buffers. Used to present content.
41  // Returns true on success.
42  virtual bool SwapBuffers() const;
43 
44  // Get the raw EGL surface.
45  virtual const EGLSurface& GetHandle() const;
46 
47  protected:
48  bool is_valid_ = true;
49 
50  EGLDisplay display_ = EGL_NO_DISPLAY;
51  EGLContext context_ = EGL_NO_CONTEXT;
52  EGLSurface surface_ = EGL_NO_SURFACE;
53 
55 };
56 
57 } // namespace egl
58 } // namespace flutter
59 
60 #endif // FLUTTER_SHELL_PLATFORM_WINDOWS_EGL_SURFACE_H_
flutter::egl::Surface::is_valid_
bool is_valid_
Definition: surface.h:48
flutter::egl::Surface::Surface
Surface(EGLDisplay display, EGLContext context, EGLSurface surface)
Definition: surface.cc:12
flutter::egl::Surface::~Surface
virtual ~Surface()
Definition: surface.cc:15
flutter::egl::Surface::FML_DISALLOW_COPY_AND_ASSIGN
FML_DISALLOW_COPY_AND_ASSIGN(Surface)
flutter::egl::Surface::Destroy
virtual bool Destroy()
Definition: surface.cc:23
flutter::egl::Surface::display_
EGLDisplay display_
Definition: surface.h:50
flutter::egl::Surface::GetHandle
virtual const EGLSurface & GetHandle() const
Definition: surface.cc:68
flutter::egl::Surface::IsValid
virtual bool IsValid() const
Definition: surface.cc:19
flutter::egl::Surface::surface_
EGLSurface surface_
Definition: surface.h:52
flutter::egl::Surface::MakeCurrent
virtual bool MakeCurrent() const
Definition: surface.cc:50
flutter::egl::Surface::SwapBuffers
virtual bool SwapBuffers() const
Definition: surface.cc:59
flutter
Definition: accessibility_bridge_windows.cc:11
flutter::egl::Surface::IsCurrent
virtual bool IsCurrent() const
Definition: surface.cc:43
flutter::egl::Surface
Definition: surface.h:18
flutter::egl::Surface::context_
EGLContext context_
Definition: surface.h:51