| 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() = default;
47
48 GlyphAtlasContextSTB::~GlyphAtlasContextSTB() = default;
49
50 std::shared_ptr<BitmapSTB> GlyphAtlasContextSTB::GetBitmap() const {
51 return bitmap_;
52 }
53
54 void GlyphAtlasContextSTB::UpdateBitmap(std::shared_ptr<BitmapSTB> bitmap) {
55 bitmap_ = std::move(bitmap);
56 }
57
58 } // namespace impeller
impeller::BitmapSTB::BitmapSTB
BitmapSTB()
impeller::TPoint::y
Type y
Definition: point.h:24
impeller::GlyphAtlasContextSTB::UpdateBitmap
void UpdateBitmap(std::shared_ptr< BitmapSTB > bitmap)
Definition: glyph_atlas_context_stb.cc:54
impeller::GlyphAtlasContextSTB::GetBitmap
std::shared_ptr< BitmapSTB > GetBitmap() const
Retrieve the previous (if any) BitmapSTB instance.
Definition: glyph_atlas_context_stb.cc:50
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::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::GlyphAtlasContextSTB::GlyphAtlasContextSTB
GlyphAtlasContextSTB()
glyph_atlas_context_stb.h
impeller::BitmapSTB::GetHeight
size_t GetHeight() const
Definition: glyph_atlas_context_stb.cc:38
impeller::TPoint::x
Type x
Definition: point.h:23
std
Definition: comparable.h:98
impeller::TPoint
Definition: point.h:20
impeller
Definition: aiks_context.cc:10