| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2003-2012, Broadcom Corporation |
|---|
| 3 | * All Rights Reserved |
|---|
| 4 | * Confidential Property of Broadcom Corporation |
|---|
| 5 | * |
|---|
| 6 | * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 7 | * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 8 | * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 9 | * |
|---|
| 10 | * $brcm_Workfile: bgrclib_packet.c $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/49 $ |
|---|
| 12 | * $brcm_Date: 2/29/12 10:19a $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/syslib/grclib/7401/bgrclib_packet.c $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/49 2/29/12 10:19a erickson |
|---|
| 21 | * SW7420-2155: fix use of default mirror packet |
|---|
| 22 | * |
|---|
| 23 | * Hydra_Software_Devel/48 2/16/12 3:45p nissen |
|---|
| 24 | * SW7405-5427: Adding flags for output mirroring when blitting |
|---|
| 25 | * |
|---|
| 26 | * Hydra_Software_Devel/47 12/8/11 10:57a erickson |
|---|
| 27 | * SW7425-1921: note that BGRC_Output_ColorKeySelection is unused, but |
|---|
| 28 | * extend BGRClib_BlitColorKeyParams for completeness |
|---|
| 29 | * |
|---|
| 30 | * Hydra_Software_Devel/46 7/28/11 2:56p nissen |
|---|
| 31 | * SW7405-5427: Modified to disable filter when not scaling in cases when |
|---|
| 32 | * it is not required. |
|---|
| 33 | * |
|---|
| 34 | * Hydra_Software_Devel/45 7/21/11 5:27p erickson |
|---|
| 35 | * SW7420-1974: add separate dest and source constantColor |
|---|
| 36 | * |
|---|
| 37 | * Hydra_Software_Devel/44 7/20/11 3:41p nissen |
|---|
| 38 | * SW7405-5427: Added support for mirroring the output. |
|---|
| 39 | * |
|---|
| 40 | * Hydra_Software_Devel/43 7/13/11 2:18p erickson |
|---|
| 41 | * SW7420-1974: add BM2MC_PACKET_PacketDestinationColor back in |
|---|
| 42 | * |
|---|
| 43 | * Hydra_Software_Devel/42 7/6/11 2:25p erickson |
|---|
| 44 | * SW7420-1974: backing out use of BM2MC_PACKET_PacketDestinationColor |
|---|
| 45 | * until fix for non-dest blits can be found |
|---|
| 46 | * |
|---|
| 47 | * Hydra_Software_Devel/41 7/1/11 4:05p erickson |
|---|
| 48 | * SW7420-1974: use BM2MC_PACKET_PacketDestinationColor if there's no |
|---|
| 49 | * destination surface |
|---|
| 50 | * |
|---|
| 51 | * Hydra_Software_Devel/40 5/31/11 1:16p erickson |
|---|
| 52 | * SW7420-1200: remove unused functions, add missing const, clean up |
|---|
| 53 | * comments |
|---|
| 54 | * |
|---|
| 55 | * Hydra_Software_Devel/39 5/24/11 4:09p erickson |
|---|
| 56 | * SW7346-149: remove unused functions |
|---|
| 57 | * |
|---|
| 58 | * Hydra_Software_Devel/38 5/24/11 3:14p erickson |
|---|
| 59 | * SW7420-1200: refactor grclib for optimal nexus use |
|---|
| 60 | * |
|---|
| 61 | * Hydra_Software_Devel/37 5/23/11 4:50p erickson |
|---|
| 62 | * SW7420-1200: refactor grclib for optimal nexus use |
|---|
| 63 | * |
|---|
| 64 | * Hydra_Software_Devel/36 4/21/11 6:02p nissen |
|---|
| 65 | * SW7335-1221: Fixed PorterDuff palette blit. |
|---|
| 66 | * |
|---|
| 67 | * Hydra_Software_Devel/35 3/18/11 1:21p nissen |
|---|
| 68 | * SW7420-1575: Added new width and height fields for surface planes. |
|---|
| 69 | * |
|---|
| 70 | * Hydra_Software_Devel/34 1/6/11 5:04p erickson |
|---|
| 71 | * SW7405-5090: fix possible div-by-zero |
|---|
| 72 | * |
|---|
| 73 | * Hydra_Software_Devel/33 11/30/10 4:28p nissen |
|---|
| 74 | * SW7405-3671: Fixed warnings. |
|---|
| 75 | * |
|---|
| 76 | * Hydra_Software_Devel/32 11/29/10 1:50p nissen |
|---|
| 77 | * SW7335-916: Fixed support for FixedScale packet. |
|---|
| 78 | * |
|---|
| 79 | * Hydra_Software_Devel/31 11/16/10 2:54p erickson |
|---|
| 80 | * SW7420-1200: when we run out of SW fifo memory for a blit, we should |
|---|
| 81 | * fail with BERR_OUT_OF_DEVICE_MEMORY and no BERR_TRACE |
|---|
| 82 | * |
|---|
| 83 | * Hydra_Software_Devel/30 11/11/10 1:35p nissen |
|---|
| 84 | * SW7335-916: Added support for FixedScale packet. |
|---|
| 85 | * |
|---|
| 86 | * Hydra_Software_Devel/29 9/20/10 4:33p nissen |
|---|
| 87 | * SW7405-4869: Fixed Rop usage. |
|---|
| 88 | * |
|---|
| 89 | * Hydra_Software_Devel/28 8/27/10 6:24p nissen |
|---|
| 90 | * SW7405-3671: Added Porter Duff support. |
|---|
| 91 | * |
|---|
| 92 | * Hydra_Software_Devel/27 8/5/10 6:04p nissen |
|---|
| 93 | * SW7405-3671: Fixed output offset packet and warnings. |
|---|
| 94 | * |
|---|
| 95 | * Hydra_Software_Devel/26 7/28/10 11:53a erickson |
|---|
| 96 | * SW7405-3671: add #if GRCPACKET_SUPPORT logic |
|---|
| 97 | * |
|---|
| 98 | * Hydra_Software_Devel/25 7/12/10 2:25p nissen |
|---|
| 99 | * SW7405-3671: Updated to work with new packet api changes. |
|---|
| 100 | * |
|---|
| 101 | * Hydra_Software_Devel/24 6/30/10 8:18p nissen |
|---|
| 102 | * SW7405-3671: Fixed support for pixel format. |
|---|
| 103 | * |
|---|
| 104 | * Hydra_Software_Devel/23 6/30/10 7:54p nissen |
|---|
| 105 | * SW7405-3671: Added to support blending and pixel format enums for |
|---|
| 106 | * packets. |
|---|
| 107 | * |
|---|
| 108 | * Hydra_Software_Devel/22 6/24/10 2:22p nissen |
|---|
| 109 | * SW7405-3671: Added source feeder destripe packet function. |
|---|
| 110 | * |
|---|
| 111 | * Hydra_Software_Devel/21 6/21/10 12:45p nissen |
|---|
| 112 | * SW7405-3671: Added context support. Switched to M2MC packets. |
|---|
| 113 | * |
|---|
| 114 | * Hydra_Software_Devel/20 3/19/10 2:24p nissen |
|---|
| 115 | * SW7405-3671: Fixed colorkey. |
|---|
| 116 | * |
|---|
| 117 | * Hydra_Software_Devel/19 3/15/10 1:34p nissen |
|---|
| 118 | * SW7405-3671: Removed unnecessary call to get palette. |
|---|
| 119 | * |
|---|
| 120 | * Hydra_Software_Devel/18 3/11/10 1:14p nissen |
|---|
| 121 | * SW7405-3671: Added support for alpha premultiply. |
|---|
| 122 | * |
|---|
| 123 | * Hydra_Software_Devel/17 3/10/10 2:42p nissen |
|---|
| 124 | * SW7405-3671: Added offset buffer pointers to batch packet blits. |
|---|
| 125 | * |
|---|
| 126 | * Hydra_Software_Devel/16 2/16/10 4:32p nissen |
|---|
| 127 | * SW7405-3671: Fixed warnings. |
|---|
| 128 | * |
|---|
| 129 | * Hydra_Software_Devel/15 2/10/10 2:20p nissen |
|---|
| 130 | * SW7405-3671: Fixed palette to palette blits. |
|---|
| 131 | * |
|---|
| 132 | * Hydra_Software_Devel/14 2/9/10 4:26p nissen |
|---|
| 133 | * SW7405-3671: Updated batch blits. |
|---|
| 134 | * |
|---|
| 135 | * Hydra_Software_Devel/13 2/8/10 11:25p nissen |
|---|
| 136 | * SW7405-3671: Added support for eUseBlendFactors. |
|---|
| 137 | * |
|---|
| 138 | * Hydra_Software_Devel/12 2/8/10 9:07p nissen |
|---|
| 139 | * SW7405-3671: Added use of surface ID for identifying surfaces. |
|---|
| 140 | * |
|---|
| 141 | * Hydra_Software_Devel/11 2/8/10 6:04p nissen |
|---|
| 142 | * SW7405-3671: Updated batching to submit as many blits as possible. |
|---|
| 143 | * |
|---|
| 144 | * Hydra_Software_Devel/10 2/5/10 8:24p nissen |
|---|
| 145 | * SW7405-3671: Fixed palette to palette blits. |
|---|
| 146 | * |
|---|
| 147 | * Hydra_Software_Devel/9 2/5/10 4:35p nissen |
|---|
| 148 | * SW7405-3671: Fixed problem with getting color. |
|---|
| 149 | * |
|---|
| 150 | * Hydra_Software_Devel/8 2/5/10 12:07p nissen |
|---|
| 151 | * SW7405-3671: Fixed problem with init packet. |
|---|
| 152 | * |
|---|
| 153 | * Hydra_Software_Devel/7 2/5/10 10:51a nissen |
|---|
| 154 | * SW7405-3671: Moved packet function. |
|---|
| 155 | * |
|---|
| 156 | * Hydra_Software_Devel/6 2/3/10 2:14p nissen |
|---|
| 157 | * SW7405-3671: Added batch packets. |
|---|
| 158 | * |
|---|
| 159 | * Hydra_Software_Devel/5 1/29/10 7:30p nissen |
|---|
| 160 | * SW7405-3671: Added support for using packets in any order. |
|---|
| 161 | * |
|---|
| 162 | * Hydra_Software_Devel/4 1/19/10 12:39p nissen |
|---|
| 163 | * SW7405-3671: Added support for sync'ing and 420 destriping. |
|---|
| 164 | * |
|---|
| 165 | * Hydra_Software_Devel/3 1/8/10 2:23p nissen |
|---|
| 166 | * SW7405-3671: Removed sync function. |
|---|
| 167 | * |
|---|
| 168 | * Hydra_Software_Devel/2 1/7/10 5:21p nissen |
|---|
| 169 | * SW7405-3671: Fixed reset when syncing. |
|---|
| 170 | * |
|---|
| 171 | * Hydra_Software_Devel/1 1/6/10 10:29p nissen |
|---|
| 172 | * SW7405-3671: Packet blits. |
|---|
| 173 | * |
|---|
| 174 | ***************************************************************************/ |
|---|
| 175 | |
|---|
| 176 | #include "bgrclib_packet.h" |
|---|
| 177 | #include "bstd.h" |
|---|
| 178 | #include "berr.h" |
|---|
| 179 | #include "berr_ids.h" |
|---|
| 180 | #include "bdbg.h" |
|---|
| 181 | #include "bkni.h" |
|---|
| 182 | |
|---|
| 183 | #include "bm2mc_packet.h" |
|---|
| 184 | #include "bgrc_packet.h" |
|---|
| 185 | #include "bgrc_packet_write.h" |
|---|
| 186 | |
|---|
| 187 | BDBG_MODULE(BGRClib); |
|---|
| 188 | |
|---|
| 189 | BDBG_OBJECT_ID(GRClib); |
|---|
| 190 | |
|---|
| 191 | typedef struct BGRClib_P_Data_tag |
|---|
| 192 | { |
|---|
| 193 | BDBG_OBJECT(GRClib) |
|---|
| 194 | BGRC_Handle hGRC; |
|---|
| 195 | BGRC_PacketContext_Handle hContext; |
|---|
| 196 | bool defaultRopPacket; |
|---|
| 197 | bool defaultSourceColorkeyPacket; |
|---|
| 198 | bool defaultDstColorkeyPacket; |
|---|
| 199 | bool defaultBlitBlendPacket; |
|---|
| 200 | bool defaultFillBlendPacket; |
|---|
| 201 | bool defaultSourceFeederPacket; |
|---|
| 202 | bool defaultDestinationFeederPacket; |
|---|
| 203 | bool defaultColorMatrixPacket; |
|---|
| 204 | bool defaultAlphaPremultiplyPacket; |
|---|
| 205 | bool defaultMirrorPacket; |
|---|
| 206 | bool defaultFixedScalePacket; |
|---|
| 207 | struct { |
|---|
| 208 | BGRC_FilterCoeffs vertCoeffs, horzCoeffs; |
|---|
| 209 | bool vertScaling, horzScaling; |
|---|
| 210 | } filterPacket; |
|---|
| 211 | } |
|---|
| 212 | BGRClib_P_Data; |
|---|
| 213 | |
|---|
| 214 | #define DEFAULT_COLOR (0xFF000000) |
|---|
| 215 | |
|---|
| 216 | #if 0 |
|---|
| 217 | /* some helpful debug code */ |
|---|
| 218 | static const char *g_blendFactor[] = |
|---|
| 219 | { |
|---|
| 220 | "Zero", |
|---|
| 221 | "Half", |
|---|
| 222 | "One", |
|---|
| 223 | "SourceColor", |
|---|
| 224 | "InverseSourceColor", |
|---|
| 225 | "SourceAlpha", |
|---|
| 226 | "InverseSourceAlpha", |
|---|
| 227 | "DestinationColor", |
|---|
| 228 | "InverseDestinationColor", |
|---|
| 229 | "DestinationAlpha", |
|---|
| 230 | "InverseDestinationAlpha", |
|---|
| 231 | "ConstantColor", |
|---|
| 232 | "InverseConstantColor", |
|---|
| 233 | "ConstantAlpha", |
|---|
| 234 | "InverseConstantAlpha" |
|---|
| 235 | }; |
|---|
| 236 | |
|---|
| 237 | static void print_eq(const char *name, const BM2MC_PACKET_Blend *eq) |
|---|
| 238 | { |
|---|
| 239 | BDBG_WRN(("%s blend: %s * %s %c %s * %s %c %s", name, |
|---|
| 240 | g_blendFactor[eq->a], g_blendFactor[eq->b], eq->sub_cd?'-':'+', |
|---|
| 241 | g_blendFactor[eq->c], g_blendFactor[eq->d], eq->sub_e?'-':'+', |
|---|
| 242 | g_blendFactor[eq->e])); |
|---|
| 243 | } |
|---|
| 244 | #endif |
|---|
| 245 | |
|---|
| 246 | /* for maximum perfornace, even in debug mode: |
|---|
| 247 | - do not use BDBG_ENTER/LEAVE. there are other ways to trace calls and we don't want to risk DBG overhead. |
|---|
| 248 | - do not BDBG_ASSERT on pointers. it's a marginal check anyway, and if it's NULL we're going to crash anyway. |
|---|
| 249 | */ |
|---|
| 250 | |
|---|
| 251 | /*****************************************************************************/ |
|---|
| 252 | static BM2MC_PACKET_Blend g_aGRClib_Packet_ColorEquation_FillOp[] = { |
|---|
| 253 | { BM2MC_PACKET_BlendFactor_eSourceColor, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 254 | { BM2MC_PACKET_BlendFactor_eConstantColor, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 255 | { BM2MC_PACKET_BlendFactor_eConstantColor, BM2MC_PACKET_BlendFactor_eConstantAlpha, 0, BM2MC_PACKET_BlendFactor_eSourceColor, BM2MC_PACKET_BlendFactor_eInverseConstantAlpha, 0,BM2MC_PACKET_BlendFactor_eZero } |
|---|
| 256 | }; |
|---|
| 257 | static BM2MC_PACKET_Blend g_aGRClib_Packet_AlphaEquation_FillOp[] = { |
|---|
| 258 | { BM2MC_PACKET_BlendFactor_eSourceAlpha, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 259 | { BM2MC_PACKET_BlendFactor_eConstantAlpha, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 260 | { BM2MC_PACKET_BlendFactor_eSourceAlpha, BM2MC_PACKET_BlendFactor_eInverseConstantAlpha, 0, BM2MC_PACKET_BlendFactor_eConstantAlpha, BM2MC_PACKET_BlendFactor_eConstantAlpha, 0, BM2MC_PACKET_BlendFactor_eZero } |
|---|
| 261 | }; |
|---|
| 262 | static BM2MC_PACKET_Blend g_aGRClib_Packet_ColorEquation_BlitOp[] = { |
|---|
| 263 | { BM2MC_PACKET_BlendFactor_eSourceColor, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 264 | { BM2MC_PACKET_BlendFactor_eSourceColor, BM2MC_PACKET_BlendFactor_eConstantAlpha, 0, BM2MC_PACKET_BlendFactor_eDestinationColor, BM2MC_PACKET_BlendFactor_eInverseConstantAlpha, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 265 | { BM2MC_PACKET_BlendFactor_eSourceColor, BM2MC_PACKET_BlendFactor_eSourceAlpha, 0, BM2MC_PACKET_BlendFactor_eDestinationColor, BM2MC_PACKET_BlendFactor_eInverseSourceAlpha, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 266 | { BM2MC_PACKET_BlendFactor_eSourceColor, BM2MC_PACKET_BlendFactor_eDestinationAlpha, 0, BM2MC_PACKET_BlendFactor_eDestinationColor, BM2MC_PACKET_BlendFactor_eInverseDestinationAlpha, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 267 | { BM2MC_PACKET_BlendFactor_eSourceColor, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 268 | { BM2MC_PACKET_BlendFactor_eSourceColor, BM2MC_PACKET_BlendFactor_eSourceAlpha, 0, BM2MC_PACKET_BlendFactor_eDestinationColor, BM2MC_PACKET_BlendFactor_eInverseSourceAlpha, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 269 | { BM2MC_PACKET_BlendFactor_eSourceColor, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eDestinationColor, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 270 | { BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero } |
|---|
| 271 | }; |
|---|
| 272 | static BM2MC_PACKET_Blend g_aGRClib_Packet_AlphaEquation_BlitOp[] = { |
|---|
| 273 | { BM2MC_PACKET_BlendFactor_eSourceAlpha, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 274 | { BM2MC_PACKET_BlendFactor_eConstantAlpha, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 275 | { BM2MC_PACKET_BlendFactor_eDestinationAlpha, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 276 | { BM2MC_PACKET_BlendFactor_eSourceAlpha, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eInverseSourceAlpha, BM2MC_PACKET_BlendFactor_eDestinationAlpha, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 277 | { BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 278 | { BM2MC_PACKET_BlendFactor_eSourceAlpha, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 279 | { BM2MC_PACKET_BlendFactor_eSourceAlpha, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eDestinationAlpha, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 280 | { BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero } |
|---|
| 281 | }; |
|---|
| 282 | static BM2MC_PACKET_Blend g_aGRClib_Packet_ColorEquation_PorterDuffFillOp[] = { |
|---|
| 283 | { BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 284 | { BM2MC_PACKET_BlendFactor_eConstantColor, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 285 | { BM2MC_PACKET_BlendFactor_eSourceColor, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 286 | { BM2MC_PACKET_BlendFactor_eConstantColor, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eSourceColor, BM2MC_PACKET_BlendFactor_eInverseConstantAlpha, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 287 | { BM2MC_PACKET_BlendFactor_eConstantColor, BM2MC_PACKET_BlendFactor_eInverseSourceAlpha, 0, BM2MC_PACKET_BlendFactor_eSourceColor, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 288 | { BM2MC_PACKET_BlendFactor_eConstantColor, BM2MC_PACKET_BlendFactor_eSourceAlpha, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 289 | { BM2MC_PACKET_BlendFactor_eSourceColor, BM2MC_PACKET_BlendFactor_eConstantAlpha, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 290 | { BM2MC_PACKET_BlendFactor_eConstantColor, BM2MC_PACKET_BlendFactor_eInverseSourceAlpha, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 291 | { BM2MC_PACKET_BlendFactor_eSourceColor, BM2MC_PACKET_BlendFactor_eInverseConstantAlpha, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 292 | { BM2MC_PACKET_BlendFactor_eConstantColor, BM2MC_PACKET_BlendFactor_eSourceAlpha, 0, BM2MC_PACKET_BlendFactor_eSourceColor, BM2MC_PACKET_BlendFactor_eInverseConstantAlpha, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 293 | { BM2MC_PACKET_BlendFactor_eConstantColor, BM2MC_PACKET_BlendFactor_eInverseSourceAlpha, 0, BM2MC_PACKET_BlendFactor_eSourceColor, BM2MC_PACKET_BlendFactor_eConstantAlpha, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 294 | { BM2MC_PACKET_BlendFactor_eConstantColor, BM2MC_PACKET_BlendFactor_eInverseSourceAlpha, 0, BM2MC_PACKET_BlendFactor_eSourceColor, BM2MC_PACKET_BlendFactor_eInverseConstantAlpha, 0, BM2MC_PACKET_BlendFactor_eZero } |
|---|
| 295 | }; |
|---|
| 296 | static BM2MC_PACKET_Blend g_aGRClib_Packet_AlphaEquation_PorterDuffFillOp[] = { |
|---|
| 297 | { BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 298 | { BM2MC_PACKET_BlendFactor_eConstantAlpha, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 299 | { BM2MC_PACKET_BlendFactor_eSourceAlpha, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 300 | { BM2MC_PACKET_BlendFactor_eConstantAlpha, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eSourceAlpha, BM2MC_PACKET_BlendFactor_eInverseConstantAlpha, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 301 | { BM2MC_PACKET_BlendFactor_eConstantAlpha, BM2MC_PACKET_BlendFactor_eInverseSourceAlpha, 0, BM2MC_PACKET_BlendFactor_eSourceAlpha, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 302 | { BM2MC_PACKET_BlendFactor_eConstantAlpha, BM2MC_PACKET_BlendFactor_eSourceAlpha, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 303 | { BM2MC_PACKET_BlendFactor_eSourceAlpha, BM2MC_PACKET_BlendFactor_eConstantAlpha, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 304 | { BM2MC_PACKET_BlendFactor_eConstantAlpha, BM2MC_PACKET_BlendFactor_eInverseSourceAlpha, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 305 | { BM2MC_PACKET_BlendFactor_eSourceAlpha, BM2MC_PACKET_BlendFactor_eInverseConstantAlpha, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 306 | { BM2MC_PACKET_BlendFactor_eSourceAlpha, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 307 | { BM2MC_PACKET_BlendFactor_eConstantAlpha, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 308 | { BM2MC_PACKET_BlendFactor_eConstantAlpha, BM2MC_PACKET_BlendFactor_eInverseSourceAlpha, 0, BM2MC_PACKET_BlendFactor_eSourceAlpha, BM2MC_PACKET_BlendFactor_eInverseConstantAlpha, 0, BM2MC_PACKET_BlendFactor_eZero } |
|---|
| 309 | }; |
|---|
| 310 | static BM2MC_PACKET_Blend g_aGRClib_Packet_ColorEquation_PorterDuffBlitOp[] = { |
|---|
| 311 | { BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 312 | { BM2MC_PACKET_BlendFactor_eSourceColor, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 313 | { BM2MC_PACKET_BlendFactor_eDestinationColor, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 314 | { BM2MC_PACKET_BlendFactor_eSourceColor, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eDestinationColor, BM2MC_PACKET_BlendFactor_eInverseSourceAlpha, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 315 | { BM2MC_PACKET_BlendFactor_eSourceColor, BM2MC_PACKET_BlendFactor_eInverseDestinationAlpha, 0, BM2MC_PACKET_BlendFactor_eDestinationColor, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 316 | { BM2MC_PACKET_BlendFactor_eSourceColor, BM2MC_PACKET_BlendFactor_eDestinationAlpha, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 317 | { BM2MC_PACKET_BlendFactor_eDestinationColor, BM2MC_PACKET_BlendFactor_eSourceAlpha, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 318 | { BM2MC_PACKET_BlendFactor_eSourceColor, BM2MC_PACKET_BlendFactor_eInverseDestinationAlpha, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 319 | { BM2MC_PACKET_BlendFactor_eDestinationColor, BM2MC_PACKET_BlendFactor_eInverseSourceAlpha, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 320 | { BM2MC_PACKET_BlendFactor_eSourceColor, BM2MC_PACKET_BlendFactor_eDestinationAlpha, 0, BM2MC_PACKET_BlendFactor_eDestinationColor, BM2MC_PACKET_BlendFactor_eInverseSourceAlpha, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 321 | { BM2MC_PACKET_BlendFactor_eSourceColor, BM2MC_PACKET_BlendFactor_eInverseDestinationAlpha, 0, BM2MC_PACKET_BlendFactor_eDestinationColor, BM2MC_PACKET_BlendFactor_eSourceAlpha, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 322 | { BM2MC_PACKET_BlendFactor_eSourceColor, BM2MC_PACKET_BlendFactor_eInverseDestinationAlpha, 0, BM2MC_PACKET_BlendFactor_eDestinationColor, BM2MC_PACKET_BlendFactor_eInverseSourceAlpha, 0, BM2MC_PACKET_BlendFactor_eZero } |
|---|
| 323 | }; |
|---|
| 324 | static BM2MC_PACKET_Blend g_aGRClib_Packet_AlphaEquation_PorterDuffBlitOp[] = { |
|---|
| 325 | { BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 326 | { BM2MC_PACKET_BlendFactor_eSourceAlpha, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 327 | { BM2MC_PACKET_BlendFactor_eDestinationAlpha, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 328 | { BM2MC_PACKET_BlendFactor_eSourceAlpha, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eDestinationAlpha, BM2MC_PACKET_BlendFactor_eInverseSourceAlpha, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 329 | { BM2MC_PACKET_BlendFactor_eSourceAlpha, BM2MC_PACKET_BlendFactor_eInverseDestinationAlpha, 0, BM2MC_PACKET_BlendFactor_eDestinationAlpha, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 330 | { BM2MC_PACKET_BlendFactor_eSourceAlpha, BM2MC_PACKET_BlendFactor_eDestinationAlpha, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 331 | { BM2MC_PACKET_BlendFactor_eDestinationAlpha, BM2MC_PACKET_BlendFactor_eSourceAlpha, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 332 | { BM2MC_PACKET_BlendFactor_eSourceAlpha, BM2MC_PACKET_BlendFactor_eInverseDestinationAlpha, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 333 | { BM2MC_PACKET_BlendFactor_eDestinationAlpha, BM2MC_PACKET_BlendFactor_eInverseSourceAlpha, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 334 | { BM2MC_PACKET_BlendFactor_eDestinationAlpha, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 335 | { BM2MC_PACKET_BlendFactor_eSourceAlpha, BM2MC_PACKET_BlendFactor_eOne, 0, BM2MC_PACKET_BlendFactor_eZero, BM2MC_PACKET_BlendFactor_eZero, 0, BM2MC_PACKET_BlendFactor_eZero }, |
|---|
| 336 | { BM2MC_PACKET_BlendFactor_eSourceAlpha, BM2MC_PACKET_BlendFactor_eInverseDestinationAlpha, 0, BM2MC_PACKET_BlendFactor_eDestinationAlpha, BM2MC_PACKET_BlendFactor_eInverseSourceAlpha, 0, BM2MC_PACKET_BlendFactor_eZero } |
|---|
| 337 | }; |
|---|
| 338 | |
|---|
| 339 | /*****************************************************************************/ |
|---|
| 340 | #define GRCLIB_FULL_PACKET_SIZE (2 * \ |
|---|
| 341 | sizeof (BM2MC_PACKET_PacketSourceFeeder) + \ |
|---|
| 342 | sizeof (BM2MC_PACKET_PacketDestinationFeeder) + \ |
|---|
| 343 | sizeof (BM2MC_PACKET_PacketOutputFeeder) + \ |
|---|
| 344 | sizeof (BM2MC_PACKET_PacketBlend) + \ |
|---|
| 345 | sizeof (BM2MC_PACKET_PacketRop) + \ |
|---|
| 346 | sizeof (BM2MC_PACKET_PacketSourceColorkey) * 2 + \ |
|---|
| 347 | sizeof (BM2MC_PACKET_PacketSourceColorkeyEnable) * 2 + \ |
|---|
| 348 | sizeof (BM2MC_PACKET_PacketFilter) + \ |
|---|
| 349 | sizeof (BM2MC_PACKET_PacketFilterEnable) + \ |
|---|
| 350 | sizeof (BM2MC_PACKET_PacketSourceColorMatrix) + \ |
|---|
| 351 | sizeof (BM2MC_PACKET_PacketSourceColorMatrixEnable) + \ |
|---|
| 352 | sizeof (BM2MC_PACKET_PacketSourcePalette) + \ |
|---|
| 353 | sizeof (BM2MC_PACKET_PacketAlphaPremultiply) + \ |
|---|
| 354 | sizeof (BM2MC_PACKET_PacketMirror) + \ |
|---|
| 355 | sizeof (BM2MC_PACKET_PacketDestripeBlit)) |
|---|
| 356 | |
|---|
| 357 | /*****************************************************************************/ |
|---|
| 358 | static void BGRClib_P_GetPacketRectangle( |
|---|
| 359 | const BM2MC_PACKET_Plane *pSurface, |
|---|
| 360 | const BRect *pInRect, |
|---|
| 361 | BM2MC_PACKET_Rectangle *pOutRect ) |
|---|
| 362 | { |
|---|
| 363 | if( pInRect && pInRect->width && pInRect->height) |
|---|
| 364 | { |
|---|
| 365 | pOutRect->x = pInRect->x; |
|---|
| 366 | pOutRect->y = pInRect->y; |
|---|
| 367 | pOutRect->width = pInRect->width; |
|---|
| 368 | pOutRect->height = pInRect->height; |
|---|
| 369 | } |
|---|
| 370 | else { |
|---|
| 371 | pOutRect->x = 0; |
|---|
| 372 | pOutRect->y = 0; |
|---|
| 373 | if ( pSurface ) { |
|---|
| 374 | pOutRect->width = pSurface->width; |
|---|
| 375 | pOutRect->height = pSurface->height; |
|---|
| 376 | } |
|---|
| 377 | else { |
|---|
| 378 | pOutRect->width = 0; |
|---|
| 379 | pOutRect->height = 0; |
|---|
| 380 | } |
|---|
| 381 | } |
|---|
| 382 | } |
|---|
| 383 | |
|---|
| 384 | /*****************************************************************************/ |
|---|
| 385 | static void BGRClib_P_GetBlendEquation( BM2MC_PACKET_Blend *pEquation, const BGRClib_BlendEquation *pBlend ) |
|---|
| 386 | { |
|---|
| 387 | if( pEquation && pBlend ) |
|---|
| 388 | { |
|---|
| 389 | pEquation->a = pBlend->a; |
|---|
| 390 | pEquation->b = pBlend->b; |
|---|
| 391 | pEquation->sub_cd = pBlend->subcd; |
|---|
| 392 | pEquation->c = pBlend->c; |
|---|
| 393 | pEquation->d = pBlend->d; |
|---|
| 394 | pEquation->sub_e = pBlend->sube; |
|---|
| 395 | pEquation->e = pBlend->e; |
|---|
| 396 | } |
|---|
| 397 | } |
|---|
| 398 | |
|---|
| 399 | /*****************************************************************************/ |
|---|
| 400 | |
|---|
| 401 | static BERR_Code BGRC_Packet_SetSourceSurfacePacket2( BGRC_Handle hGrc, void **ppPacket, |
|---|
| 402 | const BM2MC_PACKET_Plane *pSrcSurface0, const BM2MC_PACKET_Plane *pSrcSurface1, uint32_t color ) |
|---|
| 403 | { |
|---|
| 404 | if( pSrcSurface0 && pSrcSurface1 ) |
|---|
| 405 | { |
|---|
| 406 | BM2MC_PACKET_PacketSourceFeeders *pPacket = (BM2MC_PACKET_PacketSourceFeeders *) (*ppPacket); |
|---|
| 407 | BM2MC_PACKET_INIT( pPacket, SourceFeeders, false ); |
|---|
| 408 | pPacket->plane0 = *pSrcSurface0; |
|---|
| 409 | pPacket->plane1 = *pSrcSurface1; |
|---|
| 410 | pPacket->color = color; |
|---|
| 411 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 412 | *ppPacket = (void *) pPacket; |
|---|
| 413 | } |
|---|
| 414 | else if( pSrcSurface0 ) |
|---|
| 415 | { |
|---|
| 416 | BM2MC_PACKET_PacketSourceFeeder *pPacket = (BM2MC_PACKET_PacketSourceFeeder *) (*ppPacket); |
|---|
| 417 | BM2MC_PACKET_INIT( pPacket, SourceFeeder, false ); |
|---|
| 418 | pPacket->plane = *pSrcSurface0; |
|---|
| 419 | pPacket->color = color; |
|---|
| 420 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 421 | *ppPacket = (void *) pPacket; |
|---|
| 422 | } |
|---|
| 423 | else |
|---|
| 424 | { |
|---|
| 425 | BM2MC_PACKET_PacketSourceColor *pPacket = (BM2MC_PACKET_PacketSourceColor *) (*ppPacket); |
|---|
| 426 | BM2MC_PACKET_INIT( pPacket, SourceColor, false ); |
|---|
| 427 | pPacket->color = color; |
|---|
| 428 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 429 | *ppPacket = (void *) pPacket; |
|---|
| 430 | } |
|---|
| 431 | BSTD_UNUSED(hGrc); |
|---|
| 432 | return BERR_SUCCESS; |
|---|
| 433 | } |
|---|
| 434 | |
|---|
| 435 | #define BGRClib_P_SetDefaultSourceFeederPacket(grclib, pPacket) \ |
|---|
| 436 | ((grclib)->defaultSourceFeederPacket?(pPacket):BGRClib_P_SetSourceFeederPacket( (grclib), (pPacket), 0, DEFAULT_COLOR)) |
|---|
| 437 | |
|---|
| 438 | static uint32_t *BGRClib_P_SetSourceFeederPacket( BGRClib_Handle grclib, |
|---|
| 439 | void *pPacket, const BM2MC_PACKET_Plane *pSrcSurface, uint32_t color ) |
|---|
| 440 | { |
|---|
| 441 | grclib->defaultSourceFeederPacket = (!pSrcSurface && color == DEFAULT_COLOR); |
|---|
| 442 | BGRC_Packet_SetSourceSurfacePacket2( grclib->hGRC, &pPacket, pSrcSurface, 0, color ); |
|---|
| 443 | return pPacket; |
|---|
| 444 | } |
|---|
| 445 | |
|---|
| 446 | /*****************************************************************************/ |
|---|
| 447 | static uint32_t *BGRClib_P_SetSourceDestripePacket( BGRClib_Handle grclib, |
|---|
| 448 | void *pPacket, uint32_t lumaOffset, uint32_t chromaOffset, uint32_t pitch ) |
|---|
| 449 | { |
|---|
| 450 | /* BGRC_Packet_SetSourceDestripePacket uses the same packet as BGRC_Packet_SetSourceSurfacePacket2 */ |
|---|
| 451 | grclib->defaultSourceFeederPacket = false; |
|---|
| 452 | BGRC_Packet_SetSourceDestripePacket( grclib->hGRC, &pPacket, lumaOffset, chromaOffset, pitch, DEFAULT_COLOR ); |
|---|
| 453 | return pPacket; |
|---|
| 454 | } |
|---|
| 455 | |
|---|
| 456 | /*****************************************************************************/ |
|---|
| 457 | BERR_Code BGRC_Packet_SetDestinationSurfacePacket2( BGRC_Handle hGrc, void **ppPacket, |
|---|
| 458 | const BM2MC_PACKET_Plane *pSurface, uint32_t color ) |
|---|
| 459 | { |
|---|
| 460 | if( pSurface ) |
|---|
| 461 | { |
|---|
| 462 | BM2MC_PACKET_PacketDestinationFeeder *pPacket = (BM2MC_PACKET_PacketDestinationFeeder *) (*ppPacket); |
|---|
| 463 | BM2MC_PACKET_INIT( pPacket, DestinationFeeder, false ); |
|---|
| 464 | pPacket->plane = *pSurface; |
|---|
| 465 | pPacket->color = color; |
|---|
| 466 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 467 | *ppPacket = (void *) pPacket; |
|---|
| 468 | } |
|---|
| 469 | else |
|---|
| 470 | { |
|---|
| 471 | BM2MC_PACKET_PacketDestinationColor *pPacket = (BM2MC_PACKET_PacketDestinationColor *) (*ppPacket); |
|---|
| 472 | BM2MC_PACKET_INIT( pPacket, DestinationColor, false ); |
|---|
| 473 | pPacket->color = color; |
|---|
| 474 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 475 | *ppPacket = (void *) pPacket; |
|---|
| 476 | } |
|---|
| 477 | BSTD_UNUSED(hGrc); |
|---|
| 478 | return BERR_SUCCESS; |
|---|
| 479 | } |
|---|
| 480 | |
|---|
| 481 | #define BGRClib_P_SetDefaultDestinationFeederPacket(grclib, pPacket) \ |
|---|
| 482 | ((grclib)->defaultDestinationFeederPacket?(pPacket):BGRClib_P_SetDestinationFeederPacket( (grclib), (pPacket), NULL, DEFAULT_COLOR)) |
|---|
| 483 | |
|---|
| 484 | static uint32_t *BGRClib_P_SetDestinationFeederPacket( BGRClib_Handle grclib, |
|---|
| 485 | void *pPacket, const BM2MC_PACKET_Plane *pSurface, uint32_t color ) |
|---|
| 486 | { |
|---|
| 487 | grclib->defaultDestinationFeederPacket = (!pSurface && color == DEFAULT_COLOR); |
|---|
| 488 | BGRC_Packet_SetDestinationSurfacePacket2( grclib->hGRC, &pPacket, pSurface, color ); |
|---|
| 489 | return pPacket; |
|---|
| 490 | } |
|---|
| 491 | |
|---|
| 492 | /*****************************************************************************/ |
|---|
| 493 | BERR_Code BGRC_Packet_SetOutputSurfacePacket2( BGRC_Handle hGrc, void **ppPacket, |
|---|
| 494 | const BM2MC_PACKET_Plane *pSurface ) |
|---|
| 495 | { |
|---|
| 496 | BM2MC_PACKET_PacketOutputFeeder *pPacket = (BM2MC_PACKET_PacketOutputFeeder *) (*ppPacket); |
|---|
| 497 | BM2MC_PACKET_INIT( pPacket, OutputFeeder, false ); |
|---|
| 498 | pPacket->plane = *pSurface; |
|---|
| 499 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 500 | *ppPacket = (void *) pPacket; |
|---|
| 501 | BSTD_UNUSED(hGrc); |
|---|
| 502 | return BERR_SUCCESS; |
|---|
| 503 | } |
|---|
| 504 | |
|---|
| 505 | /* the only way to cache this without comparing everything is something like BSUR's SurfaceId to know if the surface has been recreated. */ |
|---|
| 506 | static uint32_t *BGRClib_P_SetOutputFeederPacket( BGRClib_Handle grclib, |
|---|
| 507 | void *pPacket, const BM2MC_PACKET_Plane *pSurface ) |
|---|
| 508 | { |
|---|
| 509 | BGRC_Packet_SetOutputSurfacePacket2( grclib->hGRC, &pPacket, pSurface ); |
|---|
| 510 | return pPacket; |
|---|
| 511 | } |
|---|
| 512 | |
|---|
| 513 | /*****************************************************************************/ |
|---|
| 514 | static uint32_t *BGRClib_P_SetOutputOffsetPacket( |
|---|
| 515 | void *pPacket, BM2MC_PACKET_PixelFormat pixelFormat, uint32_t offset, uint32_t pitch ) |
|---|
| 516 | { |
|---|
| 517 | BM2MC_PACKET_PacketOutputFeeder *pFeeder = (BM2MC_PACKET_PacketOutputFeeder *) pPacket; |
|---|
| 518 | BM2MC_PACKET_INIT( pFeeder, OutputFeeder, false ); |
|---|
| 519 | pFeeder->plane.address = offset; |
|---|
| 520 | pFeeder->plane.pitch = (uint16_t) pitch; |
|---|
| 521 | pFeeder->plane.format = pixelFormat; |
|---|
| 522 | pFeeder->plane.width = 0; |
|---|
| 523 | pFeeder->plane.height = 0; |
|---|
| 524 | BM2MC_PACKET_TERM( pFeeder ); |
|---|
| 525 | pPacket = pFeeder; |
|---|
| 526 | return pPacket; |
|---|
| 527 | } |
|---|
| 528 | |
|---|
| 529 | /*****************************************************************************/ |
|---|
| 530 | #define BGRClib_P_SetDefaultFillBlendPacket(grclib, pPacket) \ |
|---|
| 531 | ((grclib)->defaultFillBlendPacket?(pPacket):BGRClib_P_SetFillBlendPacket( (grclib), (pPacket), BGRCLib_FillOp_eCopy, BGRCLib_FillOp_eCopy, 0 )) |
|---|
| 532 | |
|---|
| 533 | static uint32_t *BGRClib_P_SetFillBlendPacket( BGRClib_Handle grclib, void *pPacket, |
|---|
| 534 | BGRCLib_FillOp colorOp, BGRCLib_FillOp alphaOp, uint32_t color ) |
|---|
| 535 | { |
|---|
| 536 | grclib->defaultBlitBlendPacket = false; |
|---|
| 537 | grclib->defaultFillBlendPacket = (colorOp == BGRCLib_FillOp_eCopy && alphaOp == BGRCLib_FillOp_eCopy && !color); |
|---|
| 538 | |
|---|
| 539 | BGRC_Packet_SetBlendPacket( grclib->hGRC, &pPacket, |
|---|
| 540 | &g_aGRClib_Packet_ColorEquation_FillOp[colorOp], &g_aGRClib_Packet_AlphaEquation_FillOp[alphaOp], color ); |
|---|
| 541 | return pPacket; |
|---|
| 542 | } |
|---|
| 543 | |
|---|
| 544 | /*****************************************************************************/ |
|---|
| 545 | #define BGRClib_P_SetDefaultBlitBlendPacket(grclib, pPacket) \ |
|---|
| 546 | ((grclib)->defaultBlitBlendPacket?(pPacket):BGRClib_P_SetBlitBlendPacket( (grclib), (pPacket), BGRCLib_BlitColorOp_eCopySource, BGRCLib_BlitAlphaOp_eCopySource, 0, 0, 0 )) |
|---|
| 547 | |
|---|
| 548 | static uint32_t *BGRClib_P_SetBlitBlendPacket( BGRClib_Handle grclib, |
|---|
| 549 | void *pPacket, BGRCLib_BlitColorOp colorOp, BGRCLib_BlitAlphaOp alphaOp, |
|---|
| 550 | const BGRClib_BlendEquation *pColorBlend, const BGRClib_BlendEquation *pAlphaBlend, uint32_t color ) |
|---|
| 551 | { |
|---|
| 552 | BM2MC_PACKET_Blend colorEquation; |
|---|
| 553 | BM2MC_PACKET_Blend alphaEquation; |
|---|
| 554 | |
|---|
| 555 | /* if both ops are eCopySource, the other params are ignored */ |
|---|
| 556 | grclib->defaultBlitBlendPacket = (colorOp == BGRCLib_BlitColorOp_eCopySource && alphaOp == BGRCLib_BlitAlphaOp_eCopySource); |
|---|
| 557 | grclib->defaultFillBlendPacket = false; |
|---|
| 558 | |
|---|
| 559 | if( colorOp == BGRCLib_BlitColorOp_eUseBlendFactors ) |
|---|
| 560 | BGRClib_P_GetBlendEquation( &colorEquation, pColorBlend ); |
|---|
| 561 | if( alphaOp == BGRCLib_BlitAlphaOp_eUseBlendFactors ) |
|---|
| 562 | BGRClib_P_GetBlendEquation( &alphaEquation, pAlphaBlend ); |
|---|
| 563 | |
|---|
| 564 | BGRC_Packet_SetBlendPacket( grclib->hGRC, &pPacket, |
|---|
| 565 | (colorOp == BGRCLib_BlitColorOp_eUseBlendFactors) ? &colorEquation : &g_aGRClib_Packet_ColorEquation_BlitOp[colorOp], |
|---|
| 566 | (alphaOp == BGRCLib_BlitAlphaOp_eUseBlendFactors) ? &alphaEquation : &g_aGRClib_Packet_AlphaEquation_BlitOp[alphaOp], color ); |
|---|
| 567 | return pPacket; |
|---|
| 568 | } |
|---|
| 569 | |
|---|
| 570 | /*****************************************************************************/ |
|---|
| 571 | static uint32_t *BGRClib_P_SetPorterDuffFillBlendPacket( BGRClib_Handle grclib, void *pPacket, |
|---|
| 572 | BGRCLib_PorterDuffOp pdOp, uint32_t color ) |
|---|
| 573 | { |
|---|
| 574 | /* no grclib defaults */ |
|---|
| 575 | grclib->defaultBlitBlendPacket = false; |
|---|
| 576 | grclib->defaultFillBlendPacket = false; |
|---|
| 577 | |
|---|
| 578 | BGRC_Packet_SetBlendPacket( grclib->hGRC, &pPacket, |
|---|
| 579 | &g_aGRClib_Packet_ColorEquation_PorterDuffFillOp[pdOp], &g_aGRClib_Packet_AlphaEquation_PorterDuffFillOp[pdOp], color ); |
|---|
| 580 | return pPacket; |
|---|
| 581 | } |
|---|
| 582 | |
|---|
| 583 | /*****************************************************************************/ |
|---|
| 584 | static uint32_t *BGRClib_P_SetPorterDuffBlitBlendPacket( BGRClib_Handle grclib, void *pPacket, |
|---|
| 585 | BGRCLib_PorterDuffOp pdOp, uint32_t color ) |
|---|
| 586 | { |
|---|
| 587 | /* no grclib defaults */ |
|---|
| 588 | grclib->defaultBlitBlendPacket = false; |
|---|
| 589 | grclib->defaultFillBlendPacket = false; |
|---|
| 590 | |
|---|
| 591 | BGRC_Packet_SetBlendPacket( grclib->hGRC, &pPacket, |
|---|
| 592 | &g_aGRClib_Packet_ColorEquation_PorterDuffBlitOp[pdOp], &g_aGRClib_Packet_AlphaEquation_PorterDuffBlitOp[pdOp], color ); |
|---|
| 593 | return pPacket; |
|---|
| 594 | } |
|---|
| 595 | |
|---|
| 596 | /*****************************************************************************/ |
|---|
| 597 | #define BGRClib_P_SetDefaultRopPacket(grclib, pPacket) \ |
|---|
| 598 | ((grclib)->defaultRopPacket?(pPacket):BGRClib_P_SetRopPacket( (grclib), (pPacket), 0xCC, NULL, 0, 0)) |
|---|
| 599 | |
|---|
| 600 | static uint32_t *BGRClib_P_SetRopPacket( BGRClib_Handle grclib, void *pPacket, |
|---|
| 601 | uint8_t rop, uint32_t* pattern, uint32_t color0, uint32_t color1 ) |
|---|
| 602 | { |
|---|
| 603 | grclib->defaultRopPacket = (rop == 0xCC && pattern == NULL && color0==0 && color1==0); |
|---|
| 604 | BGRC_Packet_SetRopPacket( grclib->hGRC, &pPacket, rop, pattern, color0, color1 ); |
|---|
| 605 | return pPacket; |
|---|
| 606 | } |
|---|
| 607 | |
|---|
| 608 | /*****************************************************************************/ |
|---|
| 609 | #define BGRClib_P_SetDefaultSourceColorkeyPacket(grclib, pPacket) \ |
|---|
| 610 | ((grclib)->defaultSourceColorkeyPacket?(pPacket):BGRClib_P_SetSourceColorkeyPacket( (grclib), (pPacket), false, 0, 0, 0, 0, 0)) |
|---|
| 611 | |
|---|
| 612 | static uint32_t *BGRClib_P_SetSourceColorkeyPacket( BGRClib_Handle grclib, void *pPacket, |
|---|
| 613 | bool enable, uint32_t high, uint32_t low, uint32_t mask, uint32_t replacement, uint32_t replacement_mask ) |
|---|
| 614 | { |
|---|
| 615 | grclib->defaultSourceColorkeyPacket = (!enable && !high && !low && !mask && !replacement && !replacement_mask); |
|---|
| 616 | BGRC_Packet_SetSourceColorkeyPacket( grclib->hGRC, &pPacket, enable, |
|---|
| 617 | high, low, mask, replacement, replacement_mask ); |
|---|
| 618 | return pPacket; |
|---|
| 619 | } |
|---|
| 620 | |
|---|
| 621 | /*****************************************************************************/ |
|---|
| 622 | #define BGRClib_P_SetDefaultDestinationColorkeyPacket(grclib, pPacket) \ |
|---|
| 623 | ((grclib)->defaultDstColorkeyPacket?(pPacket):BGRClib_P_SetDestinationColorkeyPacket( (grclib), (pPacket), false, 0, 0, 0, 0, 0)) |
|---|
| 624 | |
|---|
| 625 | static uint32_t *BGRClib_P_SetDestinationColorkeyPacket( BGRClib_Handle grclib, void *pPacket, |
|---|
| 626 | bool enable, uint32_t high, uint32_t low, uint32_t mask, uint32_t replacement, uint32_t replacement_mask ) |
|---|
| 627 | { |
|---|
| 628 | grclib->defaultDstColorkeyPacket = (!enable && !high && !low && !mask && !replacement && !replacement_mask); |
|---|
| 629 | BGRC_Packet_SetDestinationColorkeyPacket( grclib->hGRC, &pPacket, enable, |
|---|
| 630 | high, low, mask, replacement, replacement_mask ); |
|---|
| 631 | return pPacket; |
|---|
| 632 | } |
|---|
| 633 | |
|---|
| 634 | /*****************************************************************************/ |
|---|
| 635 | static uint32_t *BGRClib_P_SetFilterPacket( BGRClib_Handle grclib, void *pPacket, |
|---|
| 636 | BGRC_FilterCoeffs horz, BGRC_FilterCoeffs vert, BM2MC_PACKET_Rectangle *pSrcRect, BM2MC_PACKET_Rectangle *pOutRect ) |
|---|
| 637 | { |
|---|
| 638 | bool vertScaling = pSrcRect->height != pOutRect->height; |
|---|
| 639 | bool horzScaling = pSrcRect->width != pOutRect->width; |
|---|
| 640 | |
|---|
| 641 | /* no default value, so we cache values. the src/out rects are only used to determining scaling or no scaling. */ |
|---|
| 642 | if (grclib->filterPacket.vertCoeffs != vert || |
|---|
| 643 | grclib->filterPacket.horzCoeffs != horz || |
|---|
| 644 | grclib->filterPacket.vertScaling != vertScaling || |
|---|
| 645 | grclib->filterPacket.horzScaling != horzScaling) |
|---|
| 646 | { |
|---|
| 647 | BGRC_Packet_SetFilterPacket( grclib->hGRC, &pPacket, horz, vert, pSrcRect, pOutRect ); |
|---|
| 648 | |
|---|
| 649 | grclib->filterPacket.vertCoeffs = vert; |
|---|
| 650 | grclib->filterPacket.horzCoeffs = horz; |
|---|
| 651 | grclib->filterPacket.vertScaling = vertScaling; |
|---|
| 652 | grclib->filterPacket.horzScaling = horzScaling; |
|---|
| 653 | } |
|---|
| 654 | return pPacket; |
|---|
| 655 | } |
|---|
| 656 | |
|---|
| 657 | /*****************************************************************************/ |
|---|
| 658 | #define BGRClib_P_SetDefaultColorMatrixPacket(grclib, pPacket) \ |
|---|
| 659 | ((grclib)->defaultColorMatrixPacket?(pPacket):BGRClib_P_SetColorMatrixPacket( (grclib), (pPacket), NULL, 0)) |
|---|
| 660 | |
|---|
| 661 | static uint32_t *BGRClib_P_SetColorMatrixPacket( BGRClib_Handle grclib, |
|---|
| 662 | void *pPacket, const int32_t matrix[], uint32_t shift ) |
|---|
| 663 | { |
|---|
| 664 | grclib->defaultColorMatrixPacket = (!matrix && !shift); |
|---|
| 665 | BGRC_Packet_SetColorMatrixPacket( grclib->hGRC, &pPacket, matrix, shift ); |
|---|
| 666 | return pPacket; |
|---|
| 667 | } |
|---|
| 668 | |
|---|
| 669 | #define BM2MC_IS_PALETTE_FORMAT(FORMAT) \ |
|---|
| 670 | ((FORMAT)>=BM2MC_PACKET_PixelFormat_eA8_P8 && (FORMAT)<=BM2MC_PACKET_PixelFormat_eY8_P8) |
|---|
| 671 | |
|---|
| 672 | /*****************************************************************************/ |
|---|
| 673 | static uint32_t *BGRClib_P_SetSourcePalette(void *pPacket_, unsigned paletteOffset) |
|---|
| 674 | { |
|---|
| 675 | BM2MC_PACKET_PacketSourcePalette *pPacket = pPacket_; |
|---|
| 676 | BM2MC_PACKET_INIT( pPacket, SourcePalette, false ); |
|---|
| 677 | pPacket->address = paletteOffset; |
|---|
| 678 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 679 | return (uint32_t *)pPacket; |
|---|
| 680 | } |
|---|
| 681 | |
|---|
| 682 | /*****************************************************************************/ |
|---|
| 683 | #define BGRClib_P_SetDefaultAlphaPremultiplyPacket(grclib, pPacket) \ |
|---|
| 684 | ((grclib)->defaultAlphaPremultiplyPacket?(pPacket):BGRClib_P_SetAlphaPremultiplyPacket( (grclib), (pPacket), false)) |
|---|
| 685 | static uint32_t *BGRClib_P_SetAlphaPremultiplyPacket( BGRClib_Handle grclib, void *pPacket, bool enable ) |
|---|
| 686 | { |
|---|
| 687 | grclib->defaultAlphaPremultiplyPacket = (!enable); |
|---|
| 688 | BGRC_Packet_SetAlphaPremultiply( grclib->hGRC, &pPacket, enable ); |
|---|
| 689 | return pPacket; |
|---|
| 690 | } |
|---|
| 691 | |
|---|
| 692 | /*****************************************************************************/ |
|---|
| 693 | #define BGRClib_P_SetDefaultMirrorPacket(grclib, pPacket) \ |
|---|
| 694 | ((grclib)->defaultMirrorPacket?(pPacket):BGRClib_P_SetMirrorPacket( (grclib), (pPacket), false, false, false, false, false, false)) |
|---|
| 695 | static uint32_t *BGRClib_P_SetMirrorPacket( BGRClib_Handle grclib, void *pPacket, |
|---|
| 696 | uint16_t srcHorz, uint16_t srcVert, uint16_t dstHorz, uint16_t dstVert, uint16_t outHorz, uint16_t outVert ) |
|---|
| 697 | { |
|---|
| 698 | grclib->defaultMirrorPacket = (!srcHorz && !srcVert && !dstHorz && !dstVert && !outHorz && !outVert); |
|---|
| 699 | BGRC_Packet_SetMirrorPacket( grclib->hGRC, &pPacket, |
|---|
| 700 | (bool) srcHorz, (bool) srcVert, (bool) dstHorz, (bool) dstVert, (bool) outHorz, (bool) outVert ); |
|---|
| 701 | return pPacket; |
|---|
| 702 | } |
|---|
| 703 | |
|---|
| 704 | /*****************************************************************************/ |
|---|
| 705 | #define BGRClib_P_SetDefaultFixedScalePacket(grclib, pPacket) \ |
|---|
| 706 | ((grclib)->defaultFixedScalePacket?(pPacket):BGRClib_P_SetFixedScalePacket( (grclib), (pPacket), NULL)) |
|---|
| 707 | static uint32_t *BGRClib_P_SetFixedScalePacket( BGRClib_Handle grclib, void *pPacket, const BGRClib_BlitScalingControlParams *params ) |
|---|
| 708 | { |
|---|
| 709 | grclib->defaultFixedScalePacket = (!params); |
|---|
| 710 | if( params ) |
|---|
| 711 | { |
|---|
| 712 | BM2MC_PACKET_PacketFixedScale *pScale = (BM2MC_PACKET_PacketFixedScale *) pPacket; |
|---|
| 713 | BM2MC_PACKET_INIT( pScale, FixedScale, false ); |
|---|
| 714 | pScale->shift = 20; |
|---|
| 715 | pScale->hor_phase = params->iHorizontalPhase << (pScale->shift - params->ulPhaseFixedPointShift); |
|---|
| 716 | pScale->ver_phase = params->iVerticalPhase << (pScale->shift - params->ulPhaseFixedPointShift); |
|---|
| 717 | if (params->ulHorizontalDenominator) { |
|---|
| 718 | pScale->hor_step = (params->ulHorizontalNumerator << pScale->shift) / params->ulHorizontalDenominator; |
|---|
| 719 | } |
|---|
| 720 | else { |
|---|
| 721 | pScale->hor_step = 0; |
|---|
| 722 | } |
|---|
| 723 | if (params->ulVerticalDenominator) { |
|---|
| 724 | pScale->ver_step = (params->ulVerticalNumerator << pScale->shift) / params->ulVerticalDenominator; |
|---|
| 725 | } |
|---|
| 726 | else { |
|---|
| 727 | pScale->ver_step = 0; |
|---|
| 728 | } |
|---|
| 729 | BM2MC_PACKET_TERM( pScale ); |
|---|
| 730 | pPacket = pScale; |
|---|
| 731 | } |
|---|
| 732 | else |
|---|
| 733 | { |
|---|
| 734 | BM2MC_PACKET_PacketFixedScale *pScale = (BM2MC_PACKET_PacketFixedScale *) pPacket; |
|---|
| 735 | BM2MC_PACKET_INIT( pScale, FixedScale, false ); |
|---|
| 736 | pScale->hor_phase = 0; |
|---|
| 737 | pScale->ver_phase = 0; |
|---|
| 738 | pScale->hor_step = 0; |
|---|
| 739 | pScale->ver_step = 0; |
|---|
| 740 | pScale->shift = 0; |
|---|
| 741 | BM2MC_PACKET_TERM( pScale ); |
|---|
| 742 | pPacket = pScale; |
|---|
| 743 | } |
|---|
| 744 | return pPacket; |
|---|
| 745 | } |
|---|
| 746 | |
|---|
| 747 | /*****************************************************************************/ |
|---|
| 748 | static uint32_t *BGRClib_P_SetFillPacket( BGRClib_Handle grclib, |
|---|
| 749 | void *pPacket, BM2MC_PACKET_Rectangle *pRect ) |
|---|
| 750 | { |
|---|
| 751 | BGRC_Packet_SetBlitPacket( grclib->hGRC, &pPacket, pRect, NULL, NULL ); |
|---|
| 752 | return pPacket; |
|---|
| 753 | } |
|---|
| 754 | |
|---|
| 755 | /*****************************************************************************/ |
|---|
| 756 | static uint32_t *BGRClib_P_SetBlitPacket( BGRClib_Handle grclib, void *pPacket, |
|---|
| 757 | BM2MC_PACKET_Rectangle *pSrcRect, BM2MC_PACKET_Rectangle *pDstRect, BM2MC_PACKET_Rectangle *pOutRect, |
|---|
| 758 | BGRC_FilterCoeffs horz, BGRC_FilterCoeffs vert ) |
|---|
| 759 | { |
|---|
| 760 | if( (pSrcRect->width == pOutRect->width) && (pSrcRect->height == pOutRect->height) && |
|---|
| 761 | (horz <= BGRC_FilterCoeffs_eAnisotropic) && (vert <= BGRC_FilterCoeffs_eAnisotropic) ) |
|---|
| 762 | { |
|---|
| 763 | BGRC_Packet_SetBlitPacket( grclib->hGRC, &pPacket, |
|---|
| 764 | pSrcRect, (BM2MC_PACKET_Point *) pOutRect, (BM2MC_PACKET_Point *) pDstRect ); |
|---|
| 765 | } |
|---|
| 766 | else |
|---|
| 767 | { |
|---|
| 768 | BGRC_Packet_SetScaleBlitPacket( grclib->hGRC, &pPacket, |
|---|
| 769 | pSrcRect, pOutRect, (BM2MC_PACKET_Point *) pDstRect ); |
|---|
| 770 | } |
|---|
| 771 | return pPacket; |
|---|
| 772 | } |
|---|
| 773 | |
|---|
| 774 | /*****************************************************************************/ |
|---|
| 775 | static uint32_t *BGRClib_P_SetDestripeBlitPacket( BGRClib_Handle grclib, void *pPacket, |
|---|
| 776 | BM2MC_PACKET_Rectangle *pSrcRect, BM2MC_PACKET_Rectangle *pOutRect, |
|---|
| 777 | uint32_t stripeWidth, uint32_t lumaStripeHeight, uint32_t chromaStripeHeight ) |
|---|
| 778 | { |
|---|
| 779 | BGRC_Packet_SetDestripeBlitPacket( grclib->hGRC, &pPacket, |
|---|
| 780 | pSrcRect, pOutRect, stripeWidth, lumaStripeHeight, chromaStripeHeight ); |
|---|
| 781 | return pPacket; |
|---|
| 782 | } |
|---|
| 783 | |
|---|
| 784 | /*****************************************************************************/ |
|---|
| 785 | static BERR_Code BGRClib_P_PacketsComplete( BGRClib_Handle grclib, uint32_t ulPacketSize ) |
|---|
| 786 | { |
|---|
| 787 | BERR_Code err = BGRC_Packet_SubmitPackets( grclib->hGRC, grclib->hContext, ulPacketSize ); |
|---|
| 788 | return (err == BGRC_PACKET_MSG_PACKETS_INCOMPLETE) ? BERR_SUCCESS : err; |
|---|
| 789 | } |
|---|
| 790 | |
|---|
| 791 | /*****************************************************************************/ |
|---|
| 792 | static uint32_t *BGRClib_P_GetPacketBuffer( BGRClib_Handle grclib, size_t size ) |
|---|
| 793 | { |
|---|
| 794 | void *pPacket; |
|---|
| 795 | size_t iAllocSize = 0; |
|---|
| 796 | |
|---|
| 797 | BERR_Code err = BGRC_Packet_GetPacketMemory( grclib->hGRC, grclib->hContext, &pPacket, &iAllocSize, size ); |
|---|
| 798 | if( err != BERR_SUCCESS ) |
|---|
| 799 | return NULL; |
|---|
| 800 | |
|---|
| 801 | return pPacket; |
|---|
| 802 | } |
|---|
| 803 | |
|---|
| 804 | /***************************************************************************/ |
|---|
| 805 | BERR_Code BGRClib_Open( BGRClib_Handle *pgrclib, BGRC_Handle grcHandle, BGRC_PacketContext_Handle packetContext ) |
|---|
| 806 | { |
|---|
| 807 | BGRClib_Handle grclib; |
|---|
| 808 | BERR_Code err = BERR_SUCCESS; |
|---|
| 809 | |
|---|
| 810 | BDBG_ASSERT(pgrclib); |
|---|
| 811 | BDBG_ASSERT(grcHandle); |
|---|
| 812 | |
|---|
| 813 | grclib = (BGRClib_Handle) BKNI_Malloc( sizeof (BGRClib_P_Data) ); |
|---|
| 814 | if( !grclib ) |
|---|
| 815 | return BERR_TRACE(BERR_OUT_OF_SYSTEM_MEMORY); |
|---|
| 816 | |
|---|
| 817 | BKNI_Memset( grclib, 0, sizeof(BGRClib_P_Data) ); |
|---|
| 818 | BDBG_OBJECT_SET(grclib, GRClib); |
|---|
| 819 | |
|---|
| 820 | grclib->hGRC = grcHandle; |
|---|
| 821 | grclib->hContext = packetContext; |
|---|
| 822 | *pgrclib = grclib; |
|---|
| 823 | grclib->filterPacket.vertCoeffs = (BGRC_FilterCoeffs)-1; |
|---|
| 824 | grclib->filterPacket.horzCoeffs = (BGRC_FilterCoeffs)-1; |
|---|
| 825 | |
|---|
| 826 | return BERR_TRACE(err); |
|---|
| 827 | } |
|---|
| 828 | |
|---|
| 829 | /***************************************************************************/ |
|---|
| 830 | void BGRClib_Close( BGRClib_Handle grclib ) |
|---|
| 831 | { |
|---|
| 832 | BDBG_OBJECT_ASSERT(grclib, GRClib); |
|---|
| 833 | BDBG_OBJECT_DESTROY(grclib, GRClib); |
|---|
| 834 | BKNI_Free( (void*)grclib ); |
|---|
| 835 | } |
|---|
| 836 | |
|---|
| 837 | /*****************************************************************************/ |
|---|
| 838 | BERR_Code BGRClib_Memset32( BGRClib_Handle grclib, uint32_t offset, uint32_t data, uint32_t count ) |
|---|
| 839 | { |
|---|
| 840 | BERR_Code err = BERR_SUCCESS; |
|---|
| 841 | BM2MC_PACKET_Rectangle outRect = { 0, 0, 0, 0 }; |
|---|
| 842 | static uint32_t pitch = 4096; |
|---|
| 843 | void *pPacket; |
|---|
| 844 | void *pPacketStart; |
|---|
| 845 | |
|---|
| 846 | BDBG_OBJECT_ASSERT(grclib, GRClib); |
|---|
| 847 | |
|---|
| 848 | outRect.width = (uint16_t) (pitch / 4); |
|---|
| 849 | outRect.height = (uint16_t) (count * 4 / pitch); |
|---|
| 850 | |
|---|
| 851 | pPacketStart = BGRClib_P_GetPacketBuffer( grclib, GRCLIB_FULL_PACKET_SIZE ); |
|---|
| 852 | if( pPacketStart == 0 ) |
|---|
| 853 | { |
|---|
| 854 | return BERR_OUT_OF_DEVICE_MEMORY; /* this is normal for flow control */ |
|---|
| 855 | } |
|---|
| 856 | |
|---|
| 857 | pPacket = pPacketStart; |
|---|
| 858 | pPacket = BGRClib_P_SetDefaultSourceFeederPacket(grclib, pPacket); |
|---|
| 859 | pPacket = BGRClib_P_SetDefaultDestinationFeederPacket(grclib, pPacket); |
|---|
| 860 | pPacket = BGRClib_P_SetOutputOffsetPacket( pPacket, BM2MC_PACKET_PixelFormat_eA8_R8_G8_B8, offset, pitch ); |
|---|
| 861 | pPacket = BGRClib_P_SetFillBlendPacket( grclib, pPacket, BGRCLib_FillOp_eCopy, BGRCLib_FillOp_eCopy, data ); |
|---|
| 862 | pPacket = BGRClib_P_SetDefaultRopPacket(grclib, pPacket); |
|---|
| 863 | |
|---|
| 864 | pPacket = BGRClib_P_SetDefaultSourceColorkeyPacket(grclib, pPacket); |
|---|
| 865 | pPacket = BGRClib_P_SetDefaultDestinationColorkeyPacket(grclib, pPacket); |
|---|
| 866 | pPacket = BGRClib_P_SetDefaultColorMatrixPacket(grclib, pPacket); |
|---|
| 867 | pPacket = BGRClib_P_SetDefaultAlphaPremultiplyPacket(grclib, pPacket); |
|---|
| 868 | pPacket = BGRClib_P_SetDefaultMirrorPacket(grclib, pPacket); |
|---|
| 869 | pPacket = BGRClib_P_SetDefaultFixedScalePacket(grclib, pPacket); |
|---|
| 870 | pPacket = BGRClib_P_SetFillPacket( grclib, pPacket, &outRect ); |
|---|
| 871 | |
|---|
| 872 | err = BGRClib_P_PacketsComplete( grclib, (uint32_t) pPacket - (uint32_t) pPacketStart ); |
|---|
| 873 | |
|---|
| 874 | return BERR_TRACE(err); |
|---|
| 875 | } |
|---|
| 876 | |
|---|
| 877 | /*****************************************************************************/ |
|---|
| 878 | BERR_Code BGRClib_Destripe_Blit( BGRClib_Handle grclib, const BM2MC_PACKET_Plane *pOutSurface, const BRect *pOutRect, |
|---|
| 879 | uint32_t lumaOffset, uint32_t chromaOffset, uint32_t pitch, uint32_t width, uint32_t height, |
|---|
| 880 | uint32_t stripeWidth, uint32_t lumaStripeHeight, uint32_t chromaStripeHeight, |
|---|
| 881 | const int32_t colorMatrix[], uint32_t matrixShift ) |
|---|
| 882 | { |
|---|
| 883 | BERR_Code err = BERR_SUCCESS; |
|---|
| 884 | BM2MC_PACKET_Rectangle srcRect = { 0, 0, 0, 0 }; |
|---|
| 885 | BM2MC_PACKET_Rectangle outRect; |
|---|
| 886 | void *pPacket; |
|---|
| 887 | void *pPacketStart; |
|---|
| 888 | |
|---|
| 889 | BDBG_OBJECT_ASSERT(grclib, GRClib); |
|---|
| 890 | |
|---|
| 891 | srcRect.width = (uint16_t) width; |
|---|
| 892 | srcRect.height = (uint16_t) height; |
|---|
| 893 | BGRClib_P_GetPacketRectangle( pOutSurface, pOutRect, &outRect ); |
|---|
| 894 | |
|---|
| 895 | pPacketStart = BGRClib_P_GetPacketBuffer( grclib, GRCLIB_FULL_PACKET_SIZE ); |
|---|
| 896 | if( pPacketStart == 0 ) |
|---|
| 897 | { |
|---|
| 898 | return BERR_OUT_OF_DEVICE_MEMORY; /* this is normal for flow control */ |
|---|
| 899 | } |
|---|
| 900 | |
|---|
| 901 | pPacket = pPacketStart; |
|---|
| 902 | pPacket = BGRClib_P_SetSourceDestripePacket( grclib, pPacket, lumaOffset, chromaOffset, pitch ); |
|---|
| 903 | pPacket = BGRClib_P_SetDefaultDestinationFeederPacket(grclib, pPacket); |
|---|
| 904 | pPacket = BGRClib_P_SetOutputFeederPacket( grclib, pPacket, pOutSurface ); |
|---|
| 905 | pPacket = BGRClib_P_SetDefaultBlitBlendPacket(grclib, pPacket); |
|---|
| 906 | pPacket = BGRClib_P_SetDefaultRopPacket(grclib, pPacket); |
|---|
| 907 | |
|---|
| 908 | pPacket = BGRClib_P_SetFilterPacket( grclib, pPacket, |
|---|
| 909 | BGRC_FilterCoeffs_eAnisotropic, BGRC_FilterCoeffs_eAnisotropic, &srcRect, &outRect ); |
|---|
| 910 | |
|---|
| 911 | if( colorMatrix ) |
|---|
| 912 | pPacket = BGRClib_P_SetColorMatrixPacket( grclib, pPacket, colorMatrix, matrixShift ); |
|---|
| 913 | else |
|---|
| 914 | pPacket = BGRClib_P_SetDefaultColorMatrixPacket(grclib, pPacket); |
|---|
| 915 | |
|---|
| 916 | pPacket = BGRClib_P_SetDefaultSourceColorkeyPacket(grclib, pPacket); |
|---|
| 917 | pPacket = BGRClib_P_SetDefaultDestinationColorkeyPacket(grclib, pPacket); |
|---|
| 918 | pPacket = BGRClib_P_SetDefaultAlphaPremultiplyPacket(grclib, pPacket); |
|---|
| 919 | pPacket = BGRClib_P_SetDefaultMirrorPacket(grclib, pPacket); |
|---|
| 920 | pPacket = BGRClib_P_SetDefaultFixedScalePacket(grclib, pPacket); |
|---|
| 921 | pPacket = BGRClib_P_SetDestripeBlitPacket( grclib, pPacket, &srcRect, &outRect, stripeWidth, lumaStripeHeight, chromaStripeHeight ); |
|---|
| 922 | |
|---|
| 923 | err = BGRClib_P_PacketsComplete( grclib, (uint32_t) pPacket - (uint32_t) pPacketStart ); |
|---|
| 924 | |
|---|
| 925 | return BERR_TRACE(err); |
|---|
| 926 | } |
|---|
| 927 | |
|---|
| 928 | /*****************************************************************************/ |
|---|
| 929 | BERR_Code BGRClib_Fill( BGRClib_Handle grclib, const BM2MC_PACKET_Plane *pSurface, uint32_t constantColor, |
|---|
| 930 | const BRect *pRect ) |
|---|
| 931 | { |
|---|
| 932 | BERR_Code err; |
|---|
| 933 | |
|---|
| 934 | err = BGRClib_Blended_Fill( grclib, pSurface, constantColor, pRect, BGRCLib_FillOp_eCopy, BGRCLib_FillOp_eCopy ); |
|---|
| 935 | |
|---|
| 936 | return BERR_TRACE(err); |
|---|
| 937 | } |
|---|
| 938 | |
|---|
| 939 | /*****************************************************************************/ |
|---|
| 940 | BERR_Code BGRClib_Blended_Fill( BGRClib_Handle grclib, const BM2MC_PACKET_Plane *pSurface, uint32_t constantColor, |
|---|
| 941 | const BRect *pRect, BGRCLib_FillOp colorOp, BGRCLib_FillOp alphaOp ) |
|---|
| 942 | { |
|---|
| 943 | BERR_Code err = BERR_SUCCESS; |
|---|
| 944 | BM2MC_PACKET_Rectangle outRect; |
|---|
| 945 | void *pPacket; |
|---|
| 946 | void *pPacketStart; |
|---|
| 947 | |
|---|
| 948 | BDBG_OBJECT_ASSERT(grclib, GRClib); |
|---|
| 949 | |
|---|
| 950 | BGRClib_P_GetPacketRectangle( pSurface, pRect, &outRect ); |
|---|
| 951 | |
|---|
| 952 | pPacketStart = BGRClib_P_GetPacketBuffer( grclib, GRCLIB_FULL_PACKET_SIZE ); |
|---|
| 953 | if( pPacketStart == 0 ) |
|---|
| 954 | { |
|---|
| 955 | return BERR_OUT_OF_DEVICE_MEMORY; /* this is normal for flow control */ |
|---|
| 956 | } |
|---|
| 957 | |
|---|
| 958 | pPacket = pPacketStart; |
|---|
| 959 | if (colorOp == BGRCLib_FillOp_eCopy && alphaOp == BGRCLib_FillOp_eCopy) { |
|---|
| 960 | pPacket = BGRClib_P_SetDefaultSourceFeederPacket(grclib, pPacket); |
|---|
| 961 | } |
|---|
| 962 | else { |
|---|
| 963 | pPacket = BGRClib_P_SetSourceFeederPacket( grclib, pPacket, pSurface, DEFAULT_COLOR ); |
|---|
| 964 | } |
|---|
| 965 | pPacket = BGRClib_P_SetDefaultDestinationFeederPacket( grclib, pPacket); |
|---|
| 966 | pPacket = BGRClib_P_SetOutputFeederPacket( grclib, pPacket, pSurface ); |
|---|
| 967 | pPacket = BGRClib_P_SetFillBlendPacket( grclib, pPacket, colorOp, alphaOp, constantColor ); |
|---|
| 968 | pPacket = BGRClib_P_SetDefaultRopPacket(grclib, pPacket); |
|---|
| 969 | |
|---|
| 970 | pPacket = BGRClib_P_SetDefaultSourceColorkeyPacket(grclib, pPacket); |
|---|
| 971 | pPacket = BGRClib_P_SetDefaultDestinationColorkeyPacket(grclib, pPacket); |
|---|
| 972 | pPacket = BGRClib_P_SetDefaultColorMatrixPacket(grclib, pPacket); |
|---|
| 973 | pPacket = BGRClib_P_SetDefaultAlphaPremultiplyPacket(grclib, pPacket); |
|---|
| 974 | pPacket = BGRClib_P_SetDefaultMirrorPacket(grclib, pPacket); |
|---|
| 975 | pPacket = BGRClib_P_SetDefaultFixedScalePacket(grclib, pPacket); |
|---|
| 976 | pPacket = BGRClib_P_SetFillPacket( grclib, pPacket, &outRect ); |
|---|
| 977 | |
|---|
| 978 | err = BGRClib_P_PacketsComplete( grclib, (uint32_t) pPacket - (uint32_t) pPacketStart ); |
|---|
| 979 | |
|---|
| 980 | return BERR_TRACE(err); |
|---|
| 981 | } |
|---|
| 982 | |
|---|
| 983 | /*****************************************************************************/ |
|---|
| 984 | BERR_Code BGRClib_PorterDuffFill( BGRClib_Handle grclib, BGRCLib_PorterDuffOp pdOp, |
|---|
| 985 | const BM2MC_PACKET_Plane *pSurface, uint32_t constantColor, |
|---|
| 986 | const BRect *pRect ) |
|---|
| 987 | { |
|---|
| 988 | BERR_Code err = BERR_SUCCESS; |
|---|
| 989 | BM2MC_PACKET_Rectangle outRect; |
|---|
| 990 | void *pPacket; |
|---|
| 991 | void *pPacketStart; |
|---|
| 992 | |
|---|
| 993 | BDBG_OBJECT_ASSERT(grclib, GRClib); |
|---|
| 994 | |
|---|
| 995 | BGRClib_P_GetPacketRectangle( pSurface, pRect, &outRect ); |
|---|
| 996 | |
|---|
| 997 | pPacketStart = BGRClib_P_GetPacketBuffer( grclib, GRCLIB_FULL_PACKET_SIZE ); |
|---|
| 998 | if( pPacketStart == 0 ) |
|---|
| 999 | { |
|---|
| 1000 | return BERR_OUT_OF_DEVICE_MEMORY; /* this is normal for flow control */ |
|---|
| 1001 | } |
|---|
| 1002 | |
|---|
| 1003 | pPacket = pPacketStart; |
|---|
| 1004 | pPacket = BGRClib_P_SetSourceFeederPacket( grclib, pPacket, pSurface, DEFAULT_COLOR ); |
|---|
| 1005 | pPacket = BGRClib_P_SetDefaultDestinationFeederPacket(grclib, pPacket); |
|---|
| 1006 | pPacket = BGRClib_P_SetOutputFeederPacket( grclib, pPacket, pSurface ); |
|---|
| 1007 | pPacket = BGRClib_P_SetPorterDuffFillBlendPacket( grclib, pPacket, pdOp, constantColor ); |
|---|
| 1008 | pPacket = BGRClib_P_SetDefaultRopPacket(grclib, pPacket); |
|---|
| 1009 | |
|---|
| 1010 | pPacket = BGRClib_P_SetDefaultSourceColorkeyPacket(grclib, pPacket); |
|---|
| 1011 | pPacket = BGRClib_P_SetDefaultDestinationColorkeyPacket(grclib, pPacket); |
|---|
| 1012 | pPacket = BGRClib_P_SetDefaultColorMatrixPacket(grclib, pPacket); |
|---|
| 1013 | pPacket = BGRClib_P_SetDefaultAlphaPremultiplyPacket(grclib, pPacket); |
|---|
| 1014 | pPacket = BGRClib_P_SetDefaultMirrorPacket(grclib, pPacket); |
|---|
| 1015 | pPacket = BGRClib_P_SetDefaultFixedScalePacket(grclib, pPacket); |
|---|
| 1016 | pPacket = BGRClib_P_SetFillPacket( grclib, pPacket, &outRect ); |
|---|
| 1017 | |
|---|
| 1018 | err = BGRClib_P_PacketsComplete( grclib, (uint32_t) pPacket - (uint32_t) pPacketStart ); |
|---|
| 1019 | |
|---|
| 1020 | return BERR_TRACE(err); |
|---|
| 1021 | } |
|---|
| 1022 | |
|---|
| 1023 | /***************************************************************************/ |
|---|
| 1024 | BERR_Code BGRClib_PorterDuffBlit( BGRClib_Handle grclib, BGRCLib_PorterDuffOp pdOp, |
|---|
| 1025 | const BM2MC_PACKET_Plane *pSrcSurface, const BRect *pSrcRect, unsigned paletteOffset, const BM2MC_PACKET_Plane *pDstSurface, const BRect *pDstRect, |
|---|
| 1026 | const BM2MC_PACKET_Plane *pOutSurface, const BRect *pOutRect ) |
|---|
| 1027 | { |
|---|
| 1028 | BERR_Code err = BERR_SUCCESS; |
|---|
| 1029 | BM2MC_PACKET_Rectangle srcRect; |
|---|
| 1030 | BM2MC_PACKET_Rectangle dstRect; |
|---|
| 1031 | BM2MC_PACKET_Rectangle outRect; |
|---|
| 1032 | void *pPacket; |
|---|
| 1033 | void *pPacketStart; |
|---|
| 1034 | |
|---|
| 1035 | BDBG_OBJECT_ASSERT(grclib, GRClib); |
|---|
| 1036 | |
|---|
| 1037 | BGRClib_P_GetPacketRectangle( pSrcSurface, pSrcRect, &srcRect ); |
|---|
| 1038 | BGRClib_P_GetPacketRectangle( pOutSurface, pDstRect, &dstRect ); /* default to output surface dimensions */ |
|---|
| 1039 | BGRClib_P_GetPacketRectangle( pOutSurface, pOutRect, &outRect ); |
|---|
| 1040 | if (!dstRect.width || !dstRect.height) { |
|---|
| 1041 | dstRect.width = outRect.width; |
|---|
| 1042 | dstRect.height = outRect.height; |
|---|
| 1043 | } |
|---|
| 1044 | |
|---|
| 1045 | pPacketStart = BGRClib_P_GetPacketBuffer( grclib, GRCLIB_FULL_PACKET_SIZE ); |
|---|
| 1046 | if( pPacketStart == 0 ) |
|---|
| 1047 | { |
|---|
| 1048 | return BERR_OUT_OF_DEVICE_MEMORY; /* this is normal for flow control */ |
|---|
| 1049 | } |
|---|
| 1050 | |
|---|
| 1051 | pPacket = pPacketStart; |
|---|
| 1052 | pPacket = BGRClib_P_SetSourceFeederPacket( grclib, pPacket, pSrcSurface, DEFAULT_COLOR ); |
|---|
| 1053 | if (pDstSurface) { |
|---|
| 1054 | pPacket = BGRClib_P_SetDestinationFeederPacket( grclib, pPacket, pDstSurface, DEFAULT_COLOR ); |
|---|
| 1055 | } |
|---|
| 1056 | else { |
|---|
| 1057 | pPacket = BGRClib_P_SetDefaultDestinationFeederPacket(grclib, pPacket); |
|---|
| 1058 | } |
|---|
| 1059 | pPacket = BGRClib_P_SetOutputFeederPacket( grclib, pPacket, pOutSurface ); |
|---|
| 1060 | pPacket = BGRClib_P_SetPorterDuffBlitBlendPacket( grclib, pPacket, pdOp, 0); |
|---|
| 1061 | pPacket = BGRClib_P_SetDefaultRopPacket(grclib, pPacket); |
|---|
| 1062 | |
|---|
| 1063 | pPacket = BGRClib_P_SetDefaultSourceColorkeyPacket(grclib, pPacket); |
|---|
| 1064 | pPacket = BGRClib_P_SetDefaultDestinationColorkeyPacket(grclib, pPacket); |
|---|
| 1065 | pPacket = BGRClib_P_SetDefaultColorMatrixPacket(grclib, pPacket); |
|---|
| 1066 | if (paletteOffset) { |
|---|
| 1067 | pPacket = BGRClib_P_SetSourcePalette(pPacket, paletteOffset ); |
|---|
| 1068 | } |
|---|
| 1069 | pPacket = BGRClib_P_SetDefaultAlphaPremultiplyPacket(grclib, pPacket); |
|---|
| 1070 | pPacket = BGRClib_P_SetDefaultMirrorPacket(grclib, pPacket); |
|---|
| 1071 | pPacket = BGRClib_P_SetDefaultFixedScalePacket(grclib, pPacket); |
|---|
| 1072 | pPacket = BGRClib_P_SetBlitPacket( grclib, pPacket, &srcRect, pDstSurface ? &dstRect : NULL, &outRect, |
|---|
| 1073 | BGRC_FilterCoeffs_ePointSample, BGRC_FilterCoeffs_ePointSample ); |
|---|
| 1074 | |
|---|
| 1075 | err = BGRClib_P_PacketsComplete( grclib, (uint32_t) pPacket - (uint32_t) pPacketStart ); |
|---|
| 1076 | |
|---|
| 1077 | return BERR_TRACE(err); |
|---|
| 1078 | } |
|---|
| 1079 | |
|---|
| 1080 | /*****************************************************************************/ |
|---|
| 1081 | void BGRClib_GetDefaultBlitParams( BGRClib_BlitParams *params ) |
|---|
| 1082 | { |
|---|
| 1083 | BKNI_Memset( params, 0, sizeof(BGRClib_BlitParams) ); |
|---|
| 1084 | /* already zero: params->colorOp = BGRCLib_BlitColorOp_eCopySource; */ |
|---|
| 1085 | /* already zero: params->alphaOp = BGRCLib_BlitAlphaOp_eCopySource; */ |
|---|
| 1086 | params->horzFilter = BGRC_FilterCoeffs_eAnisotropic; |
|---|
| 1087 | params->vertFilter = BGRC_FilterCoeffs_eAnisotropic; |
|---|
| 1088 | params->colorKeySelect = BGRC_Output_ColorKeySelection_eTakeBlend; |
|---|
| 1089 | params->constantColor = DEFAULT_COLOR; |
|---|
| 1090 | } |
|---|
| 1091 | |
|---|
| 1092 | /*****************************************************************************/ |
|---|
| 1093 | void BGRClib_GetDefaultPaletteBlitParams( BGRClib_BlitParams *params ) |
|---|
| 1094 | { |
|---|
| 1095 | BKNI_Memset( params, 0, sizeof(BGRClib_BlitParams) ); |
|---|
| 1096 | /* already zero: params->horzFilter = BGRC_FilterCoeffs_ePointSample; */ |
|---|
| 1097 | /* already zero: params->vertFilter = BGRC_FilterCoeffs_ePointSample; */ |
|---|
| 1098 | params->colorKeySelect = BGRC_Output_ColorKeySelection_eTakeSource; |
|---|
| 1099 | params->constantColor = DEFAULT_COLOR; |
|---|
| 1100 | } |
|---|
| 1101 | |
|---|
| 1102 | /*****************************************************************************/ |
|---|
| 1103 | void BGRClib_GetDefaultColorKeyParams( BGRClib_BlitColorKeyParams *colorkeyparams ) |
|---|
| 1104 | { |
|---|
| 1105 | BKNI_Memset( colorkeyparams, 0, sizeof(BGRClib_BlitColorKeyParams) ); |
|---|
| 1106 | |
|---|
| 1107 | /* TODO: these are unused. need to add packet if they become needed */ |
|---|
| 1108 | colorkeyparams->cksOnlySrcColorKeyed = BGRC_Output_ColorKeySelection_eTakeDestination; |
|---|
| 1109 | colorkeyparams->cksOnlyDstColorKeyed = BGRC_Output_ColorKeySelection_eTakeSource; |
|---|
| 1110 | colorkeyparams->cksBothSrcDstColorKeyed = BGRC_Output_ColorKeySelection_eTakeDestination; |
|---|
| 1111 | colorkeyparams->cksNeitherSrcDstColorKeyed = BGRC_Output_ColorKeySelection_eTakeSource; |
|---|
| 1112 | } |
|---|
| 1113 | |
|---|
| 1114 | |
|---|
| 1115 | /*****************************************************************************/ |
|---|
| 1116 | void BGRClib_GetDefaultScalingControlParams( BGRClib_BlitScalingControlParams *scalingparams ) |
|---|
| 1117 | { |
|---|
| 1118 | BKNI_Memset( scalingparams, 0, sizeof(BGRClib_BlitScalingControlParams) ); |
|---|
| 1119 | scalingparams->ulHorizontalNumerator = 1; |
|---|
| 1120 | scalingparams->ulHorizontalDenominator = 1; |
|---|
| 1121 | scalingparams->ulVerticalNumerator = 1; |
|---|
| 1122 | scalingparams->ulVerticalDenominator = 1; |
|---|
| 1123 | } |
|---|
| 1124 | |
|---|
| 1125 | /***************************************************************************/ |
|---|
| 1126 | BERR_Code BGRClib_Blit( BGRClib_Handle grclib, const BGRClib_BlitParams *params, |
|---|
| 1127 | const BGRClib_BlitColorKeyParams *colorkeyParams, const BGRClib_BlitMatrixParams *matrixParams, |
|---|
| 1128 | const BGRClib_BlitPatternParams *patternParams, const BGRClib_BlitScalingControlParams *scalingParams ) |
|---|
| 1129 | { |
|---|
| 1130 | BERR_Code err = BERR_SUCCESS; |
|---|
| 1131 | |
|---|
| 1132 | void *pPacket; |
|---|
| 1133 | void *pPacketStart; |
|---|
| 1134 | |
|---|
| 1135 | BM2MC_PACKET_Rectangle srcRect; |
|---|
| 1136 | BM2MC_PACKET_Rectangle dstRect; |
|---|
| 1137 | BM2MC_PACKET_Rectangle outRect; |
|---|
| 1138 | |
|---|
| 1139 | BDBG_OBJECT_ASSERT(grclib, GRClib); |
|---|
| 1140 | |
|---|
| 1141 | if (params->colorOp >= BGRCLib_BlitColorOp_Count || params->alphaOp >= BGRCLib_BlitAlphaOp_Count) { |
|---|
| 1142 | return BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 1143 | } |
|---|
| 1144 | if (!params->outSurface) { |
|---|
| 1145 | return BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 1146 | } |
|---|
| 1147 | |
|---|
| 1148 | BGRClib_P_GetPacketRectangle( params->srcSurface, params->srcRect, &srcRect ); |
|---|
| 1149 | BGRClib_P_GetPacketRectangle( params->outSurface, params->dstRect, &dstRect ); /* default to output surface dimensions */ |
|---|
| 1150 | BGRClib_P_GetPacketRectangle( params->outSurface, params->outRect, &outRect ); |
|---|
| 1151 | if (!dstRect.width || !dstRect.height) { |
|---|
| 1152 | dstRect.width = outRect.width; |
|---|
| 1153 | dstRect.height = outRect.height; |
|---|
| 1154 | } |
|---|
| 1155 | |
|---|
| 1156 | pPacketStart = BGRClib_P_GetPacketBuffer( grclib, GRCLIB_FULL_PACKET_SIZE ); |
|---|
| 1157 | if( pPacketStart == 0 ) |
|---|
| 1158 | { |
|---|
| 1159 | return BERR_OUT_OF_DEVICE_MEMORY; /* this is normal for flow control */ |
|---|
| 1160 | } |
|---|
| 1161 | |
|---|
| 1162 | pPacket = pPacketStart; |
|---|
| 1163 | pPacket = BGRClib_P_SetSourceFeederPacket( grclib, pPacket, params->srcSurface, params->sourceConstantColor ); |
|---|
| 1164 | if (params->dstSurface || params->destConstantColor != DEFAULT_COLOR) { |
|---|
| 1165 | pPacket = BGRClib_P_SetDestinationFeederPacket( grclib, pPacket, params->dstSurface, params->destConstantColor ); |
|---|
| 1166 | } |
|---|
| 1167 | else { |
|---|
| 1168 | pPacket = BGRClib_P_SetDefaultDestinationFeederPacket(grclib, pPacket); |
|---|
| 1169 | } |
|---|
| 1170 | pPacket = BGRClib_P_SetOutputFeederPacket( grclib, pPacket, params->outSurface ); |
|---|
| 1171 | |
|---|
| 1172 | if (params->colorOp != BGRCLib_BlitColorOp_eCopySource || params->alphaOp != BGRCLib_BlitAlphaOp_eCopySource) { |
|---|
| 1173 | pPacket = BGRClib_P_SetBlitBlendPacket( grclib, pPacket, params->colorOp, params->alphaOp, |
|---|
| 1174 | ¶ms->colorBlend, ¶ms->alphaBlend, params->constantColor ); |
|---|
| 1175 | } |
|---|
| 1176 | else { |
|---|
| 1177 | pPacket = BGRClib_P_SetDefaultBlitBlendPacket(grclib, pPacket); |
|---|
| 1178 | } |
|---|
| 1179 | |
|---|
| 1180 | if( patternParams ) |
|---|
| 1181 | { |
|---|
| 1182 | pPacket = BGRClib_P_SetRopPacket( grclib, pPacket, patternParams->ropVector, |
|---|
| 1183 | (uint32_t *) patternParams->pattern, patternParams->backColor, patternParams->foreColor ); |
|---|
| 1184 | } |
|---|
| 1185 | else |
|---|
| 1186 | { |
|---|
| 1187 | pPacket = BGRClib_P_SetDefaultRopPacket(grclib, pPacket); |
|---|
| 1188 | } |
|---|
| 1189 | |
|---|
| 1190 | if( colorkeyParams ) |
|---|
| 1191 | { |
|---|
| 1192 | pPacket = BGRClib_P_SetSourceColorkeyPacket( grclib, pPacket, colorkeyParams->enableColorKey, |
|---|
| 1193 | colorkeyParams->colorKeyUpper, colorkeyParams->colorKeyLower, colorkeyParams->colorKeyMask, |
|---|
| 1194 | colorkeyParams->colorKeyReplace, colorkeyParams->colorKeyRplMask ); |
|---|
| 1195 | pPacket = BGRClib_P_SetDestinationColorkeyPacket( grclib, pPacket, colorkeyParams->enableDstColorKey, |
|---|
| 1196 | colorkeyParams->dstColorKeyUpper, colorkeyParams->dstColorKeyLower, colorkeyParams->dstColorKeyMask, |
|---|
| 1197 | colorkeyParams->dstColorKeyReplace, colorkeyParams->dstColorKeyRplMask ); |
|---|
| 1198 | } |
|---|
| 1199 | else |
|---|
| 1200 | { |
|---|
| 1201 | pPacket = BGRClib_P_SetDefaultSourceColorkeyPacket(grclib, pPacket); |
|---|
| 1202 | pPacket = BGRClib_P_SetDefaultDestinationColorkeyPacket(grclib, pPacket); |
|---|
| 1203 | } |
|---|
| 1204 | |
|---|
| 1205 | pPacket = BGRClib_P_SetFilterPacket( grclib, pPacket, params->horzFilter, params->vertFilter, &srcRect, &outRect ); |
|---|
| 1206 | |
|---|
| 1207 | if( matrixParams ) |
|---|
| 1208 | pPacket = BGRClib_P_SetColorMatrixPacket( grclib, pPacket, matrixParams->conversionMatrix, matrixParams->matrixShift ); |
|---|
| 1209 | else |
|---|
| 1210 | pPacket = BGRClib_P_SetDefaultColorMatrixPacket(grclib, pPacket); |
|---|
| 1211 | |
|---|
| 1212 | if (params->srcPaletteOffset) { |
|---|
| 1213 | pPacket = BGRClib_P_SetSourcePalette(pPacket, params->srcPaletteOffset ); |
|---|
| 1214 | } |
|---|
| 1215 | |
|---|
| 1216 | if (params->srcAlphaPremult) { |
|---|
| 1217 | pPacket = BGRClib_P_SetAlphaPremultiplyPacket( grclib, pPacket, params->srcAlphaPremult ); |
|---|
| 1218 | } |
|---|
| 1219 | else { |
|---|
| 1220 | pPacket = BGRClib_P_SetDefaultAlphaPremultiplyPacket(grclib, pPacket); |
|---|
| 1221 | } |
|---|
| 1222 | |
|---|
| 1223 | if (params->mirrorSrcHorizontally || params->mirrorSrcVertically || |
|---|
| 1224 | params->mirrorDstHorizontally || params->mirrorDstVertically || |
|---|
| 1225 | params->mirrorOutHorizontally || params->mirrorOutVertically ) { |
|---|
| 1226 | pPacket = BGRClib_P_SetMirrorPacket( grclib, pPacket, |
|---|
| 1227 | params->mirrorSrcHorizontally, params->mirrorSrcVertically, |
|---|
| 1228 | params->mirrorDstHorizontally, params->mirrorDstVertically, |
|---|
| 1229 | params->mirrorOutHorizontally, params->mirrorOutVertically ); |
|---|
| 1230 | } |
|---|
| 1231 | else { |
|---|
| 1232 | pPacket = BGRClib_P_SetDefaultMirrorPacket(grclib, pPacket); |
|---|
| 1233 | } |
|---|
| 1234 | |
|---|
| 1235 | /* nexus will pass scalingParams == NULL if not used */ |
|---|
| 1236 | if (scalingParams) { |
|---|
| 1237 | pPacket = BGRClib_P_SetFixedScalePacket( grclib, pPacket, scalingParams ); |
|---|
| 1238 | } |
|---|
| 1239 | else { |
|---|
| 1240 | pPacket = BGRClib_P_SetDefaultFixedScalePacket(grclib, pPacket); |
|---|
| 1241 | } |
|---|
| 1242 | |
|---|
| 1243 | pPacket = BGRClib_P_SetBlitPacket( grclib, pPacket, &srcRect, params->dstSurface ? &dstRect : NULL, &outRect, params->horzFilter, params->vertFilter ); |
|---|
| 1244 | |
|---|
| 1245 | err = BGRClib_P_PacketsComplete( grclib, (uint32_t) pPacket - (uint32_t) pPacketStart ); |
|---|
| 1246 | |
|---|
| 1247 | return BERR_TRACE(err); |
|---|
| 1248 | } |
|---|
| 1249 | |
|---|
| 1250 | /* End of File */ |
|---|