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