changing widget creation for cairo builds around to use GetThebesSurface() r=vlad

This commit is contained in:
pavlov%pavlov.net 2006-01-31 01:04:41 +00:00
Родитель a75303c36e
Коммит 5b140c101e
3 изменённых файлов: 39 добавлений и 7 удалений

Просмотреть файл

@ -799,6 +799,7 @@ nsWindow::nsWindow() : nsBaseWidget()
#endif
{
mWnd = 0;
mPaintDC = 0;
mPrevWndProc = NULL;
mBackground = ::GetSysColor(COLOR_BTNFACE);
mBrush = ::CreateSolidBrush(NSRGB_2_COLOREF(mBackground));
@ -5736,6 +5737,7 @@ PRBool nsWindow::OnPaint(HDC aDC)
#endif // NS_DEBUG
HDC hDC = aDC ? aDC : (::BeginPaint(mWnd, &ps));
mPaintDC = hDC;
RECT paintRect;
#ifdef MOZ_XUL
@ -5779,13 +5781,25 @@ PRBool nsWindow::OnPaint(HDC aDC)
(PRInt32) mWnd);
#endif // NS_DEBUG
#ifdef MOZ_CAIRO_GFX
nsCOMPtr<nsIRenderingContext> rc = getter_AddRefs(GetRenderingContext());
event.renderingContext = rc;
result = DispatchWindowEvent(&event, eventStatus);
event.renderingContext = nsnull;
if (mIsTranslucent && IsAlphaTranslucencySupported())
{
// Data from offscreen drawing surface was copied to memory bitmap of transparent
// bitmap. Now it can be read from memory bitmap to apply alpha channel and after
// that displayed on the screen.
UpdateTranslucentWindow();
}
rc = nsnull;
#else
if (NS_SUCCEEDED(CallCreateInstance(kRenderingContextCID, &event.renderingContext)))
{
#ifdef MOZ_CAIRO_GFX
nsIThebesRenderingContext *winrc;
#else
nsIRenderingContextWin *winrc;
#endif
if (NS_SUCCEEDED(CallQueryInterface(event.renderingContext, &winrc)))
{
nsIDrawingSurface* surf;
@ -5816,6 +5830,7 @@ PRBool nsWindow::OnPaint(HDC aDC)
}
else
result = PR_FALSE;
#endif
NS_RELEASE(event.widget);
}
@ -5825,6 +5840,8 @@ PRBool nsWindow::OnPaint(HDC aDC)
::EndPaint(mWnd, &ps);
}
mPaintDC = nsnull;
#ifdef NS_DEBUG
if (debug_WantPaintFlashing())
{
@ -8129,6 +8146,18 @@ nsWindow* nsWindow::GetTopLevelWindow()
}
}
#ifdef MOZ_CAIRO_GFX
#include "gfxWindowsSurface.h"
gfxASurface *nsWindow::GetThebesSurface()
{
if (mPaintDC)
return (new gfxWindowsSurface(mPaintDC));
return (new gfxWindowsSurface(mWnd));
}
#endif
void nsWindow::ResizeTranslucentWindow(PRInt32 aNewWidth, PRInt32 aNewHeight)
{
if (aNewWidth == mBounds.width && aNewHeight == mBounds.height)

Просмотреть файл

@ -200,6 +200,10 @@ public:
NS_IMETHOD GetLastInputEventTime(PRUint32& aTime);
nsWindow* GetTopLevelWindow();
#ifdef MOZ_CAIRO_GFX
gfxASurface *GetThebesSurface();
#endif
#ifdef MOZ_XUL
NS_IMETHOD SetWindowTranslucency(PRBool aTransparent);
NS_IMETHOD GetWindowTranslucency(PRBool& aTransparent);
@ -381,6 +385,7 @@ protected:
static nsWindow* gCurrentWindow;
nsPoint mLastPoint;
HWND mWnd;
HDC mPaintDC; // only set during painting
#if 0
HPALETTE mPalette;
#endif

Просмотреть файл

@ -612,9 +612,7 @@ nsIRenderingContext* nsBaseWidget::GetRenderingContext()
rv = mContext->CreateRenderingContextInstance(*getter_AddRefs(renderingCtx));
if (NS_SUCCEEDED(rv)) {
// this should be all MOZ_CAIRO_GFX, but none of the other
// platforms have GetThebesSurface() implemented yet
#if defined(MOZ_CAIRO_GFX) && defined(MOZ_WIDGET_GTK2)
#if defined(MOZ_CAIRO_GFX)
rv = renderingCtx->Init(mContext, GetThebesSurface());
#else
rv = renderingCtx->Init(mContext, this);