Flutter Impeller
texture.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_GLES_TEXTURE_H_
6 #define FLUTTER_IMPELLER_TOOLKIT_GLES_TEXTURE_H_
7 
8 #include "flutter/fml/unique_object.h"
10 
11 namespace impeller {
12 
13 // Simple holder of an GLTexture and the owning EGLDisplay.
14 struct GLTexture {
15  GLuint texture_name;
16 
17  constexpr bool operator==(const GLTexture& other) const {
18  return texture_name == other.texture_name;
19  }
20 
21  constexpr bool operator!=(const GLTexture& other) const {
22  return !(*this == other);
23  }
24 };
25 
27  static GLTexture InvalidValue() { return {0}; }
28 
29  static bool IsValid(const GLTexture& value) {
30  return value != InvalidValue();
31  }
32 
33  static void Free(GLTexture image) {
34  glDeleteTextures(1, &image.texture_name);
35  }
36 };
37 
38 using UniqueGLTexture = fml::UniqueObject<GLTexture, GLTextureTraits>;
39 
40 } // namespace impeller
41 
42 #endif // FLUTTER_IMPELLER_TOOLKIT_GLES_TEXTURE_H_
int32_t value
fml::UniqueObject< GLTexture, GLTextureTraits > UniqueGLTexture
Definition: texture.h:38
constexpr bool operator==(const GLTexture &other) const
Definition: texture.h:17
constexpr bool operator!=(const GLTexture &other) const
Definition: texture.h:21
GLuint texture_name
Definition: texture.h:15
static void Free(GLTexture image)
Definition: texture.h:33
static GLTexture InvalidValue()
Definition: texture.h:27
static bool IsValid(const GLTexture &value)
Definition: texture.h:29