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