FastUIDraw
painter_surface_gl.hpp
Go to the documentation of this file.
1 /*!
2  * \file painter_surface_gl.hpp
3  * \brief file painter_surface_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_SURFACE_GL_HPP
20 #define FASTUIDRAW_PAINTER_SURFACE_GL_HPP
21 
24 
25 namespace fastuidraw
26 {
27  namespace gl
28  {
29  ///@cond
30  class PainterEngineGL;
31  ///@endcond
32 
33 /*!\addtogroup GLBackend
34  * @{
35  */
36 
37  /*!
38  * A PainterSurfaceGL is the implementatin of \ref PainterSurface
39  * for the GL backend. A PainterSurfaceGL must only be used with at most
40  * one GL context (even GL contexts in the same share group cannot
41  * shader PainterSurfaceGL objects).
42  */
44  {
45  public:
46  /*!
47  * Ctor. Creates and uses a backing color texture.
48  * The viewport() is initialized to be exactly the
49  * entire backing store.
50  * \param dims the width and height of the PainterSurfaceGL
51  * \param backend the PainterEngineGL that produces
52  * \ref PainterBackend objects can use the
53  * created \ref PainterSurfaceGL
54  * \param render_type the render type of the surface (i.e.
55  * is it a color buffer or deferred
56  * coverage buffer)
57  */
58  explicit
60  const PainterEngineGL &backend,
62 
63  /*!
64  * Ctor. Use the passed GL texture to which to render
65  * content; the gl_texture must have as its texture
66  * target GL_TEXTURE_2D and must already have its
67  * backing store allocated (i.e. glTexImage or
68  * glTexStorage has been called on the texture). The
69  * texture object's ownership is NOT passed to the
70  * PainterSurfaceGL, the caller is still responible to delete
71  * the texture (with GL) and the texture must not be
72  * deleted (or have its backing store changed via
73  * glTexImage) until the PainterSurfaceGL is deleted. The
74  * viewport() is initialized to be exactly the entire
75  * backing store.
76  * \param dims width and height of the GL texture
77  * \param gl_texture GL name of texture
78  * \param backend the PainterEngineGL that produces
79  * \ref PainterBackend objects can use the
80  * created \ref PainterSurfaceGL
81  * \param render_type the render type of the surface (i.e.
82  * is it a color buffer or deferred
83  * coverage buffer)
84  */
85  explicit
86  PainterSurfaceGL(ivec2 dims, GLuint gl_texture,
87  const PainterEngineGL &backend,
89 
91 
92  /*!
93  * Returns the GL name of the texture backing
94  * the color buffer of the PainterSurfaceGL.
95  */
96  GLuint
97  texture(void) const;
98 
99  /*!
100  * Blit the PainterSurfaceGL color buffer to the FBO
101  * currently bound to GL_DRAW_FRAMEBUFFER.
102  * \param src source from this PainterSurfaceGL to which to bit
103  * \param dst destination in FBO to which to blit
104  * \param filter GL filter to apply to blit operation
105  */
106  void
107  blit_surface(const Viewport &src,
108  const Viewport &dst,
109  GLenum filter = GL_NEAREST) const;
110 
111  /*!
112  * Provided as a convenience, equivalent to
113  * \code
114  * PainterBackend::Viewport vw(0, 0, dimensions().x(), dimensions.y());
115  * blit_surface(vw, vw, filter);
116  * \endcode
117  * \param filter GL filter to apply to blit operation
118  */
119  void
120  blit_surface(GLenum filter = GL_NEAREST) const;
121 
122  /*!
123  * Used internally by the GL backend; do not touch
124  * the data behind the void pointer.
125  */
126  void*
127  opaque_data(void) const
128  {
129  return m_d;
130  }
131 
132  virtual
134  image(ImageAtlas &atlas) const override final;
135 
136  virtual
137  const Viewport&
138  viewport(void) const override final;
139 
140  virtual
141  void
142  viewport(const Viewport &vwp) override final;
143 
144  virtual
145  const vec4&
146  clear_color(void) const override final;
147 
148  virtual
149  void
150  clear_color(const vec4&) override final;
151 
152  virtual
153  ivec2
154  dimensions(void) const override final;
155 
156  virtual
157  enum render_type_t
158  render_type(void) const override final;
159 
160  private:
161  void *m_d;
162  };
163 /*! @} */
164  }
165 }
166 
167 #endif
virtual reference_counted_ptr< const Image > image(ImageAtlas &atlas) const override final
file painter_surface.hpp
render_type_t
Enumeration to specify the render target of a Surface.
all classes and functions of FastUIDraw are in the namespace fastuidraw.
Definition: colorstop.hpp:28
virtual ivec2 dimensions(void) const override final
PainterSurface represents an interface to specify a buffer to which a PainterBackend renders content...
PainterSurfaceGL(ivec2 dims, const PainterEngineGL &backend, enum render_type_t render_type=color_buffer_type)
A wrapper over a pointer to implement reference counting.
file gl_header.hpp
virtual enum render_type_t render_type(void) const override final
A PainterEngineGL implements PainterEngine using the GL (or GLES) API. The PainterShaderRegistrar obj...
virtual const vec4 & clear_color(void) const override final
An ImageAtlas is a common location to place images of an application.
void blit_surface(const Viewport &src, const Viewport &dst, GLenum filter=GL_NEAREST) const
virtual const Viewport & viewport(void) const override final