Flutter Engine
The Flutter Engine
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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_CORE_TEXTURE_H_
6#define FLUTTER_IMPELLER_CORE_TEXTURE_H_
7
8#include <string_view>
9
10#include "flutter/fml/mapping.h"
14
15namespace impeller {
16
17class Texture {
18 public:
19 virtual ~Texture();
20
21 virtual void SetLabel(std::string_view label) = 0;
22
23 // Deprecated: use BlitPass::AddCopy instead.
24 [[nodiscard]] bool SetContents(const uint8_t* contents,
25 size_t length,
26 size_t slice = 0,
27 bool is_opaque = false);
28
29 // Deprecated: use BlitPass::AddCopy instead.
30 [[nodiscard]] bool SetContents(std::shared_ptr<const fml::Mapping> mapping,
31 size_t slice = 0,
32 bool is_opaque = false);
33
34 virtual bool IsValid() const = 0;
35
36 virtual ISize GetSize() const = 0;
37
38 bool IsOpaque() const;
39
40 size_t GetMipCount() const;
41
43
44 /// Update the coordinate system used by the texture.
45 ///
46 /// The setting is used to conditionally invert the coordinates to
47 /// account for the different origin of GLES textures.
48 void SetCoordinateSystem(TextureCoordinateSystem coordinate_system);
49
51
52 virtual Scalar GetYCoordScale() const;
53
54 /// Returns true if mipmaps have never been generated.
55 /// The contents of the mipmap may be out of date if the root texture has been
56 /// modified and the mipmaps hasn't been regenerated.
57 bool NeedsMipmapGeneration() const;
58
59 protected:
61
62 [[nodiscard]] virtual bool OnSetContents(const uint8_t* contents,
63 size_t length,
64 size_t slice) = 0;
65
66 [[nodiscard]] virtual bool OnSetContents(
67 std::shared_ptr<const fml::Mapping> mapping,
68 size_t slice) = 0;
69
70 bool mipmap_generated_ = false;
71
72 private:
73 TextureCoordinateSystem coordinate_system_ =
75 const TextureDescriptor desc_;
76 bool is_opaque_ = false;
77
78 bool IsSliceValid(size_t slice) const;
79
80 Texture(const Texture&) = delete;
81
82 Texture& operator=(const Texture&) = delete;
83};
84
85} // namespace impeller
86
87#endif // FLUTTER_IMPELLER_CORE_TEXTURE_H_
size_t GetMipCount() const
Definition: texture.cc:53
bool IsOpaque() const
Definition: texture.cc:49
virtual ~Texture()
const TextureDescriptor & GetTextureDescriptor() const
Definition: texture.cc:57
TextureCoordinateSystem GetCoordinateSystem() const
Definition: texture.cc:77
virtual bool OnSetContents(std::shared_ptr< const fml::Mapping > mapping, size_t slice)=0
bool NeedsMipmapGeneration() const
Definition: texture.cc:85
Texture(TextureDescriptor desc)
Definition: texture.cc:11
bool mipmap_generated_
Definition: texture.h:70
void SetCoordinateSystem(TextureCoordinateSystem coordinate_system)
Definition: texture.cc:73
virtual void SetLabel(std::string_view label)=0
virtual Scalar GetYCoordScale() const
Definition: texture.cc:81
virtual ISize GetSize() const =0
virtual bool OnSetContents(const uint8_t *contents, size_t length, size_t slice)=0
virtual bool IsValid() const =0
bool SetContents(const uint8_t *contents, size_t length, size_t slice=0, bool is_opaque=false)
Definition: texture.cc:15
size_t length
float Scalar
Definition: scalar.h:18
TextureCoordinateSystem
Definition: formats.h:327
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...