зеркало из https://github.com/mozilla/gecko-dev.git
Bug 551252 - Reduce the size of painting on Qt. r=dougt
This commit is contained in:
Родитель
f1e59965d9
Коммит
e726adb2cf
|
@ -101,6 +101,7 @@ static int gBufferPixmapUsageCount = 0;
|
||||||
// Buffered shared image + pixmap
|
// Buffered shared image + pixmap
|
||||||
static gfxSharedImageSurface *gBufferImage = nsnull;
|
static gfxSharedImageSurface *gBufferImage = nsnull;
|
||||||
static gfxSharedImageSurface *gBufferImageTemp = nsnull;
|
static gfxSharedImageSurface *gBufferImageTemp = nsnull;
|
||||||
|
static QSize gBufferMaxSize(0, 0);
|
||||||
PRBool gNeedColorConversion = PR_FALSE;
|
PRBool gNeedColorConversion = PR_FALSE;
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "pixman.h"
|
#include "pixman.h"
|
||||||
|
@ -222,14 +223,16 @@ UpdateOffScreenBuffers(QSize aSize, int aDepth)
|
||||||
{
|
{
|
||||||
gfxIntSize size(aSize.width(), aSize.height());
|
gfxIntSize size(aSize.width(), aSize.height());
|
||||||
if (gBufferPixmap) {
|
if (gBufferPixmap) {
|
||||||
if (gBufferPixmap->size().width() < size.width ||
|
if (gBufferMaxSize.width() < size.width ||
|
||||||
gBufferPixmap->size().height() < size.height) {
|
gBufferMaxSize.height() < size.height) {
|
||||||
FreeOffScreenBuffers();
|
FreeOffScreenBuffers();
|
||||||
} else
|
} else
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
gBufferPixmap = new QPixmap(size.width, size.height);
|
gBufferMaxSize.setWidth(PR_MAX(gBufferMaxSize.width(), size.width));
|
||||||
|
gBufferMaxSize.setHeight(PR_MAX(gBufferMaxSize.height(), size.height));
|
||||||
|
gBufferPixmap = new QPixmap(gBufferMaxSize.width(), gBufferMaxSize.height());
|
||||||
if (!gBufferPixmap)
|
if (!gBufferPixmap)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -989,13 +992,16 @@ nsWindow::DoPaint(QPainter* aPainter, const QStyleOptionGraphicsItem* aOption)
|
||||||
else
|
else
|
||||||
r = mWidget->boundingRect();
|
r = mWidget->boundingRect();
|
||||||
|
|
||||||
|
if (r.isEmpty())
|
||||||
|
return nsEventStatus_eIgnore;
|
||||||
|
|
||||||
if (!mDirtyScrollArea.isEmpty())
|
if (!mDirtyScrollArea.isEmpty())
|
||||||
mDirtyScrollArea = QRegion();
|
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
|
||||||
if (renderMode != gfxQtPlatform::RENDER_QPAINTER)
|
if (renderMode != gfxQtPlatform::RENDER_QPAINTER)
|
||||||
if (!UpdateOffScreenBuffers(r.size().toSize(), QX11Info().depth()))
|
if (!UpdateOffScreenBuffers(QSize(r.width(), r.height()), QX11Info().depth()))
|
||||||
return nsEventStatus_eIgnore;
|
return nsEventStatus_eIgnore;
|
||||||
|
|
||||||
nsRefPtr<gfxASurface> targetSurface = nsnull;
|
nsRefPtr<gfxASurface> targetSurface = nsnull;
|
||||||
|
@ -1013,6 +1019,10 @@ nsWindow::DoPaint(QPainter* aPainter, const QStyleOptionGraphicsItem* aOption)
|
||||||
|
|
||||||
nsRefPtr<gfxContext> ctx = new gfxContext(targetSurface);
|
nsRefPtr<gfxContext> ctx = new gfxContext(targetSurface);
|
||||||
|
|
||||||
|
// We will paint to 0, 0 position in offscrenn buffer
|
||||||
|
if (renderMode != gfxQtPlatform::RENDER_QPAINTER)
|
||||||
|
ctx->Translate(gfxPoint(-r.x(), -r.y()));
|
||||||
|
|
||||||
nsPaintEvent event(PR_TRUE, NS_PAINT, this);
|
nsPaintEvent event(PR_TRUE, NS_PAINT, this);
|
||||||
|
|
||||||
nsIntRect rect(r.x(), r.y(), r.width(), r.height());
|
nsIntRect rect(r.x(), r.y(), r.width(), r.height());
|
||||||
|
@ -1060,8 +1070,7 @@ nsWindow::DoPaint(QPainter* aPainter, const QStyleOptionGraphicsItem* aOption)
|
||||||
0, 0,
|
0, 0,
|
||||||
0, 0,
|
0, 0,
|
||||||
0, 0,
|
0, 0,
|
||||||
gBufferImageTemp->GetSize().width,
|
rect.width, rect.height);
|
||||||
gBufferImageTemp->GetSize().height);
|
|
||||||
pixman_image_unref(src_image);
|
pixman_image_unref(src_image);
|
||||||
pixman_image_unref(dst_image);
|
pixman_image_unref(dst_image);
|
||||||
}
|
}
|
||||||
|
@ -1071,7 +1080,7 @@ 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(),
|
||||||
rect.x, rect.y, rect.x, rect.y, rect.width, rect.height,
|
0, 0, 0, 0, rect.width, rect.height,
|
||||||
False);
|
False);
|
||||||
XSync(disp, False);
|
XSync(disp, False);
|
||||||
XFreeGC(disp, gc);
|
XFreeGC(disp, gc);
|
||||||
|
@ -1080,7 +1089,7 @@ nsWindow::DoPaint(QPainter* aPainter, const QStyleOptionGraphicsItem* aOption)
|
||||||
if (renderMode != gfxQtPlatform::RENDER_QPAINTER) {
|
if (renderMode != gfxQtPlatform::RENDER_QPAINTER) {
|
||||||
if (gBufferPixmap->handle())
|
if (gBufferPixmap->handle())
|
||||||
aPainter->drawPixmap(QPoint(rect.x, rect.y), *gBufferPixmap,
|
aPainter->drawPixmap(QPoint(rect.x, rect.y), *gBufferPixmap,
|
||||||
QRect(rect.x, rect.y, rect.width, rect.height));
|
QRect(0, 0, rect.width, rect.height));
|
||||||
else {
|
else {
|
||||||
QImage img(gBufferImage->Data(),
|
QImage img(gBufferImage->Data(),
|
||||||
gBufferImage->Width(),
|
gBufferImage->Width(),
|
||||||
|
@ -1088,7 +1097,7 @@ nsWindow::DoPaint(QPainter* aPainter, const QStyleOptionGraphicsItem* aOption)
|
||||||
gBufferImage->Stride(),
|
gBufferImage->Stride(),
|
||||||
QImage::Format_RGB32);
|
QImage::Format_RGB32);
|
||||||
aPainter->drawImage(QPoint(rect.x, rect.y), img,
|
aPainter->drawImage(QPoint(rect.x, rect.y), img,
|
||||||
QRect(rect.x, rect.y, rect.width, rect.height));
|
QRect(0, 0, rect.width, rect.height));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1680,9 +1689,12 @@ nsWindow::SetWindowClass(const nsAString &xulWinType)
|
||||||
class_hint->res_name[0] = toupper(class_hint->res_name[0]);
|
class_hint->res_name[0] = toupper(class_hint->res_name[0]);
|
||||||
if (!role) role = class_hint->res_name;
|
if (!role) role = class_hint->res_name;
|
||||||
|
|
||||||
XSetClassHint(GetViewWidget()->x11Info().display(),
|
QWidget *widget = GetViewWidget();
|
||||||
GetViewWidget()->handle(),
|
// If widget not show, handle might be null
|
||||||
class_hint);
|
if (widget && widget->handle())
|
||||||
|
XSetClassHint(widget->x11Info().display(),
|
||||||
|
widget->handle(),
|
||||||
|
class_hint);
|
||||||
|
|
||||||
nsMemory::Free(class_hint->res_class);
|
nsMemory::Free(class_hint->res_class);
|
||||||
nsMemory::Free(class_hint->res_name);
|
nsMemory::Free(class_hint->res_name);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче