Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
surface.cc
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#include "flutter/shell/platform/windows/egl/surface.h"
6
7#include "flutter/shell/platform/windows/egl/egl.h"
8
9namespace flutter {
10namespace egl {
11
12Surface::Surface(EGLDisplay display, EGLContext context, EGLSurface surface)
13 : display_(display), context_(context), surface_(surface) {}
14
18
19bool Surface::IsValid() const {
20 return is_valid_;
21}
22
24 if (surface_ != EGL_NO_SURFACE) {
25 // Ensure the surface is not current before destroying it.
26 if (::eglMakeCurrent(display_, EGL_NO_SURFACE, EGL_NO_SURFACE,
27 EGL_NO_CONTEXT) != EGL_TRUE) {
29 return false;
30 }
31
32 if (::eglDestroySurface(display_, surface_) != EGL_TRUE) {
34 return false;
35 }
36 }
37
38 is_valid_ = false;
39 surface_ = EGL_NO_SURFACE;
40 return true;
41}
42
43bool Surface::IsCurrent() const {
44 return display_ == ::eglGetCurrentDisplay() &&
45 surface_ == ::eglGetCurrentSurface(EGL_DRAW) &&
46 surface_ == ::eglGetCurrentSurface(EGL_READ) &&
47 context_ == ::eglGetCurrentContext();
48}
49
51 if (::eglMakeCurrent(display_, surface_, surface_, context_) != EGL_TRUE) {
53 return false;
54 }
55
56 return true;
57}
58
60 if (::eglSwapBuffers(display_, surface_) != EGL_TRUE) {
62 return false;
63 }
64
65 return true;
66}
67
68const EGLSurface& Surface::GetHandle() const {
69 return surface_;
70}
71
72} // namespace egl
73} // namespace flutter
virtual bool IsValid() const
Definition surface.cc:19
EGLDisplay display_
Definition surface.h:50
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 bool MakeCurrent() const
Definition surface.cc:50
EGLSurface surface_
Definition surface.h:52
VkSurfaceKHR surface
Definition main.cc:49
EGLDisplay display_
EGLSurface surface_
#define WINDOWS_LOG_EGL_ERROR
Definition egl.h:19