Chameleon

Chameleon Svn Source Tree

Root/branches/cparm/i386/modules/Libeg/libegint.h

  • Property svn:executable set to *
1/*
2 * libeg/libegint.h
3 * EFI graphics library internal header
4 *
5 * Copyright (c) 2006 Christoph Pfisterer
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the
18 * distribution.
19 *
20 * * Neither the name of Christoph Pfisterer nor the names of the
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#ifndef __LIBEG_LIBEGINT_H__
38#define __LIBEG_LIBEGINT_H__
39
40#include <utarray.h>
41#include <stdio.h>
42#include <stdlib.h>
43#include <unistd.h>
44#include <fcntl.h>
45#include <efi.h>
46#include "libeg.h"
47#include <IOGraphics.h>
48
49/**
50 Return the maximum of two operands.
51
52 This macro returns the maximum of two operand specified by a and b.
53 Both a and b must be the same numerical types, signed or unsigned.
54
55 @param a The first operand with any numerical type.
56 @param b The second operand. Can be any numerical type as long as is
57 the same type as a.
58
59 @return Maximum of two operands.
60
61 **/
62#ifndef MAX
63#define MAX(a,b) ((a) > (b) ? (a) : (b))
64#endif
65
66/**
67 Return the minimum of two operands.
68
69 This macro returns the minimal of two operand specified by a and b.
70 Both a and b must be the same numerical types, signed or unsigned.
71
72 @param a The first operand with any numerical type.
73 @param b The second operand. It should be the same any numerical type with a.
74
75 @return Minimum of two operands.
76
77 **/
78#ifndef MIN
79#define MIN(a,b) ((a) < (b) ? (a) : (b))
80#endif
81
82/**
83 Return the absolute value of a signed operand.
84
85 This macro returns the absolute value of the signed operand specified by a.
86
87 @param a The signed operand.
88
89 @return The absolute value of the signed operand.
90
91 **/
92#ifndef ABS
93#define ABS(a) \
94(((a) < 0) ? (-(a)) : (a))
95#endif
96
97//
98// Generate an ASSERT if Status is an error code
99//
100#ifndef ASSERT_EFI_ERROR
101#define ASSERT_EFI_ERROR(status) ASSERT(!EFI_ERROR(status))
102#endif
103
104/* types */
105
106typedef EG_IMAGE * (*EG_DECODE_FUNC)(IN UINT8 *FileData, IN UINTN FileDataLength, IN UINTN IconSize, IN BOOLEAN WantAlpha);
107
108/* functions */
109
110VOID egRestrictImageArea(IN EG_IMAGE *Image,
111 IN UINTN AreaPosX, IN UINTN AreaPosY,
112 IN OUT UINTN *AreaWidth, IN OUT UINTN *AreaHeight);
113VOID egRawCopy(IN OUT EG_PIXEL *CompBasePtr, IN EG_PIXEL *TopBasePtr,
114 IN UINTN Width, IN UINTN Height,
115 IN UINTN CompLineOffset, IN UINTN TopLineOffset);
116VOID egRawCompose(IN OUT EG_PIXEL *CompBasePtr, IN EG_PIXEL *TopBasePtr,
117 IN UINTN Width, IN UINTN Height,
118 IN UINTN CompLineOffset, IN UINTN TopLineOffset);
119
120#define PLPTR(imagevar, colorname) ((UINT8 *) &((imagevar)->PixelData->colorname))
121
122VOID egDecompressIcnsRLE(IN OUT UINT8 **CompData, IN OUT UINTN *CompLen, IN UINT8 *DestPlanePtr, IN UINTN PixelCount);
123EG_IMAGE * egDecodeICNS(IN UINT8 *FileData, IN UINTN FileDataLength, IN UINTN IconSize, IN BOOLEAN WantAlpha);
124VOID egInsertPlane(IN UINT8 *SrcDataPtr, IN UINT8 *DestPlanePtr, IN UINTN PixelCount);
125VOID egSetPlane(IN UINT8 *DestPlanePtr, IN UINT8 Value, IN UINTN PixelCount);
126VOID egCopyPlane(IN UINT8 *SrcPlanePtr, IN UINT8 *DestPlanePtr, IN UINTN PixelCount);
127EG_IMAGE * egDecodePNG(IN UINT8 *FileData, IN UINTN FileDataLength, IN UINTN IconSize, IN BOOLEAN WantAlpha);
128
129VOID egEncodeBMP(IN EG_IMAGE *Image, OUT UINT8 **FileData, OUT UINTN *FileDataLength);
130EG_IMAGE * egDecodeBMP(IN UINT8 *FileData, IN UINTN FileDataLength, IN UINTN IconSize, IN BOOLEAN WantAlpha);
131
132VOID egFlipRB(IN EG_IMAGE *Image);
133BOOLEAN egComposeImageStretched(IN OUT EG_IMAGE *CompImage, IN EG_IMAGE *TopImage);
134
135
136static void image_view_t_copy(void *_dst, const void *_src) {
137 EG_IMAGE_VIEW *__dst = (EG_IMAGE_VIEW*)_dst, *__src = (EG_IMAGE_VIEW*)_src;
138 __dst->Name = __src->Name ? PoolPrint(__src->Name) : NULL;
139 __dst->PosX = __src->PosX;
140 __dst->PosY = __src->PosY;
141
142 __dst->Image = (EG_IMAGE*)malloc(sizeof(EG_IMAGE));
143 if (__dst->Image)
144 {
145 EG_IMAGE *dst = (EG_IMAGE*)__dst->Image, *src = (EG_IMAGE*)__src->Image;
146 dst->Width = src->Width;
147 dst->Height = src->Height;
148 dst->HasAlpha = src->HasAlpha;
149 dst->NeedFlip = src->NeedFlip;
150
151 dst->PixelData = (EG_PIXEL *)AllocateCopyPool(src->Width*sizeof(EG_PIXEL)*src->Height, src->PixelData);
152 }
153
154
155}
156
157static void image_view_t_dtor(void *_elt) {
158 EG_IMAGE_VIEW *__elt = (EG_IMAGE_VIEW*)_elt;
159 EG_IMAGE *elt = __elt->Image;
160 if (elt->PixelData) free(elt->PixelData);
161 if (__elt->Name) free(__elt->Name);
162 if (__elt->Image) free(__elt->Image);
163}
164static const UT_icd image_view_t_icd _UNUSED_ = {sizeof(EG_IMAGE_VIEW), NULL, image_view_t_copy, image_view_t_dtor};
165
166#endif /* __LIBEG_LIBEGINT_H__ */
167
168/* EOF */
169

Archive Download this file

Revision: 2182