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