~paulliu/ubuntu/precise/freerdp/fixext

« back to all changes in this revision

Viewing changes to dfb/dfb_gdi.c

  • Committer: Bazaar Package Importer
  • Author(s): Otavio Salvador
  • Date: 2010-10-25 14:29:02 UTC
  • mto: (9.1.1 sid) (1.1.7)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20101025142902-j8hmshnnxhu61l4m
Tags: upstream-0.8.1
ImportĀ upstreamĀ versionĀ 0.8.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- c-basic-offset: 8 -*-
2
 
   FreeRDP: A Remote Desktop Protocol client.
3
 
   DirectFB GDI Adapation Layer
4
 
 
5
 
   Copyright (C) Marc-Andre Moreau <marcandre.moreau@gmail.com> 2010
6
 
 
7
 
   This program is free software; you can redistribute it and/or modify
8
 
   it under the terms of the GNU General Public License as published by
9
 
   the Free Software Foundation; either version 2 of the License, or
10
 
   (at your option) any later version.
11
 
 
12
 
   This program is distributed in the hope that it will be useful,
13
 
   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
   GNU General Public License for more details.
16
 
 
17
 
   You should have received a copy of the GNU General Public License
18
 
   along with this program; if not, write to the Free Software
19
 
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
 
*/
21
 
 
22
 
#include <stdlib.h>
23
 
#include "dfb_gdi.h"
24
 
 
25
 
HDC GetDC()
26
 
{
27
 
        HDC hDC = (HDC) malloc(sizeof(DC));
28
 
        return hDC;
29
 
}
30
 
 
31
 
HDC CreateCompatibleDC(HDC hdc)
32
 
{
33
 
        HDC hDC = (HDC) malloc(sizeof(DC));
34
 
        hDC->bpp = hdc->bpp;
35
 
        return hDC;
36
 
}
37
 
 
38
 
HBITMAP CreateBitmap(int nWidth, int nHeight, int cBitsPerPixel, unsigned char* data)
39
 
{
40
 
        HBITMAP hBitmap = (HBITMAP) malloc(sizeof(BITMAP));
41
 
        hBitmap->objectType = GDIOBJ_BITMAP;
42
 
        hBitmap->bpp = cBitsPerPixel;
43
 
        hBitmap->width = nWidth;
44
 
        hBitmap->height = nHeight;
45
 
        hBitmap->data = (unsigned char*) data;
46
 
        return hBitmap;
47
 
}
48
 
 
49
 
HBITMAP CreateCompatibleBitmap(HDC hdc, int nWidth, int nHeight)
50
 
{
51
 
        HBITMAP hBitmap = (HBITMAP) malloc(sizeof(BITMAP));
52
 
        hBitmap->objectType = GDIOBJ_BITMAP;
53
 
        hBitmap->width = nWidth;
54
 
        hBitmap->height = nHeight;
55
 
        return hBitmap;
56
 
}
57
 
 
58
 
HPEN CreatePen(int fnPenStyle, int nWidth, int crColor)
59
 
{
60
 
        HPEN hPen = (HPEN) malloc(sizeof(PEN));
61
 
        hPen->objectType = GDIOBJ_PEN;
62
 
        return hPen;
63
 
}
64
 
 
65
 
HBRUSH CreateSolidBrush(int crColor)
66
 
{
67
 
        HBRUSH hBrush = (HBRUSH) malloc(sizeof(BRUSH));
68
 
        hBrush->objectType = GDIOBJ_BRUSH;
69
 
        return hBrush;
70
 
}
71
 
 
72
 
HBRUSH CreatePatternBrush(HBITMAP hbmp)
73
 
{
74
 
        HBRUSH hBrush = (HBRUSH) malloc(sizeof(BRUSH));
75
 
        hBrush->objectType = GDIOBJ_BRUSH;
76
 
        return hBrush;
77
 
}
78
 
 
79
 
int SetRect(HRECT rc, int xLeft, int yTop, int xRight, int yBottom)
80
 
{
81
 
        rc->left = xLeft;
82
 
        rc->top = yTop;
83
 
        rc->right = xRight;
84
 
        rc->bottom = yBottom;
85
 
        return 1;
86
 
}
87
 
 
88
 
