Decompile fn_01854 (CDCBitmap::UpdateCache)

Batch #18354 by eAthena: 0 byte-identical, 1 confirmed by peer review.

- fn_01854 CDCBitmap::UpdateCache: logic confirmed by peer review

Peer-reviewed-by: ragnarok-clanker, alisonrag, bibinir
Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
This commit is contained in:
ragnarok-clanker 2026-11-12 13:44:19 +00:00
commit 184631ec9e
3 changed files with 22 additions and 22 deletions

View file

@ -18,50 +18,50 @@ BitmapTextureCache::~BitmapTextureCache() {
// OFFSET: 0x00548380
// FUNCTION: fn_01854
void BitmapTextureCache::Update(BitmapPixels& bitmap) {
if (!bitmap.dirty) {
void CDCBitmap::UpdateCache() {
if (!this->m_bitmap.dirty) {
return;
}
if (this->m_alpha == true) {
if (this->m_textures.empty()) {
CTexture* texture = g_texMgr.CreateTexture(bitmap.width, bitmap.height, TextureFormat::A8R8G8B8, false, false);
if (this->m_cache.m_alpha == true) {
if (this->m_cache.m_textures.empty()) {
CTexture* texture = g_texMgr.CreateTexture(this->m_bitmap.width, this->m_bitmap.height, TextureFormat::A8R8G8B8, false, false);
if (texture) {
this->m_textures.push_back(texture);
this->m_cache.m_textures.push_back(texture);
}
}
for (CTexture* texture : this->m_textures) {
texture->Upload(0, 0, bitmap.width, bitmap.height, bitmap.pixels, 0, bitmap.width);
for (CTexture* texture : this->m_cache.m_textures) {
texture->Upload(0, 0, this->m_bitmap.width, this->m_bitmap.height, this->m_bitmap.pixels, 0, this->m_bitmap.width);
}
} else {
if (this->m_textures.empty()) {
for (unsigned y = 0; y < bitmap.height; y += 256) {
for (unsigned x = 0; x < bitmap.width; x += 256) {
this->m_textures.push_back(
g_texMgr.CreateTexture(std::min(256u, bitmap.width - x), std::min(256u, bitmap.height - y), TextureFormat::A1R5G5B5, false, false)
if (this->m_cache.m_textures.empty()) {
for (unsigned y = 0; y < this->m_bitmap.height; y += 256) {
for (unsigned x = 0; x < this->m_bitmap.width; x += 256) {
this->m_cache.m_textures.push_back(
g_texMgr.CreateTexture(std::min(256u, this->m_bitmap.width - x), std::min(256u, this->m_bitmap.height - y), TextureFormat::A1R5G5B5, false, false)
);
}
}
}
const std::int32_t bytes = static_cast<std::int32_t>(4u * bitmap.width * bitmap.height);
const std::int32_t bytes = static_cast<std::int32_t>(4u * this->m_bitmap.width * this->m_bitmap.height);
for (std::int32_t offset = 0; offset < bytes; offset += 4) {
reinterpret_cast<unsigned char*>(bitmap.pixels)[offset + 3] = 255;
reinterpret_cast<unsigned char*>(this->m_bitmap.pixels)[offset + 3] = 255;
}
auto texture = this->m_textures.begin();
auto texture = this->m_cache.m_textures.begin();
for (unsigned y = 0; y < bitmap.height; y += 256) {
for (unsigned x = 0; x < bitmap.width; x += 256) {
(*texture)->Upload(0, 0, std::min(256u, bitmap.width - x), std::min(256u, bitmap.height - y), bitmap.pixels + x + y * bitmap.width, 0, bitmap.width);
for (unsigned y = 0; y < this->m_bitmap.height; y += 256) {
for (unsigned x = 0; x < this->m_bitmap.width; x += 256) {
(*texture)->Upload(0, 0, std::min(256u, this->m_bitmap.width - x), std::min(256u, this->m_bitmap.height - y), this->m_bitmap.pixels + x + y * this->m_bitmap.width, 0, this->m_bitmap.width);
++texture;
}
}
}
bitmap.dirty = false;
this->m_bitmap.dirty = false;
}
// OFFSET: 0x00547B80
@ -71,7 +71,7 @@ void CDCBitmap::Draw(int x, int y, int width, int height, std::uint32_t color) {
return;
}
this->m_cache.Update(this->m_bitmap);
this->UpdateCache();
if (this->m_cache.m_textures.empty()) {
return;
}