| Flutter Impeller |

image.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_IMPELLER_TOOLKIT_EGL_IMAGE_H_
6 #define FLUTTER_IMPELLER_TOOLKIT_EGL_IMAGE_H_
7
8 #include "flutter/fml/unique_object.h"
9 #include "flutter/impeller/toolkit/egl/egl.h"
10
11 namespace impeller {
12
13 // Simple holder of an EGLImage and the owning EGLDisplay.
14 struct EGLImageWithDisplay {
15 EGLImage image = EGL_NO_IMAGE;
16 EGLDisplay display = EGL_NO_DISPLAY;
17
18 constexpr bool operator==(const EGLImageWithDisplay& other) const = default;
19 };
20
21 struct EGLImageWithDisplayTraits {
22 static EGLImageWithDisplay InvalidValue() {
23 return {EGL_NO_IMAGE, EGL_NO_DISPLAY};
24 }
25
26 static bool IsValid(const EGLImageWithDisplay& value) {
27 return value != InvalidValue();
28 }
29
30 static void Free(EGLImageWithDisplay image) {
31 eglDestroyImage(image.display, image.image);
32 }
33 };
34
35 using UniqueEGLImage =
36 fml::UniqueObject<EGLImageWithDisplay, EGLImageWithDisplayTraits>;
37
38 // Simple holder of an EGLImageKHR and the owning EGLDisplay.
39 struct EGLImageKHRWithDisplay {
40 EGLImageKHR image = EGL_NO_IMAGE_KHR;
41 EGLDisplay display = EGL_NO_DISPLAY;
42
43 constexpr bool operator==(const EGLImageKHRWithDisplay& other) const =
44 default;
45 };
46
47 struct EGLImageKHRWithDisplayTraits {
48 static EGLImageKHRWithDisplay InvalidValue() {
49 return {EGL_NO_IMAGE_KHR, EGL_NO_DISPLAY};
50 }
51
52 static bool IsValid(const EGLImageKHRWithDisplay& value) {
53 return value != InvalidValue();
54 }
55
56 static void Free(EGLImageKHRWithDisplay image) {
57 eglDestroyImageKHR(image.display, image.image);
58 }
59 };
60
61 using UniqueEGLImageKHR =
62 fml::UniqueObject<EGLImageKHRWithDisplay, EGLImageKHRWithDisplayTraits>;
63
64 } // namespace impeller
65
66 #endif // FLUTTER_IMPELLER_TOOLKIT_EGL_IMAGE_H_
value
int32_t value
Definition: dl_golden_unittests.cc:459
egl.h
impeller
Definition: allocation.cc:12
impeller::UniqueEGLImage
fml::UniqueObject< EGLImageWithDisplay, EGLImageWithDisplayTraits > UniqueEGLImage
Definition: image.h:36
impeller::UniqueEGLImageKHR
fml::UniqueObject< EGLImageKHRWithDisplay, EGLImageKHRWithDisplayTraits > UniqueEGLImageKHR
Definition: image.h:62
impeller::EGLImageKHRWithDisplay
Definition: image.h:39
impeller::EGLImageKHRWithDisplay::display
EGLDisplay display
Definition: image.h:41
impeller::EGLImageKHRWithDisplay::operator==
constexpr bool operator==(const EGLImageKHRWithDisplay &other) const =default
impeller::EGLImageKHRWithDisplay::image
EGLImageKHR image
Definition: image.h:40
impeller::EGLImageKHRWithDisplayTraits
Definition: image.h:47
impeller::EGLImageKHRWithDisplayTraits::Free
static void Free(EGLImageKHRWithDisplay image)
Definition: image.h:56
impeller::EGLImageKHRWithDisplayTraits::IsValid
static bool IsValid(const EGLImageKHRWithDisplay &value)
Definition: image.h:52
impeller::EGLImageKHRWithDisplayTraits::InvalidValue
static EGLImageKHRWithDisplay InvalidValue()
Definition: image.h:48
impeller::EGLImageWithDisplay
Definition: image.h:14
impeller::EGLImageWithDisplay::display
EGLDisplay display
Definition: image.h:16
impeller::EGLImageWithDisplay::image
EGLImage image
Definition: image.h:15
impeller::EGLImageWithDisplay::operator==
constexpr bool operator==(const EGLImageWithDisplay &other) const =default
impeller::EGLImageWithDisplayTraits
Definition: image.h:21
impeller::EGLImageWithDisplayTraits::IsValid
static bool IsValid(const EGLImageWithDisplay &value)
Definition: image.h:26
impeller::EGLImageWithDisplayTraits::Free
static void Free(EGLImageWithDisplay image)
Definition: image.h:30
impeller::EGLImageWithDisplayTraits::InvalidValue
static EGLImageWithDisplay InvalidValue()
Definition: image.h:22