Bug 417967. Align subframe drawing so that drawing at (0,0) relative to the root view's origin is aligned to a pixel boundary. r+sr=bzbarsky

This commit is contained in:
roc+%cs.cmu.edu 2008-02-25 01:39:35 +00:00
Родитель 2b0742da25
Коммит a7b501ed08
4 изменённых файлов: 28 добавлений и 7 удалений

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

@ -658,9 +658,10 @@ public:
void OptimizeVisibility(nsDisplayListBuilder* aBuilder, nsRegion* aVisibleRegion); void OptimizeVisibility(nsDisplayListBuilder* aBuilder, nsRegion* aVisibleRegion);
/** /**
* Paint the list to the rendering context. We assume that (0,0) in aCtx * Paint the list to the rendering context. We assume that (0,0) in aCtx
* corresponds to the origin of the reference frame. The rectangle in * corresponds to the origin of the reference frame. For best results,
* aDirtyRect is painted, which *must* be contained in the dirty rect * aCtx's current transform should make (0,0) pixel-aligned. The
* used to construct the display list. * rectangle in aDirtyRect is painted, which *must* be contained in the
* dirty rect used to construct the display list.
*/ */
void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx, void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx,
const nsRect& aDirtyRect) const; const nsRect& aDirtyRect) const;

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

@ -394,7 +394,8 @@ public:
* Given aFrame, the root frame of a stacking context, paint it and its * Given aFrame, the root frame of a stacking context, paint it and its
* descendants to aRenderingContext. * descendants to aRenderingContext.
* @param aRenderingContext a rendering context translated so that (0,0) * @param aRenderingContext a rendering context translated so that (0,0)
* is the origin of aFrame * is the origin of aFrame; for best results, (0,0) should transform
* to pixel-aligned coordinates
* @param aDirtyRegion the region that must be painted, in the coordinates * @param aDirtyRegion the region that must be painted, in the coordinates
* of aFrame * of aFrame
* @param aBackground paint the dirty area with this color before drawing * @param aBackground paint the dirty area with this color before drawing

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

@ -59,7 +59,10 @@ public:
/* called when the observer needs to paint. This paints the entire /* called when the observer needs to paint. This paints the entire
* frame subtree rooted at the view, including frame subtrees from * frame subtree rooted at the view, including frame subtrees from
* subdocuments. * subdocuments.
* @param aRenderingContext rendering context to paint to * @param aRenderingContext rendering context to paint to; the origin
* of the view is painted at (0,0) in the rendering context's current
* transform. For best results this should transform to pixel-aligned
* coordinates.
* @param aDirtyRegion the region to be painted, in the coordinates of aRootView * @param aDirtyRegion the region to be painted, in the coordinates of aRootView
* @return error status * @return error status
*/ */

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

@ -597,8 +597,24 @@ void nsViewManager::RenderViews(nsView *aView, nsIRenderingContext& aRC,
nsRegion damageRegion(aRegion); nsRegion damageRegion(aRegion);
damageRegion.MoveBy(offsetToRoot); damageRegion.MoveBy(offsetToRoot);
gfxContext* ctx = aRC.ThebesContext();
nsCOMPtr<nsIDeviceContext> dc;
aRC.GetDeviceContext(*getter_AddRefs(dc));
double appPerDev = dc->AppUnitsPerDevPixel();
gfxRect r(-offsetToRoot.x/appPerDev, -offsetToRoot.y/appPerDev, 1.0, 1.0);
aRC.PushState(); aRC.PushState();
// Translate by the pixel-snapped offsetToRoot so that aRC's (0,0) will
// be aligned to pixel boundaries. We use gfx pixel-snapping here to
// ensure that the snapping we do here is consistent with other gfx
// snapping. For example if someone drew a border around the outside
// of aView, we want our (0,0) to be the inside top-left of that
// border.
if (ctx->UserToDevicePixelSnapped(r)) {
ctx->Translate(ctx->DeviceToUser(r).pos);
} else {
aRC.Translate(-offsetToRoot.x, -offsetToRoot.y); aRC.Translate(-offsetToRoot.x, -offsetToRoot.y);
}
mObserver->Paint(displayRoot, &aRC, damageRegion); mObserver->Paint(displayRoot, &aRC, damageRegion);
aRC.PopState(); aRC.PopState();
} }