diff options
author | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2013-06-10 17:55:51 +0200 |
---|---|---|
committer | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2013-06-10 18:12:50 +0200 |
commit | 90c064f15d540da7b47dd382c65252fe88d0e9b2 (patch) | |
tree | 8118b02bdb3061b6ca4e17edca21bb181679b6bb /shared | |
parent | feacc0dff2d751893f88a2e3fc187914030a153e (diff) |
Fix an assert in RenderWidgetHostImpl::GetBackingStore.
Also carry the damaged rect to QWidget|QPaintedItem::update.
Diffstat (limited to 'shared')
-rw-r--r-- | shared/native_view_qt.cpp | 8 | ||||
-rw-r--r-- | shared/native_view_qt.h | 6 | ||||
-rw-r--r-- | shared/render_widget_host_view_qt.cpp | 27 | ||||
-rw-r--r-- | shared/render_widget_host_view_qt.h | 10 |
4 files changed, 37 insertions, 14 deletions
diff --git a/shared/native_view_qt.cpp b/shared/native_view_qt.cpp index d95cb6957..1a5716549 100644 --- a/shared/native_view_qt.cpp +++ b/shared/native_view_qt.cpp @@ -44,9 +44,9 @@ QWindow* QWidgetNativeView::window() const return QWidget::windowHandle(); } -void QWidgetNativeView::update() +void QWidgetNativeView::update(const QRect& rect) { - QWidget::update(); + QWidget::update(rect); } void QWidgetNativeView::setBackingStore(BackingStoreQt* backingStore) @@ -120,9 +120,9 @@ QWindow* QQuickNativeView::window() const return QQuickPaintedItem::window(); } -void QQuickNativeView::update() +void QQuickNativeView::update(const QRect& rect) { - QQuickPaintedItem::update(); + QQuickPaintedItem::update(rect); } void QQuickNativeView::paint(QPainter *painter) diff --git a/shared/native_view_qt.h b/shared/native_view_qt.h index 80bb24e87..6a15701e8 100644 --- a/shared/native_view_qt.h +++ b/shared/native_view_qt.h @@ -26,7 +26,7 @@ public: virtual void hide() = 0; virtual bool isVisible() const = 0; virtual QWindow* window() const = 0; - virtual void update() = 0; + virtual void update(const QRect& rect = QRect()) = 0; }; class QWidgetNativeView : public QWidget, public NativeViewQt @@ -40,7 +40,7 @@ public: virtual void hide(); virtual bool isVisible() const; virtual QWindow* window() const; - virtual void update(); + virtual void update(const QRect& rect = QRect()); QPainter* painter(); @@ -67,7 +67,7 @@ public: virtual void hide(); virtual bool isVisible() const; virtual QWindow* window() const; - virtual void update(); + virtual void update(const QRect& rect = QRect()); void paint(QPainter *painter); void resize(int width, int height); diff --git a/shared/render_widget_host_view_qt.cpp b/shared/render_widget_host_view_qt.cpp index 351030c7a..4fcdcbf00 100644 --- a/shared/render_widget_host_view_qt.cpp +++ b/shared/render_widget_host_view_qt.cpp @@ -91,6 +91,7 @@ void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebKit::WebScreenInfo* resul RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost* widget) : m_host(content::RenderWidgetHostImpl::From(widget)) , m_view(0) + , about_to_validate_and_paint_(false) { m_host->SetView(this); } @@ -346,14 +347,20 @@ void RenderWidgetHostViewQt::DidUpdateBackingStore(const gfx::Rect& scroll_rect, if (!m_view || !m_view->isVisible()) return; - Paint(scroll_rect); + if (about_to_validate_and_paint_) + invalid_rect_.Union(scroll_rect); + else + Paint(scroll_rect); for (size_t i = 0; i < copy_rects.size(); ++i) { gfx::Rect rect = gfx::SubtractRects(copy_rects[i], scroll_rect); if (rect.IsEmpty()) continue; - Paint(rect); + if (about_to_validate_and_paint_) + invalid_rect_.Union(rect); + else + Paint(rect); } } @@ -469,15 +476,23 @@ void RenderWidgetHostViewQt::OnAccessibilityNotifications(const std::vector<Acce QT_NOT_YET_IMPLEMENTED } -void RenderWidgetHostViewQt::Paint(const gfx::Rect& scroll_rect) +void RenderWidgetHostViewQt::Paint(const gfx::Rect& damage_rect) { + DCHECK(!about_to_validate_and_paint_); + + invalid_rect_ = damage_rect; + about_to_validate_and_paint_ = true; + bool force_create = !m_host->empty(); BackingStoreQt* backing_store = static_cast<BackingStoreQt*>(m_host->GetBackingStore(force_create)); + + // Calling GetBackingStore maybe have changed |invalid_rect_|... + about_to_validate_and_paint_ = false; + if (backing_store && m_view) { - QRectF r = m_view->screenRect(); - QRect rect(0, 0, r.width(), r.height()); m_view->setBackingStore(backing_store); - m_view->update(); + QRect r(invalid_rect_.x(), invalid_rect_.y(), invalid_rect_.width(), invalid_rect_.height()); + m_view->update(r); } } diff --git a/shared/render_widget_host_view_qt.h b/shared/render_widget_host_view_qt.h index 94faf8205..d21cbf051 100644 --- a/shared/render_widget_host_view_qt.h +++ b/shared/render_widget_host_view_qt.h @@ -128,13 +128,21 @@ public: void handleWheelEvent(QWheelEvent*); void handleFocusEvent(QFocusEvent*); private: - void Paint(const gfx::Rect& scroll_rect); + void Paint(const gfx::Rect& damage_rect); bool IsPopup() const; content::RenderWidgetHostImpl *m_host; NativeViewQt *m_view; gfx::Size m_requestedSize; + + // This is true when we are currently painting and thus should handle extra + // paint requests by expanding the invalid rect rather than actually + // painting. + bool about_to_validate_and_paint_; + + // This is the rectangle which we'll paint. + gfx::Rect invalid_rect_; }; } |