[cairo-commit] cairo/src cairo-beos-surface.cpp,1.4,1.5

Christian Biesinger commit at pdx.freedesktop.org
Mon Dec 26 16:44:43 PST 2005


Committed by: biesi

Update of /cvs/cairo/cairo/src
In directory gabe:/tmp/cvs-serv7997/src

Modified Files:
	cairo-beos-surface.cpp 
Log Message:
2005-12-26  Christian Biesinger  <cbiesinger at web.de>

	* src/cairo-beos-surface.cpp: Don't require that the caller locks
	the view; do it in cairo code.
	* test/cairo-test-beos.cpp: Remove the now-unneeded locking


Index: cairo-beos-surface.cpp
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-beos-surface.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- cairo-beos-surface.cpp	20 Dec 2005 01:16:28 -0000	1.4
+++ cairo-beos-surface.cpp	27 Dec 2005 00:44:41 -0000	1.5
@@ -72,6 +72,26 @@
 
 };
 
+class AutoLockView {
+    public:
+	AutoLockView(BView* view) : mView(view) {
+	    mOK = mView->LockLooper();
+	}
+
+	~AutoLockView() {
+	    if (mOK)
+		mView->UnlockLooper();
+	}
+
+	operator bool() {
+	    return mOK;
+	}
+
+    private:
+	BView* mView;
+	bool   mOK;
+};
+
 static BRect
 _cairo_rect_to_brect (const cairo_rectangle_t* rect)
 {
@@ -404,6 +424,13 @@
     fprintf(stderr, "Getting source image\n");
     cairo_beos_surface_t *surface = reinterpret_cast<cairo_beos_surface_t*>(
 							abstract_surface);
+    AutoLockView locker(surface->view);
+    if (!locker) {
+	_cairo_error(CAIRO_STATUS_NO_MEMORY);
+	return CAIRO_STATUS_NO_MEMORY; /// XXX not exactly right, but what can we do?
+    }
+
+
     surface->view->Sync();
 
     if (surface->bitmap) {
@@ -457,6 +484,13 @@
     cairo_beos_surface_t *surface = reinterpret_cast<cairo_beos_surface_t*>(
 							abstract_surface);
 
+    AutoLockView locker(surface->view);
+    if (!locker) {
+	*image_out = NULL;
+	*image_extra = NULL;
+	return CAIRO_STATUS_SUCCESS;
+    }
+
     if (surface->bitmap) {
 	surface->view->Sync();
 	*image_out = _cairo_beos_bitmap_to_surface(surface->bitmap);
@@ -518,8 +552,13 @@
                                         void                  *image_extra)
 {
     fprintf(stderr, "Fallback drawing\n");
+
     cairo_beos_surface_t *surface = reinterpret_cast<cairo_beos_surface_t*>(
 							abstract_surface);
+    AutoLockView locker(surface->view);
+    if (!locker)
+	return;
+
 
     BBitmap* bitmap_to_draw = _cairo_image_surface_to_bitmap(image);
 
@@ -558,6 +597,10 @@
     if (num_rects <= 0)
 	return CAIRO_INT_STATUS_SUCCESS;
 
+    AutoLockView locker(surface->view);
+    if (!locker)
+	return CAIRO_INT_STATUS_SUCCESS;
+
     drawing_mode mode;
     if (!_cairo_op_to_be_op(op, &mode))
 	return CAIRO_INT_STATUS_UNSUPPORTED;
@@ -570,7 +613,7 @@
     // For CAIRO_OPERATOR_SOURCE, cairo expects us to use the premultiplied
     // color info. This is only relevant when drawing into an rgb24 buffer
     // (as for others, we can convert when asked for the image)
-    if (mode == B_OP_COPY &&
+    if (mode == B_OP_COPY && be_color.alpha != 0xFF &&
 	(!surface->bitmap || surface->bitmap->ColorSpace() != B_RGBA32))
     {
 	be_color.red = premultiply(be_color.red, be_color.alpha);
@@ -605,6 +648,10 @@
     fprintf(stderr, "Setting clip region\n");
     cairo_beos_surface_t *surface = reinterpret_cast<cairo_beos_surface_t*>(
 							abstract_surface);
+    AutoLockView locker(surface->view);
+    if (!locker)
+	return CAIRO_INT_STATUS_SUCCESS;
+
     if (region == NULL) {
 	// No clipping
 	surface->view->ConstrainClippingRegion(NULL);
@@ -629,6 +676,9 @@
 {
     cairo_beos_surface_t *surface = reinterpret_cast<cairo_beos_surface_t*>(
 							abstract_surface);
+    AutoLockView locker(surface->view);
+    if (!locker)
+	return CAIRO_INT_STATUS_UNSUPPORTED;
 
     BRect size = surface->view->Bounds();
 



More information about the cairo-commit mailing list