summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/render/bgfx/targetmanager.h
blob: fa44e2c1bd62d76f88e7e7e6f30e92133cc1d366 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// license:BSD-3-Clause
// copyright-holders:Ryan Holtz
//============================================================
//
//  targetmanager.h - BGFX render target manager
//
//  Maintains a per-screen  string-to-entry mapping for any
//  registered render targets.
//
//============================================================

#pragma once

#ifndef __DRAWBGFX_TARGET_MANAGER__
#define __DRAWBGFX_TARGET_MANAGER__

#include <map>
#include <string>

#include <bgfx/bgfx.h>

#include "modules/osdhelper.h"

#include "texturemanager.h"

class bgfx_target;

class target_manager {
public:
	target_manager(texture_manager& textures);
	~target_manager();

	bgfx_target* create_target(std::string name, bgfx::TextureFormat::Enum format, uint16_t width, uint16_t height, uint32_t style, bool double_buffer, bool filter, uint16_t scale, uint32_t screen);
	void destroy_target(std::string name, uint32_t screen = -1);
	bgfx_target* create_backbuffer(void *handle, uint16_t width, uint16_t height);

	bool update_target_sizes(uint32_t screen, uint16_t width, uint16_t height, uint32_t style);
	void update_screen_count(uint32_t count);

	// Getters
	bgfx_target* target(uint32_t screen, std::string name);
	uint16_t width(uint32_t style, uint32_t screen);
	uint16_t height(uint32_t style, uint32_t screen);

private:
	void rebuild_targets(uint32_t screen, uint32_t style);
	void create_target_if_nonexistent(uint32_t screen, std::string name, bool double_buffered, bool filter, uint32_t style);

	std::map<std::string, bgfx_target*> m_targets;
	texture_manager& m_textures;

	std::vector<osd_dim> m_guest_dims;
	std::vector<osd_dim> m_native_dims;
	uint32_t m_screen_count;

	static const int32_t MAX_SCREENS;
};

#endif // __DRAWBGFX_TARGET_MANAGER__