QOpenGLPaintEngine Class Reference

#include <qpaintengine_opengl_p.h>

Inheritance diagram for QOpenGLPaintEngine:

Inheritance graph
[legend]
Collaboration diagram for QOpenGLPaintEngine:

Collaboration graph
[legend]
List of all members.

Detailed Description

Definition at line 42 of file qpaintengine_opengl_p.h.

Public Member Functions

 QOpenGLPaintEngine ()
 ~QOpenGLPaintEngine ()
bool begin (QPaintDevice *pdev)
bool end ()
void updateState (const QPaintEngineState &state)
void updatePen (const QPen &pen)
void updateBrush (const QBrush &brush, const QPointF &pt)
void updateFont (const QFont &font)
void updateMatrix (const QMatrix &matrix)
void updateClipRegion (const QRegion &region, Qt::ClipOperation op)
void updateRenderHints (QPainter::RenderHints hints)
void updateCompositionMode (QPainter::CompositionMode composition_mode)
void drawRects (const QRectF *r, int rectCount)
void drawLines (const QLineF *lines, int lineCount)
void drawPoints (const QPointF *p, int pointCount)
void drawPixmap (const QRectF &r, const QPixmap &pm, const QRectF &sr)
void drawPath (const QPainterPath &path)
void drawPolygon (const QPointF *points, int pointCount, PolygonDrawMode mode)
void drawTiledPixmap (const QRectF &r, const QPixmap &pixmap, const QPointF &s)
void drawImage (const QRectF &r, const QImage &image, const QRectF &sr, Qt::ImageConversionFlags conversionFlags)
void drawTextItem (const QPointF &p, const QTextItem &ti)
Qt::HANDLE handle () const
Type type () const

Private Member Functions

void drawPolyInternal (const QPolygonF &pa, bool close=true)
void drawTextureRect (int tx_width, int tx_height, const QRectF &r, const QRectF &sr, GLenum target)


Constructor & Destructor Documentation

QOpenGLPaintEngine::QOpenGLPaintEngine (  ) 

QOpenGLPaintEngine::~QOpenGLPaintEngine (  ) 


Member Function Documentation

bool QOpenGLPaintEngine::begin ( QPaintDevice pdev  )  [virtual]

Reimplement this function to initialise your paint engine when painting is to start on the paint device pdev. Return true if the initialization was successful; otherwise return false.

See also:
end() isActive()

Implements QPaintEngine.

bool QOpenGLPaintEngine::end (  )  [virtual]

Reimplement this function to finish painting on the current paint device. Return true if painting was finished successfully; otherwise return false.

See also:
begin() isActive()

Implements QPaintEngine.

void QOpenGLPaintEngine::updateState ( const QPaintEngineState state  )  [virtual]

Reimplement this function to update the state of a paint engine.

When implemented, this function is responsible for checking the paint engine's current state and update the properties that are changed. Use the QPaintEngineState::state() function to find out which properties that must be updated, then use the corresponding {GetFunction}{get function} to retrieve the current values for the given properties.

See also:
QPaintEngineState

Implements QPaintEngine.

void QOpenGLPaintEngine::updatePen ( const QPen pen  ) 

void QOpenGLPaintEngine::updateBrush ( const QBrush brush,
const QPointF pt 
)

void QOpenGLPaintEngine::updateFont ( const QFont font  ) 

void QOpenGLPaintEngine::updateMatrix ( const QMatrix matrix  ) 

void QOpenGLPaintEngine::updateClipRegion ( const QRegion region,
Qt::ClipOperation  op 
)

void QOpenGLPaintEngine::updateRenderHints ( QPainter::RenderHints  hints  ) 

void QOpenGLPaintEngine::updateCompositionMode ( QPainter::CompositionMode  composition_mode  ) 

void QOpenGLPaintEngine::drawRects ( const QRectF r,
int  rectCount 
) [virtual]

Draws the first rectCount rectangles in the buffer rects. The default implementation of this function calls drawPath() or drawPolygon() depending on the feature set of the paint engine.

Reimplemented from QPaintEngine.

void QOpenGLPaintEngine::drawLines ( const QLineF lines,
int  lineCount 
) [virtual]

The default implementation splits the list of lines in lines into lineCount separate calls to drawPath() or drawPolygon() depending on the feature set of the paint engine.

Reimplemented from QPaintEngine.

void QOpenGLPaintEngine::drawPoints ( const QPointF p,
int  pointCount 
) [virtual]

Draws the first pointCount points in the buffer points

Reimplemented from QPaintEngine.

void QOpenGLPaintEngine::drawPixmap ( const QRectF r,
const QPixmap pm,
const QRectF sr 
) [virtual]

Reimplement this function to draw the part of the pm specified by the sr rectangle in the given r.

Implements QPaintEngine.

void QOpenGLPaintEngine::drawPath ( const QPainterPath path  )  [virtual]

The default implementation ignores the path and does nothing.

Reimplemented from QPaintEngine.

void QOpenGLPaintEngine::drawPolygon ( const QPointF points,
int  pointCount,
PolygonDrawMode  mode 
) [virtual]

Reimplement this virtual function to draw the polygon defined by the pointCount first points in points, using mode mode.

The default implementation of this function will try to use drawPath if the engine supports the feature QPaintEngine::PainterPaths or try the float based drawPolygon() implementation if not.

Reimplemented from QPaintEngine.

