зеркало из https://github.com/mozilla/gecko-dev.git
bug 362015. r=vlad. makes us use a region for drawing to avoid painting too much.
This commit is contained in:
Родитель
b0e90c0c2c
Коммит
ee85b33908
|
@ -2515,33 +2515,43 @@ NSEvent* globalDragEvent = nil;
|
||||||
|
|
||||||
nsRefPtr<gfxContext> targetContext = new gfxContext(targetSurface);
|
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;
|
const NSRect *rects;
|
||||||
int count, i;
|
int count, i;
|
||||||
[self getRectsBeingDrawn:&rects count:&count];
|
[self getRectsBeingDrawn:&rects count:&count];
|
||||||
for (i = 0; i < count; ++i) {
|
for (i = 0; i < count; ++i) {
|
||||||
targetContext->Rectangle(gfxRect(rects[i].origin.x, rects[i].origin.y,
|
const NSRect& r = rects[i];
|
||||||
rects[i].size.width, rects[i].size.height));
|
|
||||||
|
/* 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();
|
targetContext->Clip();
|
||||||
|
|
||||||
nsCOMPtr<nsIRenderingContext> rc;
|
/* bounding box of the dirty area */
|
||||||
mGeckoChild->GetDeviceContext()->CreateRenderingContextInstance(*getter_AddRefs(rc));
|
nsRect fullRect;
|
||||||
rc->Init (mGeckoChild->GetDeviceContext(), targetContext);
|
NSRectToGeckoRect(aRect, fullRect);
|
||||||
|
|
||||||
nsRect r, tr;
|
|
||||||
NSRectToGeckoRect(aRect, r);
|
|
||||||
tr = r;
|
|
||||||
|
|
||||||
mGeckoChild->LocalToWindowCoordinate(tr);
|
|
||||||
//targetContext->Translate(gfxPoint(tr.x, tr.y));
|
|
||||||
|
|
||||||
nsPaintEvent paintEvent(PR_TRUE, NS_PAINT, mGeckoChild);
|
nsPaintEvent paintEvent(PR_TRUE, NS_PAINT, mGeckoChild);
|
||||||
paintEvent.renderingContext = rc;
|
paintEvent.renderingContext = rc;
|
||||||
paintEvent.rect = &r;
|
paintEvent.rect = &fullRect;
|
||||||
|
paintEvent.region = rgn;
|
||||||
|
|
||||||
mGeckoChild->DispatchWindowEvent(paintEvent);
|
mGeckoChild->DispatchWindowEvent(paintEvent);
|
||||||
|
|
||||||
paintEvent.renderingContext = nsnull;
|
paintEvent.renderingContext = nsnull;
|
||||||
|
paintEvent.region = nsnull;
|
||||||
|
|
||||||
targetContext = nsnull;
|
targetContext = nsnull;
|
||||||
targetSurface = nsnull;
|
targetSurface = nsnull;
|
||||||
|
@ -2565,7 +2575,7 @@ NSEvent* globalDragEvent = nil;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
/* non-MOZ_CAIRO_GFX */
|
||||||
nsCOMPtr<nsIRegion> rgn(do_CreateInstance(kRegionCID));
|
nsCOMPtr<nsIRegion> rgn(do_CreateInstance(kRegionCID));
|
||||||
if (rgn) {
|
if (rgn) {
|
||||||
rgn->Init();
|
rgn->Init();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче