Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 [[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
41
42 void SetCoordinateSystem(TextureCoordinateSystem coordinate_system);
43
45
46 virtual Scalar GetYCoordScale() const;
47
48 /// Returns true if mipmaps have never been generated.
49 /// The contents of the mipmap may be out of date if the root texture has been
50 /// modified and the mipmaps hasn't been regenerated.
51 bool NeedsMipmapGeneration() const;
52
53 protected:
54 explicit Texture(TextureDescriptor desc);
55
56 [[nodiscard]] virtual bool OnSetContents(const uint8_t* contents,
57 size_t length,
58 size_t slice) = 0;
59
60 [[nodiscard]] virtual bool OnSetContents(
61 std::shared_ptr<const fml::Mapping> mapping,
62 size_t slice) = 0;
63
64 bool mipmap_generated_ = false;
65
66 private:
67 TextureCoordinateSystem coordinate_system_ =
69 const TextureDescriptor desc_;
70 bool is_opaque_ = false;
71
72 bool IsSliceValid(size_t slice) const;
73
74 Texture(const Texture&) = delete;
75
76 Texture& operator=(const Texture&) = delete;
77};
78
79} // namespace impeller
80
81#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
bool mipmap_generated_
Definition texture.h:64
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:328
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...