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 #include "pipe/p_compiler.h"
16 #include "pipe/p_screen.h"
17 #include "postprocess/filters.h"
18 #include "hgl_context.h"
19 
20 #include "bitmap_wrapper.h"
21 
22 
23 
24 class GalliumContext {
25 public:
26 							GalliumContext(ulong options);
27 							~GalliumContext();
28 
29 		void				Lock();
30 		void				Unlock();
31 
32 		context_id			CreateContext(Bitmap* bitmap);
33 		void				DestroyContext(context_id contextID);
GetCurrentContext()34 		context_id			GetCurrentContext() { return fCurrentContext; };
35 		status_t			SetCurrentContext(Bitmap *bitmap,
36 								context_id contextID);
37 
38 		status_t			SwapBuffers(context_id contextID);
39 
40 		bool				Validate(uint32 width, uint32 height);
41 		void				Invalidate(uint32 width, uint32 height);
42 
43 private:
44 		status_t			CreateScreen();
45 		void				Flush();
46 
47 		ulong				fOptions;
48 		struct pipe_screen*	fScreen;
49 
50 		// Context Management
51 		struct hgl_context*	fContext[CONTEXT_MAX];
52 		context_id			fCurrentContext;
53 		mtx_t			fMutex;
54 };
55 
56 
57 #endif /* GALLIUMCONTEXT_H */
58