20 #include <freerdp/config.h>
22 #include <winpr/crt.h>
24 #include <freerdp/graphics.h>
30 rdpBitmap* Bitmap_Alloc(rdpContext* context)
32 rdpBitmap* bitmap = NULL;
33 rdpGraphics* graphics = NULL;
34 graphics = context->graphics;
35 bitmap = (rdpBitmap*)calloc(1, graphics->Bitmap_Prototype->size);
39 *bitmap = *graphics->Bitmap_Prototype;
46 void Bitmap_Free(rdpContext* context, rdpBitmap* bitmap)
49 bitmap->Free(context, bitmap);
52 BOOL Bitmap_SetRectangle(rdpBitmap* bitmap, UINT16 left, UINT16 top, UINT16 right, UINT16 bottom)
59 bitmap->right = right;
60 bitmap->bottom = bottom;
64 BOOL Bitmap_SetDimensions(rdpBitmap* bitmap, UINT16 width, UINT16 height)
69 bitmap->right = bitmap->left + width - 1;
70 bitmap->bottom = bitmap->top + height - 1;
71 bitmap->width = width;
72 bitmap->height = height;
76 void graphics_register_bitmap(rdpGraphics* graphics,
const rdpBitmap* bitmap)
78 WINPR_ASSERT(graphics);
79 WINPR_ASSERT(graphics->Bitmap_Prototype);
82 *graphics->Bitmap_Prototype = *bitmap;
86 rdpPointer* Pointer_Alloc(rdpContext* context)
88 rdpPointer* pointer = NULL;
89 rdpGraphics* graphics = NULL;
90 graphics = context->graphics;
91 pointer = (rdpPointer*)calloc(1, graphics->Pointer_Prototype->size);
95 *pointer = *graphics->Pointer_Prototype;
102 void graphics_register_pointer(rdpGraphics* graphics,
const rdpPointer* pointer)
104 WINPR_ASSERT(graphics);
105 WINPR_ASSERT(graphics->Pointer_Prototype);
106 WINPR_ASSERT(pointer);
108 *graphics->Pointer_Prototype = *pointer;
113 rdpGlyph* Glyph_Alloc(rdpContext* context, INT32 x, INT32 y, UINT32 cx, UINT32 cy, UINT32 cb,
116 rdpGlyph* glyph = NULL;
117 rdpGraphics* graphics = NULL;
119 if (!context || !context->graphics)
122 graphics = context->graphics;
124 if (!graphics->Glyph_Prototype)
127 glyph = (rdpGlyph*)calloc(1, graphics->Glyph_Prototype->size);
132 *glyph = *graphics->Glyph_Prototype;
138 glyph->aj = malloc(glyph->cb);
146 CopyMemory(glyph->aj, aj, cb);
148 if (!glyph->New(context, glyph))
158 void graphics_register_glyph(rdpGraphics* graphics,
const rdpGlyph* glyph)
160 WINPR_ASSERT(graphics);
161 WINPR_ASSERT(graphics->Glyph_Prototype);
164 *graphics->Glyph_Prototype = *glyph;
169 rdpGraphics* graphics_new(rdpContext* context)
171 rdpGraphics* graphics = NULL;
172 graphics = (rdpGraphics*)calloc(1,
sizeof(rdpGraphics));
176 graphics->context = context;
177 graphics->Bitmap_Prototype = (rdpBitmap*)calloc(1,
sizeof(rdpBitmap));
179 if (!graphics->Bitmap_Prototype)
185 graphics->Bitmap_Prototype->size =
sizeof(rdpBitmap);
186 graphics->Pointer_Prototype = (rdpPointer*)calloc(1,
sizeof(rdpPointer));
188 if (!graphics->Pointer_Prototype)
190 free(graphics->Bitmap_Prototype);
195 graphics->Pointer_Prototype->size =
sizeof(rdpPointer);
196 graphics->Glyph_Prototype = (rdpGlyph*)calloc(1,
sizeof(rdpGlyph));
198 if (!graphics->Glyph_Prototype)
200 free(graphics->Pointer_Prototype);
201 free(graphics->Bitmap_Prototype);
206 graphics->Glyph_Prototype->size =
sizeof(rdpGlyph);
212 void graphics_free(rdpGraphics* graphics)
216 free(graphics->Bitmap_Prototype);
217 free(graphics->Pointer_Prototype);
218 free(graphics->Glyph_Prototype);