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