From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.5-pre1 X-Received: by 2002:a37:6786:: with SMTP id b128mr38754513qkc.396.1600524513723; Sat, 19 Sep 2020 07:08:33 -0700 (PDT) X-Received: by 2002:ac8:6f3b:: with SMTP id i27mr38384361qtv.299.1600524513395; Sat, 19 Sep 2020 07:08:33 -0700 (PDT) Path: eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.uzoreto.com!feeder1.feed.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 19 Sep 2020 07:08:31 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=103.85.11.110; posting-account=bWHlUQoAAAC7v-GiJ64eEhxgkxAE3fB1 NNTP-Posting-Host: 103.85.11.110 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: How can I get this data into the .data section of the binary? From: erchetan33@gmail.com Injection-Date: Sat, 19 Sep 2020 14:08:33 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:60215 List-Id: On Tuesday, June 16, 2020 at 5:02:13 PM UTC+5:30, Luke A. Guest wrote: > Hi, > > I'm trying to get some static data tables into the data section rather > than be elaborated at runtime. I can see no reason why this particular > set of types, records and aggregates cannot go into the data section. > > I've searched for use of pragma Static_Elaboration_Desired, but there is > very little information. > > Here's the full modified source from SDL minus the header: > > pragma Restrictions (No_Implicit_Loops); > with Ada.Characters.Latin_1; > with Ada.Unchecked_Conversion; > with Interfaces; > with Interfaces.C; > with SDL.Video.Palettes; > > package SDL.Video.Pixel_Formats is > package C renames Interfaces.C; > > type Pixel_Types is > (Unknown, > Index_1, > Index_4, > Index_8, > Packed_8, > Packed_16, > Packed_32, > Array_U8, > Array_U16, > Array_U32, > Array_F16, > Array_F32) with > Convention => C; > pragma Static_Elaboration_Desired (Pixel_Types); > > -- Bitmap pixel order, high bit -> low bit. > type Bitmap_Pixel_Order is (None, Little_Endian, Big_Endian) with > Convention => C; > pragma Static_Elaboration_Desired (Bitmap_Pixel_Order); > > -- Packed component order, high bit -> low bit. > type Packed_Component_Order is > (None, > XRGB, > RGBX, > ARGB, > RGBA, > XBGR, > BGRX, > ABGR, > BGRA) with > Convention => C; > pragma Static_Elaboration_Desired (Packed_Component_Order); > > -- Array component order, low byte -> high byte. > type Array_Component_Order is (None, RGB, RGBA, ARGB, BGR, BGRA, ABGR); > pragma Static_Elaboration_Desired (Array_Component_Order); > > -- Describe how the components are laid out in bit form. > type Packed_Component_Layout is > (None, > Bits_332, > Bits_4444, > Bits_1555, > Bits_5551, > Bits_565, > Bits_8888, > Bits_2101010, > Bits_1010102) with > Convention => C; > pragma Static_Elaboration_Desired (Packed_Component_Layout); > > type Bits_Per_Pixels is range 0 .. 32 with > Static_Predicate => Bits_Per_Pixels in 0 | 1 | 4 | 8 | 12 | 15 | 16 > | 24 | 32, > Convention => C; > pragma Static_Elaboration_Desired (Bits_Per_Pixels); > > Bits_Per_Pixel_Error : constant Bits_Per_Pixels := 0; > > type Bytes_Per_Pixels is range 0 .. 4 with > Convention => C; > pragma Static_Elaboration_Desired (Bytes_Per_Pixels); > > Bytes_Per_Pixel_Error : constant Bytes_Per_Pixels := > Bytes_Per_Pixels'First; > > -- 29 28 24 20 16 8 0 > -- 000 1 ptpt popo llll bibibibi bybybyby > -- > -- or > -- > -- 24 16 8 0 > -- DDDDDDDD CCCCCCCC BBBBBBBB AAAAAAAA > > type Index_Order_Padding is range 0 .. 1 with > Convention => C; > pragma Static_Elaboration_Desired (Index_Order_Padding); > > type Pixel_Orders (Pixel_Type : Pixel_Types := Unknown) is > record > case Pixel_Type is > when Index_1 | Index_4 | Index_8 => > Indexed_Order : Bitmap_Pixel_Order; > Indexed_Pad : Index_Order_Padding; > > when Packed_8 | Packed_16 | Packed_32 => > Packed_Order : Packed_Component_Order; > > when Array_U8 | Array_U16 | Array_U32 | Array_F16 | Array_F32 => > Array_Order : Array_Component_Order; > > when others => > null; > end case; > end record with > Unchecked_Union => True, > Convention => C, > Size => 4; > > pragma Warnings (Off, "no component clause given"); > for Pixel_Orders use > record > Indexed_Order at 0 range 0 .. 2; -- This was 2 as that is the > max size required but it causes a bit set bug! > Indexed_Pad at 0 range 3 .. 3; > Packed_Order at 0 range 0 .. 3; > Array_Order at 0 range 0 .. 3; > end record; > pragma Static_Elaboration_Desired (Pixel_Orders); > pragma Warnings (On, "no component clause given"); > > type Planar_Pixels is > record > A : Character; > B : Character; > C : Character; > D : Character; > end record with > Size => 32, > Convention => C; > > for Planar_Pixels use > record > A at 0 range 0 .. 7; > B at 0 range 8 .. 15; > C at 0 range 16 .. 23; > D at 0 range 24 .. 31; > end record; > pragma Static_Elaboration_Desired (Planar_Pixels); > > type Non_Planar_Pixel_Padding is range 0 .. 7 with > Convention => C; > pragma Static_Elaboration_Desired (Non_Planar_Pixel_Padding); > > type Non_Planar_Pixels is > record > Bytes_Per_Pixel : Bytes_Per_Pixels; > Bits_Per_Pixel : Bits_Per_Pixels; > Layout : Packed_Component_Layout; > Pixel_Order : Pixel_Orders; > Pixel_Type : Pixel_Types; > Flag : Boolean; > Padding : Non_Planar_Pixel_Padding; > end record with > Size => 32, > Convention => C; > > for Non_Planar_Pixels use > record > Bytes_Per_Pixel at 0 range 0 .. 7; > Bits_Per_Pixel at 0 range 8 .. 15; > Layout at 0 range 16 .. 19; > Pixel_Order at 0 range 20 .. 23; > Pixel_Type at 0 range 24 .. 27; > Flag at 0 range 28 .. 28; > Padding at 0 range 29 .. 31; > end record; > pragma Static_Elaboration_Desired (Non_Planar_Pixels); > > type Pixel_Format_Names (Planar : Boolean := False) is > record > case Planar is > when True => > Planar_Format : Planar_Pixels; > when False => > Non_Planar_Format : Non_Planar_Pixels; > end case; > end record with > Unchecked_Union => True, > Size => 32, > Convention => C; > pragma Static_Elaboration_Desired (Pixel_Format_Names); > > Pixel_Format_Unknown : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => True, > Planar_Format => Planar_Pixels' > (others => Ada.Characters.Latin_1.NUL)); > pragma Static_Elaboration_Desired (Pixel_Format_Unknown); > > Pixel_Format_Index_1_LSB : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => False, > Non_Planar_Format => Non_Planar_Pixels' > (Padding => > Non_Planar_Pixel_Padding'First, > Flag => True, > Pixel_Type => Index_1, > Pixel_Order => Pixel_Orders' > (Pixel_Type => Index_1, > Indexed_Order => Little_Endian, > Indexed_Pad => Index_Order_Padding'First), > Layout => None, > Bits_Per_Pixel => 1, > Bytes_Per_Pixel => 0)); > pragma Static_Elaboration_Desired (Pixel_Format_Index_1_LSB); > > Pixel_Format_Index_1_MSB : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => False, > Non_Planar_Format => Non_Planar_Pixels' > (Padding => > Non_Planar_Pixel_Padding'First, > Flag => True, > Pixel_Type => Index_1, > Pixel_Order => Pixel_Orders' > (Pixel_Type => Index_1, > Indexed_Order => Big_Endian, > Indexed_Pad => Index_Order_Padding'First), > Layout => None, > Bits_Per_Pixel => 1, > Bytes_Per_Pixel => 0)); > pragma Static_Elaboration_Desired (Pixel_Format_Index_1_MSB); > > Pixel_Format_Index_4_LSB : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => False, > Non_Planar_Format => Non_Planar_Pixels' > (Padding => > Non_Planar_Pixel_Padding'First, > Flag => True, > Pixel_Type => Index_4, > Pixel_Order => Pixel_Orders' > (Pixel_Type => Index_4, > Indexed_Order => Little_Endian, > Indexed_Pad => Index_Order_Padding'First), > Layout => None, > Bits_Per_Pixel => 4, > Bytes_Per_Pixel => 0)); > pragma Static_Elaboration_Desired (Pixel_Format_Index_4_LSB); > > Pixel_Format_Index_4_MSB : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => False, > Non_Planar_Format => Non_Planar_Pixels' > (Padding => > Non_Planar_Pixel_Padding'First, > Flag => True, > Pixel_Type => Index_4, > Pixel_Order => Pixel_Orders' > (Pixel_Type => Index_4, > Indexed_Order => Big_Endian, > Indexed_Pad => Index_Order_Padding'First), > Layout => None, > Bits_Per_Pixel => 4, > Bytes_Per_Pixel => 0)); > pragma Static_Elaboration_Desired (Pixel_Format_Index_4_MSB); > > Pixel_Format_Index_8 : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => False, > Non_Planar_Format => Non_Planar_Pixels' > (Padding => > Non_Planar_Pixel_Padding'First, > Flag => True, > Pixel_Type => Index_8, > Pixel_Order => Pixel_Orders' > (Pixel_Type => Index_8, > Indexed_Order => None, > Indexed_Pad => Index_Order_Padding'First), > Layout => None, > Bits_Per_Pixel => 8, > Bytes_Per_Pixel => 1)); > pragma Static_Elaboration_Desired (Pixel_Format_Index_8); > > Pixel_Format_RGB_332 : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => False, > Non_Planar_Format => Non_Planar_Pixels' > (Padding => > Non_Planar_Pixel_Padding'First, > Flag => True, > Pixel_Type => Packed_8, > Pixel_Order => Pixel_Orders' > (Pixel_Type => Packed_8, > Packed_Order => XRGB), > Layout => Bits_332, > Bits_Per_Pixel => 8, > Bytes_Per_Pixel => 1)); > pragma Static_Elaboration_Desired (Pixel_Format_RGB_332); > > Pixel_Format_RGB_444 : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => False, > Non_Planar_Format => Non_Planar_Pixels' > (Padding => > Non_Planar_Pixel_Padding'First, > Flag => True, > Pixel_Type => Packed_16, > Pixel_Order => Pixel_Orders' > (Pixel_Type => Packed_16, > Packed_Order => XRGB), > Layout => Bits_4444, > Bits_Per_Pixel => 12, > Bytes_Per_Pixel => 2)); > pragma Static_Elaboration_Desired (Pixel_Format_RGB_444); > > Pixel_Format_RGB_555 : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => False, > Non_Planar_Format => Non_Planar_Pixels' > (Padding => > Non_Planar_Pixel_Padding'First, > Flag => True, > Pixel_Type => Packed_16, > Pixel_Order => Pixel_Orders' > (Pixel_Type => Packed_16, > Packed_Order => XRGB), > Layout => Bits_1555, > Bits_Per_Pixel => 15, > Bytes_Per_Pixel => 2)); > pragma Static_Elaboration_Desired (Pixel_Format_RGB_555); > > Pixel_Format_BGR_555 : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => False, > Non_Planar_Format => Non_Planar_Pixels' > (Padding => > Non_Planar_Pixel_Padding'First, > Flag => True, > Pixel_Type => Packed_16, > Pixel_Order => Pixel_Orders' > (Pixel_Type => Packed_16, > Packed_Order => XBGR), > Layout => Bits_1555, > Bits_Per_Pixel => 15, > Bytes_Per_Pixel => 2)); > pragma Static_Elaboration_Desired (Pixel_Format_BGR_555); > > Pixel_Format_ARGB_4444 : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => False, > Non_Planar_Format => Non_Planar_Pixels' > (Padding => > Non_Planar_Pixel_Padding'First, > Flag => True, > Pixel_Type => Packed_16, > Pixel_Order => Pixel_Orders' > (Pixel_Type => Packed_16, > Packed_Order => ARGB), > Layout => Bits_4444, > Bits_Per_Pixel => 16, > Bytes_Per_Pixel => 2)); > pragma Static_Elaboration_Desired (Pixel_Format_ARGB_4444); > > Pixel_Format_RGBA_4444 : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => False, > Non_Planar_Format => Non_Planar_Pixels' > (Padding => > Non_Planar_Pixel_Padding'First, > Flag => True, > Pixel_Type => Packed_16, > Pixel_Order => Pixel_Orders' > (Pixel_Type => Packed_16, > Packed_Order => RGBA), > Layout => Bits_4444, > Bits_Per_Pixel => 16, > Bytes_Per_Pixel => 2)); > pragma Static_Elaboration_Desired (Pixel_Format_RGBA_4444); > > Pixel_Format_ABGR_4444 : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => False, > Non_Planar_Format => Non_Planar_Pixels' > (Padding => > Non_Planar_Pixel_Padding'First, > Flag => True, > Pixel_Type => Packed_16, > Pixel_Order => Pixel_Orders' > (Pixel_Type => Packed_16, > Packed_Order => ABGR), > Layout => Bits_4444, > Bits_Per_Pixel => 16, > Bytes_Per_Pixel => 2)); > pragma Static_Elaboration_Desired (Pixel_Format_ABGR_4444); > > Pixel_Format_BGRA_4444 : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => False, > Non_Planar_Format => Non_Planar_Pixels' > (Padding => > Non_Planar_Pixel_Padding'First, > Flag => True, > Pixel_Type => Packed_16, > Pixel_Order => Pixel_Orders' > (Pixel_Type => Packed_16, > Packed_Order => BGRA), > Layout => Bits_4444, > Bits_Per_Pixel => 16, > Bytes_Per_Pixel => 2)); > pragma Static_Elaboration_Desired (Pixel_Format_BGRA_4444); > > Pixel_Format_ARGB_1555 : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => False, > Non_Planar_Format => Non_Planar_Pixels' > (Padding => > Non_Planar_Pixel_Padding'First, > Flag => True, > Pixel_Type => Packed_16, > Pixel_Order => Pixel_Orders' > (Pixel_Type => Packed_16, > Packed_Order => ARGB), > Layout => Bits_1555, > Bits_Per_Pixel => 16, > Bytes_Per_Pixel => 2)); > pragma Static_Elaboration_Desired (Pixel_Format_ARGB_1555); > > Pixel_Format_RGBA_5551 : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => False, > Non_Planar_Format => Non_Planar_Pixels' > (Padding => > Non_Planar_Pixel_Padding'First, > Flag => True, > Pixel_Type => Packed_16, > Pixel_Order => Pixel_Orders' > (Pixel_Type => Packed_16, > Packed_Order => RGBA), > Layout => Bits_5551, > Bits_Per_Pixel => 16, > Bytes_Per_Pixel => 2)); > pragma Static_Elaboration_Desired (Pixel_Format_RGBA_5551); > > Pixel_Format_ABGR_1555 : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => False, > Non_Planar_Format => Non_Planar_Pixels' > (Padding => > Non_Planar_Pixel_Padding'First, > Flag => True, > Pixel_Type => Packed_16, > Pixel_Order => Pixel_Orders' > (Pixel_Type => Packed_16, > Packed_Order => ABGR), > Layout => Bits_1555, > Bits_Per_Pixel => 16, > Bytes_Per_Pixel => 2)); > pragma Static_Elaboration_Desired (Pixel_Format_ABGR_1555); > > Pixel_Format_BGRA_5551 : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => False, > Non_Planar_Format => Non_Planar_Pixels' > (Padding => > Non_Planar_Pixel_Padding'First, > Flag => True, > Pixel_Type => Packed_16, > Pixel_Order => Pixel_Orders' > (Pixel_Type => Packed_16, > Packed_Order => BGRA), > Layout => Bits_5551, > Bits_Per_Pixel => 16, > Bytes_Per_Pixel => 2)); > pragma Static_Elaboration_Desired (Pixel_Format_BGRA_5551); > > Pixel_Format_RGB_565 : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => False, > Non_Planar_Format => Non_Planar_Pixels' > (Padding => > Non_Planar_Pixel_Padding'First, > Flag => True, > Pixel_Type => Packed_16, > Pixel_Order => Pixel_Orders' > (Pixel_Type => Packed_16, > Packed_Order => XRGB), > Layout => Bits_565, > Bits_Per_Pixel => 16, > Bytes_Per_Pixel => 2)); > pragma Static_Elaboration_Desired (Pixel_Format_RGB_565); > > Pixel_Format_BGR_565 : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => False, > Non_Planar_Format => Non_Planar_Pixels' > (Padding => > Non_Planar_Pixel_Padding'First, > Flag => True, > Pixel_Type => Packed_16, > Pixel_Order => Pixel_Orders' > (Pixel_Type => Packed_16, > Packed_Order => XBGR), > Layout => Bits_565, > Bits_Per_Pixel => 16, > Bytes_Per_Pixel => 2)); > pragma Static_Elaboration_Desired (Pixel_Format_BGR_565); > > Pixel_Format_RGB_24 : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => False, > Non_Planar_Format => Non_Planar_Pixels' > (Padding => > Non_Planar_Pixel_Padding'First, > Flag => True, > Pixel_Type => Array_U8, > Pixel_Order => Pixel_Orders' > (Pixel_Type => Array_U8, > Array_Order => RGB), > Layout => None, > Bits_Per_Pixel => 24, > Bytes_Per_Pixel => 3)); > pragma Static_Elaboration_Desired (Pixel_Format_RGB_24); > > Pixel_Format_BGR_24 : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => False, > Non_Planar_Format => Non_Planar_Pixels' > (Padding => > Non_Planar_Pixel_Padding'First, > Flag => True, > Pixel_Type => Array_U8, > Pixel_Order => Pixel_Orders' > (Pixel_Type => Array_U8, > Array_Order => BGR), > Layout => None, > Bits_Per_Pixel => 24, > Bytes_Per_Pixel => 3)); > pragma Static_Elaboration_Desired (Pixel_Format_BGR_24); > > Pixel_Format_RGB_888 : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => False, > Non_Planar_Format => Non_Planar_Pixels' > (Padding => > Non_Planar_Pixel_Padding'First, > Flag => True, > Pixel_Type => Packed_32, > Pixel_Order => Pixel_Orders' > (Pixel_Type => Packed_32, > Packed_Order => XRGB), > Layout => Bits_8888, > Bits_Per_Pixel => 24, > Bytes_Per_Pixel => 4)); > pragma Static_Elaboration_Desired (Pixel_Format_RGB_888); > > Pixel_Format_RGBX_8888 : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => False, > Non_Planar_Format => Non_Planar_Pixels' > (Padding => > Non_Planar_Pixel_Padding'First, > Flag => True, > Pixel_Type => Packed_32, > Pixel_Order => Pixel_Orders' > (Pixel_Type => Packed_32, > Packed_Order => RGBX), > Layout => Bits_8888, > Bits_Per_Pixel => 24, > Bytes_Per_Pixel => 4)); > pragma Static_Elaboration_Desired (Pixel_Format_RGBX_8888); > > Pixel_Format_BGR_888 : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => False, > Non_Planar_Format => Non_Planar_Pixels' > (Padding => > Non_Planar_Pixel_Padding'First, > Flag => True, > Pixel_Type => Packed_32, > Pixel_Order => Pixel_Orders' > (Pixel_Type => Packed_32, > Packed_Order => XBGR), > Layout => Bits_8888, > Bits_Per_Pixel => 24, > Bytes_Per_Pixel => 4)); > pragma Static_Elaboration_Desired (Pixel_Format_BGR_888); > > Pixel_Format_BGRX_8888 : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => False, > Non_Planar_Format => Non_Planar_Pixels' > (Padding => > Non_Planar_Pixel_Padding'First, > Flag => True, > Pixel_Type => Packed_32, > Pixel_Order => Pixel_Orders' > (Pixel_Type => Packed_32, > Packed_Order => BGRX), > Layout => Bits_8888, > Bits_Per_Pixel => 24, > Bytes_Per_Pixel => 4)); > pragma Static_Elaboration_Desired (Pixel_Format_BGRX_8888); > > Pixel_Format_ARGB_8888 : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => False, > Non_Planar_Format => Non_Planar_Pixels' > (Padding => > Non_Planar_Pixel_Padding'First, > Flag => True, > Pixel_Type => Packed_32, > Pixel_Order => Pixel_Orders' > (Pixel_Type => Packed_32, > Packed_Order => ARGB), > Layout => Bits_8888, > Bits_Per_Pixel => 32, > Bytes_Per_Pixel => 4)); > pragma Static_Elaboration_Desired (Pixel_Format_ARGB_8888); > > Pixel_Format_RGBA_8888 : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => False, > Non_Planar_Format => Non_Planar_Pixels' > (Padding => > Non_Planar_Pixel_Padding'First, > Flag => True, > Pixel_Type => Packed_32, > Pixel_Order => Pixel_Orders' > (Pixel_Type => Packed_32, > Packed_Order => RGBA), > Layout => Bits_8888, > Bits_Per_Pixel => 32, > Bytes_Per_Pixel => 4)); > pragma Static_Elaboration_Desired (Pixel_Format_RGBA_8888); > > Pixel_Format_ABGR_8888 : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => False, > Non_Planar_Format => Non_Planar_Pixels' > (Padding => > Non_Planar_Pixel_Padding'First, > Flag => True, > Pixel_Type => Packed_32, > Pixel_Order => Pixel_Orders' > (Pixel_Type => Packed_32, > Packed_Order => ABGR), > Layout => Bits_8888, > Bits_Per_Pixel => 32, > Bytes_Per_Pixel => 4)); > pragma Static_Elaboration_Desired (Pixel_Format_ABGR_8888); > > Pixel_Format_BGRA_8888 : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => False, > Non_Planar_Format => Non_Planar_Pixels' > (Padding => > Non_Planar_Pixel_Padding'First, > Flag => True, > Pixel_Type => Packed_32, > Pixel_Order => Pixel_Orders' > (Pixel_Type => Packed_32, > Packed_Order => BGRA), > Layout => Bits_8888, > Bits_Per_Pixel => 32, > Bytes_Per_Pixel => 4)); > pragma Static_Elaboration_Desired (Pixel_Format_BGRA_8888); > > Pixel_Format_ARGB_2101010 : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => False, > Non_Planar_Format => Non_Planar_Pixels' > (Padding => > Non_Planar_Pixel_Padding'First, > Flag => True, > Pixel_Type => Packed_32, > Pixel_Order => Pixel_Orders' > (Pixel_Type => Packed_32, > Packed_Order => ARGB), > Layout => Bits_2101010, > Bits_Per_Pixel => 32, > Bytes_Per_Pixel => 4)); > pragma Static_Elaboration_Desired (Pixel_Format_ARGB_2101010); > > Pixel_Format_YV_12 : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => True, > Planar_Format => Planar_Pixels' > (A => 'Y', > B => 'V', > C => '1', > D => '2')); > pragma Static_Elaboration_Desired (Pixel_Format_YV_12); > > Pixel_Format_IYUV : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => True, > Planar_Format => Planar_Pixels' > (A => 'I', > B => 'Y', > C => 'U', > D => 'V')); > pragma Static_Elaboration_Desired (Pixel_Format_IYUV); > > Pixel_Format_YUY_2 : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => True, > Planar_Format => Planar_Pixels' > (A => 'Y', > B => 'U', > C => 'Y', > D => '2')); > pragma Static_Elaboration_Desired (Pixel_Format_YUY_2); > > Pixel_Format_UYVY : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => True, > Planar_Format => Planar_Pixels' > (A => 'U', > B => 'Y', > C => 'V', > D => 'Y')); > pragma Static_Elaboration_Desired (Pixel_Format_UYVY); > > Pixel_Format_YVYU : constant Pixel_Format_Names := > Pixel_Format_Names'(Planar => True, > Planar_Format => Planar_Pixels' > (A => 'Y', > B => 'V', > C => 'Y', > D => 'U')); > pragma Static_Elaboration_Desired (Pixel_Format_YVYU); > > type Colour_Mask is mod 2 ** 32 with > Convention => C; > > type Private_Pixel_Format is private; > > type Pixel_Format is > record > Format : Pixel_Format_Names; > Palette : Palettes.Palette_Access; > Bits : Bits_Per_Pixels; > Bytes : Bytes_Per_Pixels; > Padding : Interfaces.Unsigned_16; > Red_Mask : Colour_Mask; > Green_Mask : Colour_Mask; > Blue_Mask : Colour_Mask; > Alpha_Mask : Colour_Mask; > > -- This is mainly padding to make sure the record size matches > what is expected from C. > Private_Part : Private_Pixel_Format; > end record with > Convention => C; > > -- TODO: Possibly change this to a controlled type. > type Pixel_Format_Access is access all Pixel_Format with > Convention => C; > > function Create (Format : in Pixel_Format_Names) return > Pixel_Format_Access with > Import => True, > Convention => C, > External_Name => "SDL_AllocFormat"; > > procedure Free (Format : in Pixel_Format_Access) with > Import => True, > Convention => C, > External_Name => "SDL_FreeFormat"; > > function Image (Format : in Pixel_Format_Names) return String; > -- Import => True, > -- Convention => C, > -- External_Name => "SDL_GetPixelFormatName"; > > procedure To_Components > (Pixel : in Interfaces.Unsigned_32; > Format : in Pixel_Format_Access; > Red : out Palettes.Colour_Component; > Green : out Palettes.Colour_Component; > Blue : out Palettes.Colour_Component) with > Import => True, > Convention => C, > External_Name => "SDL_GetRGB"; > > procedure To_Components > (Pixel : in Interfaces.Unsigned_32; > Format : in Pixel_Format_Access; > Red : out Palettes.Colour_Component; > Green : out Palettes.Colour_Component; > Blue : out Palettes.Colour_Component; > Alpha : out Palettes.Colour_Component) with > Import => True, > Convention => C, > External_Name => "SDL_GetRGBA"; > > function To_Pixel > (Format : in Pixel_Format_Access; > Red : in Palettes.Colour_Component; > Green : in Palettes.Colour_Component; > Blue : in Palettes.Colour_Component) return > Interfaces.Unsigned_32 with > Import => True, > Convention => C, > External_Name => "SDL_MapRGB"; > > function To_Pixel > (Format : in Pixel_Format_Access; > Red : in Palettes.Colour_Component; > Green : in Palettes.Colour_Component; > Blue : in Palettes.Colour_Component; > Alpha : in Palettes.Colour_Component) return > Interfaces.Unsigned_32 with > Import => True, > Convention => C, > External_Name => "SDL_MapRGBA"; > > function To_Colour (Pixel : in Interfaces.Unsigned_32; Format : in > Pixel_Format_Access) return Palettes.Colour with > Inline => True; > > function To_Pixel (Colour : in Palettes.Colour; Format : in > Pixel_Format_Access) return Interfaces.Unsigned_32 with > Inline => True; > > function To_Name > (Bits : in Bits_Per_Pixels; > Red_Mask : in Colour_Mask; > Green_Mask : in Colour_Mask; > Blue_Mask : in Colour_Mask; > Alpha_Mask : in Colour_Mask) return Pixel_Format_Names with > Import => True, > Convention => C, > External_Name => "SDL_MasksToPixelFormatEnum"; > > function To_Masks > (Format : in Pixel_Format_Names; > Bits : out Bits_Per_Pixels; > Red_Mask : out Colour_Mask; > Green_Mask : out Colour_Mask; > Blue_Mask : out Colour_Mask; > Alpha_Mask : out Colour_Mask) return Boolean with > Inline => True; > > -- Gamma > type Gamma_Value is mod 2 ** 16 with > Convention => C; > > type Gamma_Ramp is array (Integer range 1 .. 256) of Gamma_Value with > Convention => C; > > procedure Calculate (Gamma : in Float; Ramp : out Gamma_Ramp) with > Import => True, > Convention => C, > External_Name => "SDL_CalculateGammaRamp"; > private > -- The following fields are defined as "internal use" in the SDL docs. > type Private_Pixel_Format is > record > Rred_Loss : Interfaces.Unsigned_8; > Green_Loss : Interfaces.Unsigned_8; > Blue_Loss : Interfaces.Unsigned_8; > Alpha_Loss : Interfaces.Unsigned_8; > Red_Shift : Interfaces.Unsigned_8; > Green_Shift : Interfaces.Unsigned_8; > Blue_Shift : Interfaces.Unsigned_8; > Alpha_Shift : Interfaces.Unsigned_8; > Ref_Count : C.int; > Next : Pixel_Format_Access; > end record with > Convention => C; > end SDL.Video.Pixel_Formats;