##// END OF EJS Templates
Clear chart image to transparent when necessary....
Miikka Heikkinen -
r2850:57e4c71e5532
parent child
Show More
@@ -167,8 +167,8 QT_CHARTS_BEGIN_NAMESPACE
167 167 hardware and drivers.
168 168 \li Polar charts do not support accelerated series.
169 169 \li Mouse events are not supported for accelerated series.
170 \li Enabling chart drop shadow is not recommended when using accelerated series,
171 as that can slow the frame rate down significantly.
170 \li Enabling chart drop shadow or using transparent chart background color is not recommended
171 when using accelerated series, as that can slow the frame rate down significantly.
172 172 \endlist
173 173
174 174 These additional restrictions stem from the fact that the accelerated series is drawn on a
@@ -223,8 +223,8 QT_CHARTS_BEGIN_NAMESPACE
223 223 hardware and drivers.
224 224 \li Polar charts do not support accelerated series.
225 225 \li Mouse events are not supported for accelerated series.
226 \li Enabling chart drop shadow is not recommended when using accelerated series,
227 as that can slow the frame rate down significantly.
226 \li Enabling chart drop shadow or using transparent chart background color is not recommended
227 when using accelerated series, as that can slow the frame rate down significantly.
228 228 \endlist
229 229
230 230 The default value is \c{false}.
@@ -334,6 +334,7 void DeclarativeChart::initChart(QChart::ChartType type)
334 334 {
335 335 m_sceneImage = 0;
336 336 m_sceneImageDirty = false;
337 m_sceneImageNeedsClear = false;
337 338 m_guiThreadId = QThread::currentThreadId();
338 339 m_paintThreadId = 0;
339 340 m_updatePending = false;
@@ -590,9 +591,15 void DeclarativeChart::renderScene()
590 591 if (!m_sceneImage || chartSize != m_sceneImage->size()) {
591 592 delete m_sceneImage;
592 593 m_sceneImage = new QImage(chartSize, QImage::Format_ARGB32);
593 m_sceneImage->fill(Qt::transparent);
594 m_sceneImageNeedsClear = true;
594 595 }
595 596
597 if (m_sceneImageNeedsClear) {
598 m_sceneImage->fill(Qt::transparent);
599 // Don't clear the flag if chart background has any transparent element to it
600 if (m_chart->backgroundBrush().color().alpha() == 0xff && !m_chart->isDropShadowEnabled())
601 m_sceneImageNeedsClear = false;
602 }
596 603 QPainter painter(m_sceneImage);
597 604 if (antialiasing()) {
598 605 painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing
@@ -822,6 +829,8 void DeclarativeChart::setBackgroundColor(QColor color)
822 829 {
823 830 QBrush b = m_chart->backgroundBrush();
824 831 if (b.style() != Qt::SolidPattern || color != b.color()) {
832 if (color.alpha() < 0xff)
833 m_sceneImageNeedsClear = true;
825 834 b.setStyle(Qt::SolidPattern);
826 835 b.setColor(color);
827 836 m_chart->setBackgroundBrush(b);
@@ -885,6 +894,7 int DeclarativeChart::count()
885 894 void DeclarativeChart::setDropShadowEnabled(bool enabled)
886 895 {
887 896 if (enabled != m_chart->isDropShadowEnabled()) {
897 m_sceneImageNeedsClear = true;
888 898 m_chart->setDropShadowEnabled(enabled);
889 899 dropShadowEnabledChanged(enabled);
890 900 }
@@ -903,6 +913,7 qreal DeclarativeChart::backgroundRoundness() const
903 913 void DeclarativeChart::setBackgroundRoundness(qreal diameter)
904 914 {
905 915 if (m_chart->backgroundRoundness() != diameter) {
916 m_sceneImageNeedsClear = true;
906 917 m_chart->setBackgroundRoundness(diameter);
907 918 emit backgroundRoundnessChanged(diameter);
908 919 }
@@ -238,6 +238,7 private:
238 238 Qt::HANDLE m_guiThreadId;
239 239 DeclarativeMargins *m_margins;
240 240 GLXYSeriesDataManager *m_glXYDataManager;
241 bool m_sceneImageNeedsClear;
241 242 };
242 243
243 244 QT_CHARTS_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now