hgl: remove
Use EGL and glvnd instead on Haiku platform. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21079>
This commit is contained in:
@@ -44,7 +44,6 @@
|
||||
- src/drm-shim/**/*
|
||||
- src/gbm/**/*
|
||||
- src/gtest/**/*
|
||||
- src/hgl/**/*
|
||||
- src/include/**/*
|
||||
# Some src/util and src/compiler files use headers from mesa/ (e.g.
|
||||
# mtypes.h). We should clean that up.
|
||||
|
@@ -79,12 +79,9 @@ meson.build @dbaker @eric
|
||||
/src/glx/*glvnd* @kbrenneman
|
||||
|
||||
# Haiku
|
||||
/include/HaikuGL/ @kallisti5
|
||||
/src/egl/drivers/haiku/ @kallisti5
|
||||
/src/gallium/frontends/hgl/ @kallisti5
|
||||
/src/gallium/targets/haiku-softpipe/ @kallisti5
|
||||
/src/gallium/winsys/sw/hgl/ @kallisti5
|
||||
/src/hgl/ @kallisti5
|
||||
|
||||
# Loader - DRI/classic
|
||||
/src/loader/ @xexaxo
|
||||
|
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Copyright 2006, Philippe Houdoin. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
|
||||
* This header defines BGLRenderer, the base class making up
|
||||
* the Haiku GL renderer add-ons (essentially selfcontained C++
|
||||
* shared libraries that do the actual rendering such as
|
||||
* libswpipe.so and libswrast.so)
|
||||
*/
|
||||
#ifndef GLRENDERER_H
|
||||
#define GLRENDERER_H
|
||||
|
||||
|
||||
#include <BeBuild.h>
|
||||
#include <GLView.h>
|
||||
|
||||
|
||||
class BGLDispatcher;
|
||||
class GLRendererRoster;
|
||||
|
||||
typedef unsigned long renderer_id;
|
||||
|
||||
class _EXPORT BGLRenderer
|
||||
{
|
||||
// Private unimplemented copy constructors
|
||||
BGLRenderer(const BGLRenderer &);
|
||||
BGLRenderer & operator=(const BGLRenderer &);
|
||||
|
||||
public:
|
||||
BGLRenderer(BGLView *view, ulong bgl_options);
|
||||
virtual ~BGLRenderer();
|
||||
|
||||
void Acquire();
|
||||
void Release();
|
||||
|
||||
virtual void LockGL();
|
||||
virtual void UnlockGL();
|
||||
|
||||
virtual void SwapBuffers(bool VSync = false);
|
||||
virtual void Draw(BRect updateRect);
|
||||
virtual status_t CopyPixelsOut(BPoint source, BBitmap *dest);
|
||||
virtual status_t CopyPixelsIn(BBitmap *source, BPoint dest);
|
||||
|
||||
virtual void FrameResized(float width, float height);
|
||||
|
||||
virtual void DirectConnected(direct_buffer_info *info);
|
||||
virtual void EnableDirectMode(bool enabled);
|
||||
|
||||
inline int32 ReferenceCount() const { return fRefCount; };
|
||||
inline ulong Options() const { return fOptions; };
|
||||
inline BGLView* GLView() { return fView; };
|
||||
|
||||
private:
|
||||
friend class GLRendererRoster;
|
||||
|
||||
virtual status_t _Reserved_Renderer_0(int32, void *);
|
||||
virtual status_t _Reserved_Renderer_1(int32, void *);
|
||||
virtual status_t _Reserved_Renderer_2(int32, void *);
|
||||
virtual status_t _Reserved_Renderer_3(int32, void *);
|
||||
virtual status_t _Reserved_Renderer_4(int32, void *);
|
||||
|
||||
int32 fRefCount; // How much we're still useful
|
||||
BGLView* fView; // Never forget who is the boss!
|
||||
ulong fOptions; // Keep that tune in memory
|
||||
|
||||
GLRendererRoster* fOwningRoster;
|
||||
renderer_id fID;
|
||||
};
|
||||
|
||||
extern "C" _EXPORT BGLRenderer* instantiate_gl_renderer(BGLView *view, ulong options);
|
||||
|
||||
|
||||
#endif // GLRENDERER_H
|
@@ -1,194 +0,0 @@
|
||||
/*
|
||||
* Copyright 2008-2013, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* This header defines BGLView, the base class making up
|
||||
* the Haiku GL Kit.
|
||||
*
|
||||
*/
|
||||
#ifndef BGLVIEW_H
|
||||
#define BGLVIEW_H
|
||||
|
||||
|
||||
#include <GL/gl.h>
|
||||
|
||||
#define BGL_RGB 0
|
||||
#define BGL_INDEX 1
|
||||
#define BGL_SINGLE 0
|
||||
#define BGL_DOUBLE 2
|
||||
#define BGL_DIRECT 0
|
||||
#define BGL_INDIRECT 4
|
||||
#define BGL_ACCUM 8
|
||||
#define BGL_ALPHA 16
|
||||
#define BGL_DEPTH 32
|
||||
#define BGL_OVERLAY 64
|
||||
#define BGL_UNDERLAY 128
|
||||
#define BGL_STENCIL 512
|
||||
#define BGL_SHARE_CONTEXT 1024
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <AppKit.h>
|
||||
#include <Bitmap.h>
|
||||
#include <DirectWindow.h>
|
||||
#include <View.h>
|
||||
#include <Window.h>
|
||||
#include <WindowScreen.h>
|
||||
|
||||
|
||||
struct glview_direct_info;
|
||||
class BGLRenderer;
|
||||
class GLRendererRoster;
|
||||
|
||||
class _EXPORT BGLView : public BView {
|
||||
public:
|
||||
BGLView(BRect rect, const char* name,
|
||||
ulong resizingMode, ulong mode,
|
||||
ulong options);
|
||||
virtual ~BGLView();
|
||||
|
||||
void LockGL();
|
||||
void UnlockGL();
|
||||
void SwapBuffers();
|
||||
void SwapBuffers(bool vSync);
|
||||
|
||||
BView* EmbeddedView(); // deprecated, returns NULL
|
||||
void* GetGLProcAddress(const char* procName);
|
||||
|
||||
status_t CopyPixelsOut(BPoint source, BBitmap *dest);
|
||||
status_t CopyPixelsIn(BBitmap *source, BPoint dest);
|
||||
|
||||
// Mesa's GLenum is uint where Be's ones was ulong!
|
||||
virtual void ErrorCallback(unsigned long errorCode);
|
||||
|
||||
virtual void Draw(BRect updateRect);
|
||||
virtual void AttachedToWindow();
|
||||
virtual void AllAttached();
|
||||
virtual void DetachedFromWindow();
|
||||
virtual void AllDetached();
|
||||
|
||||
virtual void FrameResized(float newWidth, float newHeight);
|
||||
virtual status_t Perform(perform_code d, void *arg);
|
||||
|
||||
virtual status_t Archive(BMessage *data, bool deep = true) const;
|
||||
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
virtual void SetResizingMode(uint32 mode);
|
||||
|
||||
virtual void Show();
|
||||
virtual void Hide();
|
||||
|
||||
virtual BHandler* ResolveSpecifier(BMessage *msg, int32 index,
|
||||
BMessage *specifier, int32 form,
|
||||
const char *property);
|
||||
virtual status_t GetSupportedSuites(BMessage *data);
|
||||
|
||||
void DirectConnected(direct_buffer_info *info);
|
||||
void EnableDirectMode(bool enabled);
|
||||
|
||||
void* getGC() { return fGc; } // ???
|
||||
|
||||
virtual void GetPreferredSize(float* width, float* height);
|
||||
|
||||
private:
|
||||
|
||||
virtual void _ReservedGLView1();
|
||||
virtual void _ReservedGLView2();
|
||||
virtual void _ReservedGLView3();
|
||||
virtual void _ReservedGLView4();
|
||||
virtual void _ReservedGLView5();
|
||||
virtual void _ReservedGLView6();
|
||||
virtual void _ReservedGLView7();
|
||||
virtual void _ReservedGLView8();
|
||||
|
||||
BGLView(const BGLView &);
|
||||
BGLView &operator=(const BGLView &);
|
||||
|
||||
void _DitherFront();
|
||||
bool _ConfirmDither();
|
||||
void _Draw(BRect rect);
|
||||
void _CallDirectConnected();
|
||||
|
||||
void* fGc;
|
||||
uint32 fOptions;
|
||||
uint32 fDitherCount;
|
||||
BLocker fDrawLock;
|
||||
BLocker fDisplayLock;
|
||||
glview_direct_info* fClipInfo;
|
||||
|
||||
BGLRenderer* fRenderer;
|
||||
GLRendererRoster* fRoster;
|
||||
|
||||
BBitmap* fDitherMap;
|
||||
BRect fBounds;
|
||||
int16* fErrorBuffer[2];
|
||||
uint64 _reserved[8];
|
||||
|
||||
void _LockDraw();
|
||||
void _UnlockDraw();
|
||||
|
||||
// BeOS compatibility
|
||||
private:
|
||||
BGLView(BRect rect, char* name,
|
||||
ulong resizingMode, ulong mode,
|
||||
ulong options);
|
||||
};
|
||||
|
||||
|
||||
class BGLScreen : public BWindowScreen {
|
||||
public:
|
||||
BGLScreen(char* name,
|
||||
ulong screenMode, ulong options,
|
||||
status_t *error, bool debug=false);
|
||||
~BGLScreen();
|
||||
|
||||
void LockGL();
|
||||
void UnlockGL();
|
||||
void SwapBuffers();
|
||||
// Mesa's GLenum is uint where Be's ones was ulong!
|
||||
virtual void ErrorCallback(unsigned long errorCode);
|
||||
|
||||
virtual void ScreenConnected(bool connected);
|
||||
virtual void FrameResized(float width, float height);
|
||||
virtual status_t Perform(perform_code code, void *arg);
|
||||
|
||||
virtual status_t Archive(BMessage *data, bool deep = true) const;
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
|
||||
virtual void Show();
|
||||
virtual void Hide();
|
||||
|
||||
virtual BHandler* ResolveSpecifier(BMessage *message,
|
||||
int32 index,
|
||||
BMessage *specifier,
|
||||
int32 form,
|
||||
const char *property);
|
||||
virtual status_t GetSupportedSuites(BMessage *data);
|
||||
|
||||
private:
|
||||
|
||||
virtual void _ReservedGLScreen1();
|
||||
virtual void _ReservedGLScreen2();
|
||||
virtual void _ReservedGLScreen3();
|
||||
virtual void _ReservedGLScreen4();
|
||||
virtual void _ReservedGLScreen5();
|
||||
virtual void _ReservedGLScreen6();
|
||||
virtual void _ReservedGLScreen7();
|
||||
virtual void _ReservedGLScreen8();
|
||||
|
||||
BGLScreen(const BGLScreen &);
|
||||
BGLScreen &operator=(const BGLScreen &);
|
||||
|
||||
void* fGc;
|
||||
long fOptions;
|
||||
BLocker fDrawLock;
|
||||
|
||||
int32 fColorSpace;
|
||||
uint32 fScreenMode;
|
||||
|
||||
uint64 _reserved[7];
|
||||
};
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // BGLVIEW_H
|
@@ -1,10 +0,0 @@
|
||||
/*
|
||||
* Master include file for the Haiku OpenGL Kit.
|
||||
*/
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <GLView.h>
|
||||
|
||||
// Projects needing GL/glu.h and GL/glut.h should now
|
||||
// include these headers independently as glu and glut
|
||||
// are no longer core parts of mesa
|
@@ -1,27 +0,0 @@
|
||||
These headers make up the Haiku Op*nGL kit.
|
||||
|
||||
Headers in this directory preserve some BeOS™ compatibility
|
||||
compatibility, so changes should be mentioned to the Haiku
|
||||
project mailing list.
|
||||
|
||||
http://haiku-os.org
|
||||
|
||||
Normal Haiku Op*enGL layout:
|
||||
|
||||
* headers/os/OpenGLKit.h
|
||||
* headers/os/opengl/GLView.h
|
||||
* headers/os/opengl/GLRenderer.h
|
||||
* headers/os/opengl/GL/gl.h
|
||||
* headers/os/opengl/GL/glext.h
|
||||
* headers/os/opengl/GL/osmesa.h (needed?)
|
||||
|
||||
Extras:
|
||||
|
||||
* headers/os/opengl/GL/glu.h
|
||||
* headers/os/opengl/GL/glut.h
|
||||
|
||||
OpenGL™ is a trademark of SGI. The usage of this trademark
|
||||
in the Haiku GL Kit is not a sign of any certification or
|
||||
endorsement by SGI or its affiliates. Usage is purely to
|
||||
allow legacy compatibility with the BeOS™ and its 3D GL
|
||||
rendering subsystem.
|
@@ -20,7 +20,6 @@
|
||||
|
||||
inc_include = [include_directories('.')]
|
||||
inc_d3d9 = include_directories('D3D9')
|
||||
inc_haikugl = include_directories('HaikuGL')
|
||||
|
||||
# Most things assume that Android headers are in the default include
|
||||
# path when compiling for Android so add the stub headers to
|
||||
@@ -111,13 +110,6 @@ if with_gallium_st_nine
|
||||
)
|
||||
endif
|
||||
|
||||
if with_platform_haiku
|
||||
install_headers(
|
||||
'HaikuGL/GLRenderer.h', 'HaikuGL/GLView.h', 'HaikuGL/OpenGLKit.h',
|
||||
subdir : 'opengl',
|
||||
)
|
||||
endif
|
||||
|
||||
opencl_headers = files(
|
||||
'CL/cl.h',
|
||||
'CL/cl.hpp',
|
||||
|
@@ -146,7 +146,6 @@ if with_dri2
|
||||
endif
|
||||
endif
|
||||
elif with_platform_haiku
|
||||
incs_for_egl += inc_haikugl
|
||||
c_args_for_egl += [
|
||||
'-D_EGL_BUILT_IN_DRIVER_HAIKU',
|
||||
]
|
||||
|
@@ -34,7 +34,7 @@ libsthgl = static_library(
|
||||
'sthgl',
|
||||
files_libsthgl,
|
||||
include_directories : [
|
||||
inc_include, inc_haikugl, inc_util, inc_mesa, inc_mapi, inc_src,
|
||||
inc_include, inc_util, inc_mesa, inc_mapi, inc_src,
|
||||
inc_gallium, inc_gallium_aux
|
||||
],
|
||||
c_args : [libsthgl_c_args],
|
||||
|
@@ -218,7 +218,6 @@ if with_gallium_xa
|
||||
endif
|
||||
if with_platform_haiku
|
||||
subdir('frontends/hgl')
|
||||
subdir('targets/haiku-softpipe')
|
||||
endif
|
||||
if with_gallium_st_nine
|
||||
subdir('frontends/nine')
|
||||
|
@@ -1,2 +0,0 @@
|
||||
[*.{c,h,cpp,hpp}]
|
||||
indent_style = tab
|
@@ -1,416 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Artur Wyszynski, harakash@gmail.com
|
||||
* Alexander von Gluck IV, kallisti5@unixzen.com
|
||||
*/
|
||||
|
||||
|
||||
#include "GalliumContext.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include "GLView.h"
|
||||
|
||||
#include "bitmap_wrapper.h"
|
||||
|
||||
#include "glapi/glapi.h"
|
||||
#include "util/format/u_formats.h"
|
||||
//#include "state_tracker/st_cb_fbo.h"
|
||||
//#include "state_tracker/st_cb_flush.h"
|
||||
#include "state_tracker/st_context.h"
|
||||
#include "frontend/sw_winsys.h"
|
||||
#include "sw/hgl/hgl_sw_winsys.h"
|
||||
#include "util/u_atomic.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "util/u_framebuffer.h"
|
||||
|
||||
#include "target-helpers/inline_sw_helper.h"
|
||||
#include "target-helpers/inline_debug_helper.h"
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
# define TRACE(x...) printf("GalliumContext: " x)
|
||||
# define CALLED() TRACE("CALLED: %s\n", __PRETTY_FUNCTION__)
|
||||
#else
|
||||
# define TRACE(x...)
|
||||
# define CALLED()
|
||||
#endif
|
||||
#define ERROR(x...) printf("GalliumContext: " x)
|
||||
|
||||
int32 GalliumContext::fDisplayRefCount = 0;
|
||||
hgl_display* GalliumContext::fDisplay = NULL;
|
||||
|
||||
GalliumContext::GalliumContext(ulong options)
|
||||
:
|
||||
fOptions(options),
|
||||
fCurrentContext(0)
|
||||
{
|
||||
CALLED();
|
||||
|
||||
// Make all contexts a known value
|
||||
for (context_id i = 0; i < CONTEXT_MAX; i++)
|
||||
fContext[i] = NULL;
|
||||
|
||||
CreateDisplay();
|
||||
|
||||
(void) mtx_init(&fMutex, mtx_plain);
|
||||
}
|
||||
|
||||
|
||||
GalliumContext::~GalliumContext()
|
||||
{
|
||||
CALLED();
|
||||
|
||||
// Destroy our contexts
|
||||
Lock();
|
||||
for (context_id i = 0; i < CONTEXT_MAX; i++)
|
||||
DestroyContext(i);
|
||||
Unlock();
|
||||
|
||||
DestroyDisplay();
|
||||
|
||||
mtx_destroy(&fMutex);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
GalliumContext::CreateDisplay()
|
||||
{
|
||||
CALLED();
|
||||
|
||||
if (atomic_add(&fDisplayRefCount, 1) > 0)
|
||||
return B_OK;
|
||||
|
||||
// Allocate winsys and attach callback hooks
|
||||
struct sw_winsys* winsys = hgl_create_sw_winsys();
|
||||
|
||||
if (!winsys) {
|
||||
ERROR("%s: Couldn't allocate sw_winsys!\n", __func__);
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
struct pipe_screen* screen = sw_screen_create(winsys);
|
||||
|
||||
if (screen == NULL) {
|
||||
ERROR("%s: Couldn't create screen!\n", __func__);
|
||||
winsys->destroy(winsys);
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
debug_screen_wrap(screen);
|
||||
|
||||
const char* driverName = screen->get_name(screen);
|
||||
ERROR("%s: Using %s driver.\n", __func__, driverName);
|
||||
|
||||
fDisplay = hgl_create_display(screen);
|
||||
|
||||
if (fDisplay == NULL) {
|
||||
ERROR("%s: Couldn't create display!\n", __func__);
|
||||
screen->destroy(screen); // will also destroy winsys
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GalliumContext::DestroyDisplay()
|
||||
{
|
||||
if (atomic_add(&fDisplayRefCount, -1) > 1)
|
||||
return;
|
||||
|
||||
if (fDisplay != NULL) {
|
||||
struct pipe_screen* screen = fDisplay->fscreen->screen;
|
||||
hgl_destroy_display(fDisplay); fDisplay = NULL;
|
||||
screen->destroy(screen); // destroy will deallocate object
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
context_id
|
||||
GalliumContext::CreateContext(HGLWinsysContext *wsContext)
|
||||
{
|
||||
CALLED();
|
||||
|
||||
struct hgl_context* context = CALLOC_STRUCT(hgl_context);
|
||||
|
||||
if (!context) {
|
||||
ERROR("%s: Couldn't create pipe context!\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Set up the initial things our context needs
|
||||
context->display = fDisplay;
|
||||
|
||||
// Create state tracker visual
|
||||
context->stVisual = hgl_create_st_visual(fOptions);
|
||||
|
||||
// Create state tracker framebuffers
|
||||
context->buffer = hgl_create_st_framebuffer(context, wsContext);
|
||||
|
||||
if (!context->buffer) {
|
||||
ERROR("%s: Problem allocating framebuffer!\n", __func__);
|
||||
FREE(context->stVisual);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Build state tracker attributes
|
||||
struct st_context_attribs attribs;
|
||||
memset(&attribs, 0, sizeof(attribs));
|
||||
attribs.options.force_glsl_extensions_warn = false;
|
||||
attribs.profile = API_OPENGL_COMPAT;
|
||||
attribs.visual = *context->stVisual;
|
||||
attribs.major = 1;
|
||||
attribs.minor = 0;
|
||||
//attribs.flags |= ST_CONTEXT_FLAG_DEBUG;
|
||||
|
||||
struct st_context *shared = NULL;
|
||||
|
||||
if (fOptions & BGL_SHARE_CONTEXT) {
|
||||
shared = st_api_get_current();
|
||||
TRACE("shared context: %p\n", shared);
|
||||
}
|
||||
|
||||
// Create context using state tracker api call
|
||||
enum st_context_error result;
|
||||
context->st = st_api_create_context(fDisplay->fscreen,
|
||||
&attribs, &result, shared);
|
||||
|
||||
if (!context->st) {
|
||||
ERROR("%s: Couldn't create mesa state tracker context!\n",
|
||||
__func__);
|
||||
switch (result) {
|
||||
case ST_CONTEXT_SUCCESS:
|
||||
ERROR("%s: State tracker error: SUCCESS?\n", __func__);
|
||||
break;
|
||||
case ST_CONTEXT_ERROR_NO_MEMORY:
|
||||
ERROR("%s: State tracker error: NO_MEMORY\n", __func__);
|
||||
break;
|
||||
case ST_CONTEXT_ERROR_BAD_VERSION:
|
||||
ERROR("%s: State tracker error: BAD_VERSION\n", __func__);
|
||||
break;
|
||||
}
|
||||
|
||||
hgl_destroy_st_visual(context->stVisual);
|
||||
FREE(context);
|
||||
return -1;
|
||||
}
|
||||
|
||||
assert(!context->st->frontend_context);
|
||||
context->st->frontend_context = (void*)context;
|
||||
|
||||
struct st_context *stContext = context->st;
|
||||
|
||||
// Init Gallium3D Post Processing
|
||||
// TODO: no pp filters are enabled yet through postProcessEnable
|
||||
context->postProcess = pp_init(stContext->pipe, context->postProcessEnable,
|
||||
stContext->cso_context, stContext,
|
||||
st_context_invalidate_state);
|
||||
|
||||
context_id contextNext = -1;
|
||||
Lock();
|
||||
for (context_id i = 0; i < CONTEXT_MAX; i++) {
|
||||
if (fContext[i] == NULL) {
|
||||
fContext[i] = context;
|
||||
contextNext = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Unlock();
|
||||
|
||||
if (contextNext < 0) {
|
||||
ERROR("%s: The next context is invalid... something went wrong!\n",
|
||||
__func__);
|
||||
//st_destroy_context(context->st);
|
||||
FREE(context->stVisual);
|
||||
FREE(context);
|
||||
return -1;
|
||||
}
|
||||
|
||||
TRACE("%s: context #%" B_PRIu64 " is the next available context\n",
|
||||
__func__, contextNext);
|
||||
|
||||
return contextNext;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GalliumContext::DestroyContext(context_id contextID)
|
||||
{
|
||||
// fMutex should be locked *before* calling DestoryContext
|
||||
|
||||
// See if context is used
|
||||
if (!fContext[contextID])
|
||||
return;
|
||||
|
||||
if (fContext[contextID]->st) {
|
||||
st_context_flush(fContext[contextID]->st, 0, NULL, NULL, NULL);
|
||||
st_destroy_context(fContext[contextID]->st);
|
||||
}
|
||||
|
||||
if (fContext[contextID]->postProcess)
|
||||
pp_free(fContext[contextID]->postProcess);
|
||||
|
||||
// Delete state tracker framebuffer objects
|
||||
if (fContext[contextID]->buffer)
|
||||
hgl_destroy_st_framebuffer(fContext[contextID]->buffer);
|
||||
|
||||
if (fContext[contextID]->stVisual)
|
||||
hgl_destroy_st_visual(fContext[contextID]->stVisual);
|
||||
|
||||
FREE(fContext[contextID]);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
GalliumContext::SetCurrentContext(bool set, context_id contextID)
|
||||
{
|
||||
CALLED();
|
||||
|
||||
if (contextID < 0 || contextID > CONTEXT_MAX) {
|
||||
ERROR("%s: Invalid context ID range!\n", __func__);
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
Lock();
|
||||
context_id oldContextID = fCurrentContext;
|
||||
struct hgl_context* context = fContext[contextID];
|
||||
|
||||
if (!context) {
|
||||
ERROR("%s: Invalid context provided (#%" B_PRIu64 ")!\n",
|
||||
__func__, contextID);
|
||||
Unlock();
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
if (!set) {
|
||||
st_api_make_current(NULL, NULL, NULL);
|
||||
Unlock();
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// Everything seems valid, lets set the new context.
|
||||
fCurrentContext = contextID;
|
||||
|
||||
if (oldContextID > 0 && oldContextID != contextID) {
|
||||
st_context_flush(fContext[oldContextID]->st,
|
||||
ST_FLUSH_FRONT, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
// We need to lock and unlock framebuffers before accessing them
|
||||
st_api_make_current(context->st, &context->buffer->base,
|
||||
&context->buffer->base);
|
||||
Unlock();
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
GalliumContext::SwapBuffers(context_id contextID)
|
||||
{
|
||||
CALLED();
|
||||
|
||||
Lock();
|
||||
struct hgl_context* context = fContext[contextID];
|
||||
|
||||
if (!context) {
|
||||
ERROR("%s: context not found\n", __func__);
|
||||
Unlock();
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
// will flush front buffer if no double buffering is used
|
||||
st_context_flush(context->st, ST_FLUSH_FRONT, NULL, NULL, NULL);
|
||||
|
||||
struct hgl_buffer* buffer = context->buffer;
|
||||
|
||||
// flush back buffer and swap buffers if double buffering is used
|
||||
if (buffer->textures[ST_ATTACHMENT_BACK_LEFT] != NULL) {
|
||||
buffer->screen->flush_frontbuffer(buffer->screen, NULL, buffer->textures[ST_ATTACHMENT_BACK_LEFT],
|
||||
0, 0, buffer->winsysContext, NULL);
|
||||
std::swap(buffer->textures[ST_ATTACHMENT_FRONT_LEFT], buffer->textures[ST_ATTACHMENT_BACK_LEFT]);
|
||||
p_atomic_inc(&buffer->base.stamp);
|
||||
}
|
||||
|
||||
/* TODO: remove this if the framebuffer state doesn't change. */
|
||||
st_context_invalidate_state(context->st, ST_INVALIDATE_FB_STATE);
|
||||
|
||||
Unlock();
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GalliumContext::Draw(context_id contextID, BRect updateRect)
|
||||
{
|
||||
struct hgl_context *context = fContext[contextID];
|
||||
|
||||
if (!context) {
|
||||
ERROR("%s: context not found\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
struct hgl_buffer* buffer = context->buffer;
|
||||
|
||||
if (buffer->textures[ST_ATTACHMENT_FRONT_LEFT] == NULL)
|
||||
return;
|
||||
|
||||
buffer->screen->flush_frontbuffer(buffer->screen, NULL, buffer->textures[ST_ATTACHMENT_FRONT_LEFT],
|
||||
0, 0, buffer->winsysContext, NULL);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
GalliumContext::Validate(uint32 width, uint32 height)
|
||||
{
|
||||
CALLED();
|
||||
|
||||
if (!fContext[fCurrentContext])
|
||||
return false;
|
||||
|
||||
if (fContext[fCurrentContext]->width != width + 1
|
||||
|| fContext[fCurrentContext]->height != height + 1) {
|
||||
Invalidate(width, height);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GalliumContext::Invalidate(uint32 width, uint32 height)
|
||||
{
|
||||
CALLED();
|
||||
|
||||
assert(fContext[fCurrentContext]);
|
||||
|
||||
// Update st_context dimensions
|
||||
fContext[fCurrentContext]->width = width + 1;
|
||||
fContext[fCurrentContext]->height = height + 1;
|
||||
|
||||
// Is this the best way to invalidate?
|
||||
p_atomic_inc(&fContext[fCurrentContext]->buffer->base.stamp);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GalliumContext::Lock()
|
||||
{
|
||||
CALLED();
|
||||
mtx_lock(&fMutex);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GalliumContext::Unlock()
|
||||
{
|
||||
CALLED();
|
||||
mtx_unlock(&fMutex);
|
||||
}
|
||||
/* vim: set tabstop=4: */
|
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright 2009, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Alexander von Gluck IV, kallisti5@unixzen.com
|
||||
*/
|
||||
#ifndef GALLIUMCONTEXT_H
|
||||
#define GALLIUMCONTEXT_H
|
||||
|
||||
|
||||
#include <stddef.h>
|
||||
#include <kernel/image.h>
|
||||
|
||||
#include "pipe/p_compiler.h"
|
||||
#include "pipe/p_screen.h"
|
||||
#include "postprocess/filters.h"
|
||||
#include "hgl_context.h"
|
||||
#include "sw/hgl/hgl_sw_winsys.h"
|
||||
|
||||
|
||||
class BBitmap;
|
||||
|
||||
class GalliumContext {
|
||||
public:
|
||||
GalliumContext(ulong options);
|
||||
~GalliumContext();
|
||||
|
||||
void Lock();
|
||||
void Unlock();
|
||||
|
||||
context_id CreateContext(HGLWinsysContext *wsContext);
|
||||
void DestroyContext(context_id contextID);
|
||||
context_id GetCurrentContext() { return fCurrentContext; };
|
||||
status_t SetCurrentContext(bool set, context_id contextID);
|
||||
|
||||
status_t SwapBuffers(context_id contextID);
|
||||
void Draw(context_id contextID, BRect updateRect);
|
||||
|
||||
bool Validate(uint32 width, uint32 height);
|
||||
void Invalidate(uint32 width, uint32 height);
|
||||
|
||||
private:
|
||||
status_t CreateDisplay();
|
||||
void DestroyDisplay();
|
||||
void Flush();
|
||||
|
||||
ulong fOptions;
|
||||
static int32 fDisplayRefCount;
|
||||
static hgl_display* fDisplay;
|
||||
|
||||
// Context Management
|
||||
struct hgl_context* fContext[CONTEXT_MAX];
|
||||
context_id fCurrentContext;
|
||||
mtx_t fMutex;
|
||||
};
|
||||
|
||||
|
||||
#endif /* GALLIUMCONTEXT_H */
|
@@ -1,316 +0,0 @@
|
||||
/*
|
||||
* Copyright 2006-2012, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Jérôme Duval, korli@users.berlios.de
|
||||
* Philippe Houdoin, philippe.houdoin@free.fr
|
||||
* Artur Wyszynski, harakash@gmail.com
|
||||
* Alexander von Gluck IV, kallisti5@unixzen.com
|
||||
*/
|
||||
|
||||
|
||||
#include "SoftwareRenderer.h"
|
||||
|
||||
#include <Autolock.h>
|
||||
#include <interface/DirectWindowPrivate.h>
|
||||
#include <GraphicsDefs.h>
|
||||
#include <Screen.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/time.h>
|
||||
#include <new>
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
# define TRACE(x...) printf("SoftwareRenderer: " x)
|
||||
# define CALLED() TRACE("CALLED: %s\n", __PRETTY_FUNCTION__)
|
||||
#else
|
||||
# define TRACE(x...)
|
||||
# define CALLED()
|
||||
#endif
|
||||
#define ERROR(x...) printf("SoftwareRenderer: " x)
|
||||
|
||||
|
||||
extern const char* color_space_name(color_space space);
|
||||
|
||||
|
||||
extern "C" _EXPORT BGLRenderer*
|
||||
instantiate_gl_renderer(BGLView *view, ulong opts)
|
||||
{
|
||||
return new SoftwareRenderer(view, opts);
|
||||
}
|
||||
|
||||
struct RasBuf32
|
||||
{
|
||||
int32 width, height, stride;
|
||||
int32 orgX, orgY;
|
||||
int32 *colors;
|
||||
|
||||
RasBuf32(int32 width, int32 height, int32 stride, int32 orgX, int32 orgY, int32 *colors):
|
||||
width(width), height(height), stride(stride), orgX(orgX), orgY(orgY), colors(colors)
|
||||
{}
|
||||
|
||||
RasBuf32(BBitmap *bmp)
|
||||
{
|
||||
width = bmp->Bounds().IntegerWidth() + 1;
|
||||
height = bmp->Bounds().IntegerHeight() + 1;
|
||||
stride = bmp->BytesPerRow()/4;
|
||||
orgX = 0;
|
||||
orgY = 0;
|
||||
colors = (int32*)bmp->Bits();
|
||||
}
|
||||
|
||||
RasBuf32(direct_buffer_info *info)
|
||||
{
|
||||
width = 0x7fffffff;
|
||||
height = 0x7fffffff;
|
||||
stride = info->bytes_per_row/4;
|
||||
orgX = 0;
|
||||
orgY = 0;
|
||||
colors = (int32*)info->bits;
|
||||
}
|
||||
|
||||
void ClipSize(int32 x, int32 y, int32 w, int32 h)
|
||||
{
|
||||
if (x < 0) {w += x; x = 0;}
|
||||
if (y < 0) {h += y; y = 0;}
|
||||
if (x + w > width) {w = width - x;}
|
||||
if (y + h > height) {h = height - y;}
|
||||
if ((w > 0) && (h > 0)) {
|
||||
colors += y*stride + x;
|
||||
width = w;
|
||||
height = h;
|
||||
} else {
|
||||
width = 0; height = 0; colors = NULL;
|
||||
}
|
||||
if (x + orgX > 0) {orgX += x;} else {orgX = 0;}
|
||||
if (y + orgY > 0) {orgY += y;} else {orgY = 0;}
|
||||
}
|
||||
|
||||
void ClipRect(int32 l, int32 t, int32 r, int32 b)
|
||||
{
|
||||
ClipSize(l, t, r - l, b - t);
|
||||
}
|
||||
|
||||
void Shift(int32 dx, int32 dy)
|
||||
{
|
||||
orgX += dx;
|
||||
orgY += dy;
|
||||
}
|
||||
|
||||
void Clear(int32 color)
|
||||
{
|
||||
RasBuf32 dst = *this;
|
||||
dst.stride -= dst.width;
|
||||
for (; dst.height > 0; dst.height--) {
|
||||
for (int32 i = dst.width; i > 0; i--)
|
||||
*dst.colors++ = color;
|
||||
dst.colors += dst.stride;
|
||||
}
|
||||
}
|
||||
|
||||
void Blit(RasBuf32 src)
|
||||
{
|
||||
RasBuf32 dst = *this;
|
||||
int32 x, y;
|
||||
x = src.orgX - orgX;
|
||||
y = src.orgY - orgY;
|
||||
dst.ClipSize(x, y, src.width, src.height);
|
||||
src.ClipSize(-x, -y, width, height);
|
||||
for (; dst.height > 0; dst.height--) {
|
||||
memcpy(dst.colors, src.colors, 4*dst.width);
|
||||
dst.colors += dst.stride;
|
||||
src.colors += src.stride;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
SoftwareRenderer::SoftwareRenderer(BGLView *view, ulong options)
|
||||
:
|
||||
BGLRenderer(view, options),
|
||||
fDirectModeEnabled(false),
|
||||
fInfo(NULL),
|
||||
fInfoLocker("info locker"),
|
||||
fOptions(options),
|
||||
fColorSpace(B_NO_COLOR_SPACE)
|
||||
{
|
||||
CALLED();
|
||||
|
||||
// Initialize the "Haiku Software GL Pipe"
|
||||
time_t beg;
|
||||
time_t end;
|
||||
beg = time(NULL);
|
||||
fContextObj = new GalliumContext(options);
|
||||
end = time(NULL);
|
||||
TRACE("Haiku Software GL Pipe initialization time: %f.\n",
|
||||
difftime(end, beg));
|
||||
|
||||
BRect b = view->Bounds();
|
||||
fColorSpace = BScreen(view->Window()).ColorSpace();
|
||||
TRACE("%s: Colorspace:\t%s\n", __func__, color_space_name(fColorSpace));
|
||||
|
||||
fWidth = (GLint)b.IntegerWidth();
|
||||
fHeight = (GLint)b.IntegerHeight();
|
||||
|
||||
// Initialize the first "Haiku Software GL Pipe" context
|
||||
beg = time(NULL);
|
||||
fContextID = fContextObj->CreateContext(this);
|
||||
end = time(NULL);
|
||||
|
||||
if (fContextID < 0)
|
||||
ERROR("%s: There was an error creating the context!\n", __func__);
|
||||
else {
|
||||
TRACE("%s: Haiku Software GL Pipe context creation time: %f.\n",
|
||||
__func__, difftime(end, beg));
|
||||
}
|
||||
|
||||
if (!fContextObj->GetCurrentContext())
|
||||
LockGL();
|
||||
}
|
||||
|
||||
|
||||
SoftwareRenderer::~SoftwareRenderer()
|
||||
{
|
||||
CALLED();
|
||||
|
||||
if (fContextObj)
|
||||
delete fContextObj;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SoftwareRenderer::LockGL()
|
||||
{
|
||||
// CALLED();
|
||||
BGLRenderer::LockGL();
|
||||
|
||||
color_space cs = BScreen(GLView()->Window()).ColorSpace();
|
||||
|
||||
{
|
||||
BAutolock lock(fInfoLocker);
|
||||
if (fDirectModeEnabled && fInfo != NULL) {
|
||||
fWidth = fInfo->window_bounds.right - fInfo->window_bounds.left;
|
||||
fHeight = fInfo->window_bounds.bottom - fInfo->window_bounds.top;
|
||||
}
|
||||
|
||||
fContextObj->Validate(fWidth, fHeight);
|
||||
fColorSpace = cs;
|
||||
}
|
||||
|
||||
// do not hold fInfoLocker here to avoid deadlock
|
||||
fContextObj->SetCurrentContext(true, fContextID);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SoftwareRenderer::UnlockGL()
|
||||
{
|
||||
// CALLED();
|
||||
if ((fOptions & BGL_DOUBLE) == 0) {
|
||||
SwapBuffers();
|
||||
}
|
||||
fContextObj->SetCurrentContext(false, fContextID);
|
||||
BGLRenderer::UnlockGL();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SoftwareRenderer::Display(BBitmap *bitmap, BRect *updateRect)
|
||||
{
|
||||
// CALLED();
|
||||
|
||||
if (!fDirectModeEnabled) {
|
||||
// TODO: avoid timeout
|
||||
if (GLView()->LockLooperWithTimeout(1000) == B_OK) {
|
||||
GLView()->DrawBitmap(bitmap, B_ORIGIN);
|
||||
GLView()->UnlockLooper();
|
||||
}
|
||||
} else {
|
||||
BAutolock lock(fInfoLocker);
|
||||
if (fInfo != NULL) {
|
||||
RasBuf32 srcBuf(bitmap);
|
||||
RasBuf32 dstBuf(fInfo);
|
||||
for (uint32 i = 0; i < fInfo->clip_list_count; i++) {
|
||||
clipping_rect *clip = &fInfo->clip_list[i];
|
||||
RasBuf32 dstClip = dstBuf;
|
||||
dstClip.ClipRect(clip->left, clip->top, clip->right + 1, clip->bottom + 1);
|
||||
dstClip.Shift(-fInfo->window_bounds.left, -fInfo->window_bounds.top);
|
||||
dstClip.Blit(srcBuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SoftwareRenderer::SwapBuffers(bool vsync)
|
||||
{
|
||||
BScreen screen(GLView()->Window());
|
||||
fContextObj->SwapBuffers(fContextID);
|
||||
fContextObj->Validate(fWidth, fHeight);
|
||||
if (vsync)
|
||||
screen.WaitForRetrace();
|
||||
}
|
||||
|
||||
void
|
||||
SoftwareRenderer::Draw(BRect updateRect)
|
||||
{
|
||||
// CALLED();
|
||||
fContextObj->Draw(fContextID, updateRect);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
SoftwareRenderer::CopyPixelsOut(BPoint location, BBitmap *bitmap)
|
||||
{
|
||||
CALLED();
|
||||
|
||||
// TODO: implement
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
SoftwareRenderer::CopyPixelsIn(BBitmap *bitmap, BPoint location)
|
||||
{
|
||||
CALLED();
|
||||
|
||||
// TODO: implement
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SoftwareRenderer::EnableDirectMode(bool enabled)
|
||||
{
|
||||
fDirectModeEnabled = enabled;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SoftwareRenderer::DirectConnected(direct_buffer_info *info)
|
||||
{
|
||||
// CALLED();
|
||||
BAutolock lock(fInfoLocker);
|
||||
if (info) {
|
||||
if (!fInfo) {
|
||||
fInfo = (direct_buffer_info *)calloc(1,
|
||||
DIRECT_BUFFER_INFO_AREA_SIZE);
|
||||
}
|
||||
memcpy(fInfo, info, DIRECT_BUFFER_INFO_AREA_SIZE);
|
||||
} else if (fInfo) {
|
||||
free(fInfo);
|
||||
fInfo = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SoftwareRenderer::FrameResized(float width, float height)
|
||||
{
|
||||
TRACE("%s: %f x %f\n", __func__, width, height);
|
||||
|
||||
BAutolock lock(fInfoLocker);
|
||||
fWidth = (GLuint)width;
|
||||
fHeight = (GLuint)height;
|
||||
}
|
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright 2006-2012, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Jérôme Duval, korli@users.berlios.de
|
||||
* Philippe Houdoin, philippe.houdoin@free.fr
|
||||
* Artur Wyszynski, harakash@gmail.com
|
||||
* Alexander von Gluck IV, kallisti5@unixzen.com
|
||||
*/
|
||||
#ifndef SOFTWARERENDERER_H
|
||||
#define SOFTWARERENDERER_H
|
||||
|
||||
|
||||
#include <kernel/image.h>
|
||||
|
||||
#include "GLRenderer.h"
|
||||
#include "GalliumContext.h"
|
||||
|
||||
|
||||
class SoftwareRenderer : public BGLRenderer, public HGLWinsysContext {
|
||||
public:
|
||||
SoftwareRenderer(BGLView *view,
|
||||
ulong bgl_options);
|
||||
virtual ~SoftwareRenderer();
|
||||
|
||||
void LockGL();
|
||||
void UnlockGL();
|
||||
|
||||
void Display(BBitmap* bitmap, BRect* updateRect);
|
||||
|
||||
void SwapBuffers(bool vsync = false);
|
||||
void Draw(BRect updateRect);
|
||||
status_t CopyPixelsOut(BPoint source, BBitmap *dest);
|
||||
status_t CopyPixelsIn(BBitmap *source, BPoint dest);
|
||||
void FrameResized(float width, float height);
|
||||
|
||||
void EnableDirectMode(bool enabled);
|
||||
void DirectConnected(direct_buffer_info *info);
|
||||
|
||||
private:
|
||||
GalliumContext* fContextObj;
|
||||
context_id fContextID;
|
||||
|
||||
bool fDirectModeEnabled;
|
||||
direct_buffer_info* fInfo;
|
||||
BLocker fInfoLocker;
|
||||
ulong fOptions;
|
||||
GLuint fWidth;
|
||||
GLuint fHeight;
|
||||
color_space fColorSpace;
|
||||
};
|
||||
|
||||
#endif // SOFTPIPERENDERER_H
|
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
resource app_signature "application/x-vnd.Haiku-swpipe";
|
||||
|
||||
resource app_version {
|
||||
major = 9,
|
||||
middle = 0,
|
||||
minor = 0,
|
||||
variety = 0,
|
||||
internal = 0,
|
||||
short_info = "Software Renderer",
|
||||
long_info = "Haiku Gallium Software GL Renderer"
|
||||
};
|
||||
|
||||
resource vector_icon {
|
||||
$"6E6369660A0200140294A9FF18020014028DFFFF97058C0500020006023B10B7"
|
||||
$"37F036BA1A993D466848C719BEBE2000919292FFD5D5D5020016023900000000"
|
||||
$"000000003EE0004AE00048E0005EF884C702000203392E8D383001BAD97F3C12"
|
||||
$"8B4786BD48B8AD0D97BBFFFF7B4168DBE9FF4168DB97020002023A0C1238D099"
|
||||
$"BE44203F4BD14B38844678240DF56A7D9FE1EA064CC704016B0500090A044024"
|
||||
$"2438404C5C380A044028243C40505C3C0A042438243B5C3C5C380608BFBE4D59"
|
||||
$"4D59515957575659585560406044603C5E3A5C3CCB4FBFBA5E3ECA9DC11F564B"
|
||||
$"584A544C504C0606AF0F2F3D2F3D393D4034BF593542324130432F42364432C0"
|
||||
$"3FBC5A2F48354A2F480608AE9A22303EB5BD3AB42542B755422E412F3C29322D"
|
||||
$"32223C0204263726372538263F253E263F304430443143303C313D303C02043D"
|
||||
$"423D423C433D4A3C493D4A495049504A4F49474A484947060DAEAAAE014E445A"
|
||||
$"3456365E325E3D5D3F5A3A5542544E4D573A4E364439463342324A2242310A0A"
|
||||
$"0002020102403CA00C88888C8CC1401673C40D6544F2950A01010002403CA000"
|
||||
$"0000000000401673C40D65446CF80A08020304023EC16A0000000000003EC16A"
|
||||
$"45DD1844C6550A030105123EC16A0000000000003EC16A45DD1844C655011784"
|
||||
$"22040A040105023EC16A0000000000003EC16A45DD1844C6550A030108123EC1"
|
||||
$"6A0000000000003EC16A45DD1844C65501178422040A0503080706023EC16A00"
|
||||
$"00000000003EC16A45DD1844C6550A030206071A3EC16A0000000000003EC16A"
|
||||
$"45DD1844C65510FF0215810004178222040A060106023EC16A0000000000003E"
|
||||
$"C16A45DD1844C6550A070107023EC16A0000000000003EC16A45DD1844C655"
|
||||
};
|
@@ -1,40 +0,0 @@
|
||||
# Copyright © 2017 Dylan Baker
|
||||
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
libswpipe = shared_library(
|
||||
'swpipe',
|
||||
files('SoftwareRenderer.cpp', 'GalliumContext.cpp'),
|
||||
include_directories : [
|
||||
inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_util, inc_haikugl, inc_gallium_drivers, inc_gallium_winsys,
|
||||
include_directories('../../frontends/hgl'),
|
||||
include_directories('/boot/system/develop/headers/private')
|
||||
],
|
||||
gnu_symbol_visibility : 'hidden',
|
||||
link_args : [ld_args_bsymbolic, ld_args_gc_sections],
|
||||
link_with : [
|
||||
libglapi, libswhgl, libsthgl, libcompiler,
|
||||
libmesa, libglsl, libgallium, libgl
|
||||
],
|
||||
dependencies : [
|
||||
driver_swrast, cpp.find_library('be'), cpp.find_library('translation'),
|
||||
cpp.find_library('network'), dep_unwind, idep_mesautil, idep_nir,
|
||||
],
|
||||
install : true,
|
||||
)
|
@@ -1,2 +0,0 @@
|
||||
[*.{cpp,h}]
|
||||
indent_style = tab
|
@@ -1,101 +0,0 @@
|
||||
/*
|
||||
* Copyright 2006-2008, Philippe Houdoin. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include <kernel/image.h>
|
||||
|
||||
#include "GLRenderer.h"
|
||||
|
||||
|
||||
BGLRenderer::BGLRenderer(BGLView* view, ulong glOptions)
|
||||
:
|
||||
fRefCount(1),
|
||||
fView(view),
|
||||
fOptions(glOptions)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BGLRenderer::~BGLRenderer()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLRenderer::Acquire()
|
||||
{
|
||||
atomic_add(&fRefCount, 1);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLRenderer::Release()
|
||||
{
|
||||
if (atomic_add(&fRefCount, -1) <= 1)
|
||||
delete this;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLRenderer::LockGL()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLRenderer::UnlockGL()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLRenderer::SwapBuffers(bool VSync)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLRenderer::Draw(BRect updateRect)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BGLRenderer::CopyPixelsOut(BPoint source, BBitmap* dest)
|
||||
{
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BGLRenderer::CopyPixelsIn(BBitmap* source, BPoint dest)
|
||||
{
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLRenderer::FrameResized(float width, float height)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLRenderer::DirectConnected(direct_buffer_info* info)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLRenderer::EnableDirectMode(bool enabled)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
status_t BGLRenderer::_Reserved_Renderer_0(int32 n, void* p) { return B_ERROR; }
|
||||
status_t BGLRenderer::_Reserved_Renderer_1(int32 n, void* p) { return B_ERROR; }
|
||||
status_t BGLRenderer::_Reserved_Renderer_2(int32 n, void* p) { return B_ERROR; }
|
||||
status_t BGLRenderer::_Reserved_Renderer_3(int32 n, void* p) { return B_ERROR; }
|
||||
status_t BGLRenderer::_Reserved_Renderer_4(int32 n, void* p) { return B_ERROR; }
|
@@ -1,233 +0,0 @@
|
||||
/*
|
||||
* Copyright 2006-2012 Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Philippe Houdoin <philippe.houdoin@free.fr>
|
||||
* Alexander von Gluck IV <kallisti5@unixzen.com>
|
||||
*/
|
||||
|
||||
|
||||
#include <driver_settings.h>
|
||||
#include <image.h>
|
||||
|
||||
#include <kernel/image.h>
|
||||
#include <private/system/safemode_defs.h>
|
||||
|
||||
#include <Directory.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <Path.h>
|
||||
#include <strings.h>
|
||||
#include "GLRendererRoster.h"
|
||||
|
||||
#include <new>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
extern "C" status_t _kern_get_safemode_option(const char* parameter,
|
||||
char* buffer, size_t* _bufferSize);
|
||||
|
||||
GLRendererRoster *GLRendererRoster::fInstance = NULL;
|
||||
|
||||
GLRendererRoster *GLRendererRoster::Roster()
|
||||
{
|
||||
if (fInstance == NULL) {
|
||||
fInstance = new GLRendererRoster();
|
||||
}
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
GLRendererRoster::GLRendererRoster()
|
||||
:
|
||||
fSafeMode(false),
|
||||
fABISubDirectory(NULL)
|
||||
{
|
||||
char parameter[32];
|
||||
size_t parameterLength = sizeof(parameter);
|
||||
|
||||
if (_kern_get_safemode_option(B_SAFEMODE_SAFE_MODE,
|
||||
parameter, ¶meterLength) == B_OK) {
|
||||
if (!strcasecmp(parameter, "enabled") || !strcasecmp(parameter, "on")
|
||||
|| !strcasecmp(parameter, "true") || !strcasecmp(parameter, "yes")
|
||||
|| !strcasecmp(parameter, "enable") || !strcmp(parameter, "1"))
|
||||
fSafeMode = true;
|
||||
}
|
||||
|
||||
if (_kern_get_safemode_option(B_SAFEMODE_DISABLE_USER_ADD_ONS,
|
||||
parameter, ¶meterLength) == B_OK) {
|
||||
if (!strcasecmp(parameter, "enabled") || !strcasecmp(parameter, "on")
|
||||
|| !strcasecmp(parameter, "true") || !strcasecmp(parameter, "yes")
|
||||
|| !strcasecmp(parameter, "enable") || !strcmp(parameter, "1"))
|
||||
fSafeMode = true;
|
||||
}
|
||||
|
||||
// We might run in compatibility mode on a system with a different ABI. The
|
||||
// renderers matching our ABI can usually be found in respective
|
||||
// subdirectories of the opengl add-ons directories.
|
||||
system_info info;
|
||||
if (get_system_info(&info) == B_OK
|
||||
&& (info.abi & B_HAIKU_ABI_MAJOR)
|
||||
!= (B_HAIKU_ABI & B_HAIKU_ABI_MAJOR)) {
|
||||
switch (B_HAIKU_ABI & B_HAIKU_ABI_MAJOR) {
|
||||
case B_HAIKU_ABI_GCC_2:
|
||||
fABISubDirectory = "gcc2";
|
||||
break;
|
||||
case B_HAIKU_ABI_GCC_4:
|
||||
fABISubDirectory = "gcc4";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
AddDefaultPaths();
|
||||
}
|
||||
|
||||
|
||||
GLRendererRoster::~GLRendererRoster()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
BGLRenderer*
|
||||
GLRendererRoster::GetRenderer(BGLView *view, ulong options)
|
||||
{
|
||||
for (
|
||||
RendererMap::const_iterator iterator = fRenderers.begin();
|
||||
iterator != fRenderers.end();
|
||||
iterator++
|
||||
) {
|
||||
renderer_item item = *iterator;
|
||||
BGLRenderer* renderer;
|
||||
renderer = item.entry(view, options);
|
||||
return renderer;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GLRendererRoster::AddDefaultPaths()
|
||||
{
|
||||
// add user directories first, so that they can override system renderers
|
||||
const directory_which paths[] = {
|
||||
B_USER_NONPACKAGED_ADDONS_DIRECTORY,
|
||||
B_USER_ADDONS_DIRECTORY,
|
||||
B_SYSTEM_NONPACKAGED_ADDONS_DIRECTORY,
|
||||
B_SYSTEM_ADDONS_DIRECTORY,
|
||||
};
|
||||
|
||||
for (uint32 i = fSafeMode ? 4 : 0;
|
||||
i < sizeof(paths) / sizeof(paths[0]); i++) {
|
||||
BPath path;
|
||||
status_t status = find_directory(paths[i], &path, true);
|
||||
if (status == B_OK && path.Append("opengl") == B_OK)
|
||||
AddPath(path.Path());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
GLRendererRoster::AddPath(const char* path)
|
||||
{
|
||||
BDirectory directory(path);
|
||||
status_t status = directory.InitCheck();
|
||||
if (status < B_OK)
|
||||
return status;
|
||||
|
||||
// if a subdirectory for our ABI exists, use that instead
|
||||
if (fABISubDirectory != NULL) {
|
||||
BEntry entry(&directory, fABISubDirectory);
|
||||
if (entry.IsDirectory()) {
|
||||
status = directory.SetTo(&entry);
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
node_ref nodeRef;
|
||||
status = directory.GetNodeRef(&nodeRef);
|
||||
if (status < B_OK)
|
||||
return status;
|
||||
|
||||
int32 count = 0;
|
||||
int32 files = 0;
|
||||
|
||||
entry_ref ref;
|
||||
BEntry entry;
|
||||
while (directory.GetNextRef(&ref) == B_OK) {
|
||||
entry.SetTo(&ref, true);
|
||||
if (entry.InitCheck() == B_OK && !entry.IsFile())
|
||||
continue;
|
||||
|
||||
if (CreateRenderer(ref) == B_OK)
|
||||
count++;
|
||||
|
||||
files++;
|
||||
}
|
||||
|
||||
if (files != 0 && count == 0)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
GLRendererRoster::AddRenderer(InstantiateRenderer entry,
|
||||
image_id image, const entry_ref* ref, ino_t node)
|
||||
{
|
||||
renderer_item item;
|
||||
item.entry = entry;
|
||||
item.image = image;
|
||||
item.node = node;
|
||||
if (ref != NULL)
|
||||
item.ref = *ref;
|
||||
|
||||
try {
|
||||
fRenderers.push_back(item);
|
||||
} catch (...) {
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
GLRendererRoster::CreateRenderer(const entry_ref& ref)
|
||||
{
|
||||
BEntry entry(&ref, true);
|
||||
node_ref nodeRef;
|
||||
status_t status = entry.GetNodeRef(&nodeRef);
|
||||
if (status < B_OK)
|
||||
return status;
|
||||
|
||||
BPath path(&ref);
|
||||
printf("OpenGL load add-on: %s\n", path.Path());
|
||||
|
||||
image_id image = load_add_on(path.Path());
|
||||
if (image < B_OK)
|
||||
return image;
|
||||
|
||||
InstantiateRenderer instantiate_renderer;
|
||||
|
||||
status = get_image_symbol(
|
||||
image, "instantiate_gl_renderer",
|
||||
B_SYMBOL_TYPE_TEXT, (void**)&instantiate_renderer
|
||||
);
|
||||
|
||||
if (status == B_OK) {
|
||||
if ((status = AddRenderer(instantiate_renderer, image, &ref, nodeRef.node)) != B_OK) {
|
||||
unload_add_on(image);
|
||||
return status;
|
||||
}
|
||||
printf("OpenGL add-on registered: %s\n", path.Path());
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
printf("OpenGL add-on failed to instantiate: %s\n", path.Path());
|
||||
unload_add_on(image);
|
||||
|
||||
return status;
|
||||
}
|
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright 2006-2012, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Philippe Houdoin <philippe.houdoin@free.fr>
|
||||
*/
|
||||
#ifndef _GLRENDERER_ROSTER_H
|
||||
#define _GLRENDERER_ROSTER_H
|
||||
|
||||
|
||||
#include <GLRenderer.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
||||
typedef BGLRenderer* (*InstantiateRenderer) (BGLView* view, ulong options);
|
||||
|
||||
struct renderer_item {
|
||||
InstantiateRenderer entry;
|
||||
entry_ref ref;
|
||||
ino_t node;
|
||||
image_id image;
|
||||
};
|
||||
|
||||
typedef std::vector<renderer_item> RendererMap;
|
||||
|
||||
|
||||
class GLRendererRoster {
|
||||
public:
|
||||
static GLRendererRoster *Roster();
|
||||
BGLRenderer* GetRenderer(BGLView *view, ulong options);
|
||||
|
||||
private:
|
||||
GLRendererRoster();
|
||||
virtual ~GLRendererRoster();
|
||||
|
||||
void AddDefaultPaths();
|
||||
status_t AddPath(const char* path);
|
||||
status_t AddRenderer(InstantiateRenderer entry, image_id image,
|
||||
const entry_ref* ref, ino_t node);
|
||||
status_t CreateRenderer(const entry_ref& ref);
|
||||
|
||||
static GLRendererRoster* fInstance;
|
||||
bool fSafeMode;
|
||||
const char* fABISubDirectory;
|
||||
|
||||
RendererMap fRenderers;
|
||||
};
|
||||
|
||||
|
||||
#endif /* _GLRENDERER_ROSTER_H */
|
@@ -1,635 +0,0 @@
|
||||
/*
|
||||
* Copyright 2006-2012, Haiku. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Jérôme Duval, korli@users.berlios.de
|
||||
* Philippe Houdoin, philippe.houdoin@free.fr
|
||||
* Stefano Ceccherini, burton666@libero.it
|
||||
*/
|
||||
|
||||
#include <kernel/image.h>
|
||||
|
||||
#include <GLView.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <DirectWindow.h>
|
||||
#include "GLRenderer.h"
|
||||
|
||||
#include <private/interface/DirectWindowPrivate.h>
|
||||
#include "GLRendererRoster.h"
|
||||
|
||||
#include "glapi/glapi.h"
|
||||
|
||||
struct glview_direct_info {
|
||||
direct_buffer_info* direct_info;
|
||||
bool direct_connected;
|
||||
bool enable_direct_mode;
|
||||
|
||||
glview_direct_info();
|
||||
~glview_direct_info();
|
||||
};
|
||||
|
||||
|
||||
BGLView::BGLView(BRect rect, const char* name, ulong resizingMode, ulong mode,
|
||||
ulong options)
|
||||
:
|
||||
BView(rect, name, B_FOLLOW_ALL_SIDES, mode | B_WILL_DRAW | B_FRAME_EVENTS),
|
||||
fGc(NULL),
|
||||
fOptions(options),
|
||||
fDitherCount(0),
|
||||
fDrawLock("BGLView draw lock"),
|
||||
fDisplayLock("BGLView display lock"),
|
||||
fClipInfo(NULL),
|
||||
fRenderer(NULL),
|
||||
fDitherMap(NULL)
|
||||
{
|
||||
fRenderer = GLRendererRoster::Roster()->GetRenderer(this, options);
|
||||
}
|
||||
|
||||
|
||||
BGLView::~BGLView()
|
||||
{
|
||||
delete fClipInfo;
|
||||
if (fRenderer)
|
||||
fRenderer->Release();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLView::LockGL()
|
||||
{
|
||||
// TODO: acquire the OpenGL API lock it on this glview
|
||||
|
||||
fDisplayLock.Lock();
|
||||
if (fRenderer != NULL && fDisplayLock.CountLocks() == 1)
|
||||
fRenderer->LockGL();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLView::UnlockGL()
|
||||
{
|
||||
thread_id lockerThread = fDisplayLock.LockingThread();
|
||||
thread_id callerThread = find_thread(NULL);
|
||||
|
||||
if (lockerThread != B_ERROR && lockerThread != callerThread) {
|
||||
printf("UnlockGL is called from wrong thread, lockerThread: %d, callerThread: %d\n",
|
||||
(int)lockerThread, (int)callerThread);
|
||||
debugger("[!]");
|
||||
}
|
||||
|
||||
if (fRenderer != NULL && fDisplayLock.CountLocks() == 1)
|
||||
fRenderer->UnlockGL();
|
||||
fDisplayLock.Unlock();
|
||||
|
||||
// TODO: release the GL API lock to others glviews
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLView::SwapBuffers()
|
||||
{
|
||||
SwapBuffers(false);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLView::SwapBuffers(bool vSync)
|
||||
{
|
||||
if (fRenderer) {
|
||||
_LockDraw();
|
||||
fRenderer->SwapBuffers(vSync);
|
||||
_UnlockDraw();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BView*
|
||||
BGLView::EmbeddedView()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void*
|
||||
BGLView::GetGLProcAddress(const char* procName)
|
||||
{
|
||||
return (void*)_glapi_get_proc_address(procName);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BGLView::CopyPixelsOut(BPoint source, BBitmap* dest)
|
||||
{
|
||||
if (!fRenderer)
|
||||
return B_ERROR;
|
||||
|
||||
if (!dest || !dest->Bounds().IsValid())
|
||||
return B_BAD_VALUE;
|
||||
|
||||
return fRenderer->CopyPixelsOut(source, dest);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BGLView::CopyPixelsIn(BBitmap* source, BPoint dest)
|
||||
{
|
||||
if (!fRenderer)
|
||||
return B_ERROR;
|
||||
|
||||
if (!source || !source->Bounds().IsValid())
|
||||
return B_BAD_VALUE;
|
||||
|
||||
return fRenderer->CopyPixelsIn(source, dest);
|
||||
}
|
||||
|
||||
|
||||
/*! Mesa's GLenum is not ulong but uint, so we can't use GLenum
|
||||
without breaking this method signature.
|
||||
Instead, we have to use the effective BeOS's SGI OpenGL GLenum type:
|
||||
unsigned long.
|
||||
*/
|
||||
void
|
||||
BGLView::ErrorCallback(unsigned long errorCode)
|
||||
{
|
||||
char msg[32];
|
||||
sprintf(msg, "GL: Error code $%04lx.", errorCode);
|
||||
// TODO: under BeOS R5, it call debugger(msg);
|
||||
fprintf(stderr, "%s\n", msg);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLView::Draw(BRect updateRect)
|
||||
{
|
||||
if (fRenderer) {
|
||||
if (!fClipInfo || !fClipInfo->enable_direct_mode)
|
||||
fRenderer->Draw(updateRect);
|
||||
return;
|
||||
}
|
||||
// TODO: auto-size and center the string
|
||||
MovePenTo(8, 32);
|
||||
DrawString("No OpenGL renderer available!");
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLView::AttachedToWindow()
|
||||
{
|
||||
BView::AttachedToWindow();
|
||||
|
||||
fBounds = Bounds();
|
||||
for (BView* view = this; view != NULL; view = view->Parent())
|
||||
view->ConvertToParent(&fBounds);
|
||||
|
||||
if (fRenderer != NULL) {
|
||||
// Jackburton: The following code was commented because it doesn't look
|
||||
// good in "direct" mode:
|
||||
// when the window is moved, the app_server doesn't paint the view's
|
||||
// background, and the stuff behind the window itself shows up.
|
||||
// Setting the view color to black, instead, looks a bit more elegant.
|
||||
#if 0
|
||||
// Don't paint white window background when resized
|
||||
SetViewColor(B_TRANSPARENT_32_BIT);
|
||||
#else
|
||||
SetViewColor(0, 0, 0);
|
||||
#endif
|
||||
|
||||
// Set default OpenGL viewport:
|
||||
LockGL();
|
||||
glViewport(0, 0, Bounds().IntegerWidth(), Bounds().IntegerHeight());
|
||||
UnlockGL();
|
||||
fRenderer->FrameResized(Bounds().IntegerWidth(),
|
||||
Bounds().IntegerHeight());
|
||||
|
||||
if (fClipInfo) {
|
||||
fRenderer->DirectConnected(fClipInfo->direct_info);
|
||||
fRenderer->EnableDirectMode(fClipInfo->enable_direct_mode);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(stderr, "no renderer found! \n");
|
||||
|
||||
// No Renderer, no rendering. Setup a minimal "No Renderer" string drawing
|
||||
// context
|
||||
SetFont(be_bold_font);
|
||||
// SetFontSize(16);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLView::AllAttached()
|
||||
{
|
||||
BView::AllAttached();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLView::DetachedFromWindow()
|
||||
{
|
||||
BView::DetachedFromWindow();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLView::AllDetached()
|
||||
{
|
||||
BView::AllDetached();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLView::FrameResized(float width, float height)
|
||||
{
|
||||
fBounds = Bounds();
|
||||
for (BView* v = this; v; v = v->Parent())
|
||||
v->ConvertToParent(&fBounds);
|
||||
|
||||
if (fRenderer) {
|
||||
//_LockDraw();
|
||||
fRenderer->FrameResized(width, height);
|
||||
//_UnlockDraw();
|
||||
}
|
||||
|
||||
BView::FrameResized(width, height);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BGLView::Perform(perform_code d, void* arg)
|
||||
{
|
||||
return BView::Perform(d, arg);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BGLView::Archive(BMessage* data, bool deep) const
|
||||
{
|
||||
return BView::Archive(data, deep);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLView::MessageReceived(BMessage* msg)
|
||||
{
|
||||
BView::MessageReceived(msg);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLView::SetResizingMode(uint32 mode)
|
||||
{
|
||||
BView::SetResizingMode(mode);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLView::GetPreferredSize(float* _width, float* _height)
|
||||
{
|
||||
if (_width)
|
||||
*_width = 0;
|
||||
if (_height)
|
||||
*_height = 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLView::Show()
|
||||
{
|
||||
BView::Show();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLView::Hide()
|
||||
{
|
||||
BView::Hide();
|
||||
}
|
||||
|
||||
|
||||
BHandler*
|
||||
BGLView::ResolveSpecifier(BMessage* msg, int32 index, BMessage* specifier,
|
||||
int32 form, const char* property)
|
||||
{
|
||||
return BView::ResolveSpecifier(msg, index, specifier, form, property);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BGLView::GetSupportedSuites(BMessage* data)
|
||||
{
|
||||
return BView::GetSupportedSuites(data);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLView::DirectConnected(direct_buffer_info* info)
|
||||
{
|
||||
printf("BGLView::DirectConnected\n");
|
||||
if (fClipInfo == NULL) {
|
||||
fClipInfo = new (std::nothrow) glview_direct_info();
|
||||
if (fClipInfo == NULL)
|
||||
return;
|
||||
}
|
||||
|
||||
direct_buffer_info* localInfo = fClipInfo->direct_info;
|
||||
|
||||
_LockDraw();
|
||||
switch (info->buffer_state & B_DIRECT_MODE_MASK) {
|
||||
case B_DIRECT_START:
|
||||
fClipInfo->direct_connected = true;
|
||||
memcpy(localInfo, info, DIRECT_BUFFER_INFO_AREA_SIZE);
|
||||
break;
|
||||
|
||||
case B_DIRECT_MODIFY:
|
||||
memcpy(localInfo, info, DIRECT_BUFFER_INFO_AREA_SIZE);
|
||||
break;
|
||||
|
||||
case B_DIRECT_STOP:
|
||||
fClipInfo->direct_connected = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (fRenderer)
|
||||
_CallDirectConnected();
|
||||
|
||||
_UnlockDraw();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLView::EnableDirectMode(bool enabled)
|
||||
{
|
||||
printf("BGLView::EnableDirectMode: %d\n", (int)enabled);
|
||||
if (fRenderer)
|
||||
fRenderer->EnableDirectMode(enabled);
|
||||
if (fClipInfo == NULL) {
|
||||
fClipInfo = new (std::nothrow) glview_direct_info();
|
||||
if (fClipInfo == NULL)
|
||||
return;
|
||||
}
|
||||
|
||||
fClipInfo->enable_direct_mode = enabled;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLView::_LockDraw()
|
||||
{
|
||||
if (!fClipInfo || !fClipInfo->enable_direct_mode)
|
||||
return;
|
||||
|
||||
fDrawLock.Lock();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLView::_UnlockDraw()
|
||||
{
|
||||
if (!fClipInfo || !fClipInfo->enable_direct_mode)
|
||||
return;
|
||||
|
||||
fDrawLock.Unlock();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLView::_CallDirectConnected()
|
||||
{
|
||||
if (!fClipInfo || !fClipInfo->direct_connected) {
|
||||
fRenderer->DirectConnected(NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
direct_buffer_info* localInfo = fClipInfo->direct_info;
|
||||
direct_buffer_info* info = (direct_buffer_info*)malloc(
|
||||
DIRECT_BUFFER_INFO_AREA_SIZE);
|
||||
if (info == NULL)
|
||||
return;
|
||||
|
||||
memcpy(info, localInfo, DIRECT_BUFFER_INFO_AREA_SIZE);
|
||||
|
||||
// Collect the rects into a BRegion, then clip to the view's bounds
|
||||
BRegion region;
|
||||
for (uint32 c = 0; c < localInfo->clip_list_count; c++)
|
||||
region.Include(localInfo->clip_list[c]);
|
||||
BRegion boundsRegion = fBounds.OffsetByCopy(localInfo->window_bounds.left,
|
||||
localInfo->window_bounds.top);
|
||||
info->window_bounds = boundsRegion.RectAtInt(0);
|
||||
// window_bounds are now view bounds
|
||||
region.IntersectWith(&boundsRegion);
|
||||
|
||||
info->clip_list_count = region.CountRects();
|
||||
info->clip_bounds = region.FrameInt();
|
||||
|
||||
for (uint32 c = 0; c < info->clip_list_count; c++)
|
||||
info->clip_list[c] = region.RectAtInt(c);
|
||||
fRenderer->DirectConnected(info);
|
||||
free(info);
|
||||
}
|
||||
|
||||
|
||||
//---- virtual reserved methods ----------
|
||||
|
||||
|
||||
void BGLView::_ReservedGLView1() {}
|
||||
void BGLView::_ReservedGLView2() {}
|
||||
void BGLView::_ReservedGLView3() {}
|
||||
void BGLView::_ReservedGLView4() {}
|
||||
void BGLView::_ReservedGLView5() {}
|
||||
void BGLView::_ReservedGLView6() {}
|
||||
void BGLView::_ReservedGLView7() {}
|
||||
void BGLView::_ReservedGLView8() {}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
// BeOS compatibility: contrary to others BView's contructors,
|
||||
// BGLView one wants a non-const name argument.
|
||||
BGLView::BGLView(BRect rect, char* name, ulong resizingMode, ulong mode,
|
||||
ulong options)
|
||||
:
|
||||
BView(rect, name, B_FOLLOW_ALL_SIDES, mode | B_WILL_DRAW | B_FRAME_EVENTS),
|
||||
fGc(NULL),
|
||||
fOptions(options),
|
||||
fDitherCount(0),
|
||||
fDrawLock("BGLView draw lock"),
|
||||
fDisplayLock("BGLView display lock"),
|
||||
fClipInfo(NULL),
|
||||
fRenderer(NULL),
|
||||
fDitherMap(NULL)
|
||||
{
|
||||
fRenderer = GLRendererRoster::Roster()->GetRenderer(this, options);
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
// TODO: implement BGLScreen class...
|
||||
|
||||
|
||||
BGLScreen::BGLScreen(char* name, ulong screenMode, ulong options,
|
||||
status_t* error, bool debug)
|
||||
:
|
||||
BWindowScreen(name, screenMode, error, debug)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BGLScreen::~BGLScreen()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLScreen::LockGL()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLScreen::UnlockGL()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLScreen::SwapBuffers()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLScreen::ErrorCallback(unsigned long errorCode)
|
||||
{
|
||||
// Mesa's GLenum is not ulong but uint!
|
||||
char msg[32];
|
||||
sprintf(msg, "GL: Error code $%04lx.", errorCode);
|
||||
// debugger(msg);
|
||||
fprintf(stderr, "%s\n", msg);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLScreen::ScreenConnected(bool enabled)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLScreen::FrameResized(float width, float height)
|
||||
{
|
||||
return BWindowScreen::FrameResized(width, height);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BGLScreen::Perform(perform_code d, void* arg)
|
||||
{
|
||||
return BWindowScreen::Perform(d, arg);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BGLScreen::Archive(BMessage* data, bool deep) const
|
||||
{
|
||||
return BWindowScreen::Archive(data, deep);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLScreen::MessageReceived(BMessage* msg)
|
||||
{
|
||||
BWindowScreen::MessageReceived(msg);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLScreen::Show()
|
||||
{
|
||||
BWindowScreen::Show();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGLScreen::Hide()
|
||||
{
|
||||
BWindowScreen::Hide();
|
||||
}
|
||||
|
||||
|
||||
BHandler*
|
||||
BGLScreen::ResolveSpecifier(BMessage* msg, int32 index, BMessage* specifier,
|
||||
int32 form, const char* property)
|
||||
{
|
||||
return BWindowScreen::ResolveSpecifier(msg, index, specifier,
|
||||
form, property);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BGLScreen::GetSupportedSuites(BMessage* data)
|
||||
{
|
||||
return BWindowScreen::GetSupportedSuites(data);
|
||||
}
|
||||
|
||||
|
||||
//---- virtual reserved methods ----------
|
||||
|
||||
void BGLScreen::_ReservedGLScreen1() {}
|
||||
void BGLScreen::_ReservedGLScreen2() {}
|
||||
void BGLScreen::_ReservedGLScreen3() {}
|
||||
void BGLScreen::_ReservedGLScreen4() {}
|
||||
void BGLScreen::_ReservedGLScreen5() {}
|
||||
void BGLScreen::_ReservedGLScreen6() {}
|
||||
void BGLScreen::_ReservedGLScreen7() {}
|
||||
void BGLScreen::_ReservedGLScreen8() {}
|
||||
#endif
|
||||
|
||||
|
||||
const char* color_space_name(color_space space)
|
||||
{
|
||||
#define C2N(a) case a: return #a
|
||||
|
||||
switch (space) {
|
||||
C2N(B_RGB24);
|
||||
C2N(B_RGB32);
|
||||
C2N(B_RGBA32);
|
||||
C2N(B_RGB32_BIG);
|
||||
C2N(B_RGBA32_BIG);
|
||||
C2N(B_GRAY8);
|
||||
C2N(B_GRAY1);
|
||||
C2N(B_RGB16);
|
||||
C2N(B_RGB15);
|
||||
C2N(B_RGBA15);
|
||||
C2N(B_CMAP8);
|
||||
default:
|
||||
return "Unknown!";
|
||||
};
|
||||
|
||||
#undef C2N
|
||||
};
|
||||
|
||||
|
||||
glview_direct_info::glview_direct_info()
|
||||
{
|
||||
// TODO: See direct_window_data() in app_server's ServerWindow.cpp
|
||||
direct_info = (direct_buffer_info*)calloc(1, DIRECT_BUFFER_INFO_AREA_SIZE);
|
||||
direct_connected = false;
|
||||
enable_direct_mode = false;
|
||||
}
|
||||
|
||||
|
||||
glview_direct_info::~glview_direct_info()
|
||||
{
|
||||
free(direct_info);
|
||||
}
|
||||
|
@@ -1,37 +0,0 @@
|
||||
# Copyright © 2017 Intel Corporation
|
||||
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
libgl = shared_library(
|
||||
'GL',
|
||||
files(
|
||||
'GLView.cpp', 'GLRenderer.cpp', 'GLRendererRoster.cpp',
|
||||
),
|
||||
link_args : [ld_args_bsymbolic, ld_args_gc_sections],
|
||||
include_directories : [
|
||||
inc_src, inc_mapi, inc_mesa, inc_include, inc_glapi, inc_haikugl,
|
||||
include_directories('/system/develop/headers/private')
|
||||
],
|
||||
link_with : [libglapi_static, libglapi],
|
||||
dependencies : cpp.find_library('be'),
|
||||
version : '1.0.0',
|
||||
install : true,
|
||||
)
|
||||
|
||||
# TODO: We need some tests here
|
@@ -112,9 +112,6 @@ endif
|
||||
if with_gallium or with_gbm
|
||||
subdir('loader')
|
||||
endif
|
||||
if with_platform_haiku
|
||||
subdir('hgl')
|
||||
endif
|
||||
if with_gbm
|
||||
subdir('gbm')
|
||||
else
|
||||
|
Reference in New Issue
Block a user