opengl: Header / whitespace cleanup
* I received the ok via email from Brain Paul at mesa to relicense the GLDispatcher sources to MIT + him as the author. * Update include ordering * Remove HAIKU_TARGET_PLATFORM_HAIKU ifdefs for boot options
This commit is contained in:
@@ -1,39 +1,13 @@
|
|||||||
|
|
||||||
/**************************************************************************
|
|
||||||
|
|
||||||
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
|
|
||||||
All Rights Reserved.
|
|
||||||
|
|
||||||
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, sub license, 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 (including the
|
|
||||||
next paragraph) 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 NON-INFRINGEMENT.
|
|
||||||
IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
|
|
||||||
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Authors:
|
* Copyright 2000-2012 Haiku, Inc. All Rights Reserved.
|
||||||
* Brian Paul <[email protected]>
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
|
* Authors:
|
||||||
|
* Brian Paul <[email protected]>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
#include "glapi.h"
|
#include "glapi.h"
|
||||||
#if __GNUC__ > 2
|
#if __GNUC__ > 2
|
||||||
// New Mesa
|
// New Mesa
|
||||||
@@ -41,36 +15,33 @@ extern "C" {
|
|||||||
#include "glapitable.h"
|
#include "glapitable.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NOTE: this file portion implements C-based dispatch of the OpenGL entrypoints
|
* NOTE: this file portion implements C-based dispatch of the OpenGL entrypoints
|
||||||
* (glAccum, glBegin, etc).
|
* (glAccum, glBegin, etc).
|
||||||
* This code IS NOT USED if we're compiling on an x86 system and using
|
* This code IS NOT USED if we're compiling on an x86 system and using
|
||||||
* the glapi_x86.S assembly code.
|
* the glapi_x86.S assembly code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !(defined(USE_X86_ASM) || defined(USE_SPARC_ASM))
|
#if !(defined(USE_X86_ASM) || defined(USE_SPARC_ASM))
|
||||||
|
|
||||||
#define KEYWORD1 PUBLIC
|
#define KEYWORD1 PUBLIC
|
||||||
|
|
||||||
#define KEYWORD2
|
#define KEYWORD2
|
||||||
|
|
||||||
#define NAME(func) gl##func
|
#define NAME(func) gl##func
|
||||||
|
|
||||||
#define DISPATCH(func, args, msg) \
|
#define DISPATCH(func, args, msg) \
|
||||||
const struct _glapi_table *dispatch; \
|
const struct _glapi_table *dispatch; \
|
||||||
dispatch = _glapi_Dispatch ? _glapi_Dispatch : _glapi_get_dispatch();\
|
dispatch = _glapi_Dispatch ? _glapi_Dispatch : _glapi_get_dispatch();\
|
||||||
(dispatch->func) args
|
(dispatch->func) args
|
||||||
|
|
||||||
#define RETURN_DISPATCH(func, args, msg) \
|
#define RETURN_DISPATCH(func, args, msg) \
|
||||||
const struct _glapi_table *dispatch; \
|
const struct _glapi_table *dispatch; \
|
||||||
dispatch = _glapi_Dispatch ? _glapi_Dispatch : _glapi_get_dispatch();\
|
dispatch = _glapi_Dispatch ? _glapi_Dispatch : _glapi_get_dispatch();\
|
||||||
return (dispatch->func) args
|
return (dispatch->func) args
|
||||||
|
|
||||||
|
|
||||||
#endif /* USE_X86_ASM */
|
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* NOTE: this file portion implement a thin OpenGL entrypoints dispatching
|
/* NOTE: this file portion implement a thin OpenGL entrypoints dispatching
|
||||||
C++ wrapper class
|
C++ wrapper class
|
||||||
*/
|
*/
|
||||||
@@ -81,10 +52,12 @@ BGLDispatcher::BGLDispatcher()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BGLDispatcher::~BGLDispatcher()
|
BGLDispatcher::~BGLDispatcher()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BGLDispatcher::CheckTable(const struct _glapi_table *table)
|
BGLDispatcher::CheckTable(const struct _glapi_table *table)
|
||||||
{
|
{
|
||||||
@@ -92,12 +65,10 @@ BGLDispatcher::CheckTable(const struct _glapi_table *table)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BGLDispatcher::SetTable(struct _glapi_table *table)
|
BGLDispatcher::SetTable(struct _glapi_table *table)
|
||||||
{
|
{
|
||||||
_glapi_set_dispatch(table);
|
_glapi_set_dispatch(table);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2000-2012 Haiku, Inc. All Rights Reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Brian Paul <[email protected]>
|
||||||
|
*/
|
||||||
#ifndef GLDISPATCHER_H
|
#ifndef GLDISPATCHER_H
|
||||||
#define GLDISPATCHER_H
|
#define GLDISPATCHER_H
|
||||||
|
|
||||||
@@ -12,6 +19,7 @@ extern "C" {
|
|||||||
#include "glapi.h"
|
#include "glapi.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class BGLDispatcher
|
class BGLDispatcher
|
||||||
{
|
{
|
||||||
// Private unimplemented copy constructors
|
// Private unimplemented copy constructors
|
||||||
@@ -26,7 +34,8 @@ class BGLDispatcher
|
|||||||
void * CurrentContext();
|
void * CurrentContext();
|
||||||
|
|
||||||
struct _glapi_table * Table();
|
struct _glapi_table * Table();
|
||||||
status_t CheckTable(const struct _glapi_table *dispatch = NULL);
|
status_t CheckTable(
|
||||||
|
const struct _glapi_table *dispatch = NULL);
|
||||||
status_t SetTable(struct _glapi_table *dispatch);
|
status_t SetTable(struct _glapi_table *dispatch);
|
||||||
uint32 TableSize();
|
uint32 TableSize();
|
||||||
|
|
||||||
@@ -37,6 +46,7 @@ class BGLDispatcher
|
|||||||
uint32 OffsetOf(const char *functionName);
|
uint32 OffsetOf(const char *functionName);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Inlines methods
|
// Inlines methods
|
||||||
inline void BGLDispatcher::SetCurrentContext(void * context)
|
inline void BGLDispatcher::SetCurrentContext(void * context)
|
||||||
{
|
{
|
||||||
@@ -87,8 +97,3 @@ inline uint32 BGLDispatcher::OffsetOf(const char *functionName)
|
|||||||
|
|
||||||
|
|
||||||
#endif // GLDISPATCHER_H
|
#endif // GLDISPATCHER_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,13 +4,15 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "GLDispatcher.h"
|
|
||||||
#include "GLRenderer.h"
|
#include "GLRenderer.h"
|
||||||
|
|
||||||
|
#include "GLDispatcher.h"
|
||||||
|
|
||||||
|
|
||||||
BGLRenderer::BGLRenderer(BGLView *view, ulong glOptions,
|
BGLRenderer::BGLRenderer(BGLView *view, ulong glOptions,
|
||||||
BGLDispatcher *dispatcher)
|
BGLDispatcher *dispatcher)
|
||||||
: fRefCount(1),
|
:
|
||||||
|
fRefCount(1),
|
||||||
fView(view),
|
fView(view),
|
||||||
fOptions(glOptions),
|
fOptions(glOptions),
|
||||||
fDispatcher(dispatcher)
|
fDispatcher(dispatcher)
|
||||||
@@ -24,7 +26,7 @@ BGLRenderer::~BGLRenderer()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BGLRenderer::Acquire()
|
BGLRenderer::Acquire()
|
||||||
{
|
{
|
||||||
atomic_add(&fRefCount, 1);
|
atomic_add(&fRefCount, 1);
|
||||||
@@ -39,13 +41,13 @@ BGLRenderer::Release()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BGLRenderer::LockGL()
|
BGLRenderer::LockGL()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BGLRenderer::UnlockGL()
|
BGLRenderer::UnlockGL()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -77,20 +79,19 @@ BGLRenderer::CopyPixelsIn(BBitmap *source, BPoint dest)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BGLRenderer::FrameResized(float width, float height)
|
BGLRenderer::FrameResized(float width, float height)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BGLRenderer::DirectConnected(direct_buffer_info *info)
|
BGLRenderer::DirectConnected(direct_buffer_info *info)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BGLRenderer::EnableDirectMode(bool enabled)
|
BGLRenderer::EnableDirectMode(bool enabled)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -101,4 +102,3 @@ 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_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_3(int32 n, void *p) { return B_ERROR; }
|
||||||
status_t BGLRenderer::_Reserved_Renderer_4(int32 n, void *p) { return B_ERROR; }
|
status_t BGLRenderer::_Reserved_Renderer_4(int32 n, void *p) { return B_ERROR; }
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006, Haiku, Inc. All Rights Reserved.
|
* Copyright 2006-2012 Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <driver_settings.h>
|
#include <driver_settings.h>
|
||||||
#include <image.h>
|
#include <image.h>
|
||||||
#include <safemode_defs.h>
|
#include <safemode_defs.h>
|
||||||
@@ -20,13 +21,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
|
||||||
extern "C" status_t _kern_get_safemode_option(const char *parameter,
|
extern "C" status_t _kern_get_safemode_option(const char *parameter,
|
||||||
char *buffer, size_t *_bufferSize);
|
char *buffer, size_t *_bufferSize);
|
||||||
#else
|
|
||||||
extern "C" status_t _kget_safemode_option_(const char *parameter,
|
|
||||||
char *buffer, size_t *_bufferSize);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
GLRendererRoster::GLRendererRoster(BGLView *view, ulong options)
|
GLRendererRoster::GLRendererRoster(BGLView *view, ulong options)
|
||||||
@@ -39,24 +35,16 @@ GLRendererRoster::GLRendererRoster(BGLView *view, ulong options)
|
|||||||
char parameter[32];
|
char parameter[32];
|
||||||
size_t parameterLength = sizeof(parameter);
|
size_t parameterLength = sizeof(parameter);
|
||||||
|
|
||||||
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
if (_kern_get_safemode_option(B_SAFEMODE_SAFE_MODE,
|
||||||
if (_kern_get_safemode_option(B_SAFEMODE_SAFE_MODE, parameter, ¶meterLength) == B_OK)
|
parameter, ¶meterLength) == B_OK) {
|
||||||
#else
|
|
||||||
if (_kget_safemode_option_(B_SAFEMODE_SAFE_MODE, parameter, ¶meterLength) == B_OK)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
if (!strcasecmp(parameter, "enabled") || !strcasecmp(parameter, "on")
|
if (!strcasecmp(parameter, "enabled") || !strcasecmp(parameter, "on")
|
||||||
|| !strcasecmp(parameter, "true") || !strcasecmp(parameter, "yes")
|
|| !strcasecmp(parameter, "true") || !strcasecmp(parameter, "yes")
|
||||||
|| !strcasecmp(parameter, "enable") || !strcmp(parameter, "1"))
|
|| !strcasecmp(parameter, "enable") || !strcmp(parameter, "1"))
|
||||||
fSafeMode = true;
|
fSafeMode = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
if (_kern_get_safemode_option(B_SAFEMODE_DISABLE_USER_ADD_ONS,
|
||||||
if (_kern_get_safemode_option(B_SAFEMODE_DISABLE_USER_ADD_ONS, parameter, ¶meterLength) == B_OK)
|
parameter, ¶meterLength) == B_OK) {
|
||||||
#else
|
|
||||||
if (_kget_safemode_option_(B_SAFEMODE_DISABLE_USER_ADD_ONS, parameter, ¶meterLength) == B_OK)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
if (!strcasecmp(parameter, "enabled") || !strcasecmp(parameter, "on")
|
if (!strcasecmp(parameter, "enabled") || !strcasecmp(parameter, "on")
|
||||||
|| !strcasecmp(parameter, "true") || !strcasecmp(parameter, "yes")
|
|| !strcasecmp(parameter, "true") || !strcasecmp(parameter, "yes")
|
||||||
|| !strcasecmp(parameter, "enable") || !strcmp(parameter, "1"))
|
|| !strcasecmp(parameter, "enable") || !strcmp(parameter, "1"))
|
||||||
@@ -112,7 +100,8 @@ GLRendererRoster::AddDefaultPaths()
|
|||||||
B_SYSTEM_ADDONS_DIRECTORY,
|
B_SYSTEM_ADDONS_DIRECTORY,
|
||||||
};
|
};
|
||||||
|
|
||||||
for (uint32 i = fSafeMode ? 4 : 0; i < sizeof(paths) / sizeof(paths[0]); i++) {
|
for (uint32 i = fSafeMode ? 4 : 0;
|
||||||
|
i < sizeof(paths) / sizeof(paths[0]); i++) {
|
||||||
BPath path;
|
BPath path;
|
||||||
status_t status = find_directory(paths[i], &path, true);
|
status_t status = find_directory(paths[i], &path, true);
|
||||||
if (status == B_OK && path.Append("opengl") == B_OK)
|
if (status == B_OK && path.Append("opengl") == B_OK)
|
||||||
@@ -204,12 +193,14 @@ GLRendererRoster::CreateRenderer(const entry_ref& ref)
|
|||||||
if (image < B_OK)
|
if (image < B_OK)
|
||||||
return image;
|
return image;
|
||||||
|
|
||||||
BGLRenderer *(*instantiate_renderer)(BGLView *view, ulong options, BGLDispatcher *dispatcher);
|
BGLRenderer *(*instantiate_renderer)
|
||||||
|
(BGLView *view, ulong options, BGLDispatcher *dispatcher);
|
||||||
|
|
||||||
status = get_image_symbol(image, "instantiate_gl_renderer",
|
status = get_image_symbol(image, "instantiate_gl_renderer",
|
||||||
B_SYMBOL_TYPE_TEXT, (void**)&instantiate_renderer);
|
B_SYMBOL_TYPE_TEXT, (void**)&instantiate_renderer);
|
||||||
if (status == B_OK) {
|
if (status == B_OK) {
|
||||||
BGLRenderer *renderer = instantiate_renderer(fView, fOptions, new BGLDispatcher());
|
BGLRenderer *renderer
|
||||||
|
= instantiate_renderer(fView, fOptions, new BGLDispatcher());
|
||||||
if (!renderer) {
|
if (!renderer) {
|
||||||
unload_add_on(image);
|
unload_add_on(image);
|
||||||
return B_UNSUPPORTED;
|
return B_UNSUPPORTED;
|
||||||
@@ -226,4 +217,3 @@ GLRendererRoster::CreateRenderer(const entry_ref& ref)
|
|||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,16 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006, Haiku, Inc. All Rights Reserved.
|
* Copyright 2006-2012, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef _GLRENDERER_ROSTER_H
|
#ifndef _GLRENDERER_ROSTER_H
|
||||||
#define _GLRENDERER_ROSTER_H
|
#define _GLRENDERER_ROSTER_H
|
||||||
|
|
||||||
|
|
||||||
#include <GLRenderer.h>
|
#include <GLRenderer.h>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
|
||||||
struct renderer_item {
|
struct renderer_item {
|
||||||
BGLRenderer *renderer;
|
BGLRenderer *renderer;
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
@@ -17,6 +20,7 @@ struct renderer_item {
|
|||||||
|
|
||||||
typedef std::map<renderer_id, renderer_item> RendererMap;
|
typedef std::map<renderer_id, renderer_item> RendererMap;
|
||||||
|
|
||||||
|
|
||||||
class GLRendererRoster {
|
class GLRendererRoster {
|
||||||
public:
|
public:
|
||||||
GLRendererRoster(BGLView *view, ulong options);
|
GLRendererRoster(BGLView *view, ulong options);
|
||||||
@@ -40,4 +44,5 @@ class GLRendererRoster {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* _GLRENDERER_ROSTER_H */
|
#endif /* _GLRENDERER_ROSTER_H */
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006-2009, Haiku. All rights reserved.
|
* Copyright 2006-2012, Haiku. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -23,6 +23,7 @@
|
|||||||
#include "GLDispatcher.h"
|
#include "GLDispatcher.h"
|
||||||
#include "GLRendererRoster.h"
|
#include "GLRendererRoster.h"
|
||||||
|
|
||||||
|
|
||||||
struct glview_direct_info {
|
struct glview_direct_info {
|
||||||
direct_buffer_info *direct_info;
|
direct_buffer_info *direct_info;
|
||||||
bool direct_connected;
|
bool direct_connected;
|
||||||
|
|||||||
Reference in New Issue
Block a user