2
Copyright (C) 2002 Free Software Foundation, Inc.
4
Author: Alexander Malmberg <alexander@malmberg.org>
5
Author: Banlu Kemiyatorn <object at gmail dot com>
7
This file is part of GNUstep.
9
This library is free software; you can redistribute it and/or
10
modify it under the terms of the GNU Library General Public
11
License as published by the Free Software Foundation; either
12
version 2 of the License, or (at your option) any later version.
14
This library is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
Library General Public License for more details.
19
You should have received a copy of the GNU Library General Public
20
License along with this library; if not, write to the Free
21
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24
#include <Foundation/NSUserDefaults.h>
26
#include "cairo/XGCairoGlitzSurface.h"
28
#define GSWINDEVICE ((gswindow_device_t *)gsDevice)
30
@implementation XGCairoGlitzSurface
32
+ (CairoSurface *) createSurfaceForDevice: (void *)device
33
depthInfo: (CairoInfo *)cairoInfo
35
#define NEWGSWINDEVICE ((gswindow_device_t *)device)
36
XGCairoGlitzSurface *surface;
38
surface = [[self alloc] initWithDevice:NEWGSWINDEVICE];
41
NSAssert(NEWGSWINDEVICE->buffer, @"FIXME! CairoSurface: Strange, a window doesn't have buffer");
48
- (NSString *) description
50
return [NSString stringWithFormat: @"<XGCairoSurface %p xr:%p>", self, NULL];
53
- (id) initWithDevice: (void *)device
55
/* FIXME format is ignore when Visual isn't NULL
56
* Cairo may change this API
61
if (GSWINDEVICE->type != NSBackingStoreNonretained)
63
XSetWindowBackgroundPixmap(GSWINDEVICE->display,
72
- (void) setAsTargetOfCairo: (cairo_t *)ct
74
glitz_surface_t *glsurface;
75
glitz_format_t *format;
78
unsigned long format_options = GLITZ_FORMAT_OPTION_ONSCREEN_MASK;
80
format_options |= GLITZ_FORMAT_OPTION_NO_MULTISAMPLE_MASK;
81
format_options |= GLITZ_FORMAT_OPTION_SINGLEBUFFER_MASK;
83
format = glitz_glx_find_standard_format(GSWINDEVICE->display,
86
GLITZ_STANDARD_RGB24);
90
NSLog(@"XGCairoGlitzSurface : %d : no format",__LINE__);
94
vi = glitz_glx_get_visual_info_from_format(GSWINDEVICE->display,
100
NSLog(@"XGCairoGlitzSurface : %d : no visual info",__LINE__);
105
cm = XCreateColormap(GSWINDEVICE->display,
106
GSWINDEVICE->root, vi->visual, AllocNone);
108
XSetWindowColormap(GSWINDEVICE->display,GSWINDEVICE->ident,cm);
111
glsurface = glitz_glx_surface_create(GSWINDEVICE->display,
115
// glitz_surface_update_size(glsurface);
117
cairo_set_target_gl(ct, glsurface);
122
return GSWINDEVICE->xframe.size;