include/mgba/internal/gba/renderers/thread-proxy.h (view raw)
1/* Copyright (c) 2013-2015 Jeffrey Pfau
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6#ifndef VIDEO_THREAD_PROXY_H
7#define VIDEO_THREAD_PROXY_H
8
9#include <mgba-util/common.h>
10
11CXX_GUARD_START
12
13#include <mgba/internal/gba/video.h>
14#include <mgba-util/threading.h>
15#include <mgba-util/ring-fifo.h>
16
17enum GBAVideoThreadProxyState {
18 PROXY_THREAD_STOPPED = 0,
19 PROXY_THREAD_IDLE,
20 PROXY_THREAD_BUSY
21};
22
23struct GBAVideoThreadProxyRenderer {
24 struct GBAVideoRenderer d;
25 struct GBAVideoRenderer* backend;
26
27 Thread thread;
28 Condition fromThreadCond;
29 Condition toThreadCond;
30 Mutex mutex;
31 enum GBAVideoThreadProxyState threadState;
32
33 struct RingFIFO dirtyQueue;
34
35 uint32_t vramDirtyBitmap;
36 uint32_t oamDirtyBitmap[16];
37
38 uint16_t* vramProxy;
39 union GBAOAM oamProxy;
40 uint16_t paletteProxy[512];
41};
42
43void GBAVideoThreadProxyRendererCreate(struct GBAVideoThreadProxyRenderer* renderer, struct GBAVideoRenderer* backend);
44
45CXX_GUARD_END
46
47#endif