Annotation of nono/vm/renderer.h, revision 1.1.1.6

1.1       root        1: //
                      2: // nono
1.1.1.3   root        3: // Copyright (C) 2020 nono project
                      4: // Licensed under nono-license.txt
                      5: //
                      6: 
1.1       root        7: //
                      8: // レンダラ
                      9: //
                     10: 
                     11: #pragma once
                     12: 
                     13: #include "device.h"
                     14: #include <condition_variable>
                     15: #include <mutex>
                     16: 
                     17: class Renderer : public Device
                     18: {
1.1.1.3   root       19:        using inherited = Device;
1.1       root       20:  public:
                     21:        // wxWidgets のビットマップは R8_G8_B8 の3バイト。
                     22:        static const int BPP = 3;
                     23: 
                     24:        static const uint REQ_TERMINATE         = 0x01; // スレッド終了指示
                     25:        static const uint REQ_REND_POWEROFF     = 0x02; // 電源オフ時の描画指示
                     26:        static const uint REQ_REND_NORMAL       = 0x04; // 通常の描画指示
1.1.1.6 ! root       27:        static const uint REQ_INVALIDATE        = 0x08; // 全画面更新指示
1.1       root       28: 
                     29:  public:
                     30:        Renderer();
1.1.1.5   root       31:        virtual ~Renderer() override;
1.1       root       32: 
1.1.1.3   root       33:        bool Init() override;
                     34:        bool PowerOff() override;
1.1       root       35: 
                     36:        // バッファとコールバック関数を指定
                     37:        // XXX 名前...
                     38:        void SetBuf(uint8 *, void (*)(void));
                     39: 
                     40:        // 画面合成処理 (CRTC とかから呼ばれる)
                     41:        void Render();
                     42: 
1.1.1.6 ! root       43:        // 全画面無効化の指示 (パレット変更で呼ばれる)
        !            44:        void Invalidate();
        !            45: 
1.1       root       46:        // 仮想画面幅(ピクセル)を取得
                     47:        int GetWidth() const { return width; }
                     48: 
                     49:        // 仮想画面高さ(ピクセル)を取得
                     50:        int GetHeight() const { return height; }
                     51: 
                     52:        // レンダリングスレッド (エントリポイントから呼ばれる)
                     53:        void ThreadRun();
                     54: 
                     55:  protected:
                     56:        // 画面合成。更新があれば true を返す。(派生クラス側で用意)
                     57:        virtual bool RenderMain() = 0;
                     58: 
                     59:        // ウィンドウとして表示される画面はオプションや設定などで縮尺を変える
                     60:        // ことが出来るが (こっちを実画面とする)、ここで扱う仮想画面とはそれに
                     61:        // 関わらず常にその機種の最大描画面積を指す。
                     62:        // LUNA でいう 1280 x 1024 のこと。
                     63: 
                     64:        // 仮想画面幅(ピクセル)
1.1.1.4   root       65:        int width {};
1.1       root       66: 
                     67:        // 仮想画面高さ(ピクセル)
1.1.1.4   root       68:        int height {};
1.1       root       69: 
                     70:        // バッファ (実体は wx 側で用意)
1.1.1.4   root       71:        uint8 *imagebuf {};
1.1       root       72: 
                     73:        // リフレッシュを指示するためのコールバック (wx 側で用意)
                     74:        // ここから直接 wxWindow::Refresh() を呼べないため。
1.1.1.4   root       75:        void (*refresh_callback)(void) {};
1.1       root       76: 
1.1.1.6 ! root       77:        // 次の画面更新で全画面を無効化する場合は true
        !            78:        bool invalidate {};
        !            79: 
1.1       root       80:        // リクエストフラグ
1.1.1.4   root       81:        uint32 request {};
1.1       root       82:        std::mutex mtx {};
                     83:        std::condition_variable cv {};
1.1.1.2   root       84: 
                     85:  private:
                     86:        pthread_t thread {};
1.1.1.4   root       87:        bool thread_created {};         // スレッドが作成されたら true
1.1.1.2   root       88: 
                     89:        // スレッドの終了を指示
                     90:        void Terminate();
1.1       root       91: };
                     92: 
                     93: //
                     94: // X68030 レンダラ
                     95: //
                     96: class X68030Renderer : public Renderer
                     97: {
1.1.1.3   root       98:        using inherited = Renderer;
1.1       root       99:  public:
                    100:        X68030Renderer();
1.1.1.5   root      101:        virtual ~X68030Renderer() override;
1.1       root      102: 
1.1.1.3   root      103:        bool RenderMain() override;
1.1       root      104: };
                    105: 
                    106: //
                    107: // LUNA レンダラ
                    108: //
                    109: class LunaRenderer : public Renderer
                    110: {
1.1.1.3   root      111:        using inherited = Renderer;
1.1       root      112:  public:
                    113:        LunaRenderer();
1.1.1.5   root      114:        virtual ~LunaRenderer() override;
1.1       root      115: 
1.1.1.6 ! root      116:        bool Init() override;
        !           117: 
1.1.1.3   root      118:        bool RenderMain() override;
1.1.1.6 ! root      119: 
        !           120:  private:
        !           121:        const uint8 *pal {};
1.1       root      122: };
                    123: 
1.1.1.2   root      124: extern std::unique_ptr<Renderer> gRenderer;

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.