[cairo-commit] cairo/test .cvsignore, 1.61, 1.62 Makefile.am, 1.104, 1.105 cairo-test-beos.cpp, NONE, 1.1 cairo-test-beos.h, NONE, 1.1 cairo-test.c, 1.68, 1.69

Christian Biesinger commit at pdx.freedesktop.org
Sun Dec 18 17:20:09 PST 2005


Committed by: biesi

Update of /cvs/cairo/cairo/test
In directory gabe:/tmp/cvs-serv28271/test

Modified Files:
	.cvsignore Makefile.am cairo-test.c 
Added Files:
	cairo-test-beos.cpp cairo-test-beos.h 
Log Message:
2005-12-19  Christian Biesinger  <cbiesinger at web.de>

  * INSTALL: Mention new --enable-svg option
  * README: Add notes for the new BeOS backend
  * configure.in: Add disabled by default BeOS backend
  * src/Makefile.am: Add BeOS files
  * src/cairo-beos-surface.cpp: New
  * src/cairo-beos.h: New
  * src/cairo-features.h.in: BEOS_SURFACE_FEATURE
  * src/cairoint.h: BeOS mutex functions
  * test/.cvsignore: Ignore files generates by the BeOS tests
  * test/Makefile.am: Add cairo-test-beos.*
  * test/cairo-test-beos.cpp: New. (Must be a C++ file, hence not part of
  cairo-test.c)
  * test/cairo-test-beos.h: New.
  * test/cairo-test.c: (cairo_test_expecting): Test BeOS backend.


Index: .cvsignore
===================================================================
RCS file: /cvs/cairo/cairo/test/.cvsignore,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- .cvsignore	16 Dec 2005 19:31:11 -0000	1.61
+++ .cvsignore	19 Dec 2005 01:20:06 -0000	1.62
@@ -92,6 +92,9 @@
 *-xlib-out.png
 *-xlib-argb32-out.png
 *-xlib-rgb24-out.png
+*-beos-rgb24-out.png
+*-beos_bitmap-rgb24-out.png
+*-beos_bitmap-argb32-out.png
 *-diff.png
 *.gcno
 *.la

Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/cairo/test/Makefile.am,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -d -r1.104 -r1.105
--- Makefile.am	16 Dec 2005 19:31:11 -0000	1.104
+++ Makefile.am	19 Dec 2005 01:20:07 -0000	1.105
@@ -252,6 +252,12 @@
 xmalloc.c		\
 xmalloc.h
 
+if CAIRO_HAS_BEOS_SURFACE
+libcairotest_la_SOURCES += cairo-test-beos.cpp cairo-test-beos.h
+# BeOS system headers trigger this warning
+libcairotest_la_CXXFLAGS = -Wno-multichar
+endif
+
 LDADDS = libcairotest.la $(top_builddir)/src/libcairo.la
 
 if CAIRO_CAN_TEST_GLITZ_AGL_SURFACE

--- NEW FILE: cairo-test-beos.cpp ---
/* vim:set ts=8 sw=4 noet cin: */
/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is Mozilla Communicator client code.
 *
 * The Initial Developer of the Original Code is
 * Netscape Communications Corporation.
 * Portions created by the Initial Developer are Copyright (C) 1998
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *   Takashi Toyoshima <toyoshim at be-in.org>
 *   Fredrik Holmqvist <thesuckiestemail at yahoo.se>
 *   Christian Biesinger <cbiesinger at web.de>
 *
 * Alternatively, the contents of this file may be used under the terms of
 * either of the GNU General Public License Version 2 or later (the "GPL"),
 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 *
 * ***** END LICENSE BLOCK ***** */

// Part of this code was originally part of
// xpfe/bootstrap/nsNativeAppSupportBeOS.cpp in the Mozilla source code.

#include <Application.h>
#include <Window.h>
#include <View.h>
#include <Bitmap.h>

extern "C" {
#include "cairo-test.h"
}

#include "cairo-test-beos.h"
#include "cairo-beos.h"

class CairoTestWindow : public BWindow
{
public:
    CairoTestWindow(BRect frame, const char* title);
    virtual ~CairoTestWindow();
    BView* View() const { return mView; }
private:
    BView* mView;
};

CairoTestWindow::CairoTestWindow(BRect frame, const char* title)
    : BWindow(frame, title, B_TITLED_WINDOW,
	      B_NOT_RESIZABLE|B_NOT_ZOOMABLE)
{
    mView = new BView(frame, "CairoWindowTestView", B_FOLLOW_ALL_SIDES, 0);
    AddChild(mView);
    Show();
}

CairoTestWindow::~CairoTestWindow()
{
    RemoveChild(mView);
    delete mView;
}


class nsBeOSApp : public BApplication
{
public:
    nsBeOSApp(sem_id sem) : BApplication(GetAppSig()), init(sem)
    {}

    void ReadyToRun()
    {
        release_sem(init);
    }

    static int32 Main(void *args)
    {
        nsBeOSApp *app = new nsBeOSApp( (sem_id)args );
        if(app == NULL)
            return B_ERROR;
        return app->Run();
    }

private:

    const char *GetAppSig()
    {
        return "application/x-vnd.cairo-test-app";
    }

    sem_id init;
}; //class nsBeOSApp

class AppRunner
{
    public:
	AppRunner();
	~AppRunner();
};

