summaryrefslogtreecommitdiff
path: root/src/lib/elementary/elm_glview.eo
blob: 7c5b06e7d75777350ab742b83df24a25bffb0b19 (plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
type Evas_GL: __undefined_type; [[Evas GL type]]
type Evas_GL_API: __undefined_type; [[Evas GL API type]]
type Evas_GL_Context_Version: __undefined_type; [[Evas GL context version type]]

enum Elm.GLView.Mode
{
   [[
     Selects the target surface properties

     An OR combination of Elm_GLView_Mode values should be passed to
     elm_glview_mode_set when setting up a GL widget. These flags will
     specify the properties of the rendering target surface; in particular,
     the mode can request the surface to support alpha, depth and stencil buffers.

           ELM_GLVIEW_CLIENT_SIDE_ROTATION is a special value that indicates
           to EFL that the application will handle the view rotation when the
           device is rotated. This is needed only when the application requests
           direct rendering. Please refer to Evas_GL
           for more information about direct rendering.

     See @Elm.Glview.mode.set
     See elm_opengl_page
   ]]
   legacy: elm_glview;
   none    = 0, [[Default mode]]
   // 0x1 is reserved for future use
   alpha   = (1<<1), [[Alpha channel enabled rendering mode]]
   depth   = (1<<2), [[Depth buffer enabled rendering mode (24 bits by default)]]
   stencil = (1<<3), [[Stencil buffer enabled rendering mode (8 bits by default)]]
   direct  = (1<<4), [[Request direct rendering, unless there must be a fallback]]
   client_side_rotation = (1<<5), [[Client will handle GL view rotation if direct rendering is enabled]]
   // Depth buffer sizes (3 bits)
   depth_8  = Elm.GLView.Mode.depth | (1 << 6), [[Request min. 8 bits for the depth buffer]]
   depth_16 = Elm.GLView.Mode.depth | (2 << 6), [[Request min. 16 bits for the depth buffer]]
   depth_24 = Elm.GLView.Mode.depth | (3 << 6), [[Request min. 24 bits for the depth buffer (default)]]
   depth_32 = Elm.GLView.Mode.depth | (4 << 6), [[Request min. 32 bits for the depth buffer]]
   // Stencil buffer sizes (3 bits)
   stencil_1  = Elm.GLView.Mode.stencil | (1 << 9), [[Request min. 1 bits for the stencil buffer]]
   stencil_2  = Elm.GLView.Mode.stencil | (2 << 9), [[Request min. 2 bits for the stencil buffer]]
   stencil_4  = Elm.GLView.Mode.stencil | (3 << 9), [[Request min. 4 bits for the stencil buffer]]
   stencil_8  = Elm.GLView.Mode.stencil | (4 << 9), [[Request min. 8 bits for the stencil buffer (default)]]
   stencil_16 = Elm.GLView.Mode.stencil | (5 << 9), [[Request min. 16 bits for the stencil buffer]]
   // MSAA params (2 bits)
   multisample_low  = (1 << 12), [[MSAA with minimum number of samples]]
   multisample_med  = (2 << 12), [[MSAA with half the number of maximum samples]]
   multisample_high = (3 << 12)  [[MSAA with maximum number of samples]]

}

enum Elm.GLView.Resize.Policy
{
   [[
     Defines a policy for the glview resizing.

     The resizing policy tells glview what to do with the underlying
     surface when resize happens. ELM_GLVIEW_RESIZE_POLICY_RECREATE
     will destroy the current surface and recreate the surface to the
     new size. ELM_GLVIEW_RESIZE_POLICY_SCALE will instead keep the
     current surface but only display the result at the desired size scaled.

     Default is @Elm.GLView.Resize.Policy.recreate
   ]]
   recreate = 1, [[Resize the internal surface along with the image]]
   scale    = 2  [[Only resize the internal image and not the surface]]
}

enum Elm.GLView.Render.Policy
{
   [[
     Defines a policy for gl rendering.

     The rendering policy tells glview where to run the gl rendering code.
     ELM_GLVIEW_RENDER_POLICY_ON_DEMAND tells glview to call the rendering
     calls on demand, which means that the rendering code gets called
     only when it is visible.

     Default is @Elm.GLView.Render.Policy.on_demand
   ]]
   on_demand = 1, [[Render only when there is a need for redrawing]]
   always    = 2  [[Render always even when it is not visible]]
}

class Elm.Glview (Elm.Widget, Efl.Gfx.View)
{
   [[Elementary GL view class]]
   legacy_prefix: elm_glview;
   eo_prefix: elm_obj_glview;
   event_prefix: elm_glview;
   methods {
      version_constructor {
         [[Constructor with context version number.]]
         legacy: null;
         params {
            @in version: Evas_GL_Context_Version; [[GL context version]]
         }
      }
      @property resize_policy {
         set {
            [[Set the resize policy for the glview object.

              By default, the resize policy is set to
              #ELM_GLVIEW_RESIZE_POLICY_RECREATE. When resize is called
              it destroys the previous surface and recreates the newly
              specified size. If the policy is set to
              #ELM_GLVIEW_RESIZE_POLICY_SCALE, however, glview only
              scales the image object and not the underlying GL Surface.
            ]]
            return: bool; [[$true on success, $false otherwise]]
         }
         values {
            policy: Elm.GLView.Resize.Policy; [[The scaling policy.]]
         }
      }
      @property render_policy {
         set {
            [[Set the render policy for the glview object.

              By default, the render policy is set to
              #ELM_GLVIEW_RENDER_POLICY_ON_DEMAND. This policy is set
              such that during the render loop, glview is only redrawn
              if it needs to be redrawn. (i.e. when it is visible) If the
              policy is set to #ELM_GLVIEWW_RENDER_POLICY_ALWAYS, it
              redraws regardless of whether it is visible or needs
              redrawing.
            ]]
            return: bool; [[$true on success, $false otherwise]]
         }
         values {
            policy: Elm.GLView.Render.Policy; [[The render policy.]]
         }
      }
      @property mode {
         set {
            [[Set the mode of the GLView. Supports alpha, depth, stencil.

              Direct is a hint for the elm_glview to render directly to
              the window given that the right conditions are met. Otherwise
              it falls back to rendering to an offscreen buffer before it
              gets composited to the window.
            ]]
            return: bool; [[$true on success, $false otherwise]]
         }
         values {
            mode: Elm.GLView.Mode; [[The mode Options OR'ed enabling Alpha, Depth, Stencil, Direct.]]
         }
      }
      @property gl_api {
         get {
            [[Get the gl api struct for gl rendering.]]
            return: ptr(Evas_GL_API); [[GL API]]
         }
      }
      @property evas_gl {
         get {
            [[Get the internal Evas GL attached to this view.

              Note: The returned Evas_GL must not be destroyed as it is
              still owned by the view. But this pointer can be used then
              to call all the evas_gl_ functions.

              @since 1.12
            ]]
            return: ptr(Evas_GL); [[Evas GL]]
         }
      }
      @property rotation {
         get {
            [[Get the current GL view's rotation when using direct rendering

              Note: This rotation can be different from the device
              orientation. This rotation value must be used in case of
              direct rendering and should be taken into account by the
              application when setting the internal rotation matrix for
              the view.

              @since 1.12
            ]]
            return: int; [[A window rotation in degrees (0, 90, 180 or 270).]]
         }
      }
      draw_request {
         [[Notifies that there has been changes in the GLView.

           @since 1.18
         ]]
         legacy: null;
      }
   }
   implements {
      class.constructor;
      Efl.Object.finalize;
      Efl.Gfx.size { set; }
      Elm.Widget.on_focus_update;
      Efl.Gfx.View.view_size { get; set; }
   }
   events {
      created; [[Event dispatched when first render happens.

              The callback function gets called once during the
              render loop. Callback function allows glview to hide all the
              rendering context/surface details and have the user just
              call GL calls that they desire for initialization GL calls.
            ]]
      destroyed; [[Event dispatched when GLView object is deleted.

              The registered destroyed function gets called when GLView object
              is deleted. Callback function allows glview to hide all the
              rendering context/surface  details and have the user just
              call GL calls that they desire  when delete happens.
            ]]
      resized; [[Event dispatched when resize happens.

              The resized event callback functions gets called
              during the render loop. The callback function allows
              glview to hide all the rendering context/surface
              details and have the user just call GL alls that
              they desire when resize happens.
            ]]
      render; [[Event dispatched when GLView is rendered.

              The callback function gets called in the main loop but whether
              it runs depends on the rendering policy and whether
              @.draw_request gets called.
            ]]
   }
   constructors {
      .version_constructor;
   }
}