| 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 {
19 return image == other.image && display == other.display;
20 }
21
22 constexpr bool operator!=(const EGLImageWithDisplay& other) const {
23 return !(*this == other);
24 }
25 };
26
27 struct EGLImageWithDisplayTraits {
28 static EGLImageWithDisplay InvalidValue() {
29 return {EGL_NO_IMAGE, EGL_NO_DISPLAY};
30 }
31
32 static bool IsValid(const EGLImageWithDisplay& value) {
33 return value != InvalidValue();
34 }
35
36 static void Free(EGLImageWithDisplay image) {
37 eglDestroyImage(image.display, image.image);
38 }
39 };
40
41 using UniqueEGLImage =
42 fml::UniqueObject<EGLImageWithDisplay, EGLImageWithDisplayTraits>;
43
44 // Simple holder of an EGLImageKHR and the owning EGLDisplay.
45 struct EGLImageKHRWithDisplay {
46 EGLImageKHR image = EGL_NO_IMAGE_KHR;
47 EGLDisplay display = EGL_NO_DISPLAY;
48
49 constexpr bool operator==(const EGLImageKHRWithDisplay& other) const {
50 return image == other.image && display == other.display;
51 }
52
53 constexpr bool operator!=(const EGLImageKHRWithDisplay& other) const {
54 return !(*this == other);
55 }
56 };
57
58 struct EGLImageKHRWithDisplayTraits {
59 static EGLImageKHRWithDisplay InvalidValue() {
60 return {EGL_NO_IMAGE_KHR, EGL_NO_DISPLAY};
61 }
62
63 static bool IsValid(const EGLImageKHRWithDisplay& value) {
64 return value != InvalidValue();
65 }
66
67 static void Free(EGLImageKHRWithDisplay image) {
68 eglDestroyImageKHR(image.display, image.image);
69 }
70 };
71
72 using UniqueEGLImageKHR =
73 fml::UniqueObject<EGLImageKHRWithDisplay, EGLImageKHRWithDisplayTraits>;
74
75 } // namespace impeller
76
77 #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:42
impeller::UniqueEGLImageKHR
fml::UniqueObject< EGLImageKHRWithDisplay, EGLImageKHRWithDisplayTraits > UniqueEGLImageKHR
Definition: image.h:73
impeller::EGLImageKHRWithDisplay
Definition: image.h:45
impeller::EGLImageKHRWithDisplay::display
EGLDisplay display
Definition: image.h:47
impeller::EGLImageKHRWithDisplay::operator==
constexpr bool operator==(const EGLImageKHRWithDisplay &other) const
Definition: image.h:49
impeller::EGLImageKHRWithDisplay::operator!=
constexpr bool operator!=(const EGLImageKHRWithDisplay &other) const
Definition: image.h:53
impeller::EGLImageKHRWithDisplay::image
EGLImageKHR image
Definition: image.h:46
impeller::EGLImageKHRWithDisplayTraits
Definition: image.h:58
impeller::EGLImageKHRWithDisplayTraits::Free
static void Free(EGLImageKHRWithDisplay image)
Definition: image.h:67
impeller::EGLImageKHRWithDisplayTraits::IsValid
static bool IsValid(const EGLImageKHRWithDisplay &value)
Definition: image.h:63
impeller::EGLImageKHRWithDisplayTraits::InvalidValue
static EGLImageKHRWithDisplay InvalidValue()
Definition: image.h:59
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
Definition: image.h:18
impeller::EGLImageWithDisplay::operator!=
constexpr bool operator!=(const EGLImageWithDisplay &other) const
Definition: image.h:22
impeller::EGLImageWithDisplayTraits
Definition: image.h:27
impeller::EGLImageWithDisplayTraits::IsValid
static bool IsValid(const EGLImageWithDisplay &value)
Definition: image.h:32
impeller::EGLImageWithDisplayTraits::Free
static void Free(EGLImageWithDisplay image)
Definition: image.h:36
impeller::EGLImageWithDisplayTraits::InvalidValue
static EGLImageWithDisplay InvalidValue()
Definition: image.h:28