2004-08-02 21:50:17 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 2002 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
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
|
2008-06-10 04:12:46 +00:00
|
|
|
version 2 of the License, or (at your option) any later version.
|
2007-10-29 23:25:10 +00:00
|
|
|
|
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
|
|
|
*/
|
|
|
|
|
2007-09-04 22:40:43 +00:00
|
|
|
#include "config.h"
|
2007-04-27 12:23:28 +00:00
|
|
|
#include "x11/XGServer.h"
|
|
|
|
#include "x11/XGServerWindow.h"
|
|
|
|
#include "x11/XWindowBuffer.h"
|
2004-08-02 21:50:17 +00:00
|
|
|
#include "cairo/XGCairoXImageSurface.h"
|
2007-10-18 16:51:56 +00:00
|
|
|
#include "cairo/XGCairoSurface.h"
|
2004-08-02 21:50:17 +00:00
|
|
|
|
|
|
|
#define GSWINDEVICE ((gswindow_device_t *)gsDevice)
|
|
|
|
|
|
|
|
@implementation XGCairoXImageSurface
|
|
|
|
|
|
|
|
- (id) initWithDevice: (void *)device
|
|
|
|
{
|
2006-12-26 13:26:40 +00:00
|
|
|
struct XWindowBuffer_depth_info_s di;
|
|
|
|
|
2004-08-02 21:50:17 +00:00
|
|
|
gsDevice = device;
|
2007-10-18 16:51:56 +00:00
|
|
|
if (GSWINDEVICE->type == NSBackingStoreNonretained)
|
|
|
|
{
|
|
|
|
// FIXME: This is a hack to get non-reatined backing store working.
|
|
|
|
// I see no reason, why it isn't working, as the code is identical
|
|
|
|
// to the one in the art backend.
|
|
|
|
RELEASE(self);
|
|
|
|
return [[XGCairoSurface alloc] initWithDevice: device];
|
|
|
|
}
|
2006-12-26 13:26:40 +00:00
|
|
|
|
2007-10-05 14:02:31 +00:00
|
|
|
di.drawing_depth = GSWINDEVICE->depth;
|
2009-03-27 23:16:48 +00:00
|
|
|
// FIXME: The next lines may be wrong for depth <> 32.
|
2007-10-05 14:02:31 +00:00
|
|
|
// But then art uses a depth of 24 for 32 bit modes. Strange!
|
2006-12-26 13:26:40 +00:00
|
|
|
di.bytes_per_pixel = 4;
|
|
|
|
di.inline_alpha = YES;
|
|
|
|
di.inline_alpha_ofs = 0;
|
2010-01-22 08:16:50 +00:00
|
|
|
/* The cairo image surface uses the client's byte order (cf. bug #28590). */
|
2010-01-22 11:47:06 +00:00
|
|
|
#if GS_WORDS_BIGENDIAN
|
|
|
|
di.byte_order = MSBFirst;
|
|
|
|
#else
|
|
|
|
di.byte_order = LSBFirst;
|
|
|
|
#endif
|
2009-03-27 23:16:48 +00:00
|
|
|
|
|
|
|
ASSIGN(wi, [XWindowBuffer windowBufferForWindow: GSWINDEVICE depthInfo: &di]);
|
2006-12-26 13:26:40 +00:00
|
|
|
|
|
|
|
_surface = cairo_image_surface_create_for_data((unsigned char*)wi->data,
|
|
|
|
CAIRO_FORMAT_ARGB32,
|
2007-04-27 12:23:28 +00:00
|
|
|
wi->sx, wi->sy,
|
2006-12-26 13:26:40 +00:00
|
|
|
wi->bytes_per_line);
|
2004-08-02 21:50:17 +00:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
2005-08-28 00:48:12 +00:00
|
|
|
|
2007-04-27 12:23:28 +00:00
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
DESTROY(wi);
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
2004-08-02 21:50:17 +00:00
|
|
|
- (NSSize) size
|
|
|
|
{
|
|
|
|
return GSWINDEVICE->xframe.size;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|