bug 360013. draw using the region rather than the union rect. r=josh sr=vlad

This commit is contained in:
pavlov%pavlov.net 2006-11-09 22:58:11 +00:00
Родитель e5aa498240
Коммит c8e33c6c45
2 изменённых файлов: 26 добавлений и 16 удалений

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

@ -246,7 +246,7 @@ public:
#ifndef MOZ_CAIRO_GFX #ifndef MOZ_CAIRO_GFX
virtual void StartDraw(nsIRenderingContext* aRenderingContext = nsnull); virtual void StartDraw(nsIRenderingContext* aRenderingContext = nsnull);
virtual void EndDraw(); virtual void EndDraw();
void UpdateWidget(nsRect& aRect, nsIRenderingContext* aContext); void UpdateWidget(nsRect& aRect, nsIRenderingContext* aContext, nsIRegion *aRegion);
#endif #endif
NS_IMETHOD Update(); NS_IMETHOD Update();

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

@ -58,10 +58,16 @@
#include "nsIScrollableView.h" #include "nsIScrollableView.h"
#include "nsIInterfaceRequestor.h" #include "nsIInterfaceRequestor.h"
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
#include "nsGfxCIID.h"
#include "nsMacResources.h"
#include "nsDragService.h" #include "nsDragService.h"
#import "nsCursorManager.h" #import "nsCursorManager.h"
#import "nsWindowMap.h" #import "nsWindowMap.h"
static NS_DEFINE_CID(kRegionCID, NS_REGION_CID);
#ifdef MOZ_CAIRO_GFX #ifdef MOZ_CAIRO_GFX
#include "gfxContext.h" #include "gfxContext.h"
#include "gfxQuartzSurface.h" #include "gfxQuartzSurface.h"
@ -1410,7 +1416,7 @@ NS_IMETHODIMP nsChildView::Update()
// because the display system will take care of that for us. // because the display system will take care of that for us.
// //
void void
nsChildView::UpdateWidget(nsRect& aRect, nsIRenderingContext* aContext) nsChildView::UpdateWidget(nsRect& aRect, nsIRenderingContext* aContext, nsIRegion *aRegion)
{ {
if (! mVisible) if (! mVisible)
return; return;
@ -1427,6 +1433,7 @@ nsChildView::UpdateWidget(nsRect& aRect, nsIRenderingContext* aContext)
nsPaintEvent paintEvent(PR_TRUE, NS_PAINT, this); nsPaintEvent paintEvent(PR_TRUE, NS_PAINT, this);
paintEvent.renderingContext = aContext; // nsPaintEvent paintEvent.renderingContext = aContext; // nsPaintEvent
paintEvent.rect = &aRect; paintEvent.rect = &aRect;
paintEvent.region = aRegion;
// offscreen drawing is pointless. // offscreen drawing is pointless.
if (paintEvent.rect->x < 0) if (paintEvent.rect->x < 0)
@ -2517,11 +2524,6 @@ NSEvent* globalDragEvent = nil;
nsRefPtr<gfxContext> targetContext = new gfxContext(targetSurface); nsRefPtr<gfxContext> targetContext = new gfxContext(targetSurface);
#if 0
targetContext->Rectangle(gfxRect(aRect.origin.x, aRect.origin.y,
aRect.size.width, aRect.size.height));
targetContext->Clip();
#else
const NSRect *rects; const NSRect *rects;
int count, i; int count, i;
[self getRectsBeingDrawn:&rects count:&count]; [self getRectsBeingDrawn:&rects count:&count];
@ -2530,7 +2532,6 @@ NSEvent* globalDragEvent = nil;
rects[i].size.width, rects[i].size.height)); rects[i].size.width, rects[i].size.height));
} }
targetContext->Clip(); targetContext->Clip();
#endif
nsCOMPtr<nsIRenderingContext> rc; nsCOMPtr<nsIRenderingContext> rc;
mGeckoChild->GetDeviceContext()->CreateRenderingContextInstance(*getter_AddRefs(rc)); mGeckoChild->GetDeviceContext()->CreateRenderingContextInstance(*getter_AddRefs(rc));
@ -2573,16 +2574,25 @@ NSEvent* globalDragEvent = nil;
#endif #endif
#else #else
// tell gecko to paint.
const NSRect *rects; nsCOMPtr<nsIRegion> rgn(do_CreateInstance(kRegionCID));
int count, i; if (rgn) {
[self getRectsBeingDrawn:&rects count:&count]; rgn->Init();
for (i = 0; i < count; ++i) {
nsRect r; nsRect r;
NSRectToGeckoRect(rects[i], r); const NSRect *rects;
nsCOMPtr<nsIRenderingContext> rendContext = getter_AddRefs(mGeckoChild->GetRenderingContext()); int count, i;
mGeckoChild->UpdateWidget(r, rendContext); [self getRectsBeingDrawn:&rects count:&count];
for (i = 0; i < count; ++i) {
NSRectToGeckoRect(rects[i], r);
rgn->Union(r.x, r.y, r.width, r.height);
}
} }
nsRect fullRect;
NSRectToGeckoRect(aRect, fullRect);
nsCOMPtr<nsIRenderingContext> rendContext = getter_AddRefs(mGeckoChild->GetRenderingContext());
mGeckoChild->UpdateWidget(fullRect, rendContext, rgn);
#endif #endif
} }