Bug 547577 - nsWindow::Scroll must be updated for widget QT port. r=dougt
This commit is contained in:
@@ -107,6 +107,10 @@ protected:
|
|||||||
mTopLevelWidget->setGeometry( 0.0, 0.0,
|
mTopLevelWidget->setGeometry( 0.0, 0.0,
|
||||||
static_cast<qreal>(aEvent->size().width()),
|
static_cast<qreal>(aEvent->size().width()),
|
||||||
static_cast<qreal>(aEvent->size().height()));
|
static_cast<qreal>(aEvent->size().height()));
|
||||||
|
// resize scene rect to vieport size,
|
||||||
|
// to avoid extra scrolling from QAbstractScrollable
|
||||||
|
setSceneRect(viewport()->rect());
|
||||||
|
|
||||||
}
|
}
|
||||||
QGraphicsView::resizeEvent(aEvent);
|
QGraphicsView::resizeEvent(aEvent);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -231,8 +231,15 @@ UpdateOffScreenBuffers(QSize aSize, int aDepth)
|
|||||||
if (!gBufferPixmap)
|
if (!gBufferPixmap)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (gfxQtPlatform::GetPlatform()->GetRenderMode() == gfxQtPlatform::RENDER_XLIB)
|
if (gfxQtPlatform::GetPlatform()->GetRenderMode() == gfxQtPlatform::RENDER_XLIB) {
|
||||||
|
if (!gBufferPixmap->handle()) {
|
||||||
|
NS_ERROR("XDrawable must be available for QPixmap in RENDER_XLIB mode");
|
||||||
|
delete gBufferPixmap;
|
||||||
|
gBufferPixmap = nsnull;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if system depth has related gfxImage format
|
// Check if system depth has related gfxImage format
|
||||||
gfxASurface::gfxImageFormat format =
|
gfxASurface::gfxImageFormat format =
|
||||||
@@ -653,7 +660,10 @@ nsWindow::Update()
|
|||||||
if (!mWidget)
|
if (!mWidget)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
mWidget->update(); // FIXME This call cause update for whole window on each scroll event
|
// Just proceed all pending paints
|
||||||
|
if (GetViewWidget())
|
||||||
|
GetViewWidget()->repaint();
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -688,9 +698,21 @@ nsWindow::Scroll(const nsIntPoint& aDelta,
|
|||||||
|
|
||||||
for (BlitRectIter iter(aDelta, aDestRects); !iter.IsDone(); ++iter) {
|
for (BlitRectIter iter(aDelta, aDestRects); !iter.IsDone(); ++iter) {
|
||||||
const nsIntRect & r = iter.Rect();
|
const nsIntRect & r = iter.Rect();
|
||||||
QRect rect(r.x - aDelta.x, r.y - aDelta.y, r.width, r.height);
|
QRegion goodReg(QRect(r.x, r.y, r.width, r.height));
|
||||||
|
goodReg = goodReg.subtracted(mDirtyScrollArea);
|
||||||
|
|
||||||
|
const QVector<QRect> myRects = goodReg.rects();
|
||||||
|
for (QVector<QRect>::const_iterator it = myRects.constBegin(); it < myRects.constEnd(); ++it) {
|
||||||
|
QRect rect(*it);
|
||||||
mWidget->scroll(aDelta.x, aDelta.y, rect);
|
mWidget->scroll(aDelta.x, aDelta.y, rect);
|
||||||
|
// Calculate dirty area which is need to be updated
|
||||||
|
QRegion dirtyReg(rect);
|
||||||
|
rect.translate(aDelta.x, aDelta.y);
|
||||||
|
dirtyReg = dirtyReg.subtracted(rect);
|
||||||
|
mDirtyScrollArea = mDirtyScrollArea.united(dirtyReg);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ConfigureChildren(aConfigurations);
|
ConfigureChildren(aConfigurations);
|
||||||
|
|
||||||
// Show windows again...
|
// Show windows again...
|
||||||
@@ -961,20 +983,13 @@ nsWindow::DoPaint(QPainter* aPainter, const QStyleOptionGraphicsItem* aOption)
|
|||||||
if (!mWidget)
|
if (!mWidget)
|
||||||
return nsEventStatus_eIgnore;
|
return nsEventStatus_eIgnore;
|
||||||
|
|
||||||
static NS_DEFINE_CID(kRegionCID, NS_REGION_CID);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIRegion> updateRegion = do_CreateInstance(kRegionCID);
|
|
||||||
if (!updateRegion)
|
|
||||||
return nsEventStatus_eIgnore;
|
|
||||||
|
|
||||||
QRectF r;
|
QRectF r;
|
||||||
|
|
||||||
if (aOption)
|
if (aOption)
|
||||||
r = aOption->exposedRect;
|
r = aOption->exposedRect;
|
||||||
else
|
else
|
||||||
r = mWidget->boundingRect();
|
r = mWidget->boundingRect();
|
||||||
|
|
||||||
updateRegion->SetTo( (int)r.x(), (int)r.y(), (int)r.width(), (int)r.height() );
|
mDirtyScrollArea = QRegion();
|
||||||
|
|
||||||
gfxQtPlatform::RenderMode renderMode = gfxQtPlatform::GetPlatform()->GetRenderMode();
|
gfxQtPlatform::RenderMode renderMode = gfxQtPlatform::GetPlatform()->GetRenderMode();
|
||||||
// Prepare offscreen buffers if RenderMode Xlib or Image
|
// Prepare offscreen buffers if RenderMode Xlib or Image
|
||||||
@@ -1009,8 +1024,8 @@ nsWindow::DoPaint(QPainter* aPainter, const QStyleOptionGraphicsItem* aOption)
|
|||||||
nsIntRect rect(r.x(), r.y(), r.width(), r.height());
|
nsIntRect rect(r.x(), r.y(), r.width(), r.height());
|
||||||
event.refPoint.x = r.x();
|
event.refPoint.x = r.x();
|
||||||
event.refPoint.y = r.y();
|
event.refPoint.y = r.y();
|
||||||
event.rect = nsnull;
|
event.rect = ▭
|
||||||
event.region = updateRegion;
|
event.region = nsnull;
|
||||||
event.renderingContext = rc;
|
event.renderingContext = rc;
|
||||||
|
|
||||||
nsEventStatus status = DispatchEvent(&event);
|
nsEventStatus status = DispatchEvent(&event);
|
||||||
@@ -1025,7 +1040,10 @@ nsWindow::DoPaint(QPainter* aPainter, const QStyleOptionGraphicsItem* aOption)
|
|||||||
|
|
||||||
LOGDRAW(("[%p] draw done\n", this));
|
LOGDRAW(("[%p] draw done\n", this));
|
||||||
|
|
||||||
if (renderMode == gfxQtPlatform::RENDER_SHARED_IMAGE) {
|
// If handle not available for QPixmap it means that we are using
|
||||||
|
// "-graphicssystem raster" rendering backend
|
||||||
|
// in raster mode we can just wrap gBufferImage as QImage and paint directly
|
||||||
|
if (renderMode == gfxQtPlatform::RENDER_SHARED_IMAGE && gBufferPixmap->handle()) {
|
||||||
if (gNeedColorConversion) {
|
if (gNeedColorConversion) {
|
||||||
pixman_image_t *src_image = NULL;
|
pixman_image_t *src_image = NULL;
|
||||||
pixman_image_t *dst_image = NULL;
|
pixman_image_t *dst_image = NULL;
|
||||||
@@ -1057,13 +1075,25 @@ nsWindow::DoPaint(QPainter* aPainter, const QStyleOptionGraphicsItem* aOption)
|
|||||||
gcv.graphics_exposures = False;
|
gcv.graphics_exposures = False;
|
||||||
GC gc = XCreateGC (disp, gBufferPixmap->handle(), GCGraphicsExposures, &gcv);
|
GC gc = XCreateGC (disp, gBufferPixmap->handle(), GCGraphicsExposures, &gcv);
|
||||||
XShmPutImage(disp, gBufferPixmap->handle(), gc, gBufferImage->image(),
|
XShmPutImage(disp, gBufferPixmap->handle(), gc, gBufferImage->image(),
|
||||||
0, 0, 0, 0, gBufferImage->GetSize().width, gBufferImage->GetSize().height,
|
rect.x, rect.y, rect.x, rect.y, rect.width, rect.height,
|
||||||
False);
|
False);
|
||||||
XFreeGC (disp, gc);
|
XFreeGC (disp, gc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (renderMode != gfxQtPlatform::RENDER_QPAINTER)
|
if (renderMode != gfxQtPlatform::RENDER_QPAINTER) {
|
||||||
aPainter->drawPixmap(QPoint(0, 0), *gBufferPixmap);
|
if (gBufferPixmap->handle())
|
||||||
|
aPainter->drawPixmap(QPoint(rect.x, rect.y), *gBufferPixmap,
|
||||||
|
QRect(rect.x, rect.y, rect.width, rect.height));
|
||||||
|
else {
|
||||||
|
QImage img(gBufferImage->Data(),
|
||||||
|
gBufferImage->Width(),
|
||||||
|
gBufferImage->Height(),
|
||||||
|
gBufferImage->Stride(),
|
||||||
|
QImage::Format_RGB32);
|
||||||
|
aPainter->drawImage(QPoint(rect.x, rect.y), img,
|
||||||
|
QRect(rect.x, rect.y, rect.width, rect.height));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ctx = nsnull;
|
ctx = nsnull;
|
||||||
targetSurface = nsnull;
|
targetSurface = nsnull;
|
||||||
@@ -1964,6 +1994,10 @@ nsWindow::createQWidget(MozQWidget *parent, nsWidgetInitData *aInitData)
|
|||||||
if (mScene && newView) {
|
if (mScene && newView) {
|
||||||
mScene->addItem(widget);
|
mScene->addItem(widget);
|
||||||
newView->setTopLevel(widget);
|
newView->setTopLevel(widget);
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 0))
|
||||||
|
// Top level widget is just container, and should not be painted
|
||||||
|
widget->setFlag(QGraphicsItem::ItemHasNoContents);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mWindowType == eWindowType_popup) {
|
if (mWindowType == eWindowType_popup) {
|
||||||
|
|||||||
@@ -354,6 +354,8 @@ private:
|
|||||||
}
|
}
|
||||||
PRInt32 mQCursor;
|
PRInt32 mQCursor;
|
||||||
|
|
||||||
|
// Remember dirty area caused by ::Scroll
|
||||||
|
QRegion mDirtyScrollArea;
|
||||||
};
|
};
|
||||||
|
|
||||||
class nsChildWindow : public nsWindow
|
class nsChildWindow : public nsWindow
|
||||||
|
|||||||
Reference in New Issue
Block a user