blob: 1cb87f502d6c6c107934d95e672964f07044285f [file] [log] [blame]
Pierre Ossman403ac272017-01-02 17:00:41 +01001/* Copyright 2016 Pierre Ossman for Cendio AB
2 *
3 * This is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This software is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
17 */
18
19#ifndef __SURFACE_H__
20#define __SURFACE_H__
21
22#if defined(WIN32)
23#include <windows.h>
24#elif defined(__APPLE__)
25// Apple headers conflict with FLTK, so redefine types here
26typedef struct CGImage* CGImageRef;
27#else
28#include <X11/extensions/Xrender.h>
29#endif
30
31class Fl_RGB_Image;
32
33class Surface {
34public:
35 Surface(int width, int height);
36 Surface(const Fl_RGB_Image* image);
37 ~Surface();
38
39 int width() { return w; }
40 int height() { return h; }
41
42 void clear(unsigned char r, unsigned char g, unsigned char b, unsigned char a=255);
43
44 void draw(int src_x, int src_y, int x, int y, int w, int h);
Pierre Ossman3d74d882017-01-02 19:49:52 +010045 void draw(Surface* dst, int src_x, int src_y, int x, int y, int w, int h);
Pierre Ossman403ac272017-01-02 17:00:41 +010046
Pierre Ossman455566e2017-02-10 16:37:52 +010047 void blend(int src_x, int src_y, int x, int y, int w, int h, int a=255);
48 void blend(Surface* dst, int src_x, int src_y, int x, int y, int w, int h, int a=255);
Pierre Ossmande6a5802017-01-02 20:07:10 +010049
Pierre Ossman403ac272017-01-02 17:00:41 +010050protected:
51 void alloc();
52 void dealloc();
53 void update(const Fl_RGB_Image* image);
54
55protected:
56 int w, h;
57
58#if defined(WIN32)
59 RGBQUAD* data;
60 HBITMAP bitmap;
61#elif defined(__APPLE__)
62 unsigned char* data;
Pierre Ossman403ac272017-01-02 17:00:41 +010063#else
64 Pixmap pixmap;
65 Picture picture;
66 XRenderPictFormat* visFormat;
67#endif
68};
69
70#endif
71