FastUIDraw
painter_engine_gl.hpp
Go to the documentation of this file.
1 /*!
2  * \file painter_engine_gl.hpp
3  * \brief file painter_engine_gl.hpp
4  *
5  * Copyright 2019 by Intel.
6  *
7  * Contact: kevin.rogovin@gmail.com
8  *
9  * This Source Code Form is subject to the
10  * terms of the Mozilla Public License, v. 2.0.
11  * If a copy of the MPL was not distributed with
12  * this file, You can obtain one at
13  * http://mozilla.org/MPL/2.0/.
14  *
15  * \author Kevin Rogovin <kevin.rogovin@gmail.com>
16  *
17  */
18 
19 #ifndef FASTUIDRAW_PAINTER_ENGINE_GL_HPP
20 #define FASTUIDRAW_PAINTER_ENGINE_GL_HPP
21 
27 
28 namespace fastuidraw
29 {
30  namespace gl
31  {
32 /*!\addtogroup GLBackend
33  * @{
34  */
35  /*!
36  * \brief
37  * A PainterEngineGL implements \ref PainterEngine
38  * using the GL (or GLES) API. The \ref PainterShaderRegistrar
39  * object returned by \ref painter_shader_registrar()
40  * derives from \ref glsl::PainterShaderRegistrarGLSL.
41  * In addition, when adding custom shaders, the shader
42  * types need to be derived from the shader types of the
43  * \ref GLSL module, i.e.
44  * - Item shaders must be realized as \ref glsl::PainterItemShaderGLSL
45  * objects or objects derived from \ref glsl::PainterItemShaderGLSL
46  * - Item coverage shaders must be realized as \ref
47  * glsl::PainterItemCoverageShaderGLSL objects or objects derived from
48  * \ref glsl::PainterItemCoverageShaderGLSL
49  * - Blend shaders must be realized as \ref glsl::PainterBlendShaderGLSL
50  * objects or objects derived from \ref glsl::PainterBlendShaderGLSL
51  * - Custom brush shaders must be realized as \ref
52  * glsl::PainterBrushShaderGLSL objects or objects derived from
53  * \ref glsl::PainterBrushShaderGLSL
54  */
57  public PainterEngine
58  {
59  public:
60  /*!
61  * \brief
62  * Enumeration to specify which \ref Program
63  * to fetch from the methods program().
64  */
66  {
67  /*!
68  * Get the GLSL program that handles all item shaders
69  */
71 
72  /*!
73  * Get the GLSL program that handles those item shaders
74  * which do not have discard
75  */
77 
78  /*!
79  * Get the GLSL program that handles those item shaders
80  * which do have discard
81  */
83 
84  /*!
85  */
86  number_program_types
87  };
88 
89  /*!
90  * !\brief
91  * Specifies how to stream buffers into GL
92  */
94  {
95  /*!
96  * Reuse GL buffer objects and stream the data
97  * via glMapBufferRange
98  */
100 
101  /*!
102  * Reuse the same GL buffer NAMES, but use
103  * glBufferData() to orphan the GL buffer
104  * objects to replace the data.
105  */
107 
108  /*!
109  * Reuse the GL buffer objects and stream the
110  * data via glBufferSubData
111  */
113  };
114 
115  /*!
116  * \brief
117  * Class to hold the construction parameters for creating
118  * the GL-backend \ref ImageAtlas for a \ref PainterEngineGL.
119  */
121  {
122  public:
123  /*!
124  * Ctor.
125  */
126  ImageAtlasParams(void);
127 
128  /*!
129  * Copy ctor.
130  * \param obj value from which to copy
131  */
133 
134  ~ImageAtlasParams();
135 
136  /*!
137  * Assignment operator.
138  * \param obj value from which to copy
139  */
141  operator=(const ImageAtlasParams &obj);
142 
143  /*!
144  * Swap operation
145  * \param obj object with which to swap
146  */
147  void
148  swap(ImageAtlasParams &obj);
149 
150  /*!
151  * If false, indicates that sourcing from an \ref Image with
152  * \ref Image::type() having value \ref Image::on_atlas is
153  * not supported (i.e. there is no image-atlasing). Default
154  * value is true.
155  */
156  bool
157  support_image_on_atlas(void) const;
158 
159  /*!
160  * Set the value for support_image_on_atlas(void) const
161  */
164 
165  /*!
166  * The log2 of the width and height of the color tile
167  * size, initial value is 5. Value is ignored if \ref
168  * support_image_on_atlas(void) const is false.
169  */
170  unsigned int
171  log2_color_tile_size(void) const;
172 
173  /*!
174  * Set the value for log2_color_tile_size(void) const
175  */
177  log2_color_tile_size(unsigned int v);
178 
179  /*!
180  * The log2 of the number of color tiles across and
181  * down per layer, initial value is 8. Effective
182  * value is clamped to 8. Value is ignored if \ref
183  * support_image_on_atlas(void) const is false.
184  */
185  unsigned int
187 
188  /*!
189  * Set the value for log2_num_color_tiles_per_row_per_col(void) const
190  */
192  log2_num_color_tiles_per_row_per_col(unsigned int v);
193 
194  /*!
195  * Sets log2_color_tile_size() and log2_num_color_tiles_per_row_per_col()
196  * to a size that is optimal for the GL implementation given a value
197  * for log2_color_tile_size().
198  */
200  optimal_color_sizes(int log2_color_tile_size);
201 
202  /*!
203  * The initial number of color layers, initial value is 1.
204  * Value is ignored if \ref support_image_on_atlas(void) const
205  * is false.
206  */
207  unsigned int
208  num_color_layers(void) const;
209 
210  /*!
211  * Set the value for num_color_layers(void) const
212  */
214  num_color_layers(unsigned int v);
215 
216  /*!
217  * The log2 of the width and height of the index tile
218  * size, initial value is 2. Value is ignored if \ref
219  * support_image_on_atlas(void) const is false.
220  */
221  unsigned int
222  log2_index_tile_size(void) const;
223 
224  /*!
225  * Set the value for log2_index_tile_size(void) const
226  */
228  log2_index_tile_size(unsigned int v);
229 
230  /*!
231  * The log2 of the number of index tiles across and
232  * down per layer, initial value is 6. Value is ignored
233  * if \ref support_image_on_atlas(void) const is false.
234  */
235  unsigned int
237 
238  /*!
239  * Set the value for log2_num_index_tiles_per_row_per_col(void) const
240  */
242  log2_num_index_tiles_per_row_per_col(unsigned int v);
243 
244  /*!
245  * The initial number of index layers, initial value is 4.
246  * Value is ignored f \ref support_image_on_atlas(void) const
247  * is false.
248  */
249  unsigned int
250  num_index_layers(void) const;
251 
252  /*!
253  * Set the value for num_index_layers(void) const
254  */
256  num_index_layers(unsigned int v);
257 
258  private:
259  void *m_d;
260  };
261 
262  /*!
263  * \brief
264  * Class to hold the construction parameters for creating
265  * a GL-backend \ref ColorStopAtlas for a \ref PainterEngineGL.
266  */
268  {
269  public:
270  /*!
271  * Ctor.
272  */
273  ColorStopAtlasParams(void);
274 
275  /*!
276  * Copy ctor.
277  * \param obj value from which to copy
278  */
280 
282 
283  /*!
284  * Assignment operator.
285  * \param rhs value from which to copy
286  */
288  operator=(const ColorStopAtlasParams &rhs);
289 
290  /*!
291  * Swap operation
292  * \param obj object with which to swap
293  */
294  void
296 
297  /*!
298  * width of underlying 1D-texture array, initial
299  * value is 1024
300  */
301  int
302  width(void) const;
303 
304  /*!
305  * Set the value for width(void) const
306  */
308  width(int v);
309 
310  /*!
311  * number of layers of underling 1D texture, initial
312  * value is 32
313  */
314  int
315  num_layers(void) const;
316 
317  /*!
318  * Set the value for num_layers(void) const
319  */
321  num_layers(int v);
322 
323  /*!
324  * Query the current GL context and set the value for
325  * width() const to GL_MAX_TEXTURE_SIZE.
326  */
328  optimal_width(void);
329 
330  private:
331  void *m_d;
332  };
333 
334  /*!
335  * \brief
336  * Class to hold the construction parameters for creating
337  * a GL-backend \ref GlyphAtlas for a \ref PainterEngineGL.
338  */
340  {
341  public:
342  /*!
343  * Ctor.
344  */
345  GlyphAtlasParams(void);
346 
347  /*!
348  * Copy ctor.
349  * \param obj value from which to copy
350  */
352 
353  ~GlyphAtlasParams();
354 
355  /*!
356  * Assignment operator.
357  * \param obj value from which to copy
358  */
360  operator=(const GlyphAtlasParams &obj);
361 
362  /*!
363  * Swap operation
364  * \param obj object with which to swap
365  */
366  void
367  swap(GlyphAtlasParams &obj);
368 
369  /*!
370  * Number floats that can be held in the data
371  * backing store, initial value is 1024 * 1024
372  */
373  unsigned int
374  number_floats(void) const;
375 
376  /*!
377  * Set the value for number_floats(void) const
378  */
380  number_floats(unsigned int v);
381 
382  /*!
383  * Returns what kind of GL object is used to back
384  * the glyph data. Default value is
385  * \ref glsl::PainterShaderRegistrarGLSL::glyph_data_tbo.
386  */
388  glyph_data_backing_store_type(void) const;
389 
390  /*!
391  * Set glyph_data_backing_store() to \ref
392  * glsl::PainterShaderRegistrarGLSL::glyph_data_tbo,
393  * i.e. for the glyph data to be stored
394  * on a GL texture buffer object.
395  */
397  use_texture_buffer_store(void);
398 
399  /*!
400  * Set glyph_data_backing_store() to \ref
401  * glsl::PainterShaderRegistrarGLSL::glyph_data_ssbo,
402  * i.e. for the glyph data to be stored
403  * on a GL texture buffer object.
404  */
406  use_storage_buffer_store(void);
407 
408  /*!
409  * Set glyph_data_backing_store() to \ref
410  * glsl::PainterShaderRegistrarGLSL::glyph_data_texture_array,
411  * i.e. to use a 2D texture array to store the
412  * glyph data. The depth of the
413  * array is set implicitely by the size given by
414  * GlyphAtlasBackingStoreBase::size().
415  * NOTE: if either parameter is made negative, the
416  * call is ignored.
417  * \param log2_width Log2 of the width of the 2D texture array
418  * \param log2_height Log2 of the height of the 2D texture array
419  */
421  use_texture_2d_array_store(int log2_width, int log2_height);
422 
423  /*!
424  * Set glyph_data_backing_store() to \ref
425  * glsl::PainterShaderRegistrarGLSL::glyph_data_texture_array,
426  * i.e. to use a 2D texture array to store the
427  * glyph data. The depth of the
428  * array is set implicitely by the size given by
429  * GlyphAtlasBackingStoreBase::size(). The width and height
430  * of the texture will be selected from examining the context
431  * properties.
432  */
434  use_texture_2d_array_store(void);
435 
436  /*!
437  * If glyph_data_backing_store() returns \ref
438  * glsl::PainterShaderRegistrarGLSL::glyph_data_texture_array,
439  * returns the values
440  * set in use_texture_2d_array_store(), otherwise
441  * returns a value where both components are -1.
442  */
443  ivec2
444  texture_2d_array_store_log2_dims(void) const;
445 
446  /*!
447  * Query the GL context to decide what is the optimal settings
448  * to back the GlyphAtlasBackingStoreBase returned by
449  * GlyphAtlas::store(). A GL context must be current
450  * so that GL capabilities may be queried.
451  */
453  use_optimal_store_backing(void);
454 
455  private:
456  void *m_d;
457  };
458 
459  /*!
460  * \brief
461  * A ConfigurationGL gives parameters how to contruct
462  * a PainterEngineGL.
463  */
465  {
466  public:
467  /*!
468  * Ctor.
469  */
470  ConfigurationGL(void);
471 
472  /*!
473  * Copy ctor.
474  * \param obj value from which to copy
475  */
476  ConfigurationGL(const ConfigurationGL &obj);
477 
478  ~ConfigurationGL();
479 
480  /*!
481  * Assignment operator
482  * \param rhs value from which to copy
483  */
485  operator=(const ConfigurationGL &rhs);
486 
487  /*!
488  * Swap operation
489  * \param obj object with which to swap
490  */
491  void
492  swap(ConfigurationGL &obj);
493 
494  /*!
495  * Return the parameters for creating the value returned
496  * by image_atlas();
497  */
498  const ImageAtlasParams&
499  image_atlas_params(void) const;
500 
501  /*!
502  * Set the value for image_atlas_params(void) const
503  */
505  image_atlas_params(const ImageAtlasParams&);
506 
507  /*!
508  * Return the parameters for creating the value returned
509  * by glyph_atlas();
510  */
511  const GlyphAtlasParams&
512  glyph_atlas_params(void) const;
513 
514  /*!
515  * Set the value for glyph_atlas_params(void) const
516  */
518  glyph_atlas_params(const GlyphAtlasParams&);
519 
520  /*!
521  * Return the parameters for creating the value returned
522  * by _atlas();
523  */
524  const ColorStopAtlasParams&
525  colorstop_atlas_params(void) const;
526 
527  /*!
528  * Set the value for _atlas_params(void) const
529  */
531  colorstop_atlas_params(const ColorStopAtlasParams&);
532 
533  /*!
534  * The ImageAtlasGL to be used by the painter
535  */
537  image_atlas(void) const;
538 
539  /*!
540  * The ColorStopAtlasGL to be used by the painter
541  */
543  colorstop_atlas(void) const;
544 
545  /*!
546  * The GlyphAtlasGL to be used by the painter
547  */
549  glyph_atlas(void) const;
550 
551  /*!
552  * Specifies the maximum number of attributes
553  * a PainterDraw returned by
554  * map_draw() may store, i.e. the size
555  * of PainterDraw::m_attributes.
556  * Initial value is 512 * 512.
557  */
558  unsigned int
559  attributes_per_buffer(void) const;
560 
561  /*!
562  * Set the value for attributes_per_buffer(void) const
563  */
565  attributes_per_buffer(unsigned int v);
566 
567  /*!
568  * Specifies the maximum number of indices
569  * a PainterDraw returned by
570  * map_draw() may store, i.e. the size
571  * of PainterDraw::m_indices.
572  * Initial value is 1.5 times the initial value
573  * for attributes_per_buffer(void) const.
574  */
575  unsigned int
576  indices_per_buffer(void) const;
577 
578  /*!
579  * Set the value for indices_per_buffer(void) const
580  */
582  indices_per_buffer(unsigned int v);
583 
584  /*!
585  * Specifies the maximum number of blocks of
586  * data a PainterDraw returned by
587  * map_draw() may store. The size of
588  * PainterDraw::m_store is given by
589  * data_blocks_per_store_buffer() * 4.
590  * Initial value is 1024 * 64.
591  */
592  unsigned int
593  data_blocks_per_store_buffer(void) const;
594 
595  /*!
596  * Set the value for data_blocks_per_store_buffer(void) const
597  */
599  data_blocks_per_store_buffer(unsigned int v);
600 
601  /*!
602  * Returns how the data store is realized. The GL implementation
603  * may impose size limits that will force that the size of the
604  * data store might be smaller than that specified by
605  * data_blocks_per_store_buffer(). The initial value
606  * is \ref data_store_tbo.
607  */
609  data_store_backing(void) const;
610 
611  /*!
612  * Set the value for data_store_backing(void) const
613  */
615  data_store_backing(enum data_store_backing_t v);
616 
617  /*!
618  * Specifies how the uber-shader will perform clipping.
619  */
620  enum clipping_type_t
621  clipping_type(void) const;
622 
623  /*!
624  * Set the value returned by clipping_type(void) const.
625  * Default value is \ref clipping_via_gl_clip_distance.
626  */
628  clipping_type(enum clipping_type_t);
629 
630  /*!
631  * If true, use the GLSL built-in unpackHalf2x16(), otherwise
632  * use an implementation based off of bit-twiddling.
633  */
634  bool
635  use_glsl_unpack_fp16(void) const;
636 
637  /*!
638  * Set the value returned by use_glsl_unpack_fp16(void) const.
639  * Default value is true.
640  */
642  use_glsl_unpack_fp16(bool);
643 
644  /*!
645  * Returns the number of external textures (realized as
646  * sampler2D uniforms) the uber-shader is to have.
647  */
648  unsigned int
649  number_context_textures(void) const;
650 
651  /*!
652  * Set the value returned by number_context_textures(void) const.
653  * Default value is 8.
654  */
656  number_context_textures(unsigned int);
657 
658  /*!
659  * If true, use switch() statements in uber vertex shader,
660  * if false use a chain of if-else. Default value is false.
661  */
662  bool
663  vert_shader_use_switch(void) const;
664 
665  /*!
666  * Set the value for vert_shader_use_switch(void) const
667  */
669  vert_shader_use_switch(bool v);
670 
671  /*!
672  * If true, use switch() statements in uber frag shader,
673  * if false use a chain of if-else. Default value is false.
674  */
675  bool
676  frag_shader_use_switch(void) const;
677 
678  /*!
679  * Set the value for frag_shader_use_switch(void) const
680  */
682  frag_shader_use_switch(bool v);
683 
684  /*!
685  * If true, use switch() statements in uber blend shader,
686  * if false use a chain of if-else. Default value is false.
687  */
688  bool
689  blend_shader_use_switch(void) const;
690 
691  /*!
692  * Set the value for blend_shader_use_switch(void) const
693  */
695  blend_shader_use_switch(bool v);
696 
697  /*!
698  * A PainterBackend for the GL/GLES backend has a set of pools
699  * for the buffer objects to which to data to send to GL. Whenever
700  * on_end() is called, the next pool is used (wrapping around to
701  * the first pool when the last pool is finished). Ideally, one
702  * should set this value to N * L where N is the number of times
703  * Painter::begin() - Painter::end() pairs are within a frame and
704  * L is the latency in frames from ending a frame to the GPU finishes
705  * rendering the results of the frame. Initial value is 3.
706  */
707  unsigned int
708  number_pools(void) const;
709 
710  /*!
711  * Set the value for number_pools(void) const
712  */
714  number_pools(unsigned int v);
715 
716  /*!
717  * If true, place different item shaders in seperate
718  * entries of a glMultiDrawElements call.
719  * The motivation is that by placing in a seperate element
720  * of a glMultiDrawElements call, each element is a seperate
721  * HW draw call and by being seperate, the shader invocation
722  * does not divergently branch. Default value is false.
723  */
724  bool
725  break_on_shader_change(void) const;
726 
727  /*!
728  * Set the value for break_on_shader_change(void) const
729  */
731  break_on_shader_change(bool v);
732 
733  /*!
734  * If false, each differen item shader (including sub-shaders) is
735  * realized as a separate GLSL program. This means that a GLSL
736  * shader change is invoked when item shader changes, potentially
737  * massively harming performance. Default value is true.
738  */
739  bool
740  use_uber_item_shader(void) const;
741 
742  /*!
743  * Set the value for use_uber_item_shader(void) const
744  */
746  use_uber_item_shader(bool);
747 
748  /*!
749  * If true, the vertex shader inputs should be qualified
750  * with a layout(location=) specifier. Default value is
751  * true.
752  */
753  bool
754  assign_layout_to_vertex_shader_inputs(void) const;
755 
756  /*!
757  * Set the value for assign_layout_to_vertex_shader_inputs(void) const
758  */
760  assign_layout_to_vertex_shader_inputs(bool v);
761 
762  /*!
763  * If true, the varyings between vertex and fragment
764  * shading should be qualified with a layout(location=)
765  * specifier. Default value is false.
766  */
767  bool
768  assign_layout_to_varyings(void) const;
769 
770  /*!
771  * Set the value for assign_layout_to_varyings(void) const
772  */
774  assign_layout_to_varyings(bool v);
775 
776  /*!
777  * If true, the textures and buffers used in the
778  * uber-shader should be qualified with a layout(binding=)
779  * specifier. Default value is true.
780  */
781  bool
782  assign_binding_points(void) const;
783 
784  /*!
785  * Set the value for assign_binding_points(void) const
786  */
788  assign_binding_points(bool v);
789 
790  /*!
791  * If true, item and blend shaders are broken into
792  * two classes: those that use discard and those that
793  * do not. Each class is then realized as a seperate
794  * GLSL program.
795  */
796  bool
797  separate_program_for_discard(void) const;
798 
799  /*!
800  * Set the value for separate_program_for_discard(void) const
801  */
803  separate_program_for_discard(bool v);
804 
805  /*!
806  * Returns the preferred way to implement blend shaders, i.e.
807  * if a shader can be implemented with this blending type
808  * it will be.
809  */
811  preferred_blend_type(void) const;
812 
813  /*!
814  * Specify the return value to preferred_blend_type() const.
815  * Default value is \ref PainterBlendShader::dual_src
816  * \param tp blend shader type
817  */
819  preferred_blend_type(enum PainterBlendShader::shader_type tp);
820 
821  /*!
822  * If true, will support blend shaders with \ref
823  * PainterBlendShader::type() with value \ref
824  * PainterBlendShader::dual_src.
825  */
826  bool
827  support_dual_src_blend_shaders(void) const;
828 
829  /*!
830  * Specify the return value to support_dual_src_blend_shaders() const.
831  * Default value is true
832  */
834  support_dual_src_blend_shaders(bool v);
835 
836  /*!
837  * Returns how the painter will perform blending. If the
838  * value is not \ref fbf_blending_not_supported, then will
839  * support blend shaders with \ref PainterBlendShader::type()
840  * with value \ref PainterBlendShader::framebuffer_fetch.
841  */
843  fbf_blending_type(void) const;
844 
845  /*!
846  * Specify the return value to fbf_blending_type() const.
847  * Default value is \ref fbf_blending_not_supported
848  * \param tp blend shader type
849  */
851  fbf_blending_type(enum fbf_blending_type_t tp);
852 
853  /*!
854  * If true, \ref PainterSurfaceGL objects whose \ref
855  * PainterSurface::image() routine will return a \ref
856  * TextureImage whose \ref Image::type()
857  * is \ref Image::bindless_texture2d if the GL/GLES
858  * implementation support bindless texturing; otherwise
859  * PainterSurfaceSurface::image() will always return
860  * \ref TextureImage objects of \ref
861  * Image::type() \ref Image::context_texture2d. A
862  * number of buggy hardware drivers do not correctly
863  * sample from bindless textures if the texture was
864  * renderered to.
865  */
866  bool
867  allow_bindless_texture_from_surface(void) const;
868 
869  /*!
870  * Specify the return value to \ref
871  * allow_bindless_texture_from_surface() const.
872  * Default value is true.
873  */
875  allow_bindless_texture_from_surface(bool);
876 
877  /*!
878  * Specifies how attribute, index and data-store
879  * is streamed to the GL buffer objects used in
880  * drawing. Default value is \ref buffer_streaming_use_mapping
881  */
883  buffer_streaming_type(void) const;
884 
885  /*!
886  * Set the value returned by \ref buffer_streaming_type(void) const
887  */
889  buffer_streaming_type(enum buffer_streaming_type_t);
890 
891  /*!
892  * If true, for each PainterBackend made from the PainterEngineGL,
893  * the same GL context will access it. Default value is true.
894  */
895  bool
896  assume_single_gl_context(void) const;
897 
898  /*!
899  * Set the value returned by \ref assume_single_gl_context(void) const
900  */
902  assume_single_gl_context(bool);
903 
904  /*!
905  * If a non-empty string, gives the GLSL version to be used
906  * by the uber-shaders. This value is (string) maxed with
907  * the computed GLSL version that is needed from the values
908  * of ConfigurationGL. Return value is valid until the next
909  * call to glsl_version_override(). Default value is an empty
910  * string.
911  */
912  c_string
913  glsl_version_override(void) const;
914 
915  /*!
916  * Set the value returned by glsl_version_override(void) const.
917  * NOTE: the string is -copied-, thus it is legal for the passed
918  * string to be deallocated after the call.
919  */
921  glsl_version_override(c_string);
922 
923  /*!
924  * Set the values for optimal performance or rendering quality
925  * by quering the GL context.
926  * \param optimal_rendering_quality if true, select parameters
927  * that give optimal rendering
928  * quality (at potential sacrifice
929  * of performance). If false,
930  * choose for optimal performance
931  * even at the cost of rendering
932  * quality.
933  * \param ctx Optional argument to pass to avoid re-querying
934  * the current GL context for extension and version
935  */
937  configure_from_context(bool optimal_rendering_quality = false,
938  const ContextProperties &ctx = ContextProperties());
939 
940  /*!
941  * Adjust values for current GL context.
942  * \param ctx Optional argument to pass to avoid re-querying
943  * the current GL context for extension and version
944  */
946  adjust_for_context(const ContextProperties &ctx = ContextProperties());
947 
948  private:
949  void *m_d;
950  };
951 
952  ~PainterEngineGL();
953 
954  /*!
955  * Ctor. Create a PainterEngineGL configured via a ConfigurationGL
956  * value. The configuration of the created PainterEngineGL will be
957  * adjusted according to the functionaliy of the currentl current GL
958  * context. In addition, the current GL context or a GL context of
959  * its share group must be current when the PainterEngineGL is used.
960  *
961  * \param config_gl ConfigurationGL providing configuration parameters
962  * \param ctx Optional argument to pass to avoid re-querying
963  * the current GL context for extension and version
964  */
965  static
967  create(ConfigurationGL config_gl,
968  const ContextProperties &ctx = ContextProperties());
969 
970  /*!
971  * Ctor. Create a PainterEngineGL and the atlases to be used by it.
972  * The atlases and PainterEngineGL will be configured optimally as
973  * according to the current GL context. In addition, the current GL
974  * context or a GL context of its share group must be current when
975  * the PainterEngineGL is used.
976  * \param optimal_rendering_quality if true, select parameters
977  * that give optimal rendering
978  * quality (at potential sacrifice
979  * of performance). If false,
980  * choose for optimal performance
981  * even at the cost of rendering
982  * quality.
983  * \param ctx Optional argument to pass to avoid re-querying
984  * the current GL context for extension and version
985  */
986  static
988  create(bool optimal_rendering_quality,
989  const ContextProperties &ctx = ContextProperties());
990 
991  /*!
992  * Return the specified \ref Program used to draw by
993  * \ref PainterBackend objects generated by this \ref
994  * PainterEngineGL.
995  * \param discard_tp selects what item-shaders are included
996  * \param blend_type selects what blend type
997  */
999  program(enum program_type_t discard_tp,
1000  enum PainterBlendShader::shader_type blend_type);
1001 
1002  /*!
1003  * Returns the \ref Program used to draw to the deferred
1004  * coverage buffer.
1005  */
1008 
1009  /*!
1010  * Returns the number of UBO binding units used; the
1011  * units used are 0, 1, ..., num_ubo_units() - 1.
1012  */
1013  unsigned int
1014  num_ubo_units(void) const;
1015 
1016  /*!
1017  * Returns the number of SSBO binding units used; the
1018  * units used are 0, 1, ..., num_ssbo_units() - 1.
1019  */
1020  unsigned int
1021  num_ssbo_units(void) const;
1022 
1023  /*!
1024  * Returns the number of texture binding units used; the
1025  * units used are 0, 1, ..., num_texture_units() - 1.
1026  */
1027  unsigned int
1028  num_texture_units(void) const;
1029 
1030  /*!
1031  * Returns the number of image binding units used; the
1032  * units used are 0, 1, ..., num_image_units() - 1.
1033  */
1034  unsigned int
1035  num_image_units(void) const;
1036 
1037  /*!
1038  * Returns the ConfigurationGL adapted from that passed
1039  * by ctor (for the properties of the GL context) of
1040  * the PainterBackendGL.
1041  */
1042  const ConfigurationGL&
1043  configuration_gl(void) const;
1044 
1045  virtual
1047  create_backend(void) const override final;
1048 
1049  virtual
1051  create_surface(ivec2 dims,
1052  enum PainterSurface::render_type_t render_type) override final;
1053 
1054  private:
1055  PainterEngineGL(const ConfigurationGL &config_gl,
1056  const UberShaderParams &uber_params,
1057  const PainterShaderSet &shaders);
1058 
1059  void *m_d;
1060  };
1061 /*! @} */
1062  }
1063 }
1064 
1065 #endif
file texture_image_gl.hpp
A ConfigurationGL gives parameters how to contruct a PainterEngineGL.
A PainterEngine provides an interface to create Painter Backend derived objects.
reference_counted_ptr< Program > program_deferred_coverage_buffer(void)
render_type_t
Enumeration to specify the render target of a Surface.
GlyphAtlas & glyph_atlas(void) const
Class to hold the construction parameters for creating the GL-backend ImageAtlas for a PainterEngineG...
all classes and functions of FastUIDraw are in the namespace fastuidraw.
Definition: colorstop.hpp:28
glyph_data_backing_t
Enumeration to specify how to access the backing store of the glyph data stored in GlyphAtlas::store(...
A wrapper over a pointer to implement reference counting.
ImageAtlas & image_atlas(void) const
unsigned int num_ubo_units(void) const
ColorStopAtlas & colorstop_atlas(void) const
unsigned int num_ssbo_units(void) const
buffer_streaming_type_t
Specifies how to stream buffers into GL.
file painter_engine.hpp
virtual reference_counted_ptr< PainterBackend > create_backend(void) const override final
A PainterEngineGL implements PainterEngine using the GL (or GLES) API. The PainterShaderRegistrar obj...
unsigned int num_texture_units(void) const
unsigned int log2_num_index_tiles_per_row_per_col(void) const
An UberShaderParams specifies how to construct an uber-shader. Note that the usage of HW clip-planes ...
unsigned int log2_num_color_tiles_per_row_per_col(void) const
Class to hold the construction parameters for creating a GL-backend GlyphAtlas for a PainterEngineGL...
virtual reference_counted_ptr< PainterSurface > create_surface(ivec2 dims, enum PainterSurface::render_type_t render_type) override final
data_store_backing_t
Enumeration to specify how the data store filled by PainterDraw::m_store is realized.
file gl_program.hpp
A PainterShaderSet provides shaders for blending and drawing each of the item types glyphs...
program_type_t
Enumeration to specify which Program to fetch from the methods program().
reference_counted_ptr< Program > program(enum program_type_t discard_tp, enum PainterBlendShader::shader_type blend_type)
ImageAtlasParams & optimal_color_sizes(int log2_color_tile_size)
file painter_shader_registrar_glsl.hpp
const char * c_string
Conveniant typedef for C-style strings.
Definition: util.hpp:135
static reference_counted_ptr< PainterEngineGL > create(ConfigurationGL config_gl, const ContextProperties &ctx=ContextProperties())
const ConfigurationGL & configuration_gl(void) const
fbf_blending_type_t
Enumeration to specify how to perform framebuffer-fetch blending.
ImageAtlasParams & operator=(const ImageAtlasParams &obj)
unsigned int num_image_units(void) const
A ContextProperties provides an interface to query GL/GLES version and extensions.
shader_type
Enumeration to specify how blend shader operates.
file gl_context_properties.hpp
Class to hold the construction parameters for creating a GL-backend ColorStopAtlas for a PainterEngin...