source: svn/trunk/newcon3bcm2_21bu/nexus/lib/softgfx/include/b_softgfx_lib.h

Last change on this file was 2, checked in by jglee, 11 years ago

first commit

  • Property svn:executable set to *
File size: 16.7 KB
Line 
1/***************************************************************************
2* (c)2003-2009 Broadcom Corporation
3
4* This program is the proprietary software of Broadcom Corporation and/or its
5* licensors, and may only be used, duplicated, modified or distributed pursuant
6* to the terms and conditions of a separate, written license agreement executed
7* between you and Broadcom (an "Authorized License"). Except as set forth in an
8* Authorized License, Broadcom grants no license (express or implied), right to
9* use, or waiver of any kind with respect to the Software, and Broadcom expressly
10* reserves all rights in and to the Software and all intellectual property rights
11* therein. IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS
12* SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE
13* ALL USE OF THE SOFTWARE. 
14*   
15* Except as expressly set forth in the Authorized License,
16*   
17* 1.     This program, including its structure, sequence and organization,
18* constitutes the valuable trade secrets of Broadcom, and you shall use all
19* reasonable efforts to protect the confidentiality thereof, and to use this
20* information only in connection with your use of Broadcom integrated circuit
21* products.
22
23* 2.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
24* AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR
25* WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
26* THE SOFTWARE.  BROADCOM SPECIFICALLY DISCLAIMS ANY AND ALL IMPLIED WARRANTIES
27* OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE,
28* LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION
29* OR CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF
30* USE OR PERFORMANCE OF THE SOFTWARE.
31
32* 3.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR ITS
33* LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR
34* EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO YOUR
35* USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF
36* THE POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT
37* ACTUALLY PAID FOR THE SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE
38* LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF
39* ANY LIMITED REMEDY.
40*
41* $brcm_Workfile: $
42* $brcm_Revision: $
43* $brcm_Date: $
44*
45* Description: header file for Soft Graphics App Lib
46*
47* Revision History:
48*
49* $brcm_Log: $
50*
51***************************************************************************/
52#ifndef B_SOFTGFX_LIB_H__
53#define B_SOFTGFX_LIB_H__
54
55#include "bstd.h"
56#include "nexus_types.h"
57#include "nexus_platform.h"
58#include "nexus_surface.h"
59#include "nexus_striped_surface.h"
60
61
62/**************************************************************************
63 * This IP Applib module provides Soft Graphics functions including:
64 *      - Fill
65 *      - Blit (simple blit and blend)
66 *      - Anti-flutter
67 ***************************************************************************/
68
69#ifdef __cplusplus
70extern "C" {
71#endif
72
73/**
74Summary:
75Public handle for Soft Graphics App Lib
76**/
77typedef struct B_SoftGfx * B_SoftGfxHandle;
78
79/**
80Summary:
81Settings used for B_SoftGfx_Open
82**/
83typedef struct B_SoftGfx_OpenSettings
84{
85    int tbd; 
86} B_SoftGfx_OpenSettings;
87
88/***************************************************************************
89Summary:
90Get default settings for B_SoftGfx_Open
91***************************************************************************/
92void B_SoftGfx_GetDefaultOpenSettings(
93   B_SoftGfx_OpenSettings *pSettings /* [out] */
94   );
95
96/***************************************************************************
97Summary:
98Open a Soft Graphics interface for blit and fill operations.
99***************************************************************************/
100B_SoftGfxHandle B_SoftGfx_Open(
101    const B_SoftGfx_OpenSettings *pSettings
102    );
103
104/***************************************************************************
105Summary:
106Close a Soft Graphics interface.
107***************************************************************************/
108void B_SoftGfx_Close(
109    B_SoftGfxHandle handle
110    );
111
112/**
113Summary:
114How to fill the surface with the given color
115
116Description:
117Used in B_SoftGfx_FillSettings
118**/
119typedef enum B_SoftGfx_FillOp
120{
121    B_SoftGfx_FillOp_eIgnore = 0, /* Do not change the values for the channel (either color or alpha) */
122    B_SoftGfx_FillOp_eCopy,       /* Copy the value of the channel (color or alpha) from the constant color to the surface */
123    B_SoftGfx_FillOp_eBlend,      /* For color channel, blend surface color with constant color using constant alpha.
124                                     This operation is not support for the alpha channel. */
125    B_SoftGfx_FillOp_eMax
126} B_SoftGfx_FillOp;
127
128/**
129Summary:
130Parameters for B_SoftGfx_Fill
131**/
132typedef struct B_SoftGfx_FillSettings
133{
134    NEXUS_SurfaceHandle   surface;
135    NEXUS_Pixel           color;    /* Color to fill */
136    NEXUS_Rect            rect;     /* Area of surface to fill. width,height of 0,0 fills the entire surface */
137    B_SoftGfx_FillOp      colorOp;  /* Operation to take on the color channel */
138    B_SoftGfx_FillOp      alphaOp;  /* Operation to take on the alpha channel */                                       
139} B_SoftGfx_FillSettings;
140
141
142typedef struct B_SoftGfx_ScaleSettings
143{
144    NEXUS_SurfaceHandle     srcsurface;
145    NEXUS_SurfaceHandle     outsurface;
146    NEXUS_Rect              srcrect;
147    NEXUS_Rect              outrect;
148    bool                    bApplySclFiltering;
149} B_SoftGfx_ScaleSettings;
150
151/***************************************************************************
152Summary:
153Create a new surface by copying from a striped surface
154
155Description:
156A striped surface is the output of NEXUS_StillDecoder_GetStripedSurface.
157***************************************************************************/
158NEXUS_SurfaceHandle B_SoftGfx_Destripe( NEXUS_StripedSurfaceHandle stripedSurface);
159
160
161/***************************************************************************
162Summary:
163Get default settings for the structure.
164***************************************************************************/
165void B_SoftGfx_GetDefaultFillSettings(
166    B_SoftGfx_FillSettings *pSettings /* [out] */
167    );
168
169/***************************************************************************
170Summary:
171Fill, tint or otherwise modify the pixels of an area of a surface using a constant
172value. This routine modifies the color channels and/or the alpha channel of the
173pixels of a surface using a constant value.
174
175Notes:
1761) Normal fill opeartion can be achieved by specifying both colorOp and alphaOp
177   as B_SoftGfx_FillOp_eCopy
178
1792) If surface is in palette format then color represents the index to the clut.
180   If surface is in non-palette format, say ARGB8888 or ARGB4444, then color
181   parameter has to be in the ARGB8888 format.
182
183   Ex: In ARGB4444 BLUE color is represented by 0xF00F. But, for filling an
184   ARGB4444 surface with solid BLUE color, the color parameter should be 0xFF0000FF
185   (as in ARGB8888 format).
186
1873) Only B_SoftGfx_FillOp_eCopy operation is supported for palette surface.
188
1894) Color channels of a non-paletter surface can be blended with the color channels
190   of the constant color using constant alpha. For such operations, user needs
191   to specify :
192        colorOp = B_SoftGfx_FillOp_eBlend
193        alphaOp = B_SoftGfx_FillOp_eIgnore
194   Note: Blend fill is supported only for surfaces with pixel formats with alpha
195   component only.
196   Ex: Blend fill is supported for ARGB888, ARGB4444, RGBA4444, etc.
197       Blend fill is not supported for RGB565, etc.
198
199***************************************************************************/
200NEXUS_Error B_SoftGfx_Fill(
201    B_SoftGfxHandle handle,
202    const B_SoftGfx_FillSettings *pSettings
203    );
204
205/**
206Summary:
207Color operations available in B_SoftGfx_BlitSettings
208
209Description:
210Below is the generic color blend equation:
211
212    R   =       R1   *  Alpha1  +        R2     *        Alpha2  *   (1-Alpha1)
213    G   =       G1   *  Alpha1  +        G2     *        Alpha2  *   (1-Alpha1)   
214    B   =       B1   *  Alpha1  +        B2     *        Alpha2  *   (1-Alpha1)
215Alpha   =        1   -  (1   -  Alpha1)  *   (  1        -   Alpha2)   
216    R   =       R        /   Alpha       
217    G   =       G        /   Alpha       
218    B   =       B        /   Alpha       
219where,
220    [R1,G1,B1] are color components for a pixel from srcsurface
221    [R2,G2,B2] are color components for corresponding pixel from dstsurface
222    [R,G,B] are color components for the resultant blended pixel on the outsurface
223
224Alpha1 and Alpha2 are derived based on BlitColorOp as shown below:
225
226BlitColorOp         -       Alpha1       -       Alpha2             OPERATION
227------------------    ------------------   --------------------
228eCopySource         -       NA           -         NA               Blit
229eUseConstantAlpha   -  constAlphaColorOp -  constAlphaColorOp       Blend
230eUseSourceAlpha     -  srcsurface_alpha  -  srcsurface_alpha        Blend
231eUseDestAlpha       -  dstsurface_alpha  -  dstsurface_alpha        Blend
232eUseBlendEquation   -  srcsurface_alpha  -  dstsurface_alpha        Blend
233
234See B_SofGfx_BlitSettings for constAlphaColorOp parameter.
235**/
236typedef enum B_SoftGfx_BlitColorOp
237{
238    B_SoftGfx_BlitColorOp_eCopySource = 0,        /* Copy the source color with no blending. Valid only with B_SoftGfx_BlitAlphaOp_eCopySource. This means Blitting. */
239    B_SoftGfx_BlitColorOp_eUseConstantAlpha,      /* Blend the source and dest colors using the alpha from the constAlphaColorOp param */
240    B_SoftGfx_BlitColorOp_eUseSourceAlpha,        /* Blend the source and dest colors using the alpha from the source pixels */
241    B_SoftGfx_BlitColorOp_eUseDestAlpha,          /* Blend the source and dest colors using the alpha from the dest pixels */
242    B_SoftGfx_BlitColorOp_eUseBlendEquation,      /* Blend the source and dest colors using constant alpha for color & blend operations */
243    B_SoftGfx_BlitColorOp_eMax
244} B_SoftGfx_BlitColorOp;
245
246/**
247Summary:
248Alpha operations available in B_SoftGfx_BlitSettings
249
250Description:
251**/
252typedef enum B_SoftGfx_BlitAlphaOp
253{
254    B_SoftGfx_BlitAlphaOp_eCopySource = 0,        /* Oa = Sa. Copy the source alpha to the output alpha. */
255    B_SoftGfx_BlitAlphaOp_eCopyDest,              /* Oa = Da. Copy the dest alpha to the output alpha */
256    B_SoftGfx_BlitAlphaOp_eCopyConstant,          /* Oa = constAlphaAlphaOp. Copy the constant alpha for alphaOp parameter as the output alpha */
257    B_SoftGfx_BlitAlphaOp_eUseBlendEquation,      /* Alpha = 1 - (1 - Alpha1) * (1 - Alpha2)
258                                                     where, Alpha1 and Alpha2 are defined as per the BlitColorOp given
259                                                     in the description of B_SoftGfx_BlitColorOp above */
260    B_SoftGfx_BlitAlphaOp_eMax
261} B_SoftGfx_BlitAlphaOp;
262
263#define B_SOFTGFX_COLOR_MATRIX_COEFF_COUNT           (20)
264
265/***************************************************************************
266Summary:
2675x4 coefficient matrix for blitter color space convertor
268
269Description:
270        This matrix is used to modify the incoming source values.
271        Typically this is done to convert from one color space to another.
272
273        The values used for the color matrix are equal to the values stored
274        in the ai32_Matrix array right shifted by the ulShift value. In
275        addition, negative values are converted to positive values before
276        shifting and then turned back into negative values. For
277        example, if a value in the matrix was 4 and the shift value was 2, then
278        the final value is 1 (4>>2 = 1). If a value in the matrix was 7
279        and the shift value was 3, then the final value would be 0.875.
280        If a value in the matrix was -7 and the shift value was 3 then the
281        final values is -0.875.
282
283        The values within the color matrix are in the following order:
284
285              |  M[0]   M[1]   M[2]   M[3]   M[4] |
286              |  M[5]   M[6]   M[7]   M[8]   M[9] |
287              | M[10]  M[11]  M[12]  M[13]  M[14] |
288              | M[15]  M[16]  M[17]  M[18]  M[19] |
289
290        This is multiplied with a column vector of
291        < C2in, C1in, C0in, Ain, 1 > which yields the following equations:
292
293        C2out =  M[0]*C2in +  M[1]*C1in +  M[2]*C0in +  M[3]*Ain +  M[4]
294        C1out =  M[5]*C2in +  M[6]*C1in +  M[7]*C0in +  M[8]*Ain +  M[9]
295        C0out = M[10]*C2in + M[11]*C1in + M[12]*C0in + M[13]*Ain + M[14]
296        Aout  = M[15]*C2in + M[16]*C1in + M[17]*C0in + M[18]*Ain + M[19]
297
298        The default is to for the matrix to represent the identity.
299        M[0] = M[6] = M[12] = M[18] = 1. All other values are zero.
300
301    NOTE: Even though proposed interface (like Nexus_Graphics2D) has 20
302    coefficients for better performance, coefficients (M[3], M[8], M[13], M18])
303    involving Ain will not be used.
304    Also, Aout will simply be = Ain.
305    (Meaning M[15], M[16], M[17], M[18] and M[19] will not be used).
306
307Used in B_SoftGfx_Blit
308****************************************************************************/
309typedef struct B_SoftGfx_ColorMatrix
310{
311    unsigned shift;
312    int32_t  coeffMatrix[B_SOFTGFX_COLOR_MATRIX_COEFF_COUNT];
313} B_SoftGfx_ColorMatrix;
314
315/**
316Summary:
317Parameters for B_SoftGfx_Blit
318
319Description:
320B_SoftGfx_blit can be used for following two operations:
3211) Blit a rectangle from source surface to output surface
3222) Blend rectangles from source and destination surfaces on to the output surface
323
324Simple Blit Operation:
325- Copies srcrect from srcsurface to outsurface
326- dstsurface and dstx, dsty are ignored
327- colorOp should B_SoftGfx_BlitColorOp_eCopySource
328- alphaOp should B_SoftGfx_BlitAlphaOp_eCopySource
329- constAlphaColorOp and constAlphaAlphaOp are ignored
330- srcsurface and outsurface should be of same pixel format
331
332Blend Operation:
333- Blends rectangles from src and dst surfaces based on the color and alpha operations and
334  writes on to the outsurface.
335- Requires all three surfaces: src, dst and out
336- colorOp, alphaOp and constAlpha for color and alpha operations define the blend parameters
337- Blending is supported only on surfaces with non-palette RGB pixel formats
338- srcsurface, dstsurface and outsurface should be of same pixel format
339**/
340typedef struct B_SoftGfx_BlitSettings
341{
342    NEXUS_SurfaceHandle     srcsurface;
343    NEXUS_SurfaceHandle     dstsurface;         /* Required only for blending. For blt, it will be ignored. */
344    NEXUS_SurfaceHandle     outsurface; 
345   
346    NEXUS_Rect              srcrect;            /* As there is no support for scaling, the same width, height will be used for dst and out surfaces */
347    int16_t                 dstx, dsty;         /* Required only for blending. For blt, these will be ignored. */
348    int16_t                 outx, outy;         
349   
350    B_SoftGfx_BlitColorOp   colorOp;            /* Specify how to blit the color component */
351    B_SoftGfx_BlitAlphaOp   alphaOp;            /* Specify how to blit the alpha component */
352
353    uint8_t                 constAlphaColorOp;  /* Used by some operations */
354    uint8_t                 constAlphaAlphaOp;  /* Used by some operations */
355
356    bool                    bApplyAntiFlutterFiler; /* **DEPRECATED** parameter. 7550 will be using anti-flutter from GFD block.
357                                                    Anti-flutter filtering will be applied on the modified rect on the outsurface */ 
358
359    bool                    conversionMatrixEnabled;/* If true, use conversionMatrix. No automatic RGB to YCbCr conversion will take place. */
360    B_SoftGfx_ColorMatrix   conversionMatrix;
361} B_SoftGfx_BlitSettings;
362
363/***************************************************************************
364Summary:
365Get default settings for the structure.
366***************************************************************************/
367void B_SoftGfx_GetDefaultBlitSettings(
368    B_SoftGfx_BlitSettings *pSettings /* [out] */
369    );
370
371/***************************************************************************
372Summary:
373Perform a block transfer (blit) from one or two surfaces to an output.
374
375Description:
376Blit can be a simple blit or alpha blended blit. See B_SoftGfx_BlitSettings
377for details.
378***************************************************************************/
379NEXUS_Error B_SoftGfx_Blit(
380    B_SoftGfxHandle              handle,
381    const B_SoftGfx_BlitSettings *pSettings
382    );
383
384/***************************************************************************
385Summary:
386Get default settings for the structure.
387***************************************************************************/
388void B_SoftGfx_GetDefaultScaleSettings(
389    B_SoftGfx_ScaleSettings *pSettings /* [out] */
390    );
391
392
393/***************************************************************************
394Summary:
395Perform scale-up/down from one surfaces to another.
396
397Description:
398User can choose to enable filtering (slower but better quality) or not
399***************************************************************************/
400NEXUS_Error B_SoftGfx_Scale(
401    B_SoftGfxHandle              handle,
402    B_SoftGfx_ScaleSettings *pSettings
403    );
404#ifdef __cplusplus
405}
406#endif
407#endif /* #ifndef B_SOFTGFX_LIB_H__ */
Note: See TracBrowser for help on using the repository browser.