2004-08-02 21:50:17 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 2002 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Author: Alexander Malmberg <alexander@malmberg.org>
|
|
|
|
Author: Banlu Kemiyatorn <object at gmail dot com>
|
|
|
|
|
|
|
|
This file is part of GNUstep.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
2007-10-29 23:25:10 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
2004-08-02 21:50:17 +00:00
|
|
|
License as published by the Free Software Foundation; either
|
2007-10-29 23:25:10 +00:00
|
|
|
version 3 of the License, or (at your option) any later version.
|
|
|
|
|
2004-08-02 21:50:17 +00:00
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2007-10-29 23:25:10 +00:00
|
|
|
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; see the file COPYING.LIB.
|
|
|
|
If not, see <http://www.gnu.org/licenses/> or write to the
|
|
|
|
Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02110-1301, USA.
|
2004-08-02 21:50:17 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "cairo/XGCairoGlitzSurface.h"
|
2006-04-25 22:40:49 +00:00
|
|
|
#include <cairo-glitz.h>
|
|
|
|
#include <glitz-glx.h>
|
2004-08-02 21:50:17 +00:00
|
|
|
|
|
|
|
#define GSWINDEVICE ((gswindow_device_t *)gsDevice)
|
|
|
|
|
|
|
|
@implementation XGCairoGlitzSurface
|
|
|
|
|
|
|
|
- (id) initWithDevice: (void *)device
|
|
|
|
{
|
2006-04-25 22:40:49 +00:00
|
|
|
glitz_drawable_format_t templ;
|
|
|
|
glitz_drawable_format_t *dformat = NULL;
|
|
|
|
glitz_drawable_t *drawable = NULL;
|
|
|
|
glitz_format_t *format = NULL;
|
|
|
|
glitz_surface_t *surface = NULL;
|
|
|
|
|
2004-08-02 21:50:17 +00:00
|
|
|
gsDevice = device;
|
|
|
|
|
|
|
|
/*
|
|
|
|
if (GSWINDEVICE->type != NSBackingStoreNonretained)
|
|
|
|
{
|
|
|
|
XSetWindowBackgroundPixmap(GSWINDEVICE->display,
|
|
|
|
GSWINDEVICE->ident,
|
|
|
|
GSWINDEVICE->buffer);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2006-04-25 22:40:49 +00:00
|
|
|
templ.doublebuffer = 0;
|
2006-09-30 12:21:13 +00:00
|
|
|
dformat = glitz_glx_find_drawable_format_for_visual(GSWINDEVICE->display,
|
|
|
|
GSWINDEVICE->screen,
|
2006-12-19 14:05:58 +00:00
|
|
|
XVisualIDFromVisual(DefaultVisual(GSWINDEVICE->display, GSWINDEVICE->screen)));
|
2004-08-02 21:50:17 +00:00
|
|
|
|
2006-04-25 22:40:49 +00:00
|
|
|
if (!dformat)
|
2004-08-02 21:50:17 +00:00
|
|
|
{
|
|
|
|
NSLog(@"XGCairoGlitzSurface : %d : no format",__LINE__);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2006-04-25 22:40:49 +00:00
|
|
|
drawable = glitz_glx_create_drawable_for_window(GSWINDEVICE->display,
|
|
|
|
GSWINDEVICE->screen,
|
|
|
|
dformat,
|
|
|
|
GSWINDEVICE->ident,
|
|
|
|
GSWINDEVICE->xframe.size.width,
|
|
|
|
GSWINDEVICE->xframe.size.height);
|
|
|
|
if (!drawable)
|
2004-08-02 21:50:17 +00:00
|
|
|
{
|
2006-04-25 22:40:49 +00:00
|
|
|
NSLog(@"XGCairoGlitzSurface : %d : no glitz drawable", __LINE__);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
format = glitz_find_standard_format(drawable, GLITZ_STANDARD_ARGB32);
|
|
|
|
if (!format)
|
|
|
|
{
|
|
|
|
NSLog(@"XGCairoGlitzSurface : %d : couldn't find ARGB32 surface format", __LINE__);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
surface = glitz_surface_create(drawable, format,
|
|
|
|
GSWINDEVICE->xframe.size.width,
|
|
|
|
GSWINDEVICE->xframe.size.height,
|
|
|
|
0, NULL);
|
|
|
|
if (!surface)
|
|
|
|
{
|
|
|
|
NSLog(@"XGCairoGlitzSurface : %d : couldn't create glitz surface", __LINE__);
|
2004-08-02 21:50:17 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2006-09-30 12:21:13 +00:00
|
|
|
glitz_surface_attach(surface, drawable, GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
|
2006-04-25 22:40:49 +00:00
|
|
|
_surface = cairo_glitz_surface_create(surface);
|
2004-08-02 21:50:17 +00:00
|
|
|
|
2005-07-27 23:25:32 +00:00
|
|
|
return self;
|
2004-08-02 21:50:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSSize) size
|
|
|
|
{
|
|
|
|
return GSWINDEVICE->xframe.size;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|