Bug 613000: Updates to thebes-layer textures must account for resolution. r=jrmuizel a=b
authorChris Jones <jones.chris.g@gmail.com>
Thu, 09 Dec 2010 16:26:13 -0600
changeset 59030 4df7a503fcb3791902271acb91c473529ac01ff4
parent 59029 eeb76ce515d9c393a3d181622b63b09def96ee7f
child 59031 315b3a3dda0f415d6ad406b94a8346020de03963
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersjrmuizel, b
bugs613000
milestone2.0b8pre
Bug 613000: Updates to thebes-layer textures must account for resolution. r=jrmuizel a=b
gfx/layers/opengl/ThebesLayerOGL.cpp
--- a/gfx/layers/opengl/ThebesLayerOGL.cpp
+++ b/gfx/layers/opengl/ThebesLayerOGL.cpp
@@ -617,18 +617,37 @@ void
 ShadowBufferOGL::Upload(gfxASurface* aUpdate, const nsIntRegion& aUpdated,
                         const nsIntRect& aRect, const nsIntPoint& aRotation)
 {
   nsIntRegion destRegion(aUpdated);
   // aUpdated is in screen coordinates.  Move it so that the layer's
   // top-left is 0,0
   nsIntPoint visTopLeft = mLayer->GetVisibleRegion().GetBounds().TopLeft();
   destRegion.MoveBy(-visTopLeft);
+
+  // |aUpdated|, |aRect|, and |aRotation| are in thebes-layer space,
+  // unadjusted for resolution.  The texture is in device space, so
+  // first we need to map the update params to device space.
+  //
+  // XXX this prematurely commits us to updating rects instead of
+  // regions here.  This will be a perf penalty on platforms that
+  // support region updates.  This is OK for now because the
+  // TextureImage backends we care about need to update contiguous
+  // rects anyway, and would do this conversion internally.  To fix
+  // this, we would need to scale the region instead of its bounds
+  // here.
+  nsIntRect destBounds = destRegion.GetBounds();
+  gfxRect destRect(destBounds.x, destBounds.y, destBounds.width, destBounds.height);
+  destRect.Scale(mLayer->GetXResolution(), mLayer->GetYResolution());
+  destRect.RoundOut();
+
   // NB: this gfxContext must not escape EndUpdate() below
-  nsRefPtr<gfxContext> dest = mTexImage->BeginUpdate(destRegion);
+  nsIntRegion scaledDestRegion(nsIntRect(destRect.pos.x, destRect.pos.y,
+                                         destRect.size.width, destRect.size.height));
+  nsRefPtr<gfxContext> dest = mTexImage->BeginUpdate(scaledDestRegion);
 
   dest->SetOperator(gfxContext::OPERATOR_SOURCE);
   dest->DrawSurface(aUpdate, aUpdate->GetSize());
 
   mTexImage->EndUpdate();
 
   mBufferRect = aRect;
   mBufferRotation = aRotation;