efl

Форк
0
/
ector_buffer.eo 
105 строк · 4.7 Кб
1
import efl_gfx_types;
2

3
enum @beta Ector.Buffer.Flag {
4
   [[Buffer capabilities]]
5
   none              = 0x00, [[Buffer may not have any backing, indicates an invalid buffer.]]
6
   cpu_readable      = 0x01, [[Can be read from the CPU after map. Reading may still be very slow.]]
7
   cpu_writable      = 0x02, [[Can be written to by the CPU after map. Writing may still be very slow.]]
8
   renderable        = 0x04, [[Can be rendered to, ie CPU memory for SW rendering, or an FBO for GL engine.]]
9
   drawable          = 0x08, [[Can be used as a source of pixels to draw on Evas.]]
10
   cpu_readable_fast = 0x10, [[Can be read by the CPU at high speed, ie no need for glReadPixels.]]
11
   cpu_writable_fast = 0x20, [[Can be written by the CPU at high speed, ie no need for GPU texture upload.]]
12
   uncached          = 0x40, [[Backed by uncached memory, ie. slow-ish reads but faster than glReadPixels.]]
13
/* non_coherent      = 0x80, [[Memory may be mapped but will not be coherent between GPU and CPU. Call flush or invalidate to synchronize it.]] */
14
}
15

16
enum @beta Ector.Buffer.Access_Flag {
17
   [[Buffer access permissions]]
18
   none      = 0x0, [[No access permission]]
19
   read      = 0x1, [[Read access permission]]
20
   write     = 0x2, [[Write access permission]]
21
   cow       = 0x4, [[Forces copy-on-write if already mapped as read-only. Requires write.]]
22
}
23

24
mixin @beta Ector.Buffer
25
{
26
   [[2D pixel buffer interface for Ector
27
   ]]
28
   c_prefix: ector_buffer;
29
   methods {
30
      @property size {
31
         [[The (rectangular) size of the pixel buffer.]]
32
         get {}
33
         values {
34
            w: int; [[Width]]
35
            h: int; [[Height]]
36
         }
37
      }
38
      @property cspace {
39
         [[The colorspace of the pixel buffer.]]
40
         get {}
41
         values {
42
            cspace: Efl.Gfx.Colorspace; [[Colorspace]]
43
         }
44
      }
45
      map @pure_virtual {
46
         [[Map a region of this buffer for read or write access by the CPU,
47
           fetch data from the GPU if needed. This operation may be slow if
48
           cpu_readable_fast or cpu_writeable_fast are not true, or if the
49
           required colorspace is different from the internal one.
50
         ]]
51
         params {
52
            @out length: uint; [[Accessible buffer size in bytes, should not be $null.]]
53
            @in mode: Ector.Buffer.Access_Flag; [[Specifies whether to map for read-only,
54
                                                  write-only or read-write access (OR combination of flags).]]
55
            @in x: uint; [[X position of the top-left pixel to map]]
56
            @in y: uint; [[Y position of the top-left pixel to map]]
57
            @in w: uint; [[If 0, defaults to the buffer width]]
58
            @in h: uint; [[If 0, defaults to the buffer height]]
59
            @in cspace: Efl.Gfx.Colorspace; [[Requested colorspace. If different from the internal cspace,
60
                                              map should try to convert the data into a new buffer]]
61
            @out stride: uint @optional; [[Returns the length in bytes of a mapped line]]
62
         }
63
         return: void_ptr @no_unused; [[Pointer to the top-left pixel data. Returns $null in case of failure]]
64
      }
65
      unmap @pure_virtual {
66
         [[Unmap a region of this buffer, and upload data to the GPU (if needed).]]
67
         params {
68
            @in data: void_ptr; [[Data pointer returned by a previous call to map]]
69
            @in length: uint; [[Must be the same as returned by map.]]
70
         }
71
      }
72
      pixels_set @pure_virtual {
73
         [[Sets the source pixels for this buffer, or allocate a new memory region]]
74
         params {
75
            @in pixels: void_ptr; [[If $null, allocates an empty buffer]]
76
            @in width: int; [[Buffer width]]
77
            @in height: int; [[Buffer height]]
78
            @in stride: int; [[Buffer stride (in bytes). If 0 then calculated based on $cspace and $width]]
79
            @in cspace: Efl.Gfx.Colorspace; [[Buffer colorspace]]
80
            @in writable: bool; [[Buffer is writable]]
81
         }
82
         return: bool; [[True if pixels_set was successful]]
83
      }
84
      pixels_get @pure_virtual {
85
         [[Gets the source pixels for the current buffer]]
86
         params {
87
            @out pixels: void_ptr; [[Returns buffer pixel pointer]]
88
            @out width: int; [[Returns buffer width]]
89
            @out height: int; [[Returns buffer height]]
90
            @out stride: int; [[Returns buffer stride size]]
91
         }
92
         return: bool; [[True if returned pixels is writable]]
93
      }
94
      @property flags {
95
         [[The capabilities of this buffer]]
96
         get {}
97
         values {
98
            flag: Ector.Buffer.Flag; [[A bitmask of capability flags]]
99
         }
100
      }
101
   }
102
   events {
103
      detached: ptr(ubyte); [[Emitted whenever the previously attached pixels are detached during pixels_set]]
104
   }
105
}
106

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.