int CopyRect(HRECT dst, HRECT src)
89
 
{
90
 
        dst->left = src->left;
91
 
        dst->top = src->top;
92
 
        dst->right = src->right;
93
 
        dst->bottom = src->bottom;
94
 
        return 1;
95
 
}
96
 
 
97
 
int FillRect(HDC hdc, HRECT rect, HBRUSH hbr)
98
 
{
99
 
        return 1; /* 0 = failure */
100
 
}
101
 
 
102
 
int GetPixel(HDC hdc, int nXPos, int nYPos)
103
 
{
104
 
        return 0;
105
 
}
106
 
 
107
 
int SetPixel(HDC hdc, int X, int Y, int crColor)
108
 
{
109
 
        return 0;
110
 
}
111
 
 
112
 
int GetBkColor(HDC hdc)
113
 
{
114
 
        return 0;
115
 
}
116
 
 
117
 
int SetBkColor(HDC hdc, int crColor)
118
 
{
119
 
        return 0;
120
 
}
121
 
 
122
 
int PatBlt(HDC hdc, int nXLeft, int nXYLeft, int nWidth, int nHeight, int rop)
123
 
{
124
 
        /* Raster Operation is either PATCOPY, PATINVERT, DSTINVERT, BLACKNESS or WHITENESS */
125
 
}
126
 
 
127
 
int BitBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, int hdcSrc, int nXSrc, int nYSrc, int rop)
128
 
{
129
 
        return 1; /* 0 = failure */
130
 
}
131
 
 
132
 
int SelectObject(HDC hdc, HGDIOBJ hgdiobj)
133
 
{
134
 
        if (hgdiobj->objectType == GDIOBJ_BITMAP)
135
 
        {
136
 
                //HBITMAP hBitmap = (HBITMAP) hgdiobj;
137
 
                hdc->selectedObject = hgdiobj;
138
 
        }
139
 
        else if (hgdiobj->objectType == GDIOBJ_PEN)
140
 
        {
141
 
                //HPEN hPen = (HPEN) hgdiobj;
142
 
                hdc->selectedObject = hgdiobj;
143
 
        }
144
 
        else if (hgdiobj->objectType == GDIOBJ_BRUSH)
145
 
        {
146
 
                //HBRUSH hBrush = (HBRUSH) hgdiobj;
147
 
                hdc->selectedObject = hgdiobj;
148
 
        }
149
 
        else if (hgdiobj->objectType == GDIOBJ_RECT)
150
 
        {
151
 
                //HRECT hRect = (HRECT) hgdiobj;
152
 
                hdc->selectedObject = hgdiobj;
153
 
        }
154
 
        else
155
 
        {
156
 
                /* Unknown GDI Object Type */
157
 
                return 0;
158
 
        }
159
 
        
160
 
        return 1;
161
 
}
162
 
 
163
 
int DeleteObject(HGDIOBJ hgdiobj)
164
 
{
165
 
        if (hgdiobj->objectType == GDIOBJ_BITMAP)
166
 
        {
167
 
                HBITMAP hBitmap = (HBITMAP) hgdiobj;
168
 
                free(hBitmap->data);
169
 
                free(hBitmap);
170
 
        }
171
 
        else if (hgdiobj->objectType == GDIOBJ_PEN)
172
 
        {
173
 
                HPEN hPen = (HPEN) hgdiobj;
174
 
                free(hPen);
175
 
        }
176
 
        else if (hgdiobj->objectType == GDIOBJ_BRUSH)
177
 
        {
178
 
                HBRUSH hBrush = (HBRUSH) hgdiobj;
179
 
                free(hBrush);
180
 
        }
181
 
        else if (hgdiobj->objectType == GDIOBJ_RECT)
182
 
        {
183
 
                HRECT hRect = (HRECT) hgdiobj;
184
 
                free(hRect);
185
 
        }
186
 
        else
187
 
        {
188
 
                /* Unknown GDI Object Type */
189
 
                free(hgdiobj);
190
 
                return 0;
191
 
        }
192
 
        
193
 
        return 1;
194
 
}
195
 
 
196
 
int DeleteDC(HDC hdc)
197
 
{
198
 
        free(hdc);
199
 
        return 1;
200
 
}