зеркало из https://github.com/mozilla/gecko-dev.git
fix for 13140, make painting on linux not suck. a=leaf r=ramiro i=rule
This commit is contained in:
Родитель
aea9ba9359
Коммит
169d45b9e9
|
@ -38,8 +38,6 @@ public:
|
|||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
PRBool OnPaint();
|
||||
|
||||
// nsIWidget interface
|
||||
|
||||
NS_IMETHOD Create(nsIWidget *aParent,
|
||||
|
|
|
@ -361,7 +361,7 @@ gint handle_expose_event(GtkWidget *w, GdkEventExpose *event, gpointer p)
|
|||
|
||||
nsWindow *win = (nsWindow *)p;
|
||||
win->AddRef();
|
||||
win->OnPaint(pevent);
|
||||
win->OnExpose(pevent);
|
||||
win->Release();
|
||||
|
||||
UninitExposeEvent(event, p, pevent, NS_PAINT);
|
||||
|
|
|
@ -44,7 +44,6 @@ public:
|
|||
NS_IMETHOD PreCreateWidget(nsWidgetInitData *aInitData);
|
||||
|
||||
virtual PRBool OnMove(PRInt32 aX, PRInt32 aY) { return PR_FALSE; }
|
||||
virtual PRBool OnPaint(nsPaintEvent & aEvent) { return PR_FALSE; }
|
||||
virtual PRBool OnResize(nsRect &aRect) { return PR_FALSE; }
|
||||
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "nsILookAndFeel.h"
|
||||
#include "nsToolkit.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
|
||||
#include "nsGfxCIID.h"
|
||||
#include <gdk/gdkx.h>
|
||||
|
||||
|
||||
|
@ -38,7 +38,7 @@
|
|||
|
||||
|
||||
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
||||
|
||||
static NS_DEFINE_CID(kRegionCID, NS_REGION_CID);
|
||||
|
||||
nsILookAndFeel *nsWidget::sLookAndFeel = nsnull;
|
||||
PRUint32 nsWidget::sWidgetCount = 0;
|
||||
|
@ -100,7 +100,16 @@ nsWidget::nsWidget()
|
|||
mIsDragDest = PR_FALSE;
|
||||
mOnDestroyCalled = PR_FALSE;
|
||||
mIsToplevel = PR_FALSE;
|
||||
mUpdateArea.SetRect(0, 0, 0, 0);
|
||||
|
||||
if (NS_OK == nsComponentManager::CreateInstance(kRegionCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIRegion),
|
||||
(void**)&mUpdateArea))
|
||||
{
|
||||
mUpdateArea->Init();
|
||||
mUpdateArea->SetTo(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
sWidgetCount++;
|
||||
|
||||
|
||||
|
@ -120,6 +129,9 @@ nsWidget::~nsWidget()
|
|||
IndentByDepth(stdout);
|
||||
printf("nsWidget::~nsWidget:%p\n", this);
|
||||
#endif
|
||||
|
||||
NS_IF_RELEASE(mUpdateArea);
|
||||
|
||||
mIsDestroying = PR_TRUE;
|
||||
if (nsnull != mWidget) {
|
||||
Destroy();
|
||||
|
@ -467,7 +479,11 @@ PRBool nsWidget::OnMove(PRInt32 aX, PRInt32 aY)
|
|||
NS_IMETHODIMP nsWidget::Enable(PRBool bState)
|
||||
{
|
||||
if (mWidget)
|
||||
gtk_widget_set_sensitive(mWidget, bState);
|
||||
{
|
||||
if (GTK_WIDGET_SENSITIVE(mWidget) == bState)
|
||||
return NS_OK;
|
||||
gtk_widget_set_sensitive(mWidget, bState);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -655,12 +671,12 @@ NS_IMETHODIMP nsWidget::Invalidate(PRBool aIsSynchronous)
|
|||
|
||||
if (aIsSynchronous) {
|
||||
::gtk_widget_draw(mWidget, (GdkRectangle *) NULL);
|
||||
mUpdateArea.SetRect(0, 0, 0, 0);
|
||||
} else {
|
||||
::gtk_widget_queue_draw(mWidget);
|
||||
mUpdateArea.SetRect(0, 0, mBounds.width, mBounds.height);
|
||||
}
|
||||
|
||||
mUpdateArea->SetTo(mBounds.x, mBounds.y, mBounds.width, mBounds.height);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -675,6 +691,8 @@ NS_IMETHODIMP nsWidget::Invalidate(const nsRect & aRect, PRBool aIsSynchronous)
|
|||
if (!GTK_WIDGET_REALIZED(mWidget) || !GTK_WIDGET_VISIBLE(mWidget))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mUpdateArea->Union(aRect.x, aRect.y, aRect.width, aRect.height);
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
debug_DumpInvalidate(stdout,
|
||||
this,
|
||||
|
@ -684,6 +702,7 @@ NS_IMETHODIMP nsWidget::Invalidate(const nsRect & aRect, PRBool aIsSynchronous)
|
|||
debug_GetRenderXID(mWidget));
|
||||
#endif // NS_DEBUG
|
||||
|
||||
#if 0
|
||||
if (aIsSynchronous)
|
||||
{
|
||||
GdkRectangle nRect;
|
||||
|
@ -693,12 +712,15 @@ NS_IMETHODIMP nsWidget::Invalidate(const nsRect & aRect, PRBool aIsSynchronous)
|
|||
}
|
||||
else
|
||||
{
|
||||
mUpdateArea.UnionRect(mUpdateArea, aRect);
|
||||
#endif
|
||||
|
||||
gtk_widget_queue_draw_area(mWidget,
|
||||
aRect.x, aRect.y,
|
||||
aRect.width, aRect.height);
|
||||
}
|
||||
|
||||
#if 0
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -706,8 +728,8 @@ NS_IMETHODIMP nsWidget::Update(void)
|
|||
{
|
||||
if (!mWidget)
|
||||
return NS_OK;
|
||||
|
||||
if (mUpdateArea.width && mUpdateArea.height) {
|
||||
#if 0
|
||||
if (mUpdateArea->width && mUpdateArea->height) {
|
||||
if (!mIsDestroying) {
|
||||
Invalidate(mUpdateArea, PR_TRUE);
|
||||
|
||||
|
@ -721,6 +743,7 @@ NS_IMETHODIMP nsWidget::Update(void)
|
|||
else {
|
||||
// g_print("nsWidget::Update(this=%p): avoided update of empty area\n", this);
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#define nsWidget_h__
|
||||
|
||||
#include "nsBaseWidget.h"
|
||||
|
||||
#include "nsIRegion.h"
|
||||
|
||||
|
||||
// XXX: This must go away when nsAutoCString moves out of nsFileSpec.h
|
||||
|
@ -356,7 +356,7 @@ protected:
|
|||
|
||||
// This is the composite update area (union of all the calls to
|
||||
// Invalidate)
|
||||
nsRect mUpdateArea;
|
||||
nsIRegion *mUpdateArea;
|
||||
|
||||
PRBool mShown;
|
||||
|
||||
|
|
|
@ -403,10 +403,10 @@ nsresult nsWindow::SetIcon(GdkPixmap *pixmap,
|
|||
* Processes an Expose Event
|
||||
*
|
||||
**/
|
||||
PRBool nsWindow::OnPaint(nsPaintEvent &event)
|
||||
PRBool nsWindow::OnExpose(nsPaintEvent &event)
|
||||
{
|
||||
nsresult result ;
|
||||
|
||||
|
||||
// call the event callback
|
||||
if (mEventCallback)
|
||||
{
|
||||
|
@ -421,13 +421,125 @@ PRBool nsWindow::OnPaint(nsPaintEvent &event)
|
|||
#endif // NS_DEBUG
|
||||
|
||||
|
||||
// expose.. we didn't get an Invalidate, so we should up the count here
|
||||
mUpdateArea->Union(event.rect->x, event.rect->y, event.rect->width, event.rect->height);
|
||||
|
||||
|
||||
printf("\n\n");
|
||||
PRInt32 x, y, w, h;
|
||||
mUpdateArea->GetBoundingBox(&x,&y,&w,&h);
|
||||
printf("should be painting x = %i , y = %i , w = %i , h = %i\n", x, y, w, h);
|
||||
printf("\n\n");
|
||||
event.rect->x = x;
|
||||
event.rect->y = y;
|
||||
event.rect->width = w;
|
||||
event.rect->height = h;
|
||||
|
||||
if (event.rect->width == 0 || event.rect->height == 0)
|
||||
{
|
||||
printf("ignoring paint for 0x0\n");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
event.renderingContext = GetRenderingContext();
|
||||
if (event.renderingContext)
|
||||
{
|
||||
PRBool rv;
|
||||
|
||||
event.renderingContext->SetClipRegion(NS_STATIC_CAST(const nsIRegion &, *mUpdateArea),
|
||||
nsClipCombine_kReplace, rv);
|
||||
|
||||
result = DispatchWindowEvent(&event);
|
||||
NS_RELEASE(event.renderingContext);
|
||||
}
|
||||
|
||||
|
||||
|
||||
mUpdateArea->Subtract(event.rect->x, event.rect->y, event.rect->width, event.rect->height);
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
if (debug_WantPaintFlashing())
|
||||
{
|
||||
GdkWindow * gw = GetRenderWindow(mWidget);
|
||||
|
||||
if (gw)
|
||||
{
|
||||
GdkRectangle ar;
|
||||
GdkRectangle * area = (GdkRectangle*) NULL;
|
||||
|
||||
if (event.rect)
|
||||
{
|
||||
ar.x = event.rect->x;
|
||||
ar.y = event.rect->y;
|
||||
|
||||
ar.width = event.rect->width;
|
||||
ar.height = event.rect->height;
|
||||
|
||||
area = &ar;
|
||||
}
|
||||
|
||||
nsGtkUtils::gdk_window_flash(gw,1,100000,area);
|
||||
}
|
||||
}
|
||||
#endif // NS_DEBUG
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes an Draw Event
|
||||
*
|
||||
**/
|
||||
PRBool nsWindow::OnDraw(nsPaintEvent &event)
|
||||
{
|
||||
nsresult result ;
|
||||
|
||||
// call the event callback
|
||||
if (mEventCallback)
|
||||
{
|
||||
event.renderingContext = nsnull;
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
debug_DumpPaintEvent(stdout,
|
||||
this,
|
||||
&event,
|
||||
debug_GetName(mWidget),
|
||||
(PRInt32) debug_GetRenderXID(mWidget));
|
||||
#endif // NS_DEBUG
|
||||
|
||||
|
||||
// printf("\n\n");
|
||||
PRInt32 x, y, w, h;
|
||||
mUpdateArea->GetBoundingBox(&x,&y,&w,&h);
|
||||
// printf("should be painting x = %i , y = %i , w = %i , h = %i\n", x, y, w, h);
|
||||
// printf("\n\n");
|
||||
event.rect->x = x;
|
||||
event.rect->y = y;
|
||||
event.rect->width = w;
|
||||
event.rect->height = h;
|
||||
|
||||
if (event.rect->width == 0 || event.rect->height == 0)
|
||||
{
|
||||
// printf("ignoring paint for 0x0\n");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
event.renderingContext = GetRenderingContext();
|
||||
if (event.renderingContext)
|
||||
{
|
||||
PRBool rv;
|
||||
|
||||
event.renderingContext->SetClipRegion(NS_STATIC_CAST(const nsIRegion &, *mUpdateArea),
|
||||
nsClipCombine_kReplace, rv);
|
||||
|
||||
result = DispatchWindowEvent(&event);
|
||||
NS_RELEASE(event.renderingContext);
|
||||
}
|
||||
|
||||
|
||||
mUpdateArea->Subtract(event.rect->x, event.rect->y, event.rect->width, event.rect->height);
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
if (debug_WantPaintFlashing())
|
||||
{
|
||||
|
@ -810,7 +922,7 @@ nsWindow::OnDrawSignal(GdkRectangle * aArea)
|
|||
|
||||
NS_ADDREF(win);
|
||||
|
||||
win->OnPaint(pevent);
|
||||
win->OnDraw(pevent);
|
||||
|
||||
NS_RELEASE(win);
|
||||
|
||||
|
|
|
@ -80,7 +80,9 @@ public:
|
|||
}
|
||||
|
||||
// Utility methods
|
||||
virtual PRBool OnPaint(nsPaintEvent &event);
|
||||
virtual PRBool OnExpose(nsPaintEvent &event);
|
||||
virtual PRBool OnDraw(nsPaintEvent &event);
|
||||
|
||||
PRBool OnKey(nsKeyEvent &aEvent);
|
||||
virtual PRBool OnScroll(nsScrollbarEvent & aEvent, PRUint32 cPos);
|
||||
// in nsWidget now
|
||||
|
|
Загрузка…
Ссылка в новой задаче