Flutter Engine
The Flutter Engine
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
12namespace flutter {
13namespace 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.
18class 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_
virtual bool IsValid() const
Definition: surface.cc:19
EGLDisplay display_
Definition: surface.h:50
Surface(EGLDisplay display, EGLContext context, EGLSurface surface)
Definition: surface.cc:12
virtual const EGLSurface & GetHandle() const
Definition: surface.cc:68
virtual bool SwapBuffers() const
Definition: surface.cc:59
EGLContext context_
Definition: surface.h:51
virtual bool IsCurrent() const
Definition: surface.cc:43
virtual bool Destroy()
Definition: surface.cc:23
virtual ~Surface()
Definition: surface.cc:15
FML_DISALLOW_COPY_AND_ASSIGN(Surface)
virtual bool MakeCurrent() const
Definition: surface.cc:50
EGLSurface surface_
Definition: surface.h:52
VkSurfaceKHR surface
Definition: main.cc:49