| 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 #pragma once
6
7 #include <string_view>
8
9 #include "flutter/fml/macros.h"
10 #include "flutter/fml/mapping.h"
11 #include "impeller/core/formats.h"
12 #include "impeller/core/texture_descriptor.h"
13 #include "impeller/geometry/size.h"
14
15 namespace impeller {
16
17 class Texture {
18 public:
19 virtual ~Texture();
20
21 virtual void SetLabel(std::string_view label) = 0;
22
23 [[nodiscard]] bool SetContents(const uint8_t* contents,
24 size_t length,
25 size_t slice = 0,
26 bool is_opaque = false);
27
28 [[nodiscard]] bool SetContents(std::shared_ptr<const fml::Mapping> mapping,
29 size_t slice = 0,
30 bool is_opaque = false);
31
32 virtual bool IsValid() const = 0;
33
34 virtual ISize GetSize() const = 0;
35
36 bool IsOpaque() const;
37
38 size_t GetMipCount() const;
39
40 const TextureDescriptor& GetTextureDescriptor() const;
41
42 void SetCoordinateSystem(TextureCoordinateSystem coordinate_system);
43
44 TextureCoordinateSystem GetCoordinateSystem() const;
45
46 virtual Scalar GetYCoordScale() const;
47
48 bool NeedsMipmapGeneration() const;
49
50 protected:
51 explicit Texture(TextureDescriptor desc);
52
53 [[nodiscard]] virtual bool OnSetContents(const uint8_t* contents,
54 size_t length,
55 size_t slice) = 0;
56
57 [[nodiscard]] virtual bool OnSetContents(
58 std::shared_ptr<const fml::Mapping> mapping,
59 size_t slice) = 0;
60
61 bool mipmap_generated_ = false;
62
63 private:
64 TextureCoordinateSystem coordinate_system_ =
65 TextureCoordinateSystem::kRenderToTexture;
66 const TextureDescriptor desc_;
67 bool is_opaque_ = false;
68
69 bool IsSliceValid(size_t slice) const;
70
71 FML_DISALLOW_COPY_AND_ASSIGN(Texture);
72 };
73
74 } // namespace impeller
impeller::Texture::NeedsMipmapGeneration
bool NeedsMipmapGeneration() const
Definition: texture.cc:85
impeller::Texture::~Texture
virtual ~Texture()
impeller::Scalar
float Scalar
Definition: scalar.h:15
impeller::Texture::GetMipCount
size_t GetMipCount() const
Definition: texture.cc:53
impeller::Texture::GetTextureDescriptor
const TextureDescriptor & GetTextureDescriptor() const
Definition: texture.cc:57
texture_descriptor.h
formats.h
impeller::Texture::IsValid
virtual bool IsValid() const =0
impeller::Texture::GetYCoordScale
virtual Scalar GetYCoordScale() const
Definition: texture.cc:81
impeller::TextureCoordinateSystem
TextureCoordinateSystem
Definition: formats.h:304
impeller::TextureCoordinateSystem::kRenderToTexture
@ kRenderToTexture
impeller::Texture
Definition: texture.h:17
impeller::TSize< int64_t >
impeller::Texture::SetCoordinateSystem
void SetCoordinateSystem(TextureCoordinateSystem coordinate_system)
Definition: texture.cc:73
impeller::Texture::IsOpaque
bool IsOpaque() const
Definition: texture.cc:49
impeller::Texture::mipmap_generated_
bool mipmap_generated_
Definition: texture.h:61
impeller::Texture::GetSize
virtual ISize GetSize() const =0
impeller::Texture::SetLabel
virtual void SetLabel(std::string_view label)=0
impeller::TextureDescriptor
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
Definition: texture_descriptor.h:39
impeller::Texture::OnSetContents
virtual bool OnSetContents(const uint8_t *contents, size_t length, size_t slice)=0
impeller::Texture::Texture
Texture(TextureDescriptor desc)
Definition: texture.cc:11
impeller::Texture::GetCoordinateSystem
TextureCoordinateSystem GetCoordinateSystem() const
Definition: texture.cc:77
impeller
Definition: aiks_context.cc:10
impeller::Texture::SetContents
bool SetContents(const uint8_t *contents, size_t length, size_t slice=0, bool is_opaque=false)
Definition: texture.cc:15
size.h