| Flutter Impeller |

glyph_atlas_context_stb.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_TYPOGRAPHER_BACKENDS_STB_GLYPH_ATLAS_CONTEXT_STB_H_
6 #define FLUTTER_IMPELLER_TYPOGRAPHER_BACKENDS_STB_GLYPH_ATLAS_CONTEXT_STB_H_
7
8 #include "impeller/base/backend_cast.h"
9 #include "impeller/typographer/glyph_atlas.h"
10
11 namespace impeller {
12
13 class BitmapSTB {
14 public:
15 BitmapSTB();
16
17 ~BitmapSTB();
18
19 BitmapSTB(size_t width, size_t height, size_t bytes_per_pixel);
20
21 uint8_t* GetPixels();
22
23 uint8_t* GetPixelAddress(TPoint<size_t> coords);
24
25 size_t GetRowBytes() const;
26
27 size_t GetWidth() const;
28
29 size_t GetHeight() const;
30
31 size_t GetSize() const;
32
33 private:
34 size_t width_ = 0;
35 size_t height_ = 0;
36 size_t bytes_per_pixel_ = 0;
37 std::vector<uint8_t> pixels_;
38 };
39
40 class GlyphAtlasContextSTB
41 : public GlyphAtlasContext,
42 public BackendCast<GlyphAtlasContextSTB, GlyphAtlasContext> {
43 public:
44 explicit GlyphAtlasContextSTB(GlyphAtlas::Type type);
45
46 ~GlyphAtlasContextSTB() override;
47
48 //----------------------------------------------------------------------------
49 /// @brief Retrieve the previous (if any) BitmapSTB instance.
50 std::shared_ptr<BitmapSTB> GetBitmap() const;
51
52 void UpdateBitmap(std::shared_ptr<BitmapSTB> bitmap);
53
54 private:
55 std::shared_ptr<BitmapSTB> bitmap_;
56
57 GlyphAtlasContextSTB(const GlyphAtlasContextSTB&) = delete;
58
59 GlyphAtlasContextSTB& operator=(const GlyphAtlasContextSTB&) = delete;
60 };
61
62 } // namespace impeller
63
64 #endif // FLUTTER_IMPELLER_TYPOGRAPHER_BACKENDS_STB_GLYPH_ATLAS_CONTEXT_STB_H_
impeller::BitmapSTB::BitmapSTB
BitmapSTB()
impeller::GlyphAtlasContextSTB
Definition: glyph_atlas_context_stb.h:40
impeller::GlyphAtlasContextSTB::UpdateBitmap
void UpdateBitmap(std::shared_ptr< BitmapSTB > bitmap)
Definition: glyph_atlas_context_stb.cc:55
impeller::GlyphAtlasContextSTB::GetBitmap
std::shared_ptr< BitmapSTB > GetBitmap() const
Retrieve the previous (if any) BitmapSTB instance.
Definition: glyph_atlas_context_stb.cc:51
impeller::BitmapSTB::GetPixels
uint8_t * GetPixels()
Definition: glyph_atlas_context_stb.cc:19
impeller::BitmapSTB::GetWidth
size_t GetWidth() const
Definition: glyph_atlas_context_stb.cc:34
impeller::BitmapSTB::GetPixelAddress
uint8_t * GetPixelAddress(TPoint< size_t > coords)
Definition: glyph_atlas_context_stb.cc:23
impeller::BitmapSTB
Definition: glyph_atlas_context_stb.h:13
impeller::BitmapSTB::~BitmapSTB
~BitmapSTB()
impeller::GlyphAtlasContextSTB::GlyphAtlasContextSTB
GlyphAtlasContextSTB(GlyphAtlas::Type type)
Definition: glyph_atlas_context_stb.cc:46
impeller::BitmapSTB::GetSize
size_t GetSize() const
Definition: glyph_atlas_context_stb.cc:42
impeller::GlyphAtlasContextSTB::~GlyphAtlasContextSTB
~GlyphAtlasContextSTB() override
impeller::BitmapSTB::GetRowBytes
size_t GetRowBytes() const
Definition: glyph_atlas_context_stb.cc:30
impeller::GlyphAtlas::Type
Type
Describes how the glyphs are represented in the texture.
Definition: glyph_atlas.h:31
backend_cast.h
type
GLenum type
Definition: blit_command_gles.cc:126
impeller::GlyphAtlasContext
A container for caching a glyph atlas across frames.
Definition: glyph_atlas.h:149
impeller::BitmapSTB::GetHeight
size_t GetHeight() const
Definition: glyph_atlas_context_stb.cc:38
impeller::BackendCast
Definition: backend_cast.h:11
impeller::TPoint
Definition: point.h:27
glyph_atlas.h
impeller
Definition: aiks_blend_unittests.cc:18