[Mesa-dev] [PATCH 2/2] gallium/targets: Break haiku state_tracker out to own directory

Alexander von Gluck IV kallisti5 at unixzen.com
Wed Aug 27 17:31:57 PDT 2014


---
 src/gallium/SConscript                             |    1 +
 src/gallium/state_trackers/hgl/SConscript          |   23 +++
 src/gallium/state_trackers/hgl/bitmap_wrapper.cpp  |  146 +++++++++++++++
 src/gallium/state_trackers/hgl/bitmap_wrapper.h    |   62 +++++++
 src/gallium/state_trackers/hgl/hgl.c               |  169 ++++++++++++++++++
 src/gallium/state_trackers/hgl/hgl_context.h       |   79 ++++++++
 .../targets/haiku-softpipe/GalliumContext.cpp      |   14 +-
 .../targets/haiku-softpipe/GalliumContext.h        |   34 +----
 .../targets/haiku-softpipe/GalliumFramebuffer.cpp  |  188 --------------------
 .../targets/haiku-softpipe/GalliumFramebuffer.h    |   34 ----
 src/gallium/targets/haiku-softpipe/SConscript      |    3 +-
 src/gallium/winsys/sw/hgl/SConscript               |    2 +-
 src/gallium/winsys/sw/hgl/bitmap_wrapper.cpp       |  146 ---------------
 src/gallium/winsys/sw/hgl/bitmap_wrapper.h         |   62 -------
 src/hgl/GLRendererRoster.cpp                       |    2 +-
 15 files changed, 492 insertions(+), 473 deletions(-)
 create mode 100644 src/gallium/state_trackers/hgl/SConscript
 create mode 100644 src/gallium/state_trackers/hgl/bitmap_wrapper.cpp
 create mode 100644 src/gallium/state_trackers/hgl/bitmap_wrapper.h
 create mode 100644 src/gallium/state_trackers/hgl/hgl.c
 create mode 100644 src/gallium/state_trackers/hgl/hgl_context.h
 delete mode 100644 src/gallium/targets/haiku-softpipe/GalliumFramebuffer.cpp
 delete mode 100644 src/gallium/targets/haiku-softpipe/GalliumFramebuffer.h
 delete mode 100644 src/gallium/winsys/sw/hgl/bitmap_wrapper.cpp
 delete mode 100644 src/gallium/winsys/sw/hgl/bitmap_wrapper.h

diff --git a/src/gallium/SConscript b/src/gallium/SConscript
index 98d017e..977e3fb 100644
--- a/src/gallium/SConscript
+++ b/src/gallium/SConscript
@@ -85,6 +85,7 @@ if not env['embedded']:
 
     if env['platform'] == 'haiku':
         SConscript([
+            'state_trackers/hgl/SConscript',
             'targets/haiku-softpipe/SConscript',
         ])
 
