--- nono/vm/planevram.cpp 2026/04/29 17:05:42 1.1.1.6 +++ nono/vm/planevram.cpp 2026/04/29 17:05:50 1.1.1.7 @@ -13,13 +13,7 @@ #include "mybswap.h" #include #include - -// v[] がいずれかでも true なら true を返す。 -static bool -AnyOf(const std::vector& v) -{ - return std::any_of(v.begin(), v.end(), [](bool x) { return x; }); -} +#include // コンストラクタ PlaneVRAMDevice::PlaneVRAMDevice(int width_, int height_) @@ -29,9 +23,6 @@ PlaneVRAMDevice::PlaneVRAMDevice(int wid nplane = -1; composite.Create(width_, height_); - - dirty.line.resize(height_); - pending.line.resize(height_); } // 初期化 @@ -86,7 +77,7 @@ PlaneVRAMDevice::ResetHard(bool poweron) void PlaneVRAMDevice::Invalidate() { - std::fill(dirty.line.begin(), dirty.line.end(), 1); + dirty.line.set(); } // VRAM には更新がないが再レンダリングが必要。 @@ -103,26 +94,20 @@ PlaneVRAMDevice::Invalidate2() bool PlaneVRAMDevice::Snap() { - const uint height = composite.GetHeight(); bool update_needed; // 更新 (dirty) があれば pending に重ねる。 { - std::unique_lock lock(mtx); - for (int y = 0; y < height; y++) { - // std::vector には operator|=() がない。 - if (__predict_false(dirty.line[y])) { - pending.line[y] = true; - dirty.line[y] = false; - } - } + std::lock_guard lock(mtx); + pending.line |= dirty.line; + dirty.line.reset(); if (__predict_false(dirty.invalidate2)) { pending.invalidate2 = true; dirty.invalidate2 = false; } - update_needed = AnyOf(pending.line) || pending.invalidate2; + update_needed = pending.line.any() || pending.invalidate2; } return update_needed; @@ -139,15 +124,15 @@ PlaneVRAMDevice::Render(BitmapRGBX& dst) // ローカルにコピー。 ModifyInfo modified; { - std::unique_lock lock(mtx); + std::lock_guard lock(mtx); modified.line = pending.line; - std::fill(pending.line.begin(), pending.line.end(), false); modified.invalidate2 = pending.invalidate2; + pending.line.reset(); pending.invalidate2 = false; } // VRAM に更新があれば composite を更新。 - if (AnyOf(modified.line)) { + if (modified.line.any()) { RenderVRAMToComposite(modified.line); updated = true; } @@ -165,7 +150,7 @@ PlaneVRAMDevice::Render(BitmapRGBX& dst) // VRAM から composite 画面を合成する。 // レンダラスレッドから呼ばれる。 void -PlaneVRAMDevice::RenderVRAMToComposite(const std::vector& modified) +PlaneVRAMDevice::RenderVRAMToComposite(const bitset1024& modified) { const uint width = composite.GetWidth(); const uint height = composite.GetHeight(); @@ -176,8 +161,7 @@ PlaneVRAMDevice::RenderVRAMToComposite(c // テキスト合成画面を描く for (uint y = 0; y < height; y++) { - bool mod = modified[y]; - if (mod == false) { + if (modified.test(y) == false) { continue; }