Qt 4.8
Public Functions | Private Functions | Properties | List of all members
QGLTrapezoidMaskGenerator Class Referenceabstract
Inheritance diagram for QGLTrapezoidMaskGenerator:
QGLMaskGenerator QGLLineMaskGenerator QGLPathMaskGenerator QGLRectMaskGenerator

Public Functions

void drawMask (const QRect &rect)
 
 QGLTrapezoidMaskGenerator (const QPainterPath &path, const QTransform &matrix, QGLOffscreen &offscreen, GLuint maskFragmentProgram, qreal strokeWidth=-1.0)
 
QRect screenRect ()
 
- Public Functions inherited from QGLMaskGenerator
QTransform matrix () const
 
QPainterPath path () const
 
 QGLMaskGenerator (const QPainterPath &path, const QTransform &matrix, qreal stroke_width=-1)
 
qreal strokeWidth () const
 
virtual ~QGLMaskGenerator ()
 

Private Functions

virtual QRect computeScreenRect ()=0
 
virtual QVector< QGLTrapezoidgenerateTrapezoids ()=0
 

Properties

bool has_screen_rect
 
GLuint maskFragmentProgram
 
QGLOffscreenoffscreen
 
QRect screen_rect
 

Detailed Description

Definition at line 3032 of file qpaintengine_opengl.cpp.

Constructors and Destructors

◆ QGLTrapezoidMaskGenerator()

QGLTrapezoidMaskGenerator::QGLTrapezoidMaskGenerator ( const QPainterPath path,
const QTransform matrix,
QGLOffscreen offscreen,
GLuint  maskFragmentProgram,
qreal  strokeWidth = -1.0 
)

Definition at line 3110 of file qpaintengine_opengl.cpp.

3111  : QGLMaskGenerator(path, matrix, stroke_width)
3112  , has_screen_rect(false)
3113  , offscreen(&offs)
3114  , maskFragmentProgram(program)
3115 {
3116 }
QGLMaskGenerator(const QPainterPath &path, const QTransform &matrix, qreal stroke_width=-1)

Functions

◆ computeScreenRect()

virtual QRect QGLTrapezoidMaskGenerator::computeScreenRect ( )
privatepure virtual

◆ drawMask()

void QGLTrapezoidMaskGenerator::drawMask ( const QRect rect)
virtual

Implements QGLMaskGenerator.

Definition at line 3121 of file qpaintengine_opengl.cpp.

3122 {
3123 #ifdef QT_OPENGL_ES
3124  Q_UNUSED(rect);
3125 #else
3126  glMatrixMode(GL_MODELVIEW);
3127  glPushMatrix();
3128  glLoadIdentity();
3129 
3131  offscreen->bind();
3132 
3133  glDisable(GL_TEXTURE_GEN_S);
3134  glDisable(GL_TEXTURE_1D);
3135 
3136  GLfloat vertexArray[4 * 2];
3137  qt_add_rect_to_array(rect, vertexArray);
3138 
3139  bool needs_scissor = rect != screen_rect;
3140 
3141  if (needs_scissor) {
3142  glEnable(GL_SCISSOR_TEST);
3143  glScissor(rect.left(), offscreen->offscreenSize().height() - rect.bottom() - 1, rect.width(), rect.height());
3144  }
3145 
3147 
3148  // clear mask
3149  glBlendFunc(GL_ZERO, GL_ZERO); // clear
3150  glVertexPointer(2, GL_FLOAT, 0, vertexArray);
3151  glEnableClientState(GL_VERTEX_ARRAY);
3152  glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
3153  glDisableClientState(GL_VERTEX_ARRAY);
3154 
3155  glBlendFunc(GL_ONE, GL_ONE); // add mask
3156  glEnable(GL_FRAGMENT_PROGRAM_ARB);
3158 
3159  QPoint delta = rect.topLeft() - screen_rect.topLeft();
3160  glBegin(GL_QUADS);
3161  for (int i = 0; i < trapezoids.size(); ++i)
3162  drawTrapezoid(trapezoids[i].translated(delta), offscreen->offscreenSize().height(), ctx);
3163  glEnd();
3164 
3165  if (needs_scissor)
3166  glDisable(GL_SCISSOR_TEST);
3167 
3168  glDisable(GL_FRAGMENT_PROGRAM_ARB);
3169 
3170  glMatrixMode(GL_MODELVIEW);
3171  glPopMatrix();
3172 #endif
3173 }
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
static void drawTrapezoid(const QGLTrapezoid &trap, const qreal offscreenHeight, QGLContext *ctx)
#define GL_SCISSOR_TEST
The QGLContext class encapsulates an OpenGL rendering context.
Definition: qgl.h:310
#define GL_TRIANGLE_FAN
#define GL_FLOAT
#define GL_ZERO
#define ctx
Definition: qgl.cpp:6094
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
int height() const
Returns the height.
Definition: qsize.h:129
#define GL_FRAGMENT_PROGRAM_ARB
QSize offscreenSize() const
QGLContext * context() const
void qt_add_rect_to_array(const QRectF &r, GLfloat *array)
Definition: qgl.cpp:2972
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
virtual QVector< QGLTrapezoid > generateTrapezoids()=0
#define glBindProgramARB
#define GL_ONE
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ generateTrapezoids()

virtual QVector<QGLTrapezoid> QGLTrapezoidMaskGenerator::generateTrapezoids ( )
privatepure virtual

◆ screenRect()

QRect QGLTrapezoidMaskGenerator::screenRect ( )
virtual

Implements QGLMaskGenerator.

Definition at line 3175 of file qpaintengine_opengl.cpp.

3176 {
3177  if (!has_screen_rect) {
3179  has_screen_rect = true;
3180  }
3181 
3183 
3184  return screen_rect;
3185 }
QRect intersected(const QRect &other) const
Returns the intersection of this rectangle and the given rectangle.
Definition: qrect.h:481
QSize drawableSize() const
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
virtual QRect computeScreenRect()=0

Properties

◆ has_screen_rect

bool QGLTrapezoidMaskGenerator::has_screen_rect
private

Definition at line 3042 of file qpaintengine_opengl.cpp.

Referenced by screenRect().

◆ maskFragmentProgram

GLuint QGLTrapezoidMaskGenerator::maskFragmentProgram
private

Definition at line 3046 of file qpaintengine_opengl.cpp.

Referenced by drawMask().

◆ offscreen

QGLOffscreen* QGLTrapezoidMaskGenerator::offscreen
private

Definition at line 3044 of file qpaintengine_opengl.cpp.

◆ screen_rect

QRect QGLTrapezoidMaskGenerator::screen_rect
private

Definition at line 3041 of file qpaintengine_opengl.cpp.

Referenced by drawMask(), and screenRect().


The documentation for this class was generated from the following file: