You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

125 lines
3.6 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2013 CERN
  5. * @author Maciej Suminski <maciej.suminski@cern.ch>
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. /**
  25. * @file compositor.h
  26. * @brief Class that handles multitarget rendering (ie. to different textures/surfaces) and
  27. * later compositing into a single image.
  28. */
  29. #ifndef COMPOSITOR_H_
  30. #define COMPOSITOR_H_
  31. namespace KIGFX
  32. {
  33. class COLOR4D;
  34. class COMPOSITOR
  35. {
  36. public:
  37. COMPOSITOR()
  38. : m_width( 0 ), m_height( 0 )
  39. {
  40. }
  41. virtual ~COMPOSITOR()
  42. {
  43. }
  44. /**
  45. * Function Reset()
  46. * performs primary initialiation, necessary to use the object.
  47. */
  48. virtual void Initialize() = 0;
  49. /**
  50. * Function Resize()
  51. * clears the state of COMPOSITOR, so it has to be reinitialized again with the new dimensions.
  52. *
  53. * @param aWidth is the framebuffer width (in pixels).
  54. * @param aHeight is the framebuffer height (in pixels).
  55. */
  56. virtual void Resize( unsigned int aWidth, unsigned int aHeight ) = 0;
  57. /**
  58. * Function CreateBuffer()
  59. * prepares a new buffer that may be used as a rendering target.
  60. *
  61. * @return is the handle of the buffer. In case of failure 0 (zero) is returned as the handle.
  62. */
  63. virtual unsigned int CreateBuffer() = 0;
  64. /**
  65. * Function GetBuffer()
  66. * returns currently used buffer handle.
  67. *
  68. * @return Currently used buffer handle.
  69. */
  70. virtual unsigned int GetBuffer() const = 0;
  71. /**
  72. * Function SetBuffer()
  73. * sets the selected buffer as the rendering target. All the following drawing functions are
  74. * going to be rendered in the selected buffer.
  75. *
  76. * @param aBufferHandle is the handle of the buffer or 0 in case of rendering directly to the
  77. * display.
  78. */
  79. virtual void SetBuffer( unsigned int aBufferHandle ) = 0;
  80. /**
  81. * Function ClearBuffer()
  82. * clears the selected buffer (set by the SetBuffer() function).
  83. */
  84. virtual void ClearBuffer( const COLOR4D& aColor ) = 0;
  85. /**
  86. * Function Begin()
  87. * Call this at the beginning of each frame
  88. */
  89. virtual void Begin() = 0;
  90. /**
  91. * Function DrawBuffer()
  92. * draws the selected buffer to the output buffer.
  93. *
  94. * @param aBufferHandle is the handle of the buffer to be drawn.
  95. */
  96. virtual void DrawBuffer( unsigned int aBufferHandle ) = 0;
  97. /**
  98. * Function Present()
  99. * Call this to present the output buffer to the screen.
  100. */
  101. virtual void Present() = 0;
  102. protected:
  103. unsigned int m_width; ///< Width of the buffer (in pixels)
  104. unsigned int m_height; ///< Height of the buffer (in pixels)
  105. };
  106. } // namespace KIGFX
  107. #endif /* COMPOSITOR_H_ */