bug 362015. r=vlad. makes us use a region for drawing to avoid painting too much.

This commit is contained in:
pavlov%pavlov.net 2006-11-28 00:11:42 +00:00
Родитель b0e90c0c2c
Коммит ee85b33908
1 изменённых файлов: 25 добавлений и 15 удалений

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

@ -2515,33 +2515,43 @@ NSEvent* globalDragEvent = nil;
nsRefPtr<gfxContext> targetContext = new gfxContext(targetSurface);
nsCOMPtr<nsIRenderingContext> rc;
mGeckoChild->GetDeviceContext()->CreateRenderingContextInstance(*getter_AddRefs(rc));
rc->Init(mGeckoChild->GetDeviceContext(), targetContext);
/* clip and build a region */
nsCOMPtr<nsIRegion> rgn(do_CreateInstance(kRegionCID));
if (rgn)
rgn->Init();
const NSRect *rects;
int count, i;
[self getRectsBeingDrawn:&rects count:&count];
for (i = 0; i < count; ++i) {
targetContext->Rectangle(gfxRect(rects[i].origin.x, rects[i].origin.y,
rects[i].size.width, rects[i].size.height));
const NSRect& r = rects[i];
/* add to the region */
if (rgn)
rgn->Union(r.origin.x, r.origin.y, r.size.width, r.size.height);
/* to the context for clipping */
targetContext->Rectangle(gfxRect(r.origin.x, r.origin.y, r.size.width, r.size.height));
}
targetContext->Clip();
nsCOMPtr<nsIRenderingContext> rc;
mGeckoChild->GetDeviceContext()->CreateRenderingContextInstance(*getter_AddRefs(rc));
rc->Init (mGeckoChild->GetDeviceContext(), targetContext);
nsRect r, tr;
NSRectToGeckoRect(aRect, r);
tr = r;
mGeckoChild->LocalToWindowCoordinate(tr);
//targetContext->Translate(gfxPoint(tr.x, tr.y));
/* bounding box of the dirty area */
nsRect fullRect;
NSRectToGeckoRect(aRect, fullRect);
nsPaintEvent paintEvent(PR_TRUE, NS_PAINT, mGeckoChild);
paintEvent.renderingContext = rc;
paintEvent.rect = &r;
paintEvent.rect = &fullRect;
paintEvent.region = rgn;
mGeckoChild->DispatchWindowEvent(paintEvent);
paintEvent.renderingContext = nsnull;
paintEvent.region = nsnull;
targetContext = nsnull;
targetSurface = nsnull;
@ -2564,8 +2574,8 @@ NSEvent* globalDragEvent = nil;
CGRectMake(aRect.origin.x, aRect.origin.y, aRect.size.width, aRect.size.height));
#endif
#else
#else
/* non-MOZ_CAIRO_GFX */
nsCOMPtr<nsIRegion> rgn(do_CreateInstance(kRegionCID));
if (rgn) {
rgn->Init();