AppRunner::AppRunner()
{
    if (be_app)
	return;

    sem_id initsem = create_sem(0, "Cairo BApplication init");
    if (initsem < B_OK) {
	cairo_test_log("Error creating BeOS initialization semaphore\n");
        return;
    }

    thread_id tid = spawn_thread(nsBeOSApp::Main, "Cairo/BeOS test", B_NORMAL_PRIORITY, (void *)initsem);
    if (tid < B_OK || B_OK != resume_thread(tid)) {
	cairo_test_log("Error spawning thread\n");
	return;
    }

    if (B_OK != acquire_sem(initsem)) {
	cairo_test_log("Error acquiring semaphore\n");
	return;
    }

    delete_sem(initsem);
    return;
}

AppRunner::~AppRunner()
{
    if (be_app) {
	if (be_app->Lock())
	    be_app->Quit();
	delete be_app;
	be_app = NULL;
    }
}

// Make sure that the BApplication is initialized
static AppRunner sAppRunner;

struct beos_test_closure
{
    BView* view;
    BBitmap* bitmap;
    BWindow* window;
};

// Test a real window
cairo_surface_t *
create_beos_surface (cairo_test_t* test, cairo_format_t format, void **closure)
{
    float right = test->width ? test->width - 1 : 0;
    float bottom = test->height ? test->height - 1 : 0;
    BRect rect(0.0, 0.0, right, bottom);
    CairoTestWindow* wnd = new CairoTestWindow(rect, test->name);
    if (!wnd->View()->LockLooper()) {
	cairo_test_log("Error locking looper\n");
	return NULL;
    }

    beos_test_closure* bclosure = new beos_test_closure;
    bclosure->view = wnd->View();
    bclosure->bitmap = NULL;
    bclosure->window = wnd;

    *closure = bclosure;

    return cairo_beos_surface_create(wnd->View());
}

void
cleanup_beos (void* closure)
{
    beos_test_closure* bclosure = reinterpret_cast<beos_test_closure*>(closure);

    bclosure->window->Quit();

    delete bclosure;
}

// Test a bitmap
cairo_surface_t *
create_beos_bitmap_surface (cairo_test_t* test, cairo_format_t format,
	                    void **closure)
{
    BRect rect(0.0, 0.0, test->width - 1, test->height - 1);
    color_space beosformat = (format == CAIRO_FORMAT_RGB24) ? B_RGB32
							    : B_RGBA32;
    BBitmap* bmp = new BBitmap(rect, beosformat, true);
    BView* view = new BView(rect, "Cairo test view", B_FOLLOW_ALL_SIDES, 0);
    bmp->AddChild(view);

    if (!view->LockLooper()) {
	cairo_test_log("Error locking looper\n");
	return NULL;
    }

    beos_test_closure* bclosure = new beos_test_closure;
    bclosure->view = view;
    bclosure->bitmap = bmp;
    bclosure->window = NULL;
    *closure = bclosure;

    return cairo_beos_surface_create_for_bitmap(view, bmp);
}

void
cleanup_beos_bitmap (void* closure)
{
    beos_test_closure* bclosure = reinterpret_cast<beos_test_closure*>(closure);

    bclosure->view->UnlockLooper();

    bclosure->bitmap->RemoveChild(bclosure->view);


    delete bclosure->view;
    delete bclosure->bitmap;

    delete bclosure;
}



--- NEW FILE: cairo-test-beos.h ---
#ifndef CAIRO_TEST_BEOS_H_
#define CAIRO_TEST_BEOS_H_

/* Two functions: One for a real window, one for a bitmap */

#include <cairo.h>

CAIRO_BEGIN_DECLS

extern cairo_surface_t *
create_beos_surface (cairo_test_t* test, cairo_format_t format,
                     void **closure);

extern void
cleanup_beos (void* closure);

extern cairo_surface_t *
create_beos_bitmap_surface (cairo_test_t* test, cairo_format_t format,
                            void **closure);

extern void
cleanup_beos_bitmap (void* closure);

CAIRO_END_DECLS

#endif

Index: cairo-test.c
===================================================================
RCS file: /cvs/cairo/cairo/test/cairo-test.c,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- cairo-test.c	16 Dec 2005 19:31:11 -0000	1.68
+++ cairo-test.c	19 Dec 2005 01:20:07 -0000	1.69
@@ -992,6 +992,11 @@
 }
 #endif
 
+#if CAIRO_HAS_BEOS_SURFACE
+/* BeOS test functions are external as they need to be C++ */
+#include "cairo-test-beos.h"
+#endif
+
 #if CAIRO_HAS_PS_SURFACE
 #include "cairo-ps.h"
 
@@ -1302,6 +1307,14 @@
 	    { "pdf", CAIRO_FORMAT_RGB24, 
 		create_pdf_surface, pdf_surface_write_to_png, cleanup_pdf },
 #endif
+#if CAIRO_HAS_BEOS_SURFACE
+	    { "beos", CAIRO_FORMAT_RGB24,
+		create_beos_surface, cairo_surface_write_to_png, cleanup_beos},
+	    { "beos_bitmap", CAIRO_FORMAT_RGB24,
+		create_beos_bitmap_surface, cairo_surface_write_to_png, cleanup_beos_bitmap},
+	    { "beos_bitmap", CAIRO_FORMAT_ARGB32,
+		create_beos_bitmap_surface, cairo_surface_write_to_png, cleanup_beos_bitmap},
+#endif
 	};
 
     if ((tname = getenv ("CAIRO_TEST_TARGET")) != NULL) {



More information about the cairo-commit mailing list