42 #include "private/qdeclarativepainteditem_p.h" 43 #include "private/qdeclarativepainteditem_p_p.h" 48 #include <QApplication> 49 #include <QGraphicsSceneMouseEvent> 51 #include <QPaintEngine> 110 qCeil(rect.
y()*
d->contentsScale),
113 for (
int i=0; i <
d->imagecache.count(); ) {
117 delete d->imagecache.takeAt(i);
138 d->imagecache.clear();
149 return d->contentsSize;
160 if (
d->contentsSize == size)
return;
162 d->contentsSize = size;
171 return d->contentsScale;
177 if (
d->contentsScale == scale)
return;
215 const QRectF &oldGeometry)
217 if (newGeometry.
width() != oldGeometry.
width() ||
236 if (
d->cachefrozen == frozen)
238 d->cachefrozen = frozen;
246 QSizeF sz =
d->contentsSize *
d->contentsScale;
252 return QRectF(0.0,0.0,w,h);
273 effectiveClip = xinv.
map(sysClip);
284 topaint = effectiveClip;
285 }
else if (!effectiveClip.
isEmpty()) {
286 topaint &= effectiveClip;
294 for (
int i=0; i<
d->imagecache.count(); ++i) {
298 if (!
d->cachefrozen) {
299 if (!
d->imagecache[i]->dirty.isNull() && topaint.
contains(
d->imagecache[i]->dirty)) {
310 qp.
scale(
d->contentsScale,
d->contentsScale);
317 if (
d->fillColor.isValid()){
318 if(
d->fillColor.alpha() < 255){
329 d->imagecache[i]->dirty =
QRect();
332 p->
drawPixmap(target.toRect(),
d->imagecache[i]->image);
334 d->imagecache[i]->age=0;
336 d->imagecache[i]->age++;
343 if (!
d->cachefrozen) {
346 cachesize += biggerrect.
width() * biggerrect.
height();
347 while (
d->imagecache.count() && cachesize >
d->max_imagecache_size) {
350 for (
int i=0; i<
d->imagecache.count(); ++i) {
351 int a =
d->imagecache[i]->age;
357 cachesize -=
d->imagecache[oldest]->area.width()*
d->imagecache[oldest]->area.height();
358 uncached +=
d->imagecache[oldest]->area;
359 delete d->imagecache.takeAt(oldest);
363 for (
int i = 0; i < rects.
count(); ++i) {
366 if (
d->fillColor.isValid())
367 img.
fill(
d->fillColor);
380 qp.
scale(
d->contentsScale,
d->contentsScale);
389 newitem->
image = img;
390 d->imagecache.append(newitem);
395 for (
int i = 0; i < rects.
count(); ++i)
431 return d->max_imagecache_size;
437 if (pixels < d->max_imagecache_size) {
439 for (
int i=0; i<
d->imagecache.count(); ++i) {
443 while (
d->imagecache.count() && cachesize > pixels) {
446 for (
int i=0; i<
d->imagecache.count(); ++i) {
447 int a =
d->imagecache[i]->age;
453 cachesize -=
d->imagecache[oldest]->area.width()*
d->imagecache[oldest]->area.height();
454 delete d->imagecache.takeAt(oldest);
457 d->max_imagecache_size = pixels;
477 if (
d->fillColor == c)
505 return d->smoothCache;
511 if (
d->smoothCache != on) {
The QVariant class acts like a union for the most common Qt data types.
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...
The QColor class provides colors based on RGB, HSV or CMYK values.
static int inpaint_clearcache
QT_DEPRECATED int numRects() const
Returns the number of rectangles that will be returned in rects().
QRect adjusted(int x1, int y1, int x2, int y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
#define QT_END_NAMESPACE
This macro expands to.
QDeclarativePaintedItem(QDeclarativeItem *parent=0)
Constructs a new QDeclarativePaintedItem with the given parent.
QDeclarativeParserStatus ** d
CompositionMode
Defines the modes supported for digital image compositing.
int count(const T &t) const
Returns the number of occurrences of value in the vector.
qreal contentsScale() const
qreal width() const
Returns the width.
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip region to the given rectangle using the given clip operation...
void setContentsSize(const QSize &)
Sets the size of the contents to the given size.
void contentsSizeChanged()
qreal height() const
Returns the height.
virtual void drawContents(QPainter *p, const QRect &)=0
This function is called when the cache needs to be refreshed.
QRectF boundingRect() const
int width() const
Returns the width of the rectangle.
long ASN1_INTEGER_get ASN1_INTEGER * a
GraphicsItemChange
This enum describes the state changes that are notified by QGraphicsItem::itemChange().
QRect boundingRect() const
Returns the bounding rectangle of this region.
Q_GUI_EXPORT bool qt_applefontsmoothing_enabled
int height() const
Returns the height of the rectangle.
void setCacheFrozen(bool)
void update(const QRectF &rect=QRectF())
Schedules a redraw of the area covered by rect in this item.
~QDeclarativePaintedItem()
Destroys the image item.
The QSizeF class defines the size of a two-dimensional object using floating point precision...
qreal scale() const
Returns the scale factor of the item.
The QDeclarativePaintedItem class is an abstract base class for QDeclarativeView items that want cach...
void setFillColor(const QColor &)
QRegion clipRegion() const
Returns the currently set clip region.
#define QT_BEGIN_NAMESPACE
This macro expands to.
The QRectF class defines a rectangle in the plane using floating point precision. ...
The QDeclarativeItem class provides the most basic of all visual items in QML.
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
qreal height() const
Returns the height of the rectangle.
QSize size() const
Returns the size of the rectangle.
void contentsScaleChanged()
CompositionMode compositionMode() const
Returns the current composition mode.
bool contains(const QPoint &p) const
Returns true if the region contains the point p; otherwise returns false.
const QTransform & deviceTransform() const
Returns the matrix that transforms from logical coordinates to device coordinates of the platform dep...
qreal width() const
Returns the width of the rectangle.
QPaintEngine * paintEngine() const
Returns the paint engine that the painter is currently operating on if the painter is active; otherwi...
The QRegion class specifies a clip region for a painter.
void dirtyCache(const QRect &)
Marks areas of the cache that intersect with the given rect as dirty and in need of being refreshed...
QSize contentsSize() const
virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
This function is called to handle this item's changes in geometry from oldGeometry to newGeometry...
QRect toRect() const
Returns a QRect based on the values of this rectangle.
const T & at(int i) const
Returns the item at index position i in the vector.
void fill(const QColor &fillColor=Qt::white)
Fills the pixmap with the given color.
void setRenderHints(RenderHints hints, bool on=true)
Sets the given render hints on the painter if on is true; otherwise clears the render hints...
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *)
void setCompositionMode(CompositionMode mode)
Sets the composition mode to the given mode.
virtual QVariant itemChange(GraphicsItemChange, const QVariant &)
Note that unlike QGraphicsItems, QDeclarativeItem::itemChange() is not called during initial widget p...
void prepareGeometryChange()
Prepares the item for a geometry change.
int y() const
Returns the y-coordinate of the rectangle's top edge.
int x() const
Returns the x-coordinate of the rectangle's left edge.
void setSmoothCache(bool on)
QObject * parent() const
Returns a pointer to the parent object.
qreal x() const
This convenience function is equivalent to calling pos().
QVector< QRect > rects() const
Returns an array of non-overlapping rectangles that make up the region.
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value)
Note that unlike QGraphicsItems, QDeclarativeItem::itemChange() is not called during initial widget p...
if(void) toggleToolbarShown
The QRect class defines a rectangle in the plane using integer precision.
The QPixmap class is an off-screen image representation that can be used as a paint device...
void clearCache()
Marks the entirety of the contents cache as dirty.
void scale(qreal sx, qreal sy)
Scales the coordinate system by ({sx}, {sy}).
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device...
The QSize class defines the size of a two-dimensional object using integer point precision.
void setContentsScale(qreal)
The QStyleOptionGraphicsItem class is used to describe the parameters needed to draw a QGraphicsItem...
QRegion systemClip() const
Returns the system clip.
void setPixelCacheSize(int pixels)
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
This function is called to handle this item's changes in geometry from oldGeometry to newGeometry...
int pixelCacheSize() const
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
static int area(const QSize &s)
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.