source: svn/newcon3bcm2_21bu/nexus/modules/graphics2d/7552/include/nexus_graphics2d.h

Last change on this file was 76, checked in by megakiss, 10 years ago

1W 대기전력을 만족시키기 위하여 POWEROFF시 튜너를 Standby 상태로 함

  • Property svn:executable set to *
File size: 47.4 KB
Line 
1/******************************************
2 *     (c)2007-2011 Broadcom Corporation
3 *
4 *  This program is the proprietary software of Broadcom Corporation and/or its licensors,
5 *  and may only be used, duplicated, modified or distributed pursuant to the terms and
6 *  conditions of a separate, written license agreement executed between you and Broadcom
7 *  (an "Authorized License").  Except as set forth in an Authorized License, Broadcom grants
8 *  no license (express or implied), right to use, or waiver of any kind with respect to the
9 *  Software, and Broadcom expressly reserves all rights in and to the Software and all
10 *  intellectual property rights therein.  IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU
11 *  HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY
12 *  NOTIFY BROADCOM AND DISCONTINUE ALL USE OF THE SOFTWARE.
13 *
14 *  Except as expressly set forth in the Authorized License,
15 *
16 *  1.     This program, including its structure, sequence and organization, constitutes the valuable trade
17 *  secrets of Broadcom, and you shall use all reasonable efforts to protect the confidentiality thereof,
18 *  and to use this information only in connection with your use of Broadcom integrated circuit products.
19 *
20 *  2.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
21 *  AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR
22 *  WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
23 *  THE SOFTWARE.  BROADCOM SPECIFICALLY DISCLAIMS ANY AND ALL IMPLIED WARRANTIES
24 *  OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE,
25 *  LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION
26 *  OR CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF
27 *  USE OR PERFORMANCE OF THE SOFTWARE.
28 *
29 *  3.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR ITS
30 *  LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR
31 *  EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO YOUR
32 *  USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF
33 *  THE POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT
34 *  ACTUALLY PAID FOR THE SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE
35 *  LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF
36 *  ANY LIMITED REMEDY.
37 *
38 * $brcm_Workfile: nexus_graphics2d.h $
39 * $brcm_Revision: 54 $
40 * $brcm_Date: 12/8/11 10:58a $
41 *
42 * Module Description:
43 *
44 * Revision History:
45 *
46 * $brcm_Log: /nexus/modules/graphics2d/7400/include/nexus_graphics2d.h $
47 *
48 * 54   12/8/11 10:58a erickson
49 * SW7425-1921: fix comment
50 *
51 * 53   12/8/11 9:48a erickson
52 * SW7420-2155: clarify use of mirror booleans. document new auto-mirror
53 *  for overlapped blits.
54 *
55 * 52   7/21/11 5:29p erickson
56 * SW7420-1974: add option for separate dest and source constant color
57 *
58 * 51   6/16/11 3:07p erickson
59 * SW7405-5356: update comments re: requirement that
60 *  NEXUS_Graphics2D_Checkpoint be called if packetFifoThreshold is non-
61 *  zero
62 *
63 * 50   5/26/11 1:13p erickson
64 * SW7420-1894: deprecate preAllocPacketMemory and maxOperations from
65 *  NEXUS_Graphics2DOpenSettings
66 *
67 * 49   5/20/11 5:03p erickson
68 * SW7420-1894: add NEXUS_Graphics2DOpenSettings.packetFifoThreshold
69 *
70 * 48   2/11/11 5:15p erickson
71 * SW7420-1491: add attr{memory=cached} to NEXUS_Graphics2D_Memset32
72 *
73 * 47   1/20/11 6:12p erickson
74 * SW7405-5063: add NEXUS_FillOp_eUseBlendEquation
75 *
76 * 46   12/7/10 5:44p erickson
77 * SW7420-1138: add boundsHeap
78 *
79 * 45   9/22/10 5:11p erickson
80 * SW7405-4882: add NEXUS_Graphics2D_ConvertFilter and
81 *  NEXUS_Graphics2D_ConvertColorMatrix
82 *
83 * 44   9/15/10 3:55p erickson
84 * SW7420-1081: add attr hint to NEXUS_Graphics2D_GetPacketBuffer
85 *
86 * 43   8/16/10 11:08a erickson
87 * SW7405-3671: add packet blit API. switch to packet-based GRC
88 *  implementation.
89 *
90 * 42   6/23/10 12:14p erickson
91 * SW7550-453: refactor to use nexus_striped_surface.h interface
92 *
93 * 41   6/18/10 4:30p erickson
94 * SW7405-4508: virtualize NEXUS_Graphics2D_Open so that each user can
95 *  have their own blitter and their own checkpoint callback
96 *
97 * 40   6/17/10 6:25p erickson
98 * SWDEPRECATED-2425: add comment
99 *
100 * 39   3/10/10 2:53p vsilyaev
101 * SW7405-3671: Added device offsets
102 *
103 * 38   2/16/10 1:22p vsilyaev
104 * SW7405-3671: Added NEXUS_Graphics2D_BatchBlit
105 *
106 * 37   12/30/09 12:23p erickson
107 * SWDEPRECATED-2425: add comments for NEXUS_Graphics2DColorMatrix
108 *
109 * 36   11/4/09 9:47a erickson
110 * SW7405-3328: add NEXUS_Graphics2D_PorterDuffFill
111 *
112 * DirectFB_1_4_Port/1   10/30/09 2:07p robertwm
113 * SW7405-3328: Support Porter-Duff Fill Compositions.
114 *
115 * 35   9/29/09 2:53p erickson
116 * SW7405-3021: add
117 *  NEXUS_Graphics2DBlitSettings.alphaPremultiplySourceEnabled
118 *
119 * 34   9/23/09 11:45a erickson
120 * SW7405-3062: update comments for NEXUS_Graphics2D_Memset32
121 *
122 * 33   8/10/09 12:57p vsilyaev
123 * PR 57469: Return proper error code when queue is full and try to handle
124 *  condition when BGRC_WaitForOperationsComplete returns out of memory
125 *  error
126 *
127 * 32   8/5/09 1:37p erickson
128 * PR54954: clarify comments re: checkpoint
129 *
130 * 31   5/11/09 11:48a erickson
131 * PR54954: added comment about multithreaded graphics code
132 *
133 * 30   4/22/09 9:13a erickson
134 * PR53698: added comment to NEXUS_Graphics2DBlitSettings about palettized
135 *  destination surfaces
136 *
137 * 29   4/20/09 9:23a erickson
138 * PR53701: added blit reversal flags to NEXUS_Graphics2DBlitSettings
139 *
140 * 28   4/3/09 4:39p erickson
141 * PR53701: added NEXUS_Graphics2DScalingControlSettings to
142 *  NEXUS_Graphics2DBlitSettings
143 *
144 * 27   3/19/09 11:12a erickson
145 * PR53116: add support for raster operations
146 *
147 * 26   2/26/09 9:45a erickson
148 * PR52506: updated comments
149 *
150 * 25   2/25/09 4:44p vsilyaev
151 * PR 52506: Updated code to move completionCallback as part of the
152 *  graphics settings. Print warning if two methods are used
153 *  simultaneously
154 *
155 * 24   1/21/09 1:46p vsilyaev
156 * PR 51396: Use the NEXUS_Pixel datatype for pixels values
157 *
158 * 23   12/9/08 10:36a erickson
159 * PR50088: fix comment
160 *
161 * 22   11/7/08 9:55a erickson
162 * PR46300: fix comment
163 *
164 * 21   10/23/08 11:53a erickson
165 * PR48190: added NEXUS_Graphics2DOpenSettings.maxOperations and
166 *  deprecated NEXUS_Graphics2DOpenSettings
167 *
168 * 20   10/20/08 9:57a erickson
169 * PR46527: extend NEXUS_Graphics2D_DestripeToSurface with optional
170 *  pTargetRect
171 *
172 * 19   9/18/08 11:02a erickson
173 * PR47014: update blend equation enums
174 *
175 * 18   9/17/08 11:35a erickson
176 * PR47014: clarify default values for dest.rect.width and .height
177 *
178 * 17   9/17/08 10:34a erickson
179 * PR47014: add NEXUS_BlendEquation and new color and alpha ops to use it
180 *
181 * 16   9/12/08 1:00p erickson
182 * PR46844: added NEXUS_Graphics2D_Memset32
183 *
184 * 15   9/9/08 4:59p erickson
185 * PR46683: fix NEXUS_Graphics2DBlitSettings.conversionMatrix
186 *
187 * 14   9/8/08 4:12p erickson
188 * PR46430: allow destripe to a larger supplied surface
189 *
190 * 13   9/4/08 12:36p erickson
191 * PR46430: added NEXUS_Graphics2D_DestripeToSurface
192 *
193 * 12   9/3/08 11:49a erickson
194 * PR46287: clarify meaning of standard color format. handle palette index
195 *  the same for both color format types.
196 *
197 * 11   8/21/08 5:14p erickson
198 * PR45941: clarified comment
199 *
200 * 10   8/21/08 2:16p erickson
201 * PR44792: added missing attr to Open
202 *
203 * 9   8/19/08 4:19p erickson
204 * PR45866: added NEXUS_Graphics2DOpenSettings to NEXUS_Graphics2D_Open
205 *
206 * 8   5/6/08 4:05p erickson
207 * PR41738: remove NEXUS_Graphics2DColorKeyMode
208 *
209 * 7   4/14/08 3:12p erickson
210 * PR41738: added dest color key, brutus_copy_rect, filter enums. added
211 *  FastBlit.
212 *
213 * 6   3/26/08 1:33p erickson
214 * PR40948: remove alternateConst
215 *
216 * 5   2/26/08 8:54p erickson
217 * PR36275: readd NEXUS_BlitAlphaOp_eEmulateTransparentVideo
218 *
219 * 4   2/25/08 2:59p erickson
220 * PR39786: added NEXUS_Graphics2D_Destripe
221 *
222 * 3   1/25/08 3:57p erickson
223 * PR38924: added comment about downscale limits
224 *
225 * 2   1/22/08 2:41p erickson
226 * PR36159: clarify blit enums. removed unimplemented enums.
227 *
228 * Nexus_Devel/10   1/8/08 1:19p erickson
229 * PR36159: added autoFlush and blockedSync
230 *
231 * Nexus_Devel/PR36159/1   1/4/08 3:32p gezhang
232 * PR36159: Add autoFlush and blockedSync configurations to graphics and
233 * surface settings
234 *
235 * Nexus_Devel/9   11/30/07 11:12a erickson
236 * PR35457: api update
237 *
238 * Nexus_Devel/8   11/28/07 2:11p erickson
239 * PR35457: doc update
240 *
241 *****************************************/
242#ifndef NEXUS_GRAPHICS2D_H__
243#define NEXUS_GRAPHICS2D_H__
244
245/*=***********************************
246The Graphics2D Interface provides functions to blit from one surface to another surface and to
247fill a surface with a color.
248
249The main functions are NEXUS_Graphics2D_Blit and NEXUS_Graphics2D_Fill.
250
251NEXUS_Graphics2D_PorterDuffBlit is provided as a convenience. However all porter-duff blits can also be
252accomplished using NEXUS_Graphics2D_Blit along with NEXUS_BlitColorOp_eUseBlendEquation.
253
254The Graphics2D module has a non-blocking API. By default functions will not wait for an internal event to complete.
255If you need to wait for a flil or blit to complete, you can request a callback or poll.
256****/
257
258#include "nexus_surface.h"
259#include "nexus_striped_surface.h"
260
261#ifdef __cplusplus
262extern "C"
263{
264#endif
265
266/**
267Summary:
268Handle for the Graphics2D interface.
269**/
270typedef struct NEXUS_Graphics2D *NEXUS_Graphics2DHandle;
271
272/**
273Summary:
274Settings used for NEXUS_Graphics2D_Open
275**/
276typedef struct NEXUS_Graphics2DOpenSettings
277{
278    unsigned hwFifoSize;        /* Size of HW fifo for packet-based blitting. There is only one HW fifo per M2MC, so this usually only applies on the first NEXUS_Graphics2D_Open. */
279    unsigned packetFifoSize;    /* Size of SW fifo for packet-based blitting. Each NEXUS_Graphics2D has its own SW fifo. */
280    unsigned packetFifoThreshold; /* Threshold to submit packets for blitting. A higher threshold will result in greater throughput but reduced latency.
281                                     Packets will be submitted when threshold is reached or when NEXUS_Graphics2D_Checkpoint is called.
282                                     Default is packetFifoThreshold == packetFifoSize for maximum throughput; therefore, NEXUS_Graphics2D_Checkpoint is required
283                                     to execute a blit or fill. */
284    NEXUS_HeapHandle heap;      /* optional heap */
285    NEXUS_HeapHandle boundsHeap; /* optional heap to bounds check all blits */
286   
287    unsigned maxOperations;     /* deprecated. currently only used for ZSP graphics. */
288    bool preAllocPacketMemory;  /* deprecated and unused. */
289} NEXUS_Graphics2DOpenSettings;
290
291/**
292Summary:
293This error code is returned by NEXUS_Graphics2D_Checkpoint if the graphics hardware is busy
294and an asynchronous callback is scheduled to execute when HW will become available.
295**/
296#define NEXUS_GRAPHICS2D_QUEUED NEXUS_MAKE_ERR_CODE(0x101, 2)
297
298/**
299Summary:
300This error code is returned by NEXUS_Graphics2D_Checkpoint if the graphics hardware is busy
301and NEXUS_Graphics2DSettings.pollingCheckpoint is set to true.
302**/
303#define NEXUS_GRAPHICS2D_BUSY NEXUS_MAKE_ERR_CODE(0x101, 3)
304
305/**
306Summary:
307This error code is returned by NEXUS_Graphics2D_Blit, NEXUS_Graphics2D_Fill, NEXUS_Graphics2D_PorterDuffFill,
308NEXUS_Graphics2D_FastBlit or NEXUS_Graphics2D_PorterDuffBlit functions when there is no space in the hardware queue;
309user then could call NEXUS_Graphics2D_Checkpoint function to wait for queue to dry out.
310**/
311#define NEXUS_GRAPHICS2D_QUEUE_FULL NEXUS_MAKE_ERR_CODE(0x101, 4)
312
313/**
314Summary:
315Identifies the pixel format for certain color parameters.
316
317Description:
318The term "standard color format" refers to a 32 bit color value which is
319either ARGB8888 (for RGB surfaces) or AYCbCr8888 (for YCbCr surfaces).
320
321For blit constant color or a blit color key value, only the standard color format is allowed.
322
323For fill, the user has an option to use either the standard color format (NEXUS_ColorFormatType_eStandardFormat)
324or the same pixel format as the surface being filled (NEXUS_ColorFormatType_eSameAsSurface).
325
326For both types, a palette color value is simply the palette index. In lower level software (e.g. GRC), a bit shift of the
327palette index is required in some cases. Nexus handles this automatically in all cases.
328
329Used in NEXUS_Graphics2DSettings.
330**/
331typedef enum NEXUS_ColorFormatType
332{
333    NEXUS_ColorFormatType_eSameAsSurface, /* The associated color parameter has the same format as a related surface.
334                                             For example, for an ARGB1555 surface, the fill color will be ARGB1555. */
335    NEXUS_ColorFormatType_eStandardFormat /* The associated color parameter has the standard color format.
336                                             For example, for an ARGB1555 surface, the fill color will be ARGB8888. */
337} NEXUS_ColorFormatType;
338
339/**
340Summary:
341Settings for the Graphics2D object.
342
343Description:
344Used in NEXUS_Graphics2D_GetSettings and NEXUS_Graphics2D_SetSettings
345**/
346typedef struct NEXUS_Graphics2DSettings
347{
348    NEXUS_ColorFormatType colorFormatType;   /* Specifies how to interpret the NEXUS_Graphics2DFillSettings.color value. */
349    bool blockedSync;       /* deprecated */
350    bool pollingCheckpoint; /* If true, then NEXUS_Graphics2D_Checkpoint will never wait or schedule an asynchronous checkpointCallback.
351                               Instead, it will return either NEXUS_SUCCESS or NEXUS_GRAPHICS2D_BUSY. */
352    unsigned completionTimeout; /* timeout, in microseconds, on how long NEXUS_Graphics2D_Checkpoint should busy loop prior to scheduling an
353                               asynchronous checkpointCallback notification. This is ignored if pollingCheckpoint is true. */
354    NEXUS_CallbackDesc checkpointCallback; /* Callback that is used for asynchronous notification by the NEXUS_Graphics2D_Checkpoint function.
355                               Only used if pollingCheckpoint is false.
356                               This will be overwritten if you call NEXUS_Graphics2D_Checkpoint with a non-NULL callback parameter. */
357    NEXUS_CallbackDesc packetSpaceAvailable; /* if a blit fails with NEXUS_GRAPHICS2D_QUEUE_FULL, packetSpaceAvailable will be fired
358                               when space becomes available. */
359} NEXUS_Graphics2DSettings;
360
361/**
362Summary:
363Get default settings for NEXUS_Graphics2D_Open
364**/
365void NEXUS_Graphics2D_GetDefaultOpenSettings(
366   NEXUS_Graphics2DOpenSettings *pSettings /* [out] */
367   );
368
369/**
370Summary:
371Open a Graphics2D interface for blit and fill operations.
372
373Description:
374You can open more than one instance of the Graphics2D interface with the same index.
375Each instance will use the same HW blitter, but each will have its own SW handle and checkpoint.
376Only the first instance will have its NEXUS_Graphics2DOpenSettings determine the memory allocation.
377**/
378NEXUS_Graphics2DHandle NEXUS_Graphics2D_Open(   /* attr{destructor=NEXUS_Graphics2D_Close}  */
379    unsigned index,
380    const NEXUS_Graphics2DOpenSettings *pSettings /* attr{null_allowed=y} */
381    );
382
383/**
384Summary:
385Close a Graphics2D interface.
386**/
387void NEXUS_Graphics2D_Close(
388    NEXUS_Graphics2DHandle handle
389    );
390
391/**
392Summary:
393Get current settings.
394**/
395void NEXUS_Graphics2D_GetSettings(
396    NEXUS_Graphics2DHandle    handle,
397    NEXUS_Graphics2DSettings *pSettings /* [out] */
398    );
399
400/**
401Summary:
402Apply new settings.
403
404Description:
405These fill take effect on the next blit/flit.
406**/
407NEXUS_Error NEXUS_Graphics2D_SetSettings(
408    NEXUS_Graphics2DHandle          handle,
409    const NEXUS_Graphics2DSettings *pSettings
410    );
411
412/***************************************************************************
413Summary:
414Blending equation factors used in NEXUS_BlendEquation
415****************************************************************************/
416typedef enum NEXUS_BlendFactor
417{
418    NEXUS_BlendFactor_eZero,                    /* Zero */
419    NEXUS_BlendFactor_eHalf,                    /* 1/2 */
420    NEXUS_BlendFactor_eOne,                     /* One */
421    NEXUS_BlendFactor_eSourceColor,             /* Color from source */
422    NEXUS_BlendFactor_eInverseSourceColor,      /* 1-color from source */
423    NEXUS_BlendFactor_eSourceAlpha,             /* Alpha from source */
424    NEXUS_BlendFactor_eInverseSourceAlpha,      /* 1-alpha from source */
425    NEXUS_BlendFactor_eDestinationColor,        /* Color from destination */
426    NEXUS_BlendFactor_eInverseDestinationColor, /* 1-color from destination */
427    NEXUS_BlendFactor_eDestinationAlpha,        /* Alpha from destination */
428    NEXUS_BlendFactor_eInverseDestinationAlpha, /* 1-alpha from destination */
429    NEXUS_BlendFactor_eConstantColor,           /* Color from blend color. See NEXUS_Graphics2DBlitSettings.constantColor. */
430    NEXUS_BlendFactor_eInverseConstantColor,    /* 1-color from blend color */
431    NEXUS_BlendFactor_eConstantAlpha,           /* Alpha from blend color. See NEXUS_Graphics2DBlitSettings.constantColor. */
432    NEXUS_BlendFactor_eInverseConstantAlpha,    /* 1-alpha from blend color */
433    NEXUS_BlendFactor_eMax
434} NEXUS_BlendFactor;
435
436/*****************************************************************************
437Summary:
438Blend equation
439
440Description:
441This gives low-level control of the alpha and color blend equation
442used in NEXUS_Graphics2D_Blit. Used in NEXUS_Graphics2DBlitSettings.
443
444Equation is: a*b +/- c*d +/- e
445
446*****************************************************************************/
447typedef struct NEXUS_BlendEquation
448{
449    NEXUS_BlendFactor a;
450    NEXUS_BlendFactor b;
451    bool              subtract_cd;
452    NEXUS_BlendFactor c;
453    NEXUS_BlendFactor d;
454    bool              subtract_e;
455    NEXUS_BlendFactor e;
456} NEXUS_BlendEquation;
457
458/**
459Summary:
460How to fill the surface with the given color
461
462Description:
463Used in NEXUS_Graphics2DFillSettings
464**/
465typedef enum NEXUS_FillOp
466{
467    NEXUS_FillOp_eIgnore = 0,   /* Do not change the values for the channel (either color or alpha) */
468    NEXUS_FillOp_eCopy,         /* Copy the value of the channel (color or alpha) from the constant color to the surface */
469    NEXUS_FillOp_eBlend,        /* For color channel, blend surface color with constant color using constant alpha.
470                                   This operation is not support for the alpha channel. */
471    NEXUS_FillOp_eUseBlendEquation, /* Use NEXUS_BlendEquation */
472    NEXUS_FillOp_eMax
473} NEXUS_FillOp;
474
475/**
476Summary:
477Parameters for NEXUS_Graphics2D_Fill
478
479Description:
480Used in NEXUS_Graphics2D_GetDefaultFillSettings and NEXUS_Graphics2D_Fill
481**/
482typedef struct NEXUS_Graphics2DFillSettings
483{
484    NEXUS_SurfaceHandle   surface;
485    NEXUS_Pixel           color;           /* Color to fill. See NEXUS_Graphics2DSettings.colorFormatType for the pixel format of this color value. */
486    NEXUS_Rect            rect;            /* Area of surface to fill. width,height of 0,0 fills the entire surface */
487    NEXUS_FillOp          colorOp;         /* Operation to take on the color channel */
488    NEXUS_FillOp          alphaOp;         /* Operation to take on the alpha channel */
489    NEXUS_BlendEquation   colorBlend;      /* Used only if colorOp = NEXUS_FillOp_eUseBlendEquation */
490    NEXUS_BlendEquation   alphaBlend;      /* Used only if alphaOp = NEXUS_FillOp_eUseBlendEquation */
491} NEXUS_Graphics2DFillSettings;
492
493/**
494Summary:
495Get default settings for the structure.
496
497Description:
498This is required in order to make application code resilient to the addition of new structure members in the future.
499**/
500void NEXUS_Graphics2D_GetDefaultFillSettings(
501    NEXUS_Graphics2DFillSettings *pSettings /* [out] */
502    );
503
504/**
505Summary:
506Fill, tint or otherwise modify the pixels of an area of a surface using a constant value
507
508Description:
509This routine modifies the color channels and/or the alpha channel of the
510pixels of a surface using a constant value.
511This function is non-blocking. It returns immediately without waiting for the fill to actually happen.
512
513If packetFifoThreshold is non-zero, NEXUS_Graphics2D_Checkpoint is required to submit queue blits to hardware.
514The NEXUS_Graphics2D_Checkpoint callback is also used to determine when this blit is done.
515**/
516NEXUS_Error NEXUS_Graphics2D_Fill(
517    NEXUS_Graphics2DHandle handle,
518    const NEXUS_Graphics2DFillSettings *pSettings
519    );
520
521/**
522Summary:
523Color operations available in NEXUS_Graphics2DBlitSettings
524
525Description:
526If you want to make no change to the output color, then "source" must be "output".
527
528The NEXUS_BlitColorOp is orthogonal with the NEXUS_BlitAlphaOp.
529Used in NEXUS_Graphics2DBlitSettings
530**/
531typedef enum NEXUS_BlitColorOp
532{
533    NEXUS_BlitColorOp_eCopySource = 0,            /* Copy the source color with no blending. */
534    NEXUS_BlitColorOp_eUseConstantAlpha,          /* Blend the source and dest colors using the alpha from the constantColor param */
535    NEXUS_BlitColorOp_eUseSourceAlpha,            /* Blend the source and dest colors using the alpha from the source pixels */
536    NEXUS_BlitColorOp_eUseDestAlpha,              /* Blend the source and dest colors using the alpha from the dest pixels */
537    NEXUS_BlitColorOp_eSelectPaletteWithColorkey, /* Combine two palettized surfaces using colorkey to select per pixel.
538                                                     Use the colorKeyLower and colorKeyUpper fields of NEXUS_Graphics2DBlitSettings */
539    NEXUS_BlitColorOp_eAdd,                       /* Oc = Sc + Dc. Adds source and destination color.
540                                                     Can be used for brightening and over-saturation effects. */
541    NEXUS_BlitColorOp_eUseBlendEquation,          /* If true, use colorBlend equation */
542    NEXUS_BlitColorOp_eMax
543} NEXUS_BlitColorOp;
544
545/**
546Summary:
547Alpha operations available in NEXUS_Graphics2DBlitSettings
548
549Description:
550If you want to make no change to the output alpha, then either "source" or "dest" must be the same surface as "output".
551
552Using NEXUS_BlitColorOp_eUseConstantAlpha and NEXUS_BlitAlphaOp_eCopyConstant at the same time is not
553supported. There is only one constantColor and it would apply to both operations. If you want to do both
554of these operations with different alpha values, you will need to perform two blits.
555
556The NEXUS_BlitAlphaOp is orthogonal with the NEXUS_BlitColorOp.
557Used in NEXUS_Graphics2DBlitSettings
558
559**/
560typedef enum NEXUS_BlitAlphaOp
561{
562    NEXUS_BlitAlphaOp_eCopySource = 0,            /* Oa = Sa. Copy the source alpha to the output alpha. */
563    NEXUS_BlitAlphaOp_eCopyDest,                  /* Oa = Da. Copy the dest alpha to the output alpha */
564    NEXUS_BlitAlphaOp_eCopyConstant,              /* Oa = Ca (where Ca is constantColor>>24). Copy the constantColor parameter for the output alpha */
565    NEXUS_BlitAlphaOp_eCombine,                   /* Oa = Sa*Sa + Da*(1-Sa). Combine source and dest alpha. */
566    NEXUS_BlitAlphaOp_eEmulateTransparentVideo,   /* Calculate alpha values so that video window, when placed behind the
567                                                     graphics window, appears to be in front of the graphics, with an
568                                                     alpha of Ca. (Oa = 1 - (1-Sa)*Ca) */
569    NEXUS_BlitAlphaOp_eAdd,                       /* Oa = Sa + Da. Adds source and destination alpha. */
570    NEXUS_BlitAlphaOp_eUseBlendEquation,          /* If true, use alphaBlend equation */
571    NEXUS_BlitAlphaOp_eMax
572} NEXUS_BlitAlphaOp;
573
574/**
575Summary:
576Graphics filtering options used in NEXUS_Graphics2DBlitSettings
577**/
578typedef enum NEXUS_Graphics2DFilterCoeffs
579{
580    NEXUS_Graphics2DFilterCoeffs_ePointSample,      /* Point sampled filtering */
581    NEXUS_Graphics2DFilterCoeffs_eBilinear,         /* Bilinear filtering */
582    NEXUS_Graphics2DFilterCoeffs_eAnisotropic,      /* Anisotropic filtering */
583    NEXUS_Graphics2DFilterCoeffs_eSharp,            /* Tabled sin(x)/x filtering */
584    NEXUS_Graphics2DFilterCoeffs_eSharper,          /* Sharper upscale */
585    NEXUS_Graphics2DFilterCoeffs_eBlurry,           /* 3-point filtering */
586    NEXUS_Graphics2DFilterCoeffs_eAntiFlutter,      /* Anti-Flutter filtering */
587    NEXUS_Graphics2DFilterCoeffs_eAntiFlutterBlurry,/* Blurry Anti-Flutter filtering */
588    NEXUS_Graphics2DFilterCoeffs_eAntiFlutterSharp, /* Sharp Anti-Flutter filtering */
589    NEXUS_Graphics2DFilterCoeffs_eMax
590} NEXUS_Graphics2DFilterCoeffs;
591
592#define NEXUS_GRAPHICS2D_COLOR_MATRIX_COEFF_COUNT           (20)
593
594/***************************************************************************
595Summary:
5965x4 coefficient matrix for blitter color space convertor
597
598Description:
599Used in NEXUS_Graphics2DBlitSettings to modify incoming source values.
600
601The 5x4 matrix is applied as follows:
602
603    [C2out]   [M[0]  M[1]  M[2]  M[3]  M[4] ]   [C2in]
604    [C1out]   [M[5]  M[6]  M[7]  M[8]  M[9] ]   [C1in]
605    [C0out] = [M[10] M[11] M[12] M[13] M[14]] * [C0in]
606    [Aout ]   [M[15] M[16] M[17] M[18] M[19]]   [Ain ]
607    [ 1   ]                                     [ 1  ]
608
609    C2out =  M[0]*C2in +  M[1]*C1in +  M[2]*C0in +  M[3]*Ain +  M[4]
610    C1out =  M[5]*C2in +  M[6]*C1in +  M[7]*C0in +  M[8]*Ain +  M[9]
611    C0out = M[10]*C2in + M[11]*C1in + M[12]*C0in + M[13]*Ain + M[14]
612    Aout  = M[15]*C2in + M[16]*C1in + M[17]*C0in + M[18]*Ain + M[19]
613
614This is an identity matrix: M[0] = M[6] = M[12] = M[18] = 1; shift = 0;
615
616An alpha premultiply can be accomplished with:
617
618    uint8_t alpha;
619    M[0] = M[6] = M[12] = alpha;
620    M[18] = 256;
621    shift = 256;
622
623See BGRC_Source_SetColorMatrix5x4 for more detailed comments
624****************************************************************************/
625typedef struct NEXUS_Graphics2DColorMatrix
626{
627    unsigned shift;
628    int32_t  coeffMatrix[NEXUS_GRAPHICS2D_COLOR_MATRIX_COEFF_COUNT];
629} NEXUS_Graphics2DColorMatrix;
630
631
632/*****************************************************************************
633Summary:
634Pattern (raster operations) settings used in NEXUS_Graphics2DBlitSettings
635*****************************************************************************/
636typedef struct NEXUS_Graphics2DPatternSettings
637{
638    uint8_t  ropVector;     /* 8 bit ROP vector. */
639    uint8_t  pattern[64];   /* 8x8 bit ROP pattern. */
640    uint32_t backColor;     /* ROP background color. */
641    uint32_t foreColor;     /* ROP foreground color. */
642} NEXUS_Graphics2DPatternSettings;
643
644/*****************************************************************************
645Summary:
646Scaling control block for blit
647*****************************************************************************/
648typedef struct NEXUS_Graphics2DScalingControlSettings
649{
650    /* See BGRC_Source_SetFilterPhaseAdjustment for additional documentation  */
651    bool     setFilterPhaseAdj;       /* true: Set the filter phase adjustment */
652    int32_t  horizontalPhase;         /* Horizontal initial phase. */
653    int32_t  verticalPhase;           /* Vertical initial phase. */
654    uint32_t phaseFixedPointShift;    /* Fixed-point shift, in bits, to allow for fractional values. */
655
656    /* BGRC_Source_SetFixedScaleFactor for additional documentation */
657    bool     setFixedScaleFactor;     /* true: Set the fixed scale factor */
658    uint32_t horizontalNumerator;     /* Horizontal/Source numerator */
659    uint32_t horizontalDenominator;   /* Horizontal/Source denominator */
660    uint32_t verticalNumerator;       /* Vertical/Output numerator */
661    uint32_t verticalDenominator;     /* Vertical/Output denominator */
662} NEXUS_Graphics2DScalingControlSettings;
663
664/**
665Summary:
666Parameters for NEXUS_Graphics2D_Blit
667
668Description:
669The HW blitter has a maximum vertical and horizontal downscale (current 15x). If you exceed
670this limit, you will get an error from the low-level software under Nexus. If you need a
671greater downscale, you will need to perform multiple passes using an intermediate buffer.
672
673Note regarding palettized destination surfaces: the M2MC hardware cannot perform palette lookups
674on a destination surface. Therefore, any blend operation with a palettized destination surface
675is going to be a blend of the index, not a blend of the color referenced by the index.
676This has some usefulness, but only in a some narrow usage cases. For instance, a palette can be constructed
677where the 8 bits are 3R, 2G, 2B. This would have a meaningful blend.
678If you have not set up your destination palette index to have a meaningful blend, you will get strange results
679if you attempt a blend.
680
681Used in NEXUS_Graphics2D_Blit
682**/
683typedef struct NEXUS_Graphics2DBlitSettings
684{
685    struct
686    {
687        NEXUS_SurfaceHandle surface;  /* May be NULL for some operations. */
688        NEXUS_Rect rect;              /* width,height of 0,0 for source or output indicates the entire surface.
689                                         dest's width,height are ignored because, by definition, they must be the same as output's. */
690    } source, dest, output;
691
692    NEXUS_BlitColorOp       colorOp;         /* Specify how to blit the color component */
693    NEXUS_BlitAlphaOp       alphaOp;         /* Specify how to blit the alpha component */
694
695    NEXUS_BlendEquation     colorBlend;      /* Used only if colorOp = NEXUS_BlitColorOp_eUseBlendEquation */
696    NEXUS_BlendEquation     alphaBlend;      /* Used only if alphaOp = NEXUS_BlitAlphaOp_eUseBlendEquation */
697
698    NEXUS_Pixel             constantColor;       /*  Constant alpha and color. Only standard color format supported (see NEXUS_ColorFormatType). Used by some operations. */
699    bool                    useDestAndSourceConstantColor; /* if false, constantColor is used for BLEND, SRC and DEST blocks.
700                                                              if true, destConstantColor and sourceConstantColor are used. */
701    NEXUS_Pixel             destConstantColor;   /* color for DEST block, if useDestAndSourceConstantColors is true. Used if DEST surface has no color. */
702    NEXUS_Pixel             sourceConstantColor; /* color for SOURCE block, if useDestAndSourceConstantColors is true. Used if SOURCE surface has no color. */
703   
704    struct {
705        struct {
706            bool enabled;     /* Enable colorkey. If disabled, the following values are ignored. */
707            NEXUS_Pixel lower;   /* Lower colorkey value. Only standard color format supported (see NEXUS_ColorFormatType). */
708            NEXUS_Pixel upper;   /* Upper colorkey value. Only standard color format supported (see NEXUS_ColorFormatType). */
709            NEXUS_Pixel mask;    /* Mask to use when comparing color key to source color */
710            NEXUS_Pixel replace; /* Replacement color */
711            NEXUS_Pixel replaceMask; /*  Mask for replacement color */
712        } source, dest;
713    } colorKey;
714
715    bool conversionMatrixEnabled;   /* if true, use conversionMatrix. no automatic YCrCb/RGB conversion will take place. */
716    NEXUS_Graphics2DColorMatrix conversionMatrix; /* modifying incoming source values before any blend */
717
718    bool patternSettingsEnabled; /* if true, use patternSettings */
719    NEXUS_Graphics2DPatternSettings patternSettings;
720
721    NEXUS_Graphics2DFilterCoeffs horizontalFilter;
722    NEXUS_Graphics2DFilterCoeffs verticalFilter;
723
724    bool scalingControlSettingsEnabled; /* if true, use scalingControlSettings */
725    NEXUS_Graphics2DScalingControlSettings scalingControlSettings;
726
727    /* Blit direction reversal flags. Default is false which is top to bottom, left to right.
728    If you mirror both source and dest at the same time, you will get non-mirrored output. This is a useful technique for a memmove-style blit
729    where the output overlaps the source in the same surface. This is done by default if mirror booleans are left at their default false values. */
730    bool mirrorSourceVertically; /* If true, read source bottom to top. */
731    bool mirrorSourceHorizontally; /* If true, read source right to left. */
732    bool mirrorDestVertically; /* If true, read dest and write output bottom to top. mirrorDest flags apply to both dest and output surfaces. */
733    bool mirrorDestHorizontally; /* If true, read dest and write output left to right. mirrorDest flags apply to both dest and output surfaces. */
734
735    /* Enable/Disable Alpha Premultiplication */
736    bool alphaPremultiplySourceEnabled; /* If true, then each color component in the source surface will be modulated with the
737                                           source's alpha component before scaling. */
738} NEXUS_Graphics2DBlitSettings;
739
740/**
741Summary:
742Get default settings for the structure.
743
744Description:
745This is required in order to make application code resilient to the addition of new structure members in the future.
746**/
747void NEXUS_Graphics2D_GetDefaultBlitSettings(
748    NEXUS_Graphics2DBlitSettings *pSettings /* [out] */
749    );
750
751/**
752Summary:
753Perform a block transfer (blit) from one or two surfaces to a destination.
754
755Description:
756This function is non-blocking. It returns immediately without waiting for the fill to actually happen.
757
758Example:
759A simple copy of a whole surface to another surface can be performed as follows:
760
761    NEXUS_Graphics2D_GetDefaultBlitSettings(&blitSettings);
762    blitSettings.source.surface = source_surface;
763    blitSettings.output.surface = output_surface;
764    NEXUS_Graphics2D_Blit(handle, &blitSettings);
765
766If packetFifoThreshold is non-zero, NEXUS_Graphics2D_Checkpoint is required to submit queue blits to hardware.
767The NEXUS_Graphics2D_Checkpoint callback is also used to determine when this blit is done.
768**/
769NEXUS_Error NEXUS_Graphics2D_Blit(
770    NEXUS_Graphics2DHandle              handle,
771    const NEXUS_Graphics2DBlitSettings *pSettings
772    );
773
774/**
775Summary:
776Perform a block transfer (blit) from one surface to a destination.
777
778Description:
779This is a faster, less feature-rich version of NEXUS_Graphics2D_Blit.
780
781Example:
782A simple copy of a whole surface to another surface can be performed as follows:
783
784    NEXUS_Graphics2D_FastBlit(handle,
785        output_surface, NULL,
786        source_surface, NULL,
787        NEXUS_BlitColorOp_eCopySource,
788        NEXUS_BlitAlphaOp_eCopySource,
789        0);
790
791Only the following ops are supported:
792    NEXUS_BlitColorOp_eCopySource
793    NEXUS_BlitAlphaOp_eCopySource
794    NEXUS_BlitAlphaOp_eCopyConstant
795
796This blit does not support color keying, dest surface, matrix conversion or YCrCb/RGB conversion.
797
798If packetFifoThreshold is non-zero, NEXUS_Graphics2D_Checkpoint is required to submit queue blits to hardware.
799The NEXUS_Graphics2D_Checkpoint callback is also used to determine when this blit is done.
800**/
801NEXUS_Error NEXUS_Graphics2D_FastBlit(
802    NEXUS_Graphics2DHandle handle,
803    NEXUS_SurfaceHandle outputSurface,
804    const NEXUS_Rect *pOutputRect,          /* attr{null_allowed=y} if NULL, blit to whole surface */
805    NEXUS_SurfaceHandle sourceSurface,
806    const NEXUS_Rect *pSourceRect,          /* attr{null_allowed=y} if NULL, blit from whole surface */
807    NEXUS_BlitColorOp colorOp,
808    NEXUS_BlitAlphaOp alphaOp,
809    NEXUS_Pixel constantColor
810    );
811
812/**
813Summary:
814PorterDuff Operations used in NEXUS_Graphics2D_PorterDuffFill and NEXUS_Graphics2D_PorterDuffBlit
815
816Description:
817Used in NEXUS_Graphics2DPorterDuffFillSettings and NEXUS_Graphics2DPorterDuffBlitSettings
818**/
819typedef enum NEXUS_PorterDuffOp
820{
821    NEXUS_PorterDuffOp_eClear = 0,   /* Erase output  */
822    NEXUS_PorterDuffOp_eSrc,         /* Copy source to output */
823    NEXUS_PorterDuffOp_eDst,         /* Copy dest to output */
824    NEXUS_PorterDuffOp_eSrcOver,     /* Source over dest */
825    NEXUS_PorterDuffOp_eDstOver,     /* Dest over source */
826    NEXUS_PorterDuffOp_eSrcIn,       /* Part of source within dest */
827    NEXUS_PorterDuffOp_eDstIn,       /* Part of dest within source */
828    NEXUS_PorterDuffOp_eSrcOut,      /* Part of source not in dest */
829    NEXUS_PorterDuffOp_eDstOut,      /* Part of dest not in source */
830    NEXUS_PorterDuffOp_eSrcAtop,     /* Part of source in dest and remainder is dest */
831    NEXUS_PorterDuffOp_eDstAtop,     /* Part of dest in source and remainder is source */
832    NEXUS_PorterDuffOp_eXor,         /* Part of src not in dest and part of dest not in source */
833    NEXUS_PorterDuffOp_eMax
834} NEXUS_PorterDuffOp;
835
836/**
837Summary:
838Parameters for NEXUS_Graphics2D_PorterDuffFill
839
840Description:
841Used in NEXUS_Graphics2D_GetDefaultPorterDuffFillSettings and NEXUS_Graphics2D_PorterDuffFill
842**/
843typedef struct NEXUS_Graphics2DPorterDuffFillSettings
844{
845    NEXUS_PorterDuffOp    operation;       /*  A Porter-Duff operation */
846    NEXUS_SurfaceHandle   surface;
847    NEXUS_Pixel           color;           /* Color to fill. See NEXUS_Graphics2DSettings.colorFormatType for the pixel format of this color value. */
848    NEXUS_Rect            rect;            /* Area of surface to fill. width,height of 0,0 fills the entire surface */
849} NEXUS_Graphics2DPorterDuffFillSettings;
850
851/**
852Summary:
853Get default settings for the structure.
854
855Description:
856This is required in order to make application code resilient to the addition of new structure members in the future.
857**/
858void NEXUS_Graphics2D_GetDefaultPorterDuffFillSettings(
859    NEXUS_Graphics2DPorterDuffFillSettings *pSettings /* [out] */
860    );
861
862/**
863Summary:
864Fill, tint or otherwise modify the pixels of an area of a surface using a constant value and
865Porter-Duff composition rules.
866
867Description:
868This routine modifies the color channels and/or the alpha channel of the
869pixels of a surface using a combination of constant value and Porter-Duff composition rules.
870This function is non-blocking. It returns immediately without waiting for the fill to actually happen.
871
872If packetFifoThreshold is non-zero, NEXUS_Graphics2D_Checkpoint is required to submit queue blits to hardware.
873The NEXUS_Graphics2D_Checkpoint callback is also used to determine when this blit is done.
874**/
875NEXUS_Error NEXUS_Graphics2D_PorterDuffFill(
876    NEXUS_Graphics2DHandle handle,
877    const NEXUS_Graphics2DPorterDuffFillSettings *pSettings
878    );
879
880/**
881Summary:
882Parameters for a Porter-Duff blit.
883
884Description:
885Used in NEXUS_Graphics2D_PorterDuffBlit
886**/
887typedef struct NEXUS_Graphics2DPorterDuffBlitSettings
888{
889    NEXUS_PorterDuffOp   operation;        /*  A Porter-Duff operation */
890    NEXUS_SurfaceHandle  sourceSurface;
891    NEXUS_Rect           sourceRect;       /*  Area of sourceSurface to blit from. width,height of 0,0 blits from the entire surface */
892    NEXUS_SurfaceHandle  destSurface;
893    NEXUS_Rect           destRect;         /*  Area of destSurface to blit from. width,height of 0,0 blits from the entire surface */
894    NEXUS_SurfaceHandle  outSurface;
895    NEXUS_Rect           outRect;          /*  Area of outSurface to blit from. width,height of 0,0 blits to the entire surface */
896} NEXUS_Graphics2DPorterDuffBlitSettings;
897
898/**
899Summary:
900Get default settings for the structure.
901
902Description:
903;his is required in order to make application code resilient to the addition of new structure members in the future.
904**/
905void NEXUS_Graphics2D_GetDefaultPorterDuffBlitSettings(
906    NEXUS_Graphics2DPorterDuffBlitSettings *pSettings /* [out] */
907    );
908
909/**
910Summary:
911Combine two surfaces into a third using Porter-Duff composition rules
912
913Description:
914This routine combines an area of the source surface and an area of the
915destination surface into an area of the output surface using Porter-Duff
916composition rules. No color space conversion or color keying is performed.
917
918If the source surface is palette-based and the output surface is not
919paletted-based, then the palette entries in the source pixels will be
920converted to colors in the output pixels
921
922This function is non-blocking. It returns immediately without waiting for the fill to actually happen.
923
924If packetFifoThreshold is non-zero, NEXUS_Graphics2D_Checkpoint is required to submit queue blits to hardware.
925The NEXUS_Graphics2D_Checkpoint callback is also used to determine when this blit is done.
926**/
927NEXUS_Error NEXUS_Graphics2D_PorterDuffBlit(
928    NEXUS_Graphics2DHandle handle,
929    const NEXUS_Graphics2DPorterDuffBlitSettings *pSettings
930    );
931
932/**
933Summary:
934Submit queue blits to hardware and check status of the graphics hardware for completion of all blit and fill operations.
935
936Description:
937If packetFifoThreshold is non-zero, NEXUS_Graphics2D_Checkpoint is required to submit queue blits to hardware.
938
939Prior to the CPU accessing the surface memory (see NEXUS_Surface_GetMemory)
940or before setting a surface as the current framebuffer (see NEXUS_Display_SetGraphicsFramebuffer)
941you should check that the graphics hardware has completed all operations.
942For maximum throughput, you should only call NEXUS_Graphics2D_Checkpoint when one of these boundary conditions occurs.
943
944NEXUS_Graphics2D_Checkpoint will notify the caller when all blits prior it being called have completed.
945NEXUS_Graphics2D_Checkpoint can either return immediately with those results or return immediately after
946scheduling a checkpointCallback.
947NEXUS_Graphics2D_Checkpoint never blocks.
948
949Return values if pLegacyCallback is NULL:
950    NEXUS_SUCCESS - there are no outstanding blit and fill operations in the hardware.
951    NEXUS_GRAPHICS2D_QUEUED - there are some outstanding blit and/or fill operations in the hardware queue. when these blits are completed NEXUS_Graphics2DSettings.checkpointCallback is fired.
952    NEXUS_GRAPHICS2D_BUSY - there are some outstanding blit and/or fill operations in the hardware queue. This can only occur if NEXUS_Graphics2DSettings.pollingCheckpoint is true.
953
954Return values if pLegacyCallback is not NULL (not recommended):
955    NEXUS_SUCCESS - the pLegacyCallback has been scheduled. wait on that callback to learn when all blits prior to NEXUS_Graphics2D_Checkpoint have completed.
956    Non-zero value - a system error has occured
957
958Be aware that if NEXUS_Graphics2D_Checkpoint schedules a checkpointCallback, it is possible for other blits to be issued after NEXUS_Graphics2D_Checkpoint is called
959but before the checkpointCallback arrives. When the checkpointCallback arrives, it only means that all blits prior to NEXUS_Graphics2D_Checkpoint have completed.
960
961NEXUS_Graphics2D_Checkpoint should not be called from multiple threads with the same handle.
962Instead, each thread should open its own instance of NEXUS_Graphics2D.
963See nexus/examples/graphics/multithreaded_fill for an example of how to write multi-threaded graphics code.
964
965See Also:
966NEXUS_Graphics2D_Blit
967NEXUS_Graphics2D_Fill
968NEXUS_Graphics2D_PorterDuffFill
969NEXUS_Graphics2D_PorterDuffBlit
970NEXUS_Surface_GetMemory
971NEXUS_Display_SetGraphicsFramebuffer
972NEXUS_Graphics2DSettings
973**/
974NEXUS_Error NEXUS_Graphics2D_Checkpoint(
975    NEXUS_Graphics2DHandle handle,
976    const NEXUS_CallbackDesc *pLegacyCallback /* attr{null_allowed=y} Legacy argument. New code should pass NULL here and use NEXUS_Graphics2DSettings.checkpointCallback instead. */
977    );
978
979/**
980Summary:
981Create a new surface by copying from a striped surface
982
983Description:
984A striped surface is the output of NEXUS_StillDecoder_GetStripedSurface
985When the user is done with the returned surface, the user must destroy it by calling NEXUS_Surface_Destroy.
986**/
987NEXUS_SurfaceHandle NEXUS_Graphics2D_Destripe(
988    NEXUS_Graphics2DHandle handle,
989    NEXUS_StripedSurfaceHandle stripedSurface
990    );
991
992/**
993Summary:
994Destripe a surface into another surface which has already been created
995
996Description:
997Call NEXUS_StripedSurface_GetStatus to get the width and height before destriping.
998
999A striped surface is the output of NEXUS_StillDecoder_GetStripedSurface.
1000
1001This function is preferred over NEXUS_Graphics2D_Destripe in a memory constrained system because the application
1002can minimize heap allocations.
1003
1004If the striped surface is smaller than the target surface (in both width and height), then the resulting destriped pixels
1005will be placed in the upper left corner of the target surface. If the striped surface is larger than the target surface,
1006this function will fail.
1007**/
1008NEXUS_Error NEXUS_Graphics2D_DestripeToSurface(
1009    NEXUS_Graphics2DHandle handle,
1010    NEXUS_StripedSurfaceHandle stripedSurface,
1011    NEXUS_SurfaceHandle targetSurface,
1012    const NEXUS_Rect *pTargetRect /* attr{null_allowed=y} optional */
1013    );
1014
1015/**
1016Summary:
1017Perform a 32 bit memset using M2MC hardware
1018
1019Description:
1020This call is asynchronous, just like NEXUS_Graphics2D_Blit. Use NEXUS_Graphics2D_Checkpoint.
1021
1022Some caveats:
1023- The count parameter is the number of uint32_t's, not the number of bytes.
1024- The count parameter must be a multiple of 1024, which means NEXUS_Graphics2D_Memset32 works in multiples of 4096 bytes.
1025- Because NEXUS_Graphics2D_Memset32 uses the M2MC hardware, you may need to flush the cache (NEXUS_Memory_FlushCache) before calling it.
1026**/
1027NEXUS_Error NEXUS_Graphics2D_Memset32(
1028    NEXUS_Graphics2DHandle handle,
1029    void *address,  /* attr{memory=cached} address to buffer which was allocated from the heap (e.g. NEXUS_Memory_Allocate). */
1030    uint32_t data,  /* 32 value to write to the buffer */
1031    unsigned count  /* number of uint32_t's to write (not number of bytes). because of constraints of M2MC hardware, count must be between 1K and 16M and
1032                       must be evenly divisible by 1K. */
1033    );
1034
1035/**
1036Summary:
1037Deprecated. Use packet blit instead.
1038**/
1039typedef struct NEXUS_Graphics2DBatchBlitSettings
1040{
1041    NEXUS_SurfaceHandle outSurface;   /* output surface (always set) */
1042    const uint32_t     *pOutOffsets;  /* attr{memory=cached} pointer to output device offsets (replaces address in output surface) */
1043    const uint16_t     *pOutPoints;   /* attr{memory=cached} pointer to output x and y buffer (always set) */
1044    const uint16_t     *pOutSizes;    /* attr{memory=cached} pointer to output width and height buffer (always set) */
1045    NEXUS_SurfaceHandle srcSurface;   /* source surface */
1046    const uint32_t     *pSrcOffsets;  /* attr{memory=cached} pointer to source device offsets (replaces address in source surface) */
1047    const uint16_t     *pSrcPoints;   /* attr{memory=cached} pointer to source x and y buffer */
1048    const uint16_t     *pSrcSizes;    /* attr{memory=cached} pointer to source width and height buffer (only set when scaling) */
1049    NEXUS_SurfaceHandle dstSurface;   /* destination surface (only set with blends, rops, or colorkey) */
1050    const uint32_t     *pDstOffsets;  /* attr{memory=cached} pointer to destination device offsets (replaces address in destination surface) */
1051    const uint16_t     *pDstPoints;   /* attr{memory=cached} pointer to destination x and y buffer */
1052    const NEXUS_Pixel  *pColors;      /* attr{memory=cached} pointer to constant color buffer (32bpp ARGB or AYCbCr)*/
1053} NEXUS_Graphics2DBatchBlitSettings;
1054
1055/**
1056Summary:
1057Deprecated. Use packet blit instead.
1058**/
1059void NEXUS_Graphics2D_GetDefaultBatchBlitSettings(
1060    NEXUS_Graphics2DBatchBlitSettings *pSettings /* [out] */
1061    );
1062
1063/**
1064Summary:
1065Deprecated. Use packet blit instead.
1066**/
1067NEXUS_Error NEXUS_Graphics2D_BatchBlit(
1068    NEXUS_Graphics2DHandle handle,
1069    size_t count,     /* number of blits in batch */
1070    size_t index,     /* index of first blit */
1071    size_t *next,     /* [out] index of first blit not submitted due to lack of memory. */
1072                      /* All blits are complete when *next=count after returning. */
1073    const NEXUS_Graphics2DBatchBlitSettings *pBatchSettings,   /* surfaces and pointers to point, size, and color buffers */
1074    const NEXUS_Graphics2DBlitSettings *pBlitSettings          /* blit state */
1075    );
1076
1077/**
1078Summary:
1079Get memory for packet-based blitting
1080
1081Description:
1082See bm2mc_packet.h and nexus/examples/graphics/packet_* for packet API documentation.
1083**/
1084NEXUS_Error NEXUS_Graphics2D_GetPacketBuffer(
1085    NEXUS_Graphics2DHandle handle,
1086    void **pBuffer, /* [out] attr{memory=cached} */
1087    size_t *pSize, /* [out] */
1088    size_t minSize
1089    );
1090
1091/**
1092Summary:
1093Submit packet blits
1094**/
1095NEXUS_Error NEXUS_Graphics2D_PacketWriteComplete(
1096    NEXUS_Graphics2DHandle handle,
1097    size_t size
1098    );
1099
1100/**
1101Summary:
1102Applications can #if NEXUS_GRAPHICS2D_PACKET_SUPPORT if they are running older versions
1103which do not have the packet api.
1104**/
1105#define NEXUS_GRAPHICS2D_PACKET_SUPPORT
1106
1107#include "bm2mc_packet.h"
1108
1109/**
1110Summary:
1111Convert NEXUS_Graphics2DFilterCoeffs to BM2MC_PACKET_FilterCoeffs
1112**/
1113NEXUS_Error NEXUS_Graphics2D_ConvertFilter(
1114    NEXUS_Graphics2DFilterCoeffs filter,
1115    size_t srcSize,                        /* source width or height */
1116    size_t outSize,                        /* output width or height */
1117    BM2MC_PACKET_FilterCoeffs *pCoeffs     /* [out] packet filter coeffs */
1118    );
1119
1120/**
1121Summary:
1122Convert NEXUS_Graphics2DColorMatrix to BM2MC_PACKET_ColorMatrix
1123**/
1124NEXUS_Error NEXUS_Graphics2D_ConvertColorMatrix(
1125    const NEXUS_Graphics2DColorMatrix *pMatrixIn,
1126    BM2MC_PACKET_ColorMatrix *pMatrixOut /* [out] */
1127    );
1128
1129#ifdef __cplusplus
1130}
1131#endif
1132
1133#endif
Note: See TracBrowser for help on using the repository browser.