/*
- * Copyright (C) 2004-2006 Claudio Ciccani <klan@users.sf.net>
+ * Copyright (C) 2004-2007 Claudio Ciccani <klan@directfb.org>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* Based on glfbdev.c, written by Brian Paul.
#include <direct/interface.h>
#undef CLAMP
-#include "glheader.h"
-#include "buffers.h"
-#include "context.h"
-#include "extensions.h"
-#include "framebuffer.h"
-#include "renderbuffer.h"
-#include "imports.h"
-#include "texformat.h"
-#include "teximage.h"
-#include "texstore.h"
+#include "main/glheader.h"
+#include "main/buffers.h"
+#include "main/context.h"
+#include "main/extensions.h"
+#include "main/framebuffer.h"
+#include "main/renderbuffer.h"
+#include "main/imports.h"
+#include "main/texformat.h"
+#include "main/teximage.h"
+#include "main/texstore.h"
#include "vbo/vbo.h"
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
static pthread_mutex_t global_lock = PTHREAD_MUTEX_INITIALIZER;
static unsigned int global_ref = 0;
-static inline int directfbgl_init( void )
+static INLINE int directfbgl_init( void )
{
pthread_mutexattr_t attr;
int ret;
return ret;
}
-static inline void directfbgl_finish( void )
+static INLINE void directfbgl_finish( void )
{
if (--global_ref == 0)
pthread_mutex_destroy( &global_lock );
static bool directfbgl_create_context ( GLcontext *context,
GLframebuffer *framebuffer,
GLvisual *visual,
- DFBSurfacePixelFormat format,
IDirectFBGL_data *data );
static void directfbgl_destroy_context( GLcontext *context,
GLframebuffer *framebuffer );
}
/* Create context. */
- if (!directfbgl_create_context( &data->context, &data->framebuffer,
- &data->visual, data->format, data )) {
+ if (!directfbgl_create_context( &data->context,
+ &data->framebuffer,
+ &data->visual, data )) {
D_ERROR( "DirectFBGL/Mesa: failed to create context.\n" );
IDirectFBGL_Mesa_Destruct( thiz );
return DFB_UNSUPPORTED;
{
_swrast_InvalidateState( ctx, new_state );
_swsetup_InvalidateState( ctx, new_state );
- _ac_InvalidateState( ctx, new_state );
+ _vbo_InvalidateState( ctx, new_state );
_tnl_InvalidateState( ctx, new_state );
}
(((S[GCOMP]) & 0xf0) ) | \
(((S[BCOMP]) & 0xf0) >> 4) )
#define FETCH_PIXEL(D, P) \
- D[RCOMP] = ((*P & 0x0f00) >> 4); \
- D[GCOMP] = ((*P & 0x00f0) ); \
- D[BCOMP] = ((*P & 0x000f) << 4); \
- D[ACOMP] = ((*P & 0xf000) >> 8)
+ D[RCOMP] = ((*P & 0x0f00) >> 4) | ((*P & 0x0f00) >> 8); \
+ D[GCOMP] = ((*P & 0x00f0) ) | ((*P & 0x00f0) >> 4); \
+ D[BCOMP] = ((*P & 0x000f) << 4) | ((*P & 0x000f) ); \
+ D[ACOMP] = ((*P & 0xf000) >> 8) | ((*P & 0xf000) >> 12)
+
+#include "swrast/s_spantemp.h"
+
+/* RGB444 */
+#define NAME(PREFIX) PREFIX##_RGB444
+#define FORMAT GL_RGBA8
+#define RB_TYPE GLubyte
+#define SPAN_VARS \
+ IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx;
+#define INIT_PIXEL_PTR(P, X, Y) \
+ GLushort *P = (GLushort *) (data->video.end - (Y) * data->video.pitch + (X) * 2);
+#define INC_PIXEL_PTR(P) P += 1
+#define STORE_PIXEL(P, X, Y, S) \
+ *P = ( (((S[RCOMP]) & 0xf0) << 4) | \
+ (((S[GCOMP]) & 0xf0) ) | \
+ (((S[BCOMP]) & 0xf0) >> 4) )
+#define FETCH_PIXEL(D, P) \
+ D[RCOMP] = ((*P & 0x0f00) >> 4) | ((*P & 0x0f00) >> 8); \
+ D[GCOMP] = ((*P & 0x00f0) ) | ((*P & 0x00f0) >> 4); \
+ D[BCOMP] = ((*P & 0x000f) << 4) | ((*P & 0x000f) ); \
+ D[ACOMP] = 0xff
#include "swrast/s_spantemp.h"
(((S[GCOMP]) & 0xf8) << 2) | \
(((S[BCOMP]) ) >> 3) )
#define FETCH_PIXEL(D, P) \
- D[RCOMP] = ((*P & 0x7c00) >> 7); \
- D[GCOMP] = ((*P & 0x03e0) >> 2); \
- D[BCOMP] = ((*P & 0x001f) << 3); \
+ D[RCOMP] = ((*P & 0x7c00) >> 7) | ((*P & 0x7c00) >> 12); \
+ D[GCOMP] = ((*P & 0x03e0) >> 2) | ((*P & 0x03e0) >> 7); \
+ D[BCOMP] = ((*P & 0x001f) << 3) | ((*P & 0x001f) << 2); \
D[ACOMP] = ((*P & 0x8000) ? 0xff : 0)
#include "swrast/s_spantemp.h"
+/* RGB555 */
+#define NAME(PREFIX) PREFIX##_RGB555
+#define FORMAT GL_RGBA8
+#define RB_TYPE GLubyte
+#define SPAN_VARS \
+ IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx;
+#define INIT_PIXEL_PTR(P, X, Y) \
+ GLushort *P = (GLushort *) (data->video.end - (Y) * data->video.pitch + (X) * 2);
+#define INC_PIXEL_PTR(P) P += 1
+#define STORE_PIXEL(P, X, Y, S) \
+ *P = ( (((S[RCOMP]) & 0xf8) << 7) | \
+ (((S[GCOMP]) & 0xf8) << 2) | \
+ (((S[BCOMP]) ) >> 3) )
+#define FETCH_PIXEL(D, P) \
+ D[RCOMP] = ((*P & 0x7c00) >> 7) | ((*P & 0x7c00) >> 12); \
+ D[GCOMP] = ((*P & 0x03e0) >> 2) | ((*P & 0x03e0) >> 7); \
+ D[BCOMP] = ((*P & 0x001f) << 3) | ((*P & 0x001f) << 2); \
+ D[ACOMP] = 0xff
+
+#include "swrast/s_spantemp.h"
+
/* RGB16 */
#define NAME(PREFIX) PREFIX##_RGB16
#define FORMAT GL_RGBA8
(((S[GCOMP]) & 0xfc) << 3) | \
(((S[BCOMP]) ) >> 3) )
#define FETCH_PIXEL(D, P) \
- D[RCOMP] = ((*P & 0xf800) >> 8); \
- D[GCOMP] = ((*P & 0x07e0) >> 3); \
- D[BCOMP] = ((*P & 0x001f) << 3); \
+ D[RCOMP] = ((*P & 0xf800) >> 8) | ((*P & 0xf800) >> 13); \
+ D[GCOMP] = ((*P & 0x07e0) >> 3) | ((*P & 0x07e0) >> 9); \
+ D[BCOMP] = ((*P & 0x001f) << 3) | ((*P & 0x001f) >> 2); \
D[ACOMP] = 0xff
#include "swrast/s_spantemp.h"
blueBits = 2;
break;
case DSPF_ARGB4444:
+ alphaBits = 4;
+ case DSPF_RGB444:
redBits = 4;
greenBits = 4;
blueBits = 4;
- alphaBits = 4;
break;
case DSPF_ARGB2554:
+ alphaBits = 2;
redBits = 5;
greenBits = 5;
blueBits = 4;
- alphaBits = 2;
break;
case DSPF_ARGB1555:
+ alphaBits = 1;
+ case DSPF_RGB555:
redBits = 5;
greenBits = 5;
blueBits = 5;
- alphaBits = 1;
break;
case DSPF_RGB16:
redBits = 5;
}
static bool
-directfbgl_create_context( GLcontext *context,
- GLframebuffer *framebuffer,
- GLvisual *visual,
- DFBSurfacePixelFormat format,
- IDirectFBGL_data *data )
+directfbgl_create_context( GLcontext *context,
+ GLframebuffer *framebuffer,
+ GLvisual *visual,
+ IDirectFBGL_data *data )
{
struct dd_function_table functions;
}
_swrast_CreateContext( context );
- _ac_CreateContext( context );
+ _vbo_CreateContext( context );
_tnl_CreateContext( context );
_swsetup_CreateContext( context );
_swsetup_Wakeup( context );
data->render.Delete = dfbDeleteRenderbuffer;
data->render.AllocStorage = dfbRenderbufferStorage;
- switch (format) {
+ switch (data->format) {
case DSPF_RGB332:
data->render.GetRow = get_row_RGB332;
data->render.GetValues = get_values_RGB332;
data->render.PutValues = put_values_ARGB4444;
data->render.PutMonoValues = put_mono_values_ARGB4444;
break;
+ case DSPF_RGB444:
+ data->render.GetRow = get_row_RGB444;
+ data->render.GetValues = get_values_RGB444;
+ data->render.PutRow = put_row_RGB444;
+ data->render.PutRowRGB = put_row_rgb_RGB444;
+ data->render.PutMonoRow = put_mono_row_RGB444;
+ data->render.PutValues = put_values_RGB444;
+ data->render.PutMonoValues = put_mono_values_RGB444;
+ break;
case DSPF_ARGB2554:
data->render.GetRow = get_row_ARGB2554;
data->render.GetValues = get_values_ARGB2554;
data->render.PutValues = put_values_ARGB1555;
data->render.PutMonoValues = put_mono_values_ARGB1555;
break;
+ case DSPF_RGB555:
+ data->render.GetRow = get_row_RGB555;
+ data->render.GetValues = get_values_RGB555;
+ data->render.PutRow = put_row_RGB555;
+ data->render.PutRowRGB = put_row_rgb_RGB555;
+ data->render.PutMonoRow = put_mono_row_RGB555;
+ data->render.PutValues = put_values_RGB555;
+ data->render.PutMonoValues = put_mono_values_RGB555;
+ break;
case DSPF_RGB16:
data->render.GetRow = get_row_RGB16;
data->render.GetValues = get_values_RGB16;
return false;
}
+ data->render.Width = data->width;
+ data->render.Height = data->height;
+
_mesa_add_renderbuffer( framebuffer, BUFFER_FRONT_LEFT, &data->render );
_mesa_add_soft_renderbuffers( framebuffer,
directfbgl_destroy_context( GLcontext *context,
GLframebuffer *framebuffer )
{
- _mesa_free_framebuffer_data( framebuffer );
- _mesa_notifyDestroy( context );
+ _swsetup_DestroyContext( context );
+ _swrast_DestroyContext( context );
+ _tnl_DestroyContext( context );
+ _vbo_DestroyContext( context );
+ //_mesa_free_framebuffer_data( framebuffer );
_mesa_free_context_data( context );
}