Bug 468399. Use image surfaces on windows mobile for performance reasons. r=vlad

This commit is contained in:
Doug Turner 2009-01-14 16:19:39 -08:00
parent 7fad8f76a1
commit 6cc200565f
2 changed files with 29 additions and 1 deletions

View File

@ -111,7 +111,11 @@ already_AddRefed<gfxASurface>
gfxWindowsPlatform::CreateOffscreenSurface(const gfxIntSize& size,
gfxASurface::gfxImageFormat imageFormat)
{
#ifndef WINCE
gfxASurface *surf = new gfxWindowsSurface(size, imageFormat);
#else
gfxASurface *surf = new gfxImageSurface(size, imageFormat);
#endif
NS_IF_ADDREF(surf);
return surf;
}

View File

@ -74,6 +74,8 @@
#include "prlog.h"
#include "nsISupportsPrimitives.h"
#include "gfxImageSurface.h"
#ifdef WINCE
#include "aygshell.h"
#include "imm.h"
@ -6028,6 +6030,7 @@ PRBool nsWindow::OnPaint(HDC aDC)
(PRInt32) mWnd);
#endif // NS_DEBUG
#ifndef WINCE
#ifdef MOZ_XUL
nsRefPtr<gfxASurface> targetSurface;
if (eTransparencyTransparent == mTransparencyMode) {
@ -6040,11 +6043,21 @@ PRBool nsWindow::OnPaint(HDC aDC)
#else
nsRefPtr<gfxASurface> targetSurface = new gfxWindowsSurface(hDC);
#endif
#else
nsRefPtr<gfxImageSurface> targetSurface = new gfxImageSurface(gfxIntSize(ps.rcPaint.right - ps.rcPaint.left,
ps.rcPaint.bottom - ps.rcPaint.top),
gfxASurface::ImageFormatRGB24);
if (targetSurface && !targetSurface->CairoStatus()) {
targetSurface->SetDeviceOffset(gfxPoint(-ps.rcPaint.left, -ps.rcPaint.top));
}
#endif
nsRefPtr<gfxContext> thebesContext = new gfxContext(targetSurface);
thebesContext->SetFlag(gfxContext::FLAG_DESTINED_FOR_SCREEN);
#if defined(MOZ_XUL) && !defined(WINCE)
#ifndef WINCE
#if defined(MOZ_XUL)
if (eTransparencyGlass == mTransparencyMode && nsUXThemeData::sHaveCompositor) {
thebesContext->PushGroup(gfxASurface::CONTENT_COLOR_ALPHA);
} else if (eTransparencyTransparent == mTransparencyMode) {
@ -6061,6 +6074,7 @@ PRBool nsWindow::OnPaint(HDC aDC)
// If we're not doing translucency, then double buffer
thebesContext->PushGroup(gfxASurface::CONTENT_COLOR);
#endif
#endif /* ifndef WINCE */
nsCOMPtr<nsIRenderingContext> rc;
nsresult rv = mContext->CreateRenderingContextInstance (*getter_AddRefs(rc));
@ -6086,11 +6100,21 @@ PRBool nsWindow::OnPaint(HDC aDC)
// that displayed on the screen.
UpdateTranslucentWindow();
} else if (result) {
#ifndef WINCE
// Only update if DispatchWindowEvent returned TRUE; otherwise, nothing handled
// this, and we'll just end up painting with black.
thebesContext->PopGroupToSource();
thebesContext->SetOperator(gfxContext::OPERATOR_SOURCE);
thebesContext->Paint();
#else
nsRefPtr<gfxASurface> winSurface = new gfxWindowsSurface(hDC);
nsRefPtr<gfxContext> winCtx = new gfxContext(winSurface);
winCtx->SetOperator(gfxContext::OPERATOR_SOURCE);
winCtx->SetSource(targetSurface);
winCtx->Paint();
#endif
}
#endif
}