46 #include <QDeclarativeItem> 64 #ifndef QT_NO_DYNAMIC_CAST 101 for (
int i = 0; i < count; i++) {
116 qreal yscale = 1.0 * yflip;
118 qreal leftMargin = 0.0;
119 qreal rightMargin = 0.0;
120 qreal topMargin = 0.0;
121 qreal bottomMargin = 0.0;
127 leftMargin = -sourceRect.
left();
128 rightMargin = sourceRect.
right() - width;
129 topMargin = -sourceRect.
top();
130 bottomMargin = sourceRect.
bottom() - height;
133 if ((width + leftMargin + rightMargin) > 0 && (height + topMargin + bottomMargin) > 0) {
138 xscale = width / (width + leftMargin + rightMargin);
139 yscale = height / (height + topMargin + bottomMargin);
141 p.
translate(textureWidth / 2, textureHeight / 2);
142 p.
scale(xscale, yscale * yflip);
143 p.
translate(-textureWidth / 2, -textureHeight / 2);
144 p.
scale(textureWidth / width, textureHeight / height);
146 xscale = width / (width + leftMargin + rightMargin);
147 yscale = height / (height + topMargin + bottomMargin);
150 p.
scale(xscale, yscale * yflip);
181 qWarning() <<
"ShaderEffect::removeRenderTarget - did not find target.";
191 for (
int i = 0; i < count; i++) {
The QPainter class performs low-level painting on widgets and other paint devices.
QPaintDevice * device() const
Returns the paint device on which this painter is currently painting, or 0 if the painter is not acti...
QSize size() const
Returns the size of the texture attached to this framebuffer object.
static QTransform savedWorldTransform
qreal right() const
Returns the x-coordinate of the rectangle's right edge.
bool hideOriginal() const
void remove(int i)
Removes the element at index position i.
int count(const T &t) const
Returns the number of occurrences of value in the vector.
bool isValid() const
Returns true if the framebuffer object is valid.
qreal left() const
Returns the x-coordinate of the rectangle's left edge.
void drawSource(QPainter *painter)
Draws the source directly using the given painter.
virtual void draw(QPainter *painter)
This pure virtual function draws the effect and is called whenever the source needs to be drawn...
The QObject class is the base class of all Qt objects.
void addRenderTarget(ShaderEffectSource *target)
static const QGLContext * currentContext()
Returns the current context, i.e.
ShaderEffect(QObject *parent=0)
int width() const
Returns the width.
The QRectF class defines a rectangle in the plane using floating point precision. ...
The QGLContext class encapsulates an OpenGL rendering context.
virtual void sourceChanged(ChangeFlags flags)
This virtual function is called by QGraphicsEffect to notify the effect that the source has changed...
void append(const T &t)
Inserts value at the end of the vector.
Q_CORE_EXPORT void qWarning(const char *,...)
void prepareBufferedDraw(QPainter *painter)
void updateRenderTargets()
int indexOf(const T &t, int from=0) const
Returns the index position of the first occurrence of value in the vector, searching forward from ind...
The ShaderEffectSource object encapsulates the source content for the ShaderEffectItem.
QVector< ShaderEffectSource * > m_renderTargets
const QTransform & worldTransform() const
Returns the world transformation matrix.
void setCompositionMode(CompositionMode mode)
Sets the composition mode to the given mode.
The QPoint class defines a point in the plane using integer precision.
int height() const
Returns the height.
The QRect class defines a rectangle in the plane using integer precision.
void setWorldTransform(const QTransform &matrix, bool combine=false)
Sets the world transformation matrix.
bool contains(const T &t) const
Returns true if the vector contains an occurrence of value; otherwise returns false.
void removeRenderTarget(ShaderEffectSource *target)
qreal top() const
Returns the y-coordinate of the rectangle's top edge.
void scale(qreal sx, qreal sy)
Scales the coordinate system by ({sx}, {sy}).
The QSize class defines the size of a two-dimensional object using integer point precision.
qreal bottom() const
Returns the y-coordinate of the rectangle's bottom edge.
bool isEmpty() const
Returns true if either of the width and height is less than or equal to 0; otherwise returns false...
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
The QGraphicsEffect class is the base class for all graphics effects.
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.