| Flutter Impeller |

glyph_atlas_context_stb.cc
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 #include "impeller/typographer/backends/stb/glyph_atlas_context_stb.h"
6
7 namespace impeller {
8
9 BitmapSTB::BitmapSTB() = default;
10
11 BitmapSTB::~BitmapSTB() = default;
12
13 BitmapSTB::BitmapSTB(size_t width, size_t height, size_t bytes_per_pixel)
14 : width_(width),
15 height_(height),
16 bytes_per_pixel_(bytes_per_pixel),
17 pixels_(std::vector<uint8_t>(width * height * bytes_per_pixel, 0)) {}
18
19 uint8_t* BitmapSTB::GetPixels() {
20 return pixels_.data();
21 }
22
23 uint8_t* BitmapSTB::GetPixelAddress(TPoint<size_t> coords) {
24 FML_DCHECK(coords.x < width_);
25 FML_DCHECK(coords.x < height_);
26
27 return &pixels_.data()[(coords.x + width_ * coords.y) * bytes_per_pixel_];
28 }
29
30 size_t BitmapSTB::GetRowBytes() const {
31 return width_ * bytes_per_pixel_;
32 }
33
34 size_t BitmapSTB::GetWidth() const {
35 return width_;
36 }
37
38 size_t BitmapSTB::GetHeight() const {
39 return height_;
40 }
41
42 size_t BitmapSTB::GetSize() const {
43 return width_ * height_ * bytes_per_pixel_;
44 }
45
46 GlyphAtlasContextSTB::GlyphAtlasContextSTB(GlyphAtlas::Type type)
47 : GlyphAtlasContext(type) {}
48
49 GlyphAtlasContextSTB::~GlyphAtlasContextSTB() = default;
50
51 std::shared_ptr<BitmapSTB> GlyphAtlasContextSTB::GetBitmap() const {
52 return bitmap_;
53 }
54
55 void GlyphAtlasContextSTB::UpdateBitmap(std::shared_ptr<BitmapSTB> bitmap) {
56 bitmap_ = std::move(bitmap);
57 }
58
59 } // namespace impeller
impeller::BitmapSTB::BitmapSTB
BitmapSTB()
impeller::TPoint::y
Type y
Definition: point.h:31
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::~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
glyph_atlas_context_stb.h
impeller::GlyphAtlas::Type
Type
Describes how the glyphs are represented in the texture.
Definition: glyph_atlas.h:31
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::TPoint::x
Type x
Definition: point.h:30
std
Definition: comparable.h:95
impeller::TPoint
Definition: point.h:27
impeller
Definition: aiks_blend_unittests.cc:18