diff --git a/src/gallium/state_trackers/hgl/SConscript b/src/gallium/state_trackers/hgl/SConscript
new file mode 100644
index 0000000..05b8214
--- /dev/null
+++ b/src/gallium/state_trackers/hgl/SConscript
@@ -0,0 +1,23 @@
+#######################################################################
+# SConscript for Haiku state_tracker
+
+Import('*')
+
+env = env.Clone()
+
+env.Append(CPPPATH = [
+    '#/src',
+    '#/src/mapi',
+    '#/src/mesa',
+])
+
+sources = [
+    'hgl.c',
+	'bitmap_wrapper.cpp',
+]
+
+st_haiku = env.ConvenienceLibrary(
+    target = 'st_haiku',
+    source = sources
+)
+Export('st_haiku')
diff --git a/src/gallium/state_trackers/hgl/bitmap_wrapper.cpp b/src/gallium/state_trackers/hgl/bitmap_wrapper.cpp
new file mode 100644
index 0000000..ef81edc
--- /dev/null
+++ b/src/gallium/state_trackers/hgl/bitmap_wrapper.cpp
@@ -0,0 +1,146 @@
+/**************************************************************************
+ *
+ * Copyright 2009 Artur Wyszynski <harakash at gmail.com>
+ * Copyright 2013 Alexander von Gluck IV <kallisti5 at unixzen.com>
+ *
+ * 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 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
+ * THE COPYRIGHT HOLDERS, AUTHORS 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.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ **************************************************************************/
+
+
+#include <stdio.h>
+#include <interface/Bitmap.h>
+#include <storage/File.h>
+#include <support/String.h>
+#include <translation/BitmapStream.h>
+#include <translation/TranslatorRoster.h>
+
+#include "bitmap_wrapper.h"
+
+
+extern "C" {
+static int frameNo = 0;
+
+
+Bitmap*
+create_bitmap(int32 width, int32 height, color_space colorSpace)
+{
+	BBitmap *bb = new BBitmap(BRect(0, 0, width, height), colorSpace);
+	if (bb)
+		return (Bitmap*)bb;
+	return NULL;
+}
+
+
+void
+get_bitmap_size(const Bitmap* bitmap, int32* width, int32* height)
+{
+	BBitmap *bb = (BBitmap*)bitmap;
+	if (bb && width && height) {
+		uint32 w = bb->Bounds().IntegerWidth() + 1;
+		uint32 h = bb->Bounds().IntegerHeight() + 1;
+		*width = w;
+		*height = h;
+	}
+}
+
+
+color_space
+get_bitmap_color_space(const Bitmap* bitmap)
+{
+	BBitmap *bb = (BBitmap*)bitmap;
+	if (bb)
+		return bb->ColorSpace();
+	return B_NO_COLOR_SPACE;
+}
+
+
+void
+copy_bitmap_bits(const Bitmap* bitmap, void* data, int32 length)
+{
+	BBitmap *bb = (BBitmap*)bitmap;
+
+	// We assume the data is 1:1 the format of the bitmap
+	if (bb)
+		bb->ImportBits(data, length, bb->BytesPerRow(), 0, bb->ColorSpace());
+}
+
+
+void
+import_bitmap_bits(const Bitmap* bitmap, void* data, int32 length,
+	unsigned srcStride, color_space srcColorSpace)
+{
+	BBitmap *bb = (BBitmap*)bitmap;
+
+	// Import image and adjust image format from source to dest
+	if (bb)
+		bb->ImportBits(data, length, srcStride, 0, srcColorSpace);
+}
+
+
+void
+delete_bitmap(Bitmap* bitmap)
+{
+	BBitmap *bb = (BBitmap*)bitmap;
+	delete bb;
+}
+
+
+int32
+get_bitmap_bytes_per_row(const Bitmap* bitmap)
+{
+	BBitmap *bb = (BBitmap*)bitmap;
+	if (bb)
+		return bb->BytesPerRow();
+	return 0;
+}
+
+
+int32
+get_bitmap_bits_length(const Bitmap* bitmap)
+{
+	BBitmap *bb = (BBitmap*)bitmap;
+	if (bb)
+		return bb->BitsLength();
+	return 0;
+}
+
+
+void
+dump_bitmap(const Bitmap* bitmap)
+{
+	BBitmap *bb = (BBitmap*)bitmap;
+	if (!bb)
+		return;
+
+	BString filename("/boot/home/frame_");
+	filename << (int32)frameNo << ".png";
+
+	BTranslatorRoster *roster = BTranslatorRoster::Default();
+	BBitmapStream stream(bb);
+	BFile dump(filename, B_CREATE_FILE | B_WRITE_ONLY);
+
+	roster->Translate(&stream, NULL, NULL, &dump, 0);
+
+	frameNo++;
+}
+
+}
diff --git a/src/gallium/state_trackers/hgl/bitmap_wrapper.h b/src/gallium/state_trackers/hgl/bitmap_wrapper.h
new file mode 100644
index 0000000..65ba140
--- /dev/null
+++ b/src/gallium/state_trackers/hgl/bitmap_wrapper.h
@@ -0,0 +1,62 @@
+/**************************************************************************
+ *
+ * Copyright 2009 Artur Wyszynski <harakash at gmail.com>
+ * Copyright 2013 Alexander von Gluck IV <kallisti5 at unixzen.com>
+ *
+ * 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 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
+ * THE COPYRIGHT HOLDERS, AUTHORS 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.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ **************************************************************************/
+#ifndef __BBITMAP_WRAPPER_H__
+#define __BBITMAP_WRAPPER_H__
+
+
+#include <interface/GraphicsDefs.h>
+#include <support/SupportDefs.h>
+
+
+typedef void Bitmap;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+Bitmap* create_bitmap(int32 width, int32 height, color_space colorSpace);
+void delete_bitmap(Bitmap* bitmap);
+
+void copy_bitmap_bits(const Bitmap* bitmap, void* data, int32 length);
+void import_bitmap_bits(const Bitmap* bitmap, void* data, int32 length,
+	unsigned srcStride, color_space srcColorSpace);
+
+void get_bitmap_size(const Bitmap* bitmap, int32* width, int32* height);
+color_space get_bitmap_color_space(const Bitmap* bitmap);
+int32 get_bitmap_bytes_per_row(const Bitmap* bitmap);
+int32 get_bitmap_bits_length(const Bitmap* bitmap);
+
+void dump_bitmap(const Bitmap* bitmap);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __BBITMAP_WRAPPER_H__ */
diff --git a/src/gallium/state_trackers/hgl/hgl.c b/src/gallium/state_trackers/hgl/hgl.c
new file mode 100644
index 0000000..1d6fa73
--- /dev/null
+++ b/src/gallium/state_trackers/hgl/hgl.c
@@ -0,0 +1,169 @@
+/*
+ * Copyright 2012-2013, Haiku, Inc. All Rights Reserved.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ *      Artur Wyszynski, harakash at gmail.com
+ *      Alexander von Gluck IV, kallisti5 at unixzen.com
+ */
+
+
+#include "main/context.h"
+#include "main/framebuffer.h"
+#include "main/renderbuffer.h"
+#include "pipe/p_format.h"
+#include "util/u_atomic.h"
+#include "util/u_memory.h"
+
+#include "hgl_context.h"
+
+
+#ifdef DEBUG
+#   define TRACE(x...) printf("hgl:state_tracker: " x)
+#   define CALLED() TRACE("CALLED: %s\n", __PRETTY_FUNCTION__)
+#else
+#   define TRACE(x...)
+#   define CALLED()
+#endif
+#define ERROR(x...) printf("hgl:state_tracker: " x)
+
+
+static boolean
+hgl_st_framebuffer_flush_front(struct st_context_iface *stctx,
+	struct st_framebuffer_iface* stfb, enum st_attachment_type statt)
+{
+	CALLED();
+
+	struct hgl_context* context = (struct hgl_context*)stfb->st_manager_private;
+
+	if (!context) {
+		ERROR("%s: Couldn't obtain valid hgl_context!\n", __func__);
+		return FALSE;
+	}
+
+	#if 0
+	struct stw_st_framebuffer *stwfb = stw_st_framebuffer(stfb);
+	pipe_mutex_lock(stwfb->fb->mutex);
+
+	struct pipe_resource* resource = textures[statt];
+	if (resource)
+		stw_framebuffer_present_locked(...);
+	#endif
+
+	return TRUE;
+}
+
+
+/**
+ * Called by the st manager to validate the framebuffer (allocate
+ * its resources).
+ */
+static boolean
+hgl_st_framebuffer_validate(struct st_context_iface *stctx,
+	struct st_framebuffer_iface *stfbi, const enum st_attachment_type *statts,
+	unsigned count, struct pipe_resource **out)
+{
+	CALLED();
+
+	if (!stfbi) {
+		ERROR("%s: Invalid st framebuffer interface!\n", __func__);
+		return FALSE;
+	}
+
+	struct hgl_context* context = (struct hgl_context*)stfbi->st_manager_private;
+
+	if (!context) {
+		ERROR("%s: Couldn't obtain valid hgl_context!\n", __func__);
+		return FALSE;
+	}
+
+	int32 width = 0;
+	int32 height = 0;
+	get_bitmap_size(context->bitmap, &width, &height);
+
+	struct pipe_resource templat;
+	memset(&templat, 0, sizeof(templat));
+	templat.target = PIPE_TEXTURE_RECT;
+	templat.width0 = width;
+	templat.height0 = height;
+	templat.depth0 = 1;
+	templat.array_size = 1;
+	templat.usage = PIPE_USAGE_DEFAULT;
+
+	if (context->stVisual && context->manager && context->manager->screen) {
+		TRACE("%s: Updating resources\n", __func__);
+		for (unsigned i = 0; i < count; i++) {
+			enum pipe_format format = PIPE_FORMAT_NONE;
+			unsigned bind = 0;
+	
+			switch(statts[i]) {
+				case ST_ATTACHMENT_FRONT_LEFT:
+				case ST_ATTACHMENT_BACK_LEFT:
+					format = context->stVisual->color_format;
+					bind = PIPE_BIND_DISPLAY_TARGET
+						| PIPE_BIND_RENDER_TARGET;
+					break;
+				case ST_ATTACHMENT_DEPTH_STENCIL:
+					format = context->stVisual->depth_stencil_format;
+					bind = PIPE_BIND_DEPTH_STENCIL;
+					break;
+				case ST_ATTACHMENT_ACCUM:
+					format = context->stVisual->accum_format;
+					bind = PIPE_BIND_RENDER_TARGET;
+					break;
+				default:
+					format = PIPE_FORMAT_NONE;
+					break;
+			}
+
+			if (format != PIPE_FORMAT_NONE) {
+				templat.format = format;
+				templat.bind = bind;
+
+				struct pipe_screen* screen = context->manager->screen;
+				context->textures[i] = screen->resource_create(screen, &templat);
+				out[i] = context->textures[i];
+			}
+		}
+	}
+
+	return TRUE;
+}
+
+
+/**
+ * Create new framebuffer
+ */
+struct hgl_buffer *
+hgl_create_st_framebuffer(struct hgl_context* context)
+{
+	CALLED();
+
+	struct hgl_buffer *buffer = CALLOC_STRUCT(hgl_buffer);
+
+	assert(context);
+	assert(context->stVisual);
+
+	if (buffer) {
+		// Copy context visual into framebuffer
+		memcpy(&buffer->visual, context->stVisual, sizeof(struct st_visual));
+
+		// calloc our st_framebuffer interface
+		buffer->stfbi = CALLOC_STRUCT(st_framebuffer_iface);
+		if (!buffer->stfbi) {
+			ERROR("%s: Couldn't calloc framebuffer!\n", __func__);
+			return NULL;
+		}
+
+		struct st_framebuffer_iface* stfbi = buffer->stfbi;
+		p_atomic_set(&stfbi->stamp, 1);
+		stfbi->flush_front = hgl_st_framebuffer_flush_front;
+		stfbi->validate = hgl_st_framebuffer_validate;
+		stfbi->st_manager_private = (void*)context;
+		stfbi->visual = &buffer->visual;
+
+		// TODO: Do we need linked list?
+	}
+
+   return buffer;
+}
diff --git a/src/gallium/state_trackers/hgl/hgl_context.h b/src/gallium/state_trackers/hgl/hgl_context.h
new file mode 100644
index 0000000..f1f43fa
--- /dev/null
+++ b/src/gallium/state_trackers/hgl/hgl_context.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2009-2014, Haiku, Inc. All Rights Reserved.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ *		Alexander von Gluck IV, kallisti5 at unixzen.com
+ */
+#ifndef HGL_CONTEXT_H
+#define HGL_CONTEXT_H
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include "state_tracker/st_api.h"
+#include "state_tracker/st_manager.h"
+#include "pipe/p_compiler.h"
+#include "pipe/p_screen.h"
+#include "postprocess/filters.h"
+#include "os/os_thread.h"
+
+#include "bitmap_wrapper.h"
+#ifdef __cplusplus
+}
+#endif
+
+
+#define CONTEXT_MAX 32
+
+typedef int64 context_id;
+
+
+struct hgl_buffer
+{
+	struct st_framebuffer_iface *stfbi;
+	struct st_visual* visual;
+
+	unsigned width;
+	unsigned height;
+
+	struct pipe_resource* textures[ST_ATTACHMENT_COUNT];
+
+	void *map;
+
+	//struct hgl_buffer *next;  /**< next in linked list */
+};
+
+
+struct hgl_context
+{
+	struct st_api* api;
+		// State Tracker API
+	struct st_manager* manager;
+		// State Tracker Manager
+	struct st_context_iface* st;
+		// State Tracker Interface Object
+	struct st_visual* stVisual;
+		// State Tracker Visual
+
+	struct pipe_resource* textures[ST_ATTACHMENT_COUNT];
+
+	// Post processing
+	struct pp_queue_t* postProcess;
+	unsigned int postProcessEnable[PP_FILTERS];
+
+	Bitmap* bitmap;
+	color_space colorSpace;
+
+	pipe_mutex fbMutex;
+
+	struct hgl_buffer* draw;
+	struct hgl_buffer* read;
+};
+
+
+struct hgl_buffer* hgl_create_st_framebuffer(struct hgl_context* context);
+
+
+#endif /* HGL_CONTEXT_H */
diff --git a/src/gallium/targets/haiku-softpipe/GalliumContext.cpp b/src/gallium/targets/haiku-softpipe/GalliumContext.cpp
index 7b13260..c740458 100644
--- a/src/gallium/targets/haiku-softpipe/GalliumContext.cpp
+++ b/src/gallium/targets/haiku-softpipe/GalliumContext.cpp
@@ -278,8 +278,8 @@ GalliumContext::CreateContext(Bitmap *bitmap)
 		return -1;
 	}
 
