|
|
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; // 通常の描画指示
27:
28: public:
29: Renderer();
1.1.1.5 ! root 30: virtual ~Renderer() override;
1.1 root 31:
1.1.1.3 root 32: bool Init() override;
33: bool PowerOff() override;
1.1 root 34:
35: // バッファとコールバック関数を指定
36: // XXX 名前...
37: void SetBuf(uint8 *, void (*)(void));
38:
39: // 画面合成処理 (CRTC とかから呼ばれる)
40: void Render();
41:
42: // 仮想画面幅(ピクセル)を取得
43: int GetWidth() const { return width; }
44:
45: // 仮想画面高さ(ピクセル)を取得
46: int GetHeight() const { return height; }
47:
48: // レンダリングスレッド (エントリポイントから呼ばれる)
49: void ThreadRun();
50:
51: protected:
52: // 画面合成。更新があれば true を返す。(派生クラス側で用意)
53: virtual bool RenderMain() = 0;
54:
55: // ウィンドウとして表示される画面はオプションや設定などで縮尺を変える
56: // ことが出来るが (こっちを実画面とする)、ここで扱う仮想画面とはそれに
57: // 関わらず常にその機種の最大描画面積を指す。
58: // LUNA でいう 1280 x 1024 のこと。
59:
60: // 仮想画面幅(ピクセル)
1.1.1.4 root 61: int width {};
1.1 root 62:
63: // 仮想画面高さ(ピクセル)
1.1.1.4 root 64: int height {};
1.1 root 65:
66: // バッファ (実体は wx 側で用意)
1.1.1.4 root 67: uint8 *imagebuf {};
1.1 root 68:
69: // リフレッシュを指示するためのコールバック (wx 側で用意)
70: // ここから直接 wxWindow::Refresh() を呼べないため。
1.1.1.4 root 71: void (*refresh_callback)(void) {};
1.1 root 72:
73: // リクエストフラグ
1.1.1.4 root 74: uint32 request {};
1.1 root 75: std::mutex mtx {};
76: std::condition_variable cv {};
1.1.1.2 root 77:
78: private:
79: pthread_t thread {};
1.1.1.4 root 80: bool thread_created {}; // スレッドが作成されたら true
1.1.1.2 root 81:
82: // スレッドの終了を指示
83: void Terminate();
1.1 root 84: };
85:
86: //
87: // X68030 レンダラ
88: //
89: class X68030Renderer : public Renderer
90: {
1.1.1.3 root 91: using inherited = Renderer;
1.1 root 92: public:
93: X68030Renderer();
1.1.1.5 ! root 94: virtual ~X68030Renderer() override;
1.1 root 95:
1.1.1.3 root 96: bool RenderMain() override;
1.1 root 97: };
98:
99: //
100: // LUNA レンダラ
101: //
102: class LunaRenderer : public Renderer
103: {
1.1.1.3 root 104: using inherited = Renderer;
1.1 root 105: public:
106: LunaRenderer();
1.1.1.5 ! root 107: virtual ~LunaRenderer() override;
1.1 root 108:
1.1.1.3 root 109: bool RenderMain() override;
1.1 root 110: };
111:
1.1.1.2 root 112: extern std::unique_ptr<Renderer> gRenderer;
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.