6c11c0fdf46c46a2359f4f0c15b60a7d2d8427ac
[mesa.git] / src / gallium / targets / haiku-softpipe / GalliumContext.h
1 /*
2 * Copyright 2009, 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 GALLIUMCONTEXT_H
9 #define GALLIUMCONTEXT_H
10
11
12 #include <stddef.h>
13 #include <kernel/image.h>
14
15 extern "C" {
16 #include "state_tracker/st_api.h"
17 #include "pipe/p_compiler.h"
18 #include "pipe/p_screen.h"
19 #include "postprocess/filters.h"
20 #include "os/os_thread.h"
21 }
22 #include "bitmap_wrapper.h"
23 #include "GalliumFramebuffer.h"
24
25
26 #define CONTEXT_MAX 32
27
28
29 typedef int64 context_id;
30
31 struct hgl_context
32 {
33 struct st_api* api;
34 // State Tracker API
35 struct st_manager* manager;
36 // State Tracker Manager
37 struct st_context_iface* st;
38 // State Tracker Interface Object
39 struct st_visual* stVisual;
40 // State Tracker Visual
41
42 struct pipe_resource* textures[ST_ATTACHMENT_COUNT];
43
44 // Post processing
45 struct pp_queue_t* postProcess;
46 unsigned int postProcessEnable[PP_FILTERS];
47
48 Bitmap* bitmap;
49 color_space colorSpace;
50
51 GalliumFramebuffer* draw;
52 GalliumFramebuffer* read;
53 };
54
55
56 class GalliumContext {
57 public:
58 GalliumContext(ulong options);
59 ~GalliumContext();
60
61 void Lock();
62 void Unlock();
63
64 struct st_visual* CreateVisual();
65
66 context_id CreateContext(Bitmap* bitmap);
67 void DestroyContext(context_id contextID);
68 context_id GetCurrentContext() { return fCurrentContext; };
69 status_t SetCurrentContext(Bitmap *bitmap,
70 context_id contextID);
71
72 status_t SwapBuffers(context_id contextID);
73 void ResizeViewport(int32 width, int32 height);
74
75 private:
76 status_t CreateScreen();
77 void Flush();
78
79 ulong fOptions;
80 struct pipe_screen* fScreen;
81
82 // Context Management
83 struct hgl_context* fContext[CONTEXT_MAX];
84 context_id fCurrentContext;
85 pipe_mutex fMutex;
86 };
87
88
89 #endif /* GALLIUMCONTEXT_H */