Runtime atlas generation
No files matched your search
@@ -56,7 +56,7 @@ uint8_t *ZipFileReader::ReadFile(const char *path, size_t *size) {
|
||||
std::string temp_path = inZipPath_ + path;
|
||||
|
||||
std::lock_guard<std::mutex> guard(lock_);
|
||||
// Figure out the file size first.
|
||||
// Figure out the file size first. TODO: Can this part be done without locking the mutex?
|
||||
struct zip_stat zstat;
|
||||
int retval = zip_stat(zip_file_, temp_path.c_str(), ZIP_FL_NOCASE | ZIP_FL_UNCHANGED, &zstat);
|
||||
if (retval != 0) {
|
||||
|
||||
@@ -15,10 +15,9 @@
|
||||
#include "Common/Data/Format/ZIMSave.h"
|
||||
|
||||
#include "Common/Data/Encoding/Utf8.h"
|
||||
#include "Common/File/VFS/VFS.h"
|
||||
#include "Common/Render/AtlasGen.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef unsigned short u16;
|
||||
|
||||
void Image::copyfrom(const Image &img, int ox, int oy, Effect effect) {
|
||||
@@ -51,12 +50,6 @@ void Image::copyfrom(const Image &img, int ox, int oy, Effect effect) {
|
||||
set1(x + ox, y + oy, color);
|
||||
break;
|
||||
}
|
||||
case Effect::FX_PINK_TO_ALPHA:
|
||||
{
|
||||
u32 val = img.get1(x, y);
|
||||
set1(x + ox, y + oy, ((val & 0xFFFFFF) == 0xFF00FF) ? 0x00FFFFFF : (val | 0xFF000000));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
set1(x + ox, y + oy, 0xFFFF00FF);
|
||||
break;
|
||||
@@ -66,12 +59,21 @@ void Image::copyfrom(const Image &img, int ox, int oy, Effect effect) {
|
||||
}
|
||||
|
||||
bool Image::LoadPNG(const char *png_name) {
|
||||
size_t sz;
|
||||
const uint8_t *file_data = g_VFS.ReadFile(png_name, &sz);
|
||||
if (!file_data) {
|
||||
printf("Failed to load png from VFS");
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned char *img_data;
|
||||
int w, h;
|
||||
if (1 != pngLoad(png_name, &w, &h, &img_data)) {
|
||||
if (1 != pngLoadPtr(file_data, sz, &w, &h, &img_data)) {
|
||||
delete[] file_data;
|
||||
printf("Failed to load %s\n", png_name);
|
||||
return false;
|
||||
}
|
||||
delete[] file_data;
|
||||
resize(w, h);
|
||||
for (int y = 0; y < h; y++) {
|
||||
memcpy(dat.data() + y * w, img_data + 4 * y * w, 4 * w);
|
||||
@@ -157,7 +159,7 @@ std::vector<Data> Bucket::Resolve(int image_width, Image &dest) {
|
||||
}
|
||||
|
||||
// Output the glyph data.
|
||||
vector<Data> dats;
|
||||
std::vector<Data> dats;
|
||||
for (int i = 0; i < (int)items.size(); i++)
|
||||
dats.push_back(items[i].second);
|
||||
return dats;
|
||||
@@ -187,11 +189,11 @@ bool LoadImage(const char *imagefile, Effect effect, Bucket *bucket, int &global
|
||||
dat.ex = (int)img.width();
|
||||
dat.ey = (int)img.height();
|
||||
dat.effect = (int)effect;
|
||||
bucket->AddItem(img, dat);
|
||||
bucket->AddItem(std::move(img), dat);
|
||||
return true;
|
||||
}
|
||||
|
||||
AtlasImage ImageDesc::ToAtlasImage(float tw, float th, const vector<Data> &results) const {
|
||||
AtlasImage ImageDesc::ToAtlasImage(float tw, float th, const std::vector<Data> &results) const {
|
||||
AtlasImage img{};
|
||||
int i = result_index;
|
||||
float toffx = 0.5f / tw;
|
||||
@@ -206,7 +208,7 @@ AtlasImage ImageDesc::ToAtlasImage(float tw, float th, const vector<Data> &resul
|
||||
return img;
|
||||
}
|
||||
|
||||
void ImageDesc::OutputSelf(FILE *fil, float tw, float th, const vector<Data> &results) const {
|
||||
void ImageDesc::OutputSelf(FILE *fil, float tw, float th, const std::vector<Data> &results) const {
|
||||
int i = result_index;
|
||||
float toffx = 0.5f / tw;
|
||||
float toffy = 0.5f / th;
|
||||
|
||||
@@ -16,7 +16,6 @@ enum class Effect {
|
||||
FX_RED_TO_ALPHA_SOLID_WHITE = 1, // for alpha fonts
|
||||
FX_RED_TO_INTENSITY_ALPHA_255 = 2,
|
||||
FX_PREMULTIPLY_ALPHA = 3,
|
||||
FX_PINK_TO_ALPHA = 4, // for alpha fonts
|
||||
FX_INVALID = 5,
|
||||
};
|
||||
|
||||
@@ -96,8 +95,8 @@ inline bool operator<(const Data &lhs, const Data &rhs) {
|
||||
|
||||
struct Bucket {
|
||||
std::vector<std::pair<Image, Data> > items;
|
||||
void AddItem(const Image &img, const Data &dat) {
|
||||
items.push_back(std::make_pair(img, dat));
|
||||
void AddItem(const Image &&img, const Data &dat) {
|
||||
items.emplace_back(std::move(img), dat);
|
||||
}
|
||||
std::vector<Data> Resolve(int image_width, Image &dest);
|
||||
};
|
||||
|
||||
@@ -51,18 +51,27 @@ private:
|
||||
size_t size_;
|
||||
};
|
||||
|
||||
bool Atlas::Load(const uint8_t *data, size_t data_size) {
|
||||
void Atlas::Clear() {
|
||||
num_images = 0;
|
||||
num_fonts = 0;
|
||||
delete[] images;
|
||||
delete[] fonts;
|
||||
images = nullptr;
|
||||
fonts = nullptr;
|
||||
}
|
||||
|
||||
bool Atlas::LoadMeta(const uint8_t *data, size_t data_size) {
|
||||
ByteReader reader(data, data_size);
|
||||
|
||||
AtlasHeader header = reader.Read<AtlasHeader>();
|
||||
num_images = header.numImages;
|
||||
num_fonts = header.numFonts;
|
||||
if (header.magic != ATLAS_MAGIC) {
|
||||
return false;
|
||||
}
|
||||
|
||||
delete[] images;
|
||||
delete[] fonts;
|
||||
Clear();
|
||||
|
||||
num_images = header.numImages;
|
||||
num_fonts = header.numFonts;
|
||||
|
||||
images = reader.ReadMultipleAlloc<AtlasImage>(num_images, header.version >= 1);
|
||||
fonts = new AtlasFont[num_fonts];
|
||||
|
||||
@@ -128,10 +128,11 @@ struct AtlasHeader {
|
||||
|
||||
struct Atlas {
|
||||
~Atlas();
|
||||
bool Load(const uint8_t *data, size_t data_size);
|
||||
bool LoadMeta(const uint8_t *data, size_t data_size);
|
||||
bool IsMetadataLoaded() const {
|
||||
return images != nullptr;
|
||||
}
|
||||
void Clear();
|
||||
|
||||
AtlasFont *fonts = nullptr;
|
||||
int num_fonts = 0;
|
||||
|
||||
@@ -13,6 +13,11 @@
|
||||
#include "Common/Log.h"
|
||||
#include "Common/TimeUtil.h"
|
||||
#include "Common/LogReporting.h"
|
||||
#include "Common/Render/AtlasGen.h"
|
||||
|
||||
// The generated atlas.. This is temporary.
|
||||
std::vector<AtlasImage> genAtlasImages;
|
||||
Atlas genAtlas;
|
||||
|
||||
UIContext::UIContext() {
|
||||
fontStyle_ = new UI::FontStyle();
|
||||
|
||||
@@ -128,6 +128,8 @@ public:
|
||||
void SetAtlasProvider(UIAtlasProviderFunc func) { atlasProvider_ = func; }
|
||||
|
||||
private:
|
||||
void GenerateUIAtlas();
|
||||
|
||||
Draw::DrawContext *draw_ = nullptr;
|
||||
Bounds bounds_;
|
||||
|
||||
|
||||
@@ -263,7 +263,7 @@ void __PPGeInit() {
|
||||
if (!g_ppge_atlas.IsMetadataLoaded()) {
|
||||
uint8_t *atlas_data = g_VFS.ReadFile("ppge_atlas.meta", &atlas_data_size);
|
||||
if (atlas_data)
|
||||
g_ppge_atlas.Load(atlas_data, atlas_data_size);
|
||||
g_ppge_atlas.LoadMeta(atlas_data, atlas_data_size);
|
||||
delete[] atlas_data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -848,8 +848,9 @@ bool NativeInitGraphics(GraphicsContext *graphicsContext) {
|
||||
ui_draw2d.Init(g_draw, texColorPipeline);
|
||||
|
||||
uiContext->Init(g_draw, texColorPipeline, colorPipeline, &ui_draw2d);
|
||||
if (uiContext->Text())
|
||||
if (uiContext->Text()) {
|
||||
uiContext->Text()->SetFont("Tahoma", 20, 0);
|
||||
}
|
||||
|
||||
g_screenManager->setUIContext(uiContext);
|
||||
g_screenManager->setPostRenderCallback(&CallbackPostRender, nullptr);
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#include "Common/File/DirListing.h"
|
||||
#include "Common/Log/LogManager.h"
|
||||
#include "Common/Render/ManagedTexture.h"
|
||||
#include "Common/Render/AtlasGen.h"
|
||||
#include "Common/TimeUtil.h"
|
||||
|
||||
#include "Core/Config.h"
|
||||
|
||||
@@ -175,7 +177,7 @@ static UI::Style MakeStyle(uint32_t fg, uint32_t bg) {
|
||||
static void LoadAtlasMetadata(Atlas &metadata, const char *filename) {
|
||||
size_t atlas_data_size = 0;
|
||||
const uint8_t *atlas_data = g_VFS.ReadFile(filename, &atlas_data_size);
|
||||
bool load_success = atlas_data != nullptr && metadata.Load(atlas_data, atlas_data_size);
|
||||
bool load_success = atlas_data != nullptr && metadata.LoadMeta(atlas_data, atlas_data_size);
|
||||
if (!load_success) {
|
||||
ERROR_LOG(Log::G3D, "Failed to load %s - graphics may be broken", filename);
|
||||
// Stumble along with broken visuals instead of dying...
|
||||
@@ -278,16 +280,171 @@ std::vector<std::string> GetThemeInfoNames() {
|
||||
return names;
|
||||
}
|
||||
|
||||
Draw::Texture *GenerateUIAtlas(Draw::DrawContext *draw, Atlas *atlas) {
|
||||
// can't be const, yet...
|
||||
ImageDesc images[] = {
|
||||
{"I_SOLIDWHITE", "white.png"},
|
||||
{"I_CROSS", "cross.png"},
|
||||
{"I_CIRCLE", "circle.png"},
|
||||
{"I_SQUARE", "square.png"},
|
||||
{"I_TRIANGLE", "triangle.png"},
|
||||
{"I_SELECT", "select.png"},
|
||||
{"I_START", "start.png"},
|
||||
{"I_ARROW", "arrow.png"},
|
||||
{"I_DIR", "dir.png"},
|
||||
{"I_ROUND", "round.png"},
|
||||
{"I_RECT", "rect.png"},
|
||||
{"I_STICK", "stick.png"},
|
||||
{"I_STICK_BG", "stick_bg.png"},
|
||||
{"I_SHOULDER", "shoulder.png"},
|
||||
{"I_DIR_LINE", "dir_line.png"},
|
||||
{"I_ROUND_LINE", "round_line.png"},
|
||||
{"I_RECT_LINE", "rect_line.png"},
|
||||
{"I_SHOULDER_LINE", "shoulder_line.png"},
|
||||
{"I_STICK_LINE", "stick_line.png"},
|
||||
{"I_STICK_BG_LINE", "stick_bg_line.png"},
|
||||
{"I_CHECKEDBOX", "checkedbox.png"},
|
||||
{"I_BG", "background2.png"},
|
||||
{"I_L", "L.png"},
|
||||
{"I_R", "R.png"},
|
||||
{"I_DROP_SHADOW", "dropshadow.png"},
|
||||
{"I_LINES", "lines.png"},
|
||||
{"I_GRID", "grid.png"},
|
||||
{"I_LOGO", "logo.png"},
|
||||
{"I_ICON", "icon_regular_72.png"},
|
||||
{"I_ICONGOLD", "icon_gold_72.png"},
|
||||
{"I_FOLDER", "folder_line.png"},
|
||||
{"I_UP_DIRECTORY", "up_line.png"},
|
||||
{"I_GEAR", "gear.png"},
|
||||
{"I_1", "1.png"},
|
||||
{"I_2", "2.png"},
|
||||
{"I_3", "3.png"},
|
||||
{"I_4", "4.png"},
|
||||
{"I_5", "5.png"},
|
||||
{"I_6", "6.png"},
|
||||
{"I_PSP_DISPLAY", "psp_display.png"},
|
||||
{"I_FLAG_JP", "flag_jp.png"},
|
||||
{"I_FLAG_US", "flag_us.png"},
|
||||
{"I_FLAG_EU", "flag_eu.png"},
|
||||
{"I_FLAG_HK", "flag_hk.png"},
|
||||
{"I_FLAG_AS", "flag_as.png"},
|
||||
{"I_FLAG_KO", "flag_ko.png"},
|
||||
{"I_FULLSCREEN", "fullscreen.png"},
|
||||
{"I_RESTORE", "restore.png"},
|
||||
{"I_SDCARD", "sdcard.png"},
|
||||
{"I_HOME", "home.png"},
|
||||
{"I_A", "a.png"},
|
||||
{"I_B", "b.png"},
|
||||
{"I_C", "c.png"},
|
||||
{"I_D", "d.png"},
|
||||
{"I_E", "e.png"},
|
||||
{"I_F", "f.png"},
|
||||
{"I_SQUARE_SHAPE", "square_shape.png"},
|
||||
{"I_SQUARE_SHAPE_LINE", "square_shape_line.png"},
|
||||
{"I_FOLDER_OPEN", "folder_open_line.png"},
|
||||
{"I_WARNING", "warning.png"},
|
||||
{"I_TRASHCAN", "trashcan.png"},
|
||||
{"I_PLUS", "plus.png"},
|
||||
{"I_ROTATE_LEFT", "rotate_left.png"},
|
||||
{"I_ROTATE_RIGHT", "rotate_right.png"},
|
||||
{"I_ARROW_LEFT", "arrow_left.png"},
|
||||
{"I_ARROW_RIGHT", "arrow_right.png"},
|
||||
{"I_ARROW_UP", "arrow_up.png"},
|
||||
{"I_ARROW_DOWN", "arrow_down.png"},
|
||||
{"I_SLIDERS", "sliders.png"},
|
||||
{"I_THREE_DOTS", "three_dots.png"},
|
||||
{"I_INFO", "info.png"},
|
||||
{"I_RETROACHIEVEMENTS_LOGO", "retroachievements_logo.png"},
|
||||
{"I_CHECKMARK", "checkmark.png"},
|
||||
{"I_PLAY", "play.png"},
|
||||
{"I_STOP", "stop.png"},
|
||||
{"I_PAUSE", "pause.png"},
|
||||
{"I_FASTFORWARD", "fast_forward.png"},
|
||||
{"I_RECORD", "record.png"},
|
||||
{"I_SPEAKER", "speaker.png"},
|
||||
{"I_SPEAKER_MAX", "speaker_max.png"},
|
||||
{"I_SPEAKER_OFF", "speaker_off.png"},
|
||||
{"I_WINNER_CUP", "winner_cup.png"},
|
||||
{"I_EMPTY", "empty.png"},
|
||||
};
|
||||
int global_id = 0;
|
||||
|
||||
Instant start = Instant::Now();
|
||||
|
||||
Bucket bucket;
|
||||
|
||||
// Script fully read, now read images and rasterize the fonts.
|
||||
std::vector<int> resultIds;
|
||||
resultIds.reserve(ARRAY_SIZE(images));
|
||||
for (auto &image : images) {
|
||||
std::string name = "ui_images/";
|
||||
if (image.fileName == "white.png") {
|
||||
name = "white.png";
|
||||
} else {
|
||||
name.append(image.fileName);
|
||||
}
|
||||
image.result_index = (int)bucket.items.size();
|
||||
if (!LoadImage(name.c_str(), image.effect, &bucket, global_id)) {
|
||||
ERROR_LOG(Log::G3D, "Failed to load image %s\n", image.fileName.c_str());
|
||||
}
|
||||
}
|
||||
INFO_LOG(Log::G3D, " - Loaded %zu images in %.2f ms\n", bucket.items.size(), start.ElapsedMs());
|
||||
|
||||
int image_width = 512;
|
||||
Image dest;
|
||||
|
||||
Instant now = Instant::Now();
|
||||
std::vector<Data> results = bucket.Resolve(image_width, dest);
|
||||
INFO_LOG(Log::G3D, " - Bucketed %zu images in %.2f ms\n", results.size(), now.ElapsedMs());
|
||||
|
||||
// Need to sort the results by ID, after the bucket messed up the order.
|
||||
sort(results.begin(), results.end());
|
||||
|
||||
// Fill out the atlas structure.
|
||||
std::vector<AtlasImage> genAtlasImages;
|
||||
genAtlasImages.reserve(ARRAY_SIZE(images));
|
||||
for (int i = 0; i < ARRAY_SIZE(images); i++) {
|
||||
genAtlasImages.push_back(images[i].ToAtlasImage((float)dest.width(), (float)dest.height(), results));
|
||||
}
|
||||
|
||||
atlas->Clear();
|
||||
atlas->images = new AtlasImage[genAtlasImages.size()];
|
||||
std::copy(genAtlasImages.begin(), genAtlasImages.end(), atlas->images);
|
||||
atlas->num_images = (int)genAtlasImages.size();
|
||||
|
||||
// For debug, write out the atlas.
|
||||
// dest.SavePNG("../gen.png");
|
||||
|
||||
// Then, create the texture too.
|
||||
Draw::TextureDesc desc{};
|
||||
desc.width = image_width;
|
||||
desc.height = dest.height();
|
||||
desc.depth = 1;
|
||||
desc.mipLevels = 1;
|
||||
desc.format = Draw::DataFormat::R8G8B8A8_UNORM;
|
||||
desc.type = Draw::TextureType::LINEAR2D;
|
||||
desc.initData.push_back((const u8 *)dest.data());
|
||||
desc.tag = "UIAtlas";
|
||||
|
||||
INFO_LOG(Log::G3D, "UI atlas generated in %.2f ms, size %dx%d with %zu images\n", start.ElapsedMs(), desc.width, desc.height, genAtlasImages.size());
|
||||
return draw->CreateTexture(desc);
|
||||
}
|
||||
|
||||
AtlasData AtlasProvider(Draw::DrawContext *draw, AtlasChoice atlas) {
|
||||
switch (atlas) {
|
||||
case AtlasChoice::General:
|
||||
{
|
||||
// Generate the atlas from scratch.
|
||||
Draw::Texture *tex = GenerateUIAtlas(draw, &ui_atlas);
|
||||
return { &ui_atlas, tex };
|
||||
|
||||
// Load any missing atlas metadata (the images are loaded from UIContext).
|
||||
/*
|
||||
LoadAtlasMetadata(ui_atlas, "ui_atlas.meta");
|
||||
return {
|
||||
&ui_atlas,
|
||||
CreateTextureFromFile(draw, "ui_atlas.zim", ImageFileType::ZIM, false)
|
||||
};
|
||||
};*/
|
||||
}
|
||||
case AtlasChoice::Font:
|
||||
{
|
||||
|
||||
|
After Width: | Height: | Size: 473 B |
|
After Width: | Height: | Size: 828 B |
|
After Width: | Height: | Size: 991 B |
|
After Width: | Height: | Size: 783 B |
|
After Width: | Height: | Size: 818 B |
|
After Width: | Height: | Size: 1008 B |
|
After Width: | Height: | Size: 309 B |
|
After Width: | Height: | Size: 709 B |
|
After Width: | Height: | Size: 941 B |
|
After Width: | Height: | Size: 530 B |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 815 B |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 749 B |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 973 B |
|
After Width: | Height: | Size: 645 B |
|
After Width: | Height: | Size: 809 B |
|
After Width: | Height: | Size: 774 B |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 512 B |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 468 B |
|
After Width: | Height: | Size: 936 B |
|
After Width: | Height: | Size: 669 B |
|
After Width: | Height: | Size: 806 B |
|
After Width: | Height: | Size: 766 B |
|
After Width: | Height: | Size: 529 B |
|
After Width: | Height: | Size: 807 B |
|
After Width: | Height: | Size: 792 B |
|
After Width: | Height: | Size: 788 B |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 710 B |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 284 B |
|
After Width: | Height: | Size: 1006 B |
|
After Width: | Height: | Size: 5.6 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 218 B |
|
After Width: | Height: | Size: 5.5 KiB |
|
After Width: | Height: | Size: 396 B |
|
After Width: | Height: | Size: 751 B |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 438 B |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 281 B |
|
After Width: | Height: | Size: 536 B |
|
After Width: | Height: | Size: 667 B |
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 818 B |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 825 B |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 454 B |
|
After Width: | Height: | Size: 268 B |
|
After Width: | Height: | Size: 424 B |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 8.8 KiB |
|
After Width: | Height: | Size: 315 B |
|
After Width: | Height: | Size: 1005 B |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
@@ -221,8 +221,8 @@ void RasterizeFonts(const FontReferenceList &fontRefs, vector<CharRange> &ranges
|
||||
missing_chars++;
|
||||
}
|
||||
|
||||
Image img;
|
||||
if (!foundMatch || filtered || 0 != FT_Load_Char(font, kar, FT_LOAD_RENDER | FT_LOAD_MONOCHROME)) {
|
||||
Image img;
|
||||
img.resize(1, 1);
|
||||
Data dat;
|
||||
|
||||
@@ -238,9 +238,10 @@ void RasterizeFonts(const FontReferenceList &fontRefs, vector<CharRange> &ranges
|
||||
dat.voffset = 0;
|
||||
dat.charNum = kar;
|
||||
dat.effect = (int)Effect::FX_RED_TO_ALPHA_SOLID_WHITE;
|
||||
bucket->AddItem(img, dat);
|
||||
bucket->AddItem(std::move(img), dat);
|
||||
continue;
|
||||
}
|
||||
Image img;
|
||||
|
||||
// printf("%dx%d %p\n", font->glyph->bitmap.width, font->glyph->bitmap.rows, font->glyph->bitmap.buffer);
|
||||
const int bord = (128 + distmult - 1) / distmult + 1;
|
||||
@@ -295,7 +296,7 @@ void RasterizeFonts(const FontReferenceList &fontRefs, vector<CharRange> &ranges
|
||||
dat.charNum = kar;
|
||||
|
||||
dat.effect = (int)Effect::FX_RED_TO_ALPHA_SOLID_WHITE;
|
||||
bucket->AddItem(img, dat);
|
||||
bucket->AddItem(std::move(img), dat);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -731,11 +732,11 @@ int GenerateFromScript(const char *script_file, const char *atlas_name, bool hig
|
||||
header.numImages = (int)images.size();
|
||||
fwrite(&header, 1, sizeof(header), meta);
|
||||
// For each image
|
||||
AtlasImage *atalas_images = new AtlasImage[images.size()];
|
||||
AtlasImage *atlas_images = new AtlasImage[images.size()];
|
||||
for (int i = 0; i < (int)images.size(); i++) {
|
||||
atalas_images[i] = images[i].ToAtlasImage((float)dest.width(), (float)dest.height(), results);
|
||||
atlas_images[i] = images[i].ToAtlasImage((float)dest.width(), (float)dest.height(), results);
|
||||
}
|
||||
WriteCompressed(atalas_images, sizeof(AtlasImage), images.size(), meta);
|
||||
WriteCompressed(atlas_images, sizeof(AtlasImage), images.size(), meta);
|
||||
// For each font
|
||||
for (int i = 0; i < (int)fonts.size(); i++) {
|
||||
auto &font = fonts[i];
|
||||
|
||||