void QOpenGLPaintEngine::drawTiledPixmap ( const QRectF r,
const QPixmap pixmap,
const QPointF s 
) [virtual]

Reimplement this function to draw the pixmap in the given rect, starting at the given p. The pixmap will be drawn repeatedly until the rect is filled.

Reimplemented from QPaintEngine.

void QOpenGLPaintEngine::drawImage ( const QRectF r,
const QImage image,
const QRectF sr,
Qt::ImageConversionFlags  conversionFlags 
) [virtual]

Reimplement this function to draw the part of the image specified by the sr rectangle in the given rectangle using the given conversion flags flags, to convert it to a pixmap.

Reimplemented from QPaintEngine.

void QOpenGLPaintEngine::drawTextItem ( const QPointF p,
const QTextItem ti 
) [virtual]

This function draws the text item textItem at position p. The default implementation of this function converts the text to a QPainterPath and paints the resulting path.

Reimplemented from QPaintEngine.

Definition at line 2732 of file qpaintengine_opengl.cpp.

References Qt::ConicalGradientPattern, QPaintEngine::drawTextItem(), QTextItemInt::flags, QTextItemInt::fontEngine, g, QFontEngine::getGlyphPositions(), QTextItemInt::glyphs, Qt::LinearGradientPattern, QTextItemInt::num_glyphs, p, positions, qRound(), QVarLengthArray< T, Prealloc >::size(), Qt::SolidPattern, QMatrix::translate(), and x.

02733 {
02734     Q_D(QOpenGLPaintEngine);
02735 
02736     // fall back to drawing a polygon if the scale factor is large, or
02737     // we use a gradient pen
02738     if ((d->matrix.det() > 2) || (d->pen_brush_style >= Qt::LinearGradientPattern
02739                                   && d->pen_brush_style <= Qt::ConicalGradientPattern)) {
02740         QPaintEngine::drawTextItem(p, textItem);
02741         return;
02742     }
02743 
02744     // add the glyphs used to the glyph texture cache
02745     const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem);
02746     QVarLengthArray<QFixedPoint> positions;
02747     QVarLengthArray<glyph_t> glyphs;
02748     QMatrix matrix;
02749     matrix.translate(qRound(p.x()), qRound(p.y()));
02750     ti.fontEngine->getGlyphPositions(ti.glyphs, ti.num_glyphs, matrix, ti.flags, glyphs, positions);
02751 
02752     // make sure the glyphs we want to draw are in the cache
02753     qt_glyph_cache()->cacheGlyphs(d->drawable.context(), ti, glyphs);
02754 
02755     d->setGradientOps(Qt::SolidPattern); // turns off gradient ops
02756 #ifdef Q_WS_QWS
02757     glColor4f(d->pen_color[0]/255.0, d->pen_color[1]/255.0, d->pen_color[2]/255.0, d->pen_color[3]/255.0);
02758 #else
02759     glColor4ubv(d->pen_color);
02760 #endif
02761     glEnable(GL_TEXTURE_2D);
02762 
02763     // do the actual drawing
02764     float vertexArray[4*2];
02765     float texCoordArray[4*2];
02766 
02767     glVertexPointer(2, GL_FLOAT, 0, vertexArray);
02768     glTexCoordPointer(2, GL_FLOAT, 0, texCoordArray);
02769 
02770     glEnableClientState(GL_VERTEX_ARRAY);
02771     glEnableClientState(GL_TEXTURE_COORD_ARRAY);
02772 
02773     for (int i=0; i< glyphs.size(); ++i) {
02774         QGLGlyphCoord *g = qt_glyph_cache()->lookup(ti.fontEngine, glyphs[i]);
02775 
02776         // we don't cache glyphs with no width/height
02777   if (!g)
02778       continue;
02779 
02780         qreal x1, x2, y1, y2;
02781         x1 = g->x;
02782         y1 = g->y;
02783         x2 = x1 + g->width;
02784         y2 = y1 + g->height;
02785 
02786         QPointF logical_pos((positions[i].x - g->x_offset).toReal(),
02787                             (positions[i].y + g->y_offset).toReal());
02788 
02789         qt_add_rect_to_array(QRectF(logical_pos, QSizeF(g->log_width, g->log_height)), vertexArray);
02790         qt_add_texcoords_to_array(x1, y1, x2, y2, texCoordArray);
02791 
02792         glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
02793     }
02794 
02795     glDisableClientState(GL_TEXTURE_COORD_ARRAY);
02796     glDisableClientState(GL_VERTEX_ARRAY);
02797 
02798     glDisable(GL_TEXTURE_2D);
02799 }

Here is the call graph for this function:

Qt::HANDLE QOpenGLPaintEngine::handle (  )  const

Type QOpenGLPaintEngine::type (  )  const [inline, virtual]

Reimplement this function to return the paint engine {Type}.

Implements QPaintEngine.

Definition at line 93 of file qpaintengine_opengl_p.h.

References QPaintEngine::OpenGL.

00093 { return QPaintEngine::OpenGL; }

void QOpenGLPaintEngine::drawPolyInternal ( const QPolygonF pa,
bool  close = true 
) [private]

void QOpenGLPaintEngine::drawTextureRect ( int  tx_width,
int  tx_height,
const QRectF r,
const QRectF sr,
GLenum  target 
) [private]


The documentation for this class was generated from the following files:
Generated on Thu Mar 15 18:32:55 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1