1/*
2 * Copyright 2009-2014, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Alexander von Gluck IV, kallisti5@unixzen.com
7 */
8#ifndef HGL_CONTEXT_H
9#define HGL_CONTEXT_H
10
11#include "os/os_thread.h"
12#include "pipe/p_format.h"
13#include "pipe/p_compiler.h"
14#include "pipe/p_screen.h"
15#include "postprocess/filters.h"
16
17#include "frontend/api.h"
18
19#include "bitmap_wrapper.h"
20
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26
27#define CONTEXT_MAX 32
28
29typedef int64 context_id;
30
31
32struct hgl_buffer
33{
34	struct st_framebuffer_iface *stfbi;
35	struct st_visual* visual;
36
37	unsigned width;
38	unsigned height;
39	unsigned mask;
40
41	struct pipe_screen* screen;
42	void* winsysContext;
43
44	enum pipe_texture_target target;
45	struct pipe_resource* textures[ST_ATTACHMENT_COUNT];
46
47	void *map;
48};
49
50
51struct hgl_display
52{
53	mtx_t mutex;
54
55	struct st_api* api;
56	struct st_manager* manager;
57};
58
59
60struct hgl_context
61{
62	struct hgl_display* display;
63	struct st_context_iface* st;
64	struct st_visual* stVisual;
65
66	// Post processing
67	struct pp_queue_t* postProcess;
68	unsigned int postProcessEnable[PP_FILTERS];
69
70	// Desired viewport size
71	unsigned width;
72	unsigned height;
73
74	mtx_t fbMutex;
75
76	struct hgl_buffer* buffer;
77};
78
79// hgl_buffer from statetracker interface
80struct hgl_buffer* hgl_st_framebuffer(struct st_framebuffer_iface *stfbi);
81
82// hgl frontend
83struct st_api* hgl_create_st_api(void);
84
85// hgl framebuffer
86struct hgl_buffer* hgl_create_st_framebuffer(struct hgl_context* context, void *winsysContext);
87void hgl_destroy_st_framebuffer(struct hgl_buffer *buffer);
88
89// hgl manager
90struct st_manager* hgl_create_st_manager(struct hgl_context* screen);
91void hgl_destroy_st_manager(struct st_manager *manager);
92
93// hgl visual
94struct st_visual* hgl_create_st_visual(ulong options);
95void hgl_destroy_st_visual(struct st_visual* visual);
96
97// hgl display
98struct hgl_display* hgl_create_display(struct pipe_screen* screen);
99void hgl_destroy_display(struct hgl_display *display);
100
101
102#ifdef __cplusplus
103}
104#endif
105
106#endif /* HGL_CONTEXT_H */
107