sdlada_2.5.20_cd53c280/src/video/sdl-video-surfaces-makers.ads

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
--------------------------------------------------------------------------------------------------------------------
--  This source code is subject to the Zlib license, see the LICENCE file in the root of this directory.
--------------------------------------------------------------------------------------------------------------------
--  SDL.Video.Surfaces.Makers
--
--  Functions to create surface objects.
--------------------------------------------------------------------------------------------------------------------
with System.Storage_Elements;

package SDL.Video.Surfaces.Makers is
   pragma Preelaborate;

   procedure Create (Self       : in out Surface;
                     Size       : in SDL.Sizes;
                     BPP        : in Pixel_Depths;
                     Red_Mask   : in Colour_Masks;
                     Blue_Mask  : in Colour_Masks;
                     Green_Mask : in Colour_Masks;
                     Alpha_Mask : in Colour_Masks);

   generic
       type Element is private;
       type Element_Pointer is access all Element;
   procedure Create_From (Self       : in out Surface;
                          Pixels     : in Element_Pointer;
                          Size       : in SDL.Sizes;
                          BPP        : in Pixel_Depths := Element'Size;
                          Pitch      : in System.Storage_Elements.Storage_Offset;
                          Red_Mask   : in Colour_Masks;
                          Green_Mask : in Colour_Masks;
                          Blue_Mask  : in Colour_Masks;
                          Alpha_Mask : in Colour_Masks);

   generic
      type Element is private;
      type Index is (<>);
      type Element_Array is array (Index range <>, Index range <>) of Element;
   procedure Create_From_Array (Self       : in out Surface;
                                Pixels     : access Element_Array;
                                Red_Mask   : in Colour_Masks;
                                Green_Mask : in Colour_Masks;
                                Blue_Mask  : in Colour_Masks;
                                Alpha_Mask : in Colour_Masks);
   --  Note: I'm unsure what happen when packed (1- or -4bit) arrays are used here.
   --        So, at least check that they have whole number of bytes per row
   --        (E. g. even width in 4-bit)
   --  Note: There may be issue with 24-bit pixels (does SDL imply 4-byte alignment in this case?)

   --  TODO: This is likely a temporary place for this. It's likely I will add a Streams package.
   --     procedure Create (Self : in out Surface; File_Name : in String);
private
   function Get_Internal_Surface (Self : in Surface) return Internal_Surface_Pointer with
     Export     => True,
     Convention => Ada;

   --  Create a surface from an internal pointer, this pointer will be owned by something else, so we don't delete it.
   function Make_Surface_From_Pointer (S : in Internal_Surface_Pointer; Owns : in Boolean := False) return Surface with
     Export     => True,
     Convention => Ada;

   --  TODO: SDL_ConvertSurface
   --  TODO: SDL_ConvertSurfaceFormat
   --  TODO: SDL_CreateRGBSurfaceFrom
end SDL.Video.Surfaces.Makers;