forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsurface.cc
38 lines (30 loc) · 873 Bytes
/
surface.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "impeller/toolkit/egl/surface.h"
namespace impeller {
namespace egl {
Surface::Surface(EGLDisplay display, EGLSurface surface)
: display_(display), surface_(surface) {}
Surface::~Surface() {
if (surface_ != EGL_NO_SURFACE) {
if (::eglDestroySurface(display_, surface_) != EGL_TRUE) {
IMPELLER_LOG_EGL_ERROR;
}
}
}
const EGLSurface& Surface::GetHandle() const {
return surface_;
}
bool Surface::IsValid() const {
return surface_ != EGL_NO_SURFACE;
}
bool Surface::Present() const {
const auto result = ::eglSwapBuffers(display_, surface_) == EGL_TRUE;
if (!result) {
IMPELLER_LOG_EGL_ERROR;
}
return result;
}
} // namespace egl
} // namespace impeller