blob: 06b5a93e2f9dd2be469bb913586831f85404ba76 [file] [log] [blame]
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#pragma once
#include "impeller/base/backend_cast.h"
#include "impeller/typographer/glyph_atlas.h"
namespace impeller {
class BitmapSTB {
public:
BitmapSTB();
~BitmapSTB();
BitmapSTB(size_t width, size_t height, size_t bytes_per_pixel);
uint8_t* GetPixels();
uint8_t* GetPixelAddress(TPoint<size_t> coords);
size_t GetRowBytes() const;
size_t GetWidth() const;
size_t GetHeight() const;
size_t GetSize() const;
private:
size_t width_ = 0;
size_t height_ = 0;
size_t bytes_per_pixel_ = 0;
std::vector<uint8_t> pixels_;
};
class GlyphAtlasContextSTB
: public GlyphAtlasContext,
public BackendCast<GlyphAtlasContextSTB, GlyphAtlasContext> {
public:
GlyphAtlasContextSTB();
~GlyphAtlasContextSTB() override;
//----------------------------------------------------------------------------
/// @brief Retrieve the previous (if any) BitmapSTB instance.
std::shared_ptr<BitmapSTB> GetBitmap() const;
void UpdateBitmap(std::shared_ptr<BitmapSTB> bitmap);
private:
std::shared_ptr<BitmapSTB> bitmap_;
FML_DISALLOW_COPY_AND_ASSIGN(GlyphAtlasContextSTB);
};
} // namespace impeller