58 #include <QPixmapCache> |
58 #include <QPixmapCache> |
59 |
59 |
60 #include <private/qobject_p.h> |
60 #include <private/qobject_p.h> |
61 #include <private/qpixmapfilter_p.h> |
61 #include <private/qpixmapfilter_p.h> |
62 |
62 |
|
63 #ifndef QT_NO_GRAPHICSEFFECT |
63 QT_BEGIN_NAMESPACE |
64 QT_BEGIN_NAMESPACE |
64 |
65 |
|
66 class QGraphicsEffectSourcePrivate; |
|
67 class Q_GUI_EXPORT QGraphicsEffectSource : public QObject |
|
68 { |
|
69 Q_OBJECT |
|
70 public: |
|
71 ~QGraphicsEffectSource(); |
|
72 const QGraphicsItem *graphicsItem() const; |
|
73 const QWidget *widget() const; |
|
74 const QStyleOption *styleOption() const; |
|
75 |
|
76 bool isPixmap() const; |
|
77 void draw(QPainter *painter); |
|
78 void update(); |
|
79 |
|
80 QRectF boundingRect(Qt::CoordinateSystem coordinateSystem = Qt::LogicalCoordinates) const; |
|
81 QRect deviceRect() const; |
|
82 QPixmap pixmap(Qt::CoordinateSystem system = Qt::LogicalCoordinates, |
|
83 QPoint *offset = 0, |
|
84 QGraphicsEffect::PixmapPadMode mode = QGraphicsEffect::PadToEffectiveBoundingRect) const; |
|
85 |
|
86 protected: |
|
87 QGraphicsEffectSource(QGraphicsEffectSourcePrivate &dd, QObject *parent = 0); |
|
88 |
|
89 private: |
|
90 Q_DECLARE_PRIVATE(QGraphicsEffectSource) |
|
91 Q_DISABLE_COPY(QGraphicsEffectSource) |
|
92 friend class QGraphicsEffect; |
|
93 friend class QGraphicsEffectPrivate; |
|
94 friend class QGraphicsScenePrivate; |
|
95 friend class QGraphicsItem; |
|
96 friend class QGraphicsItemPrivate; |
|
97 friend class QWidget; |
|
98 friend class QWidgetPrivate; |
|
99 }; |
|
100 |
65 class QGraphicsEffectSourcePrivate : public QObjectPrivate |
101 class QGraphicsEffectSourcePrivate : public QObjectPrivate |
66 { |
102 { |
67 Q_DECLARE_PUBLIC(QGraphicsEffectSource) |
103 Q_DECLARE_PUBLIC(QGraphicsEffectSource) |
68 public: |
104 public: |
69 QGraphicsEffectSourcePrivate() : QObjectPrivate() {} |
105 QGraphicsEffectSourcePrivate() |
70 virtual ~QGraphicsEffectSourcePrivate() { invalidateCache(); } |
106 : QObjectPrivate() |
|
107 , m_cachedSystem(Qt::DeviceCoordinates) |
|
108 , m_cachedMode(QGraphicsEffect::PadToTransparentBorder) |
|
109 {} |
|
110 |
|
111 enum InvalidateReason |
|
112 { |
|
113 TransformChanged, |
|
114 EffectRectChanged, |
|
115 SourceChanged |
|
116 }; |
|
117 |
|
118 virtual ~QGraphicsEffectSourcePrivate(); |
71 virtual void detach() = 0; |
119 virtual void detach() = 0; |
72 virtual QRectF boundingRect(Qt::CoordinateSystem system) const = 0; |
120 virtual QRectF boundingRect(Qt::CoordinateSystem system) const = 0; |
73 virtual QRect deviceRect() const = 0; |
121 virtual QRect deviceRect() const = 0; |
74 virtual const QGraphicsItem *graphicsItem() const = 0; |
122 virtual const QGraphicsItem *graphicsItem() const = 0; |
75 virtual const QWidget *widget() const = 0; |
123 virtual const QWidget *widget() const = 0; |
76 virtual const QStyleOption *styleOption() const = 0; |
124 virtual const QStyleOption *styleOption() const = 0; |
77 virtual void draw(QPainter *p) = 0; |
125 virtual void draw(QPainter *p) = 0; |
78 virtual void update() = 0; |
126 virtual void update() = 0; |
79 virtual bool isPixmap() const = 0; |
127 virtual bool isPixmap() const = 0; |
80 virtual QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset = 0) const = 0; |
128 virtual QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset = 0, |
|
129 QGraphicsEffect::PixmapPadMode mode = QGraphicsEffect::PadToTransparentBorder) const = 0; |
81 virtual void effectBoundingRectChanged() = 0; |
130 virtual void effectBoundingRectChanged() = 0; |
82 void invalidateCache() const { QPixmapCache::remove(m_cacheKey); } |
131 |
|
132 void invalidateCache(InvalidateReason reason = SourceChanged) const; |
|
133 Qt::CoordinateSystem currentCachedSystem() const { return m_cachedSystem; } |
83 |
134 |
84 friend class QGraphicsScenePrivate; |
135 friend class QGraphicsScenePrivate; |
85 friend class QGraphicsItem; |
136 friend class QGraphicsItem; |
86 friend class QGraphicsItemPrivate; |
137 friend class QGraphicsItemPrivate; |
87 |
138 |
88 private: |
139 private: |
89 mutable Qt::CoordinateSystem m_cachedSystem; |
140 mutable Qt::CoordinateSystem m_cachedSystem; |
|
141 mutable QGraphicsEffect::PixmapPadMode m_cachedMode; |
90 mutable QPoint m_cachedOffset; |
142 mutable QPoint m_cachedOffset; |
91 mutable QPixmapCache::Key m_cacheKey; |
143 mutable QPixmapCache::Key m_cacheKey; |
92 }; |
144 }; |
93 |
145 |
94 class Q_GUI_EXPORT QGraphicsEffectPrivate : public QObjectPrivate |
146 class Q_GUI_EXPORT QGraphicsEffectPrivate : public QObjectPrivate |