1209513Simp/* 2209513Simp * Copyright 2009, Haiku, Inc. All Rights Reserved. 3209513Simp * Distributed under the terms of the MIT License. 4209513Simp * 5209513Simp * Authors: 6209513Simp * Alexander von Gluck IV, kallisti5@unixzen.com 7209513Simp */ 8209513Simp#ifndef GALLIUMCONTEXT_H 9209513Simp#define GALLIUMCONTEXT_H 10209513Simp 11209513Simp 12209513Simpextern "C" { 13209513Simp#include "state_tracker/st_api.h" 14209513Simp#include "pipe/p_compiler.h" 15209513Simp#include "pipe/p_screen.h" 16209513Simp#include "postprocess/filters.h" 17209513Simp#include "os/os_thread.h" 18209513Simp} 19209513Simp#include "bitmap_wrapper.h" 20209513Simp#include "GalliumFramebuffer.h" 21209513Simp 22209513Simp 23209513Simp#define CONTEXT_MAX 32 24209513Simp 25209513Simp// HACK: offsetof must be redefined before loading sp_context.h 26209513Simp// in GalliumContext.cpp 27209513Simp#undef offsetof 28209513Simp#define offsetof( type, member ) ((size_t) &((type *)0)->member) 29209513Simp 30209513Simp 31209513Simptypedef int64 context_id; 32209513Simp 33209513Simpstruct hgl_context 34209513Simp{ 35209513Simp struct st_api* api; 36209513Simp // State Tracker API 37209513Simp struct st_manager* manager; 38209513Simp // State Tracker Manager 39209513Simp struct st_context_iface* st; 40209513Simp // State Tracker Interface Object 41209513Simp struct st_visual* stVisual; 42209513Simp // State Tracker Visual 43209513Simp 44209513Simp struct pipe_resource* textures[ST_ATTACHMENT_COUNT]; 45209513Simp 46209513Simp // Post processing 47209513Simp struct pp_queue_t* postProcess; 48209513Simp unsigned int postProcessEnable[PP_FILTERS]; 49209513Simp 50209513Simp Bitmap* bitmap; 51209513Simp color_space colorSpace; 52209513Simp 53209513Simp GalliumFramebuffer* draw; 54209513Simp GalliumFramebuffer* read; 55209513Simp}; 56209513Simp 57209513Simp 58209513Simpclass GalliumContext { 59209513Simppublic: 60209513Simp GalliumContext(ulong options); 61209513Simp ~GalliumContext(); 62209513Simp 63209513Simp context_id CreateContext(Bitmap* bitmap); 64209513Simp void DestroyContext(context_id contextID); 65209513Simp context_id GetCurrentContext() { return fCurrentContext; }; 66209513Simp status_t SetCurrentContext(Bitmap *bitmap, 67209513Simp context_id contextID); 68209513Simp 69209513Simp status_t SwapBuffers(context_id contextID); 70209513Simp 71209513Simpprivate: 72 status_t CreateScreen(); 73 void Flush(); 74 75 ulong fOptions; 76 77 struct hgl_context* fContext[CONTEXT_MAX]; 78 context_id fCurrentContext; 79 80 struct pipe_screen* fScreen; 81 pipe_mutex fMutex; 82}; 83 84 85#endif /* GALLIUMCONTEXT_H */ 86