-	context->draw = new GalliumFramebuffer(context->stVisual, (void*)this);
-	context->read = new GalliumFramebuffer(context->stVisual, (void*)this);
+	context->draw = hgl_create_st_framebuffer(context);
+	context->read = hgl_create_st_framebuffer(context);
 
 	if (!context->draw || !context->read) {
 		ERROR("%s: Problem allocating framebuffer!\n", __func__);
@@ -448,12 +448,8 @@ GalliumContext::SetCurrentContext(Bitmap *bitmap, context_id contextID)
 	}
 
 	// We need to lock and unlock framebuffers before accessing them
-	context->draw->Lock();
-	context->read->Lock();
-	api->make_current(context->api, context->st, context->draw->fBuffer,
-		context->read->fBuffer);
-	context->draw->Unlock();
-	context->read->Unlock();
+	api->make_current(context->api, context->st, context->draw->stfbi,
+		context->read->stfbi);
 
 	if (context->textures[ST_ATTACHMENT_BACK_LEFT]
 		&& context->textures[ST_ATTACHMENT_DEPTH_STENCIL]
@@ -486,7 +482,7 @@ GalliumContext::SwapBuffers(context_id contextID)
 	}
 
 	// TODO: Where did st_notify_swapbuffers go?
-	//st_notify_swapbuffers(context->draw->stfb);
+	//st_notify_swapbuffers(context->draw->stfbi);
 
 	context->st->flush(context->st, ST_FLUSH_FRONT, NULL);
 
diff --git a/src/gallium/targets/haiku-softpipe/GalliumContext.h b/src/gallium/targets/haiku-softpipe/GalliumContext.h
index 6c11c0f..cf8895e 100644
--- a/src/gallium/targets/haiku-softpipe/GalliumContext.h
+++ b/src/gallium/targets/haiku-softpipe/GalliumContext.h
@@ -13,44 +13,16 @@
 #include <kernel/image.h>
 
 extern "C" {
-#include "state_tracker/st_api.h"
+//#include "state_tracker/st_api.h"
 #include "pipe/p_compiler.h"
 #include "pipe/p_screen.h"
 #include "postprocess/filters.h"
 #include "os/os_thread.h"
+#include "hgl_context.h"
 }
-#include "bitmap_wrapper.h"
-#include "GalliumFramebuffer.h"
-
-
-#define CONTEXT_MAX 32
-
-
-typedef int64 context_id;
 
-struct hgl_context
-{
-	struct st_api* api;
-		// State Tracker API
-	struct st_manager* manager;
-		// State Tracker Manager
-	struct st_context_iface* st;
-		// State Tracker Interface Object
-	struct st_visual* stVisual;
-		// State Tracker Visual
-
-	struct pipe_resource* textures[ST_ATTACHMENT_COUNT];
-
-	// Post processing
-	struct pp_queue_t* postProcess;
-	unsigned int postProcessEnable[PP_FILTERS];
-
-	Bitmap* bitmap;
-	color_space colorSpace;
+#include "bitmap_wrapper.h"
 
-	GalliumFramebuffer* draw;
-	GalliumFramebuffer* read;
-};
 
 
 class GalliumContext {
diff --git a/src/gallium/targets/haiku-softpipe/GalliumFramebuffer.cpp b/src/gallium/targets/haiku-softpipe/GalliumFramebuffer.cpp
deleted file mode 100644
index d6bfdb4..0000000
--- a/src/gallium/targets/haiku-softpipe/GalliumFramebuffer.cpp
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Copyright 2012-2013, Haiku, Inc. All Rights Reserved.
- * Distributed under the terms of the MIT License.
- *
- * Authors:
- *      Artur Wyszynski, harakash at gmail.com
- *      Alexander von Gluck IV, kallisti5 at unixzen.com
- */
-
-
-#include "GalliumFramebuffer.h"
-
-extern "C" {
-#include "main/context.h"
-#include "main/framebuffer.h"
-#include "main/renderbuffer.h"
-#include "pipe/p_format.h"
-#include "state_tracker/st_manager.h"
-#include "util/u_memory.h"
-}
-
-#include "GalliumContext.h"
-
-
-#ifdef DEBUG
-#   define TRACE(x...) printf("GalliumFramebuffer: " x)
-#   define CALLED() TRACE("CALLED: %s\n", __PRETTY_FUNCTION__)
-#else
-#   define TRACE(x...)
-#   define CALLED()
-#endif
-#define ERROR(x...) printf("GalliumFramebuffer: " x)
-
-
-static boolean
-hgl_framebuffer_flush_front(struct st_context_iface *stctx,
-	struct st_framebuffer_iface* stfb, enum st_attachment_type statt)
-{
-	CALLED();
-
-	hgl_context* context = (hgl_context*)stfb->st_manager_private;
-
-	if (!context) {
-		ERROR("%s: Couldn't obtain valid hgl_context!\n", __func__);
-		return FALSE;
-	}
-
-	#if 0
-	struct stw_st_framebuffer *stwfb = stw_st_framebuffer(stfb);
-	pipe_mutex_lock(stwfb->fb->mutex);
-
-	struct pipe_resource* resource = textures[statt];
-	if (resource)
-		stw_framebuffer_present_locked(...);
-	#endif
-
-	return TRUE;
-}
-
-
-static boolean
-hgl_framebuffer_validate(struct st_context_iface* stctx,
-	struct st_framebuffer_iface* stfb,
-	const enum st_attachment_type* statts, unsigned count,
-	struct pipe_resource** out)
-{
-	CALLED();
-
-	if (!stfb) {
-		ERROR("%s: Invalid st framebuffer interface!\n", __func__);
-		return FALSE;
-	}
-
-	hgl_context* context = (hgl_context*)stfb->st_manager_private;
-
-	if (!context) {
-		ERROR("%s: Couldn't obtain valid hgl_context!\n", __func__);
-		return FALSE;
-	}
-
-	int32 width = 0;
-	int32 height = 0;
-	get_bitmap_size(context->bitmap, &width, &height);
-
-	struct pipe_resource templat;
-	memset(&templat, 0, sizeof(templat));
-	templat.target = PIPE_TEXTURE_RECT;
-	templat.width0 = width;
-	templat.height0 = height;
-	templat.depth0 = 1;
-	templat.array_size = 1;
-	templat.usage = PIPE_USAGE_DEFAULT;
-
-	if (context->stVisual && context->manager && context->manager->screen) {
-		TRACE("%s: Updating resources\n", __func__);
-		unsigned i;
-		for (i = 0; i < count; i++) {
-			enum pipe_format format = PIPE_FORMAT_NONE;
-			unsigned bind = 0;
-	
-			switch(statts[i]) {
-				case ST_ATTACHMENT_FRONT_LEFT:
-				case ST_ATTACHMENT_BACK_LEFT:
-					format = context->stVisual->color_format;
-					bind = PIPE_BIND_DISPLAY_TARGET
-						| PIPE_BIND_RENDER_TARGET;
-					break;
-				case ST_ATTACHMENT_DEPTH_STENCIL:
-					format = context->stVisual->depth_stencil_format;
-					bind = PIPE_BIND_DEPTH_STENCIL;
-					break;
-				case ST_ATTACHMENT_ACCUM:
-					format = context->stVisual->accum_format;
-					bind = PIPE_BIND_RENDER_TARGET;
-					break;
-				default:
-					format = PIPE_FORMAT_NONE;
-					break;
-			}
-
-			if (format != PIPE_FORMAT_NONE) {
-				templat.format = format;
-				templat.bind = bind;
-
-				struct pipe_screen* screen = context->manager->screen;
-				context->textures[i] = screen->resource_create(screen, &templat);
-				out[i] = context->textures[i];
-			}
-		}
-	}
-
-	return TRUE;
-}
-
-
-GalliumFramebuffer::GalliumFramebuffer(struct st_visual* visual,
-	void* privateContext)
-	:
-	fBuffer(NULL)
-{
-	CALLED();
-	fBuffer = CALLOC_STRUCT(st_framebuffer_iface);
-	if (!fBuffer) {
-		ERROR("%s: Couldn't calloc framebuffer!\n", __func__);
-		return;
-	}
-	fBuffer->visual = visual;
-	fBuffer->flush_front = hgl_framebuffer_flush_front;
-	fBuffer->validate = hgl_framebuffer_validate;
-	fBuffer->st_manager_private = privateContext;
-
-	pipe_mutex_init(fMutex);
-}
-
-
-GalliumFramebuffer::~GalliumFramebuffer()
-{
-	CALLED();
-	// We lock and unlock to try and make sure we wait for anything
-	// using the framebuffer to finish
-	Lock();
-	if (!fBuffer) {
-		ERROR("%s: Strange, no Gallium Framebuffer to free?\n", __func__);
-		return;
-	}
-	FREE(fBuffer);
-	Unlock();
-
-	pipe_mutex_destroy(fMutex);
-}
-
-
-status_t
-GalliumFramebuffer::Lock()
-{
-	CALLED();
-	pipe_mutex_lock(fMutex);
-	return B_OK;
-}
-
-
-status_t
-GalliumFramebuffer::Unlock()
-{
-	CALLED();
-	pipe_mutex_unlock(fMutex);
-	return B_OK;
-}
diff --git a/src/gallium/targets/haiku-softpipe/GalliumFramebuffer.h b/src/gallium/targets/haiku-softpipe/GalliumFramebuffer.h
deleted file mode 100644
index 11e6b73..0000000
--- a/src/gallium/targets/haiku-softpipe/GalliumFramebuffer.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2012, Haiku, Inc. All Rights Reserved.
- * Distributed under the terms of the MIT License.
- *
- * Authors:
- *      Alexander von Gluck IV, kallisti5 at unixzen.com
- */
-#ifndef GALLIUMFRAMEBUFFER_H
-#define GALLIUMFRAMEBUFFER_H
-
-
-extern "C" {
-#include "os/os_thread.h"
-#include "pipe/p_screen.h"
-#include "state_tracker/st_api.h"
-}
-
-
-class GalliumFramebuffer {
-public:
-							GalliumFramebuffer(struct st_visual* visual,
-								void* privateContext);
-							~GalliumFramebuffer();
-		status_t			Lock();
-		status_t			Unlock();
-
-		struct st_framebuffer_iface* fBuffer;
-
-private:
-		pipe_mutex			fMutex;
-};
-
-
-#endif /* GALLIUMFRAMEBUFFER_H */
diff --git a/src/gallium/targets/haiku-softpipe/SConscript b/src/gallium/targets/haiku-softpipe/SConscript
index c730fde..d89a2af 100644
--- a/src/gallium/targets/haiku-softpipe/SConscript
+++ b/src/gallium/targets/haiku-softpipe/SConscript
@@ -2,6 +2,7 @@ Import('*')
 
 env.Prepend(LIBS = [
     ws_haiku,
+	st_haiku,
     trace,
     rbug,
     mesautil,
@@ -26,6 +27,7 @@ env.Append(CPPPATH = [
     '#/src/mesa/main',
     '#/include/HaikuGL',
     '#/src/gallium/winsys/sw/hgl',
+    '#/src/gallium/state_trackers/hgl',
     '/boot/system/develop/headers/private',
 ])
 
@@ -35,7 +37,6 @@ if env['llvm']:
 
 softpipe_sources = [
     'GalliumContext.cpp',
-    'GalliumFramebuffer.cpp',
     'SoftwareRenderer.cpp'
 ]
 
diff --git a/src/gallium/winsys/sw/hgl/SConscript b/src/gallium/winsys/sw/hgl/SConscript
index 44080a6..7755b00 100644
--- a/src/gallium/winsys/sw/hgl/SConscript
+++ b/src/gallium/winsys/sw/hgl/SConscript
@@ -12,13 +12,13 @@ if env['platform'] in ('haiku'):
         '#/src/gallium/include',
         '#/src/gallium/auxiliary',
         '#/src/gallium/drivers',
+        '#/src/gallium/state_trackers/hgl',
     ])
 
     ws_haiku = env.ConvenienceLibrary(
         target = 'ws_haiku',
         source = [
            'hgl_sw_winsys.c',
-           'bitmap_wrapper.cpp',
         ]
     )
     Export('ws_haiku')
diff --git a/src/gallium/winsys/sw/hgl/bitmap_wrapper.cpp b/src/gallium/winsys/sw/hgl/bitmap_wrapper.cpp
deleted file mode 100644
index ef81edc..0000000
--- a/src/gallium/winsys/sw/hgl/bitmap_wrapper.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Artur Wyszynski <harakash at gmail.com>
- * Copyright 2013 Alexander von Gluck IV <kallisti5 at unixzen.com>
- *
- * 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 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
- * THE COPYRIGHT HOLDERS, AUTHORS 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.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- **************************************************************************/
-
-
-#include <stdio.h>
-#include <interface/Bitmap.h>
-#include <storage/File.h>
-#include <support/String.h>
-#include <translation/BitmapStream.h>
-#include <translation/TranslatorRoster.h>
-
-#include "bitmap_wrapper.h"
-
-
-extern "C" {
-static int frameNo = 0;
-
-
-Bitmap*
-create_bitmap(int32 width, int32 height, color_space colorSpace)
-{
-	BBitmap *bb = new BBitmap(BRect(0, 0, width, height), colorSpace);
-	if (bb)
-		return (Bitmap*)bb;
-	return NULL;
-}
-
-
-void
-get_bitmap_size(const Bitmap* bitmap, int32* width, int32* height)
-{
-	BBitmap *bb = (BBitmap*)bitmap;
-	if (bb && width && height) {
-		uint32 w = bb->Bounds().IntegerWidth() + 1;
-		uint32 h = bb->Bounds().IntegerHeight() + 1;
-		*width = w;
-		*height = h;
-	}
-}
-
-
-color_space
-get_bitmap_color_space(const Bitmap* bitmap)
-{
-	BBitmap *bb = (BBitmap*)bitmap;
-	if (bb)
-		return bb->ColorSpace();
-	return B_NO_COLOR_SPACE;
-}
-
-
-void
-copy_bitmap_bits(const Bitmap* bitmap, void* data, int32 length)
-{
-	BBitmap *bb = (BBitmap*)bitmap;
-
-	// We assume the data is 1:1 the format of the bitmap
-	if (bb)
-		bb->ImportBits(data, length, bb->BytesPerRow(), 0, bb->ColorSpace());
-}
-
-
-void
-import_bitmap_bits(const Bitmap* bitmap, void* data, int32 length,
-	unsigned srcStride, color_space srcColorSpace)
-{
-	BBitmap *bb = (BBitmap*)bitmap;
-
-	// Import image and adjust image format from source to dest
-	if (bb)
-		bb->ImportBits(data, length, srcStride, 0, srcColorSpace);
-}
-
-
-void
-delete_bitmap(Bitmap* bitmap)
-{
-	BBitmap *bb = (BBitmap*)bitmap;
-	delete bb;
-}
-
-
-int32
-get_bitmap_bytes_per_row(const Bitmap* bitmap)
-{
-	BBitmap *bb = (BBitmap*)bitmap;
-	if (bb)
-		return bb->BytesPerRow();
-	return 0;
-}
-
-
-int32
-get_bitmap_bits_length(const Bitmap* bitmap)
-{
-	BBitmap *bb = (BBitmap*)bitmap;
-	if (bb)
-		return bb->BitsLength();
-	return 0;
-}
-
-
-void
-dump_bitmap(const Bitmap* bitmap)
-{
-	BBitmap *bb = (BBitmap*)bitmap;
-	if (!bb)
-		return;
-
-	BString filename("/boot/home/frame_");
-	filename << (int32)frameNo << ".png";
-
-	BTranslatorRoster *roster = BTranslatorRoster::Default();
-	BBitmapStream stream(bb);
-	BFile dump(filename, B_CREATE_FILE | B_WRITE_ONLY);
-
-	roster->Translate(&stream, NULL, NULL, &dump, 0);
-
-	frameNo++;
-}
-
-}
diff --git a/src/gallium/winsys/sw/hgl/bitmap_wrapper.h b/src/gallium/winsys/sw/hgl/bitmap_wrapper.h
deleted file mode 100644
index 65ba140..0000000
--- a/src/gallium/winsys/sw/hgl/bitmap_wrapper.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Artur Wyszynski <harakash at gmail.com>
- * Copyright 2013 Alexander von Gluck IV <kallisti5 at unixzen.com>
- *
- * 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 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
- * THE COPYRIGHT HOLDERS, AUTHORS 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.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- **************************************************************************/
-#ifndef __BBITMAP_WRAPPER_H__
-#define __BBITMAP_WRAPPER_H__
-
-
-#include <interface/GraphicsDefs.h>
-#include <support/SupportDefs.h>
-
-
-typedef void Bitmap;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-Bitmap* create_bitmap(int32 width, int32 height, color_space colorSpace);
-void delete_bitmap(Bitmap* bitmap);
-
-void copy_bitmap_bits(const Bitmap* bitmap, void* data, int32 length);
-void import_bitmap_bits(const Bitmap* bitmap, void* data, int32 length,
-	unsigned srcStride, color_space srcColorSpace);
-
-void get_bitmap_size(const Bitmap* bitmap, int32* width, int32* height);
-color_space get_bitmap_color_space(const Bitmap* bitmap);
-int32 get_bitmap_bytes_per_row(const Bitmap* bitmap);
-int32 get_bitmap_bits_length(const Bitmap* bitmap);
-
-void dump_bitmap(const Bitmap* bitmap);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* __BBITMAP_WRAPPER_H__ */
diff --git a/src/hgl/GLRendererRoster.cpp b/src/hgl/GLRendererRoster.cpp
index 1712a87..d29f7ec 100644
--- a/src/hgl/GLRendererRoster.cpp
+++ b/src/hgl/GLRendererRoster.cpp
@@ -17,7 +17,7 @@
 #include <Directory.h>
 #include <FindDirectory.h>
 #include <Path.h>
-#include <String.h>
+#include <strings.h>
 #include "GLDispatcher.h"
 #include "GLRendererRoster.h"
 
-- 
1.7.1



More information about the mesa-dev mailing list