Backout changeset 3db901280232, (Bug 666385) to investigate Mac Tdhtml regression.
authorMarco Bonardo <mbonardo@mozilla.com>
Wed, 17 Aug 2011 22:55:14 +0200
changeset 75436 de9252e8b8f46d84a84d7c89892d5d98252983bd
parent 75435 8fd6d6928229ab2defac3a1e5d7d3618414a0dc6
child 75437 2c5ef30a89b26fc38d88c0848c391e68db8756dd
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
bugs666385
milestone9.0a1
backs out3db9012802323ecc0265e8e4b0418e5f29f355e1
Backout changeset 3db901280232, (Bug 666385) to investigate Mac Tdhtml regression.
gfx/layers/opengl/ThebesLayerOGL.cpp
--- a/gfx/layers/opengl/ThebesLayerOGL.cpp
+++ b/gfx/layers/opengl/ThebesLayerOGL.cpp
@@ -111,17 +111,16 @@ public:
   nsIntSize GetSize() {
     if (mTexImage)
       return mTexImage->GetSize();
     return nsIntSize(0, 0);
   }
 
 protected:
   virtual nsIntPoint GetOriginOffset() = 0;
-  virtual nsIntRect GetBufferRect() = 0;
 
   GLContext* gl() const { return mOGLLayer->gl(); }
 
   ThebesLayer* mLayer;
   LayerOGL* mOGLLayer;
   nsRefPtr<TextureImage> mTexImage;
   nsRefPtr<TextureImage> mTexImageOnWhite;
 };
@@ -193,45 +192,45 @@ ThebesLayerBufferOGL::RenderTo(const nsI
     }
 
     mTexImage->BeginTileIteration();
     if (mTexImageOnWhite) {
       mTexImageOnWhite->BeginTileIteration();
       NS_ASSERTION(mTexImageOnWhite->GetTileRect() == mTexImage->GetTileRect(), "component alpha textures should be the same size.");
     }
     nsIntRegion region(*renderRegion);
+    nsIntPoint origin = GetOriginOffset();
+    region.MoveBy(-origin);           // translate into TexImage space, buffer origin might not be at texture (0,0)
 
-    nsIntPoint origin = GetOriginOffset();
     do {
       nsIntRect textureRect = mTexImage->GetTileRect();
+      textureRect.MoveBy(region.GetBounds().x, region.GetBounds().y);
       nsIntRegion subregion(region);
-      textureRect.MoveBy(GetBufferRect().TopLeft());
-      subregion.And(subregion, textureRect); // region this texture is visible in
+      subregion.And(region, textureRect); // region this texture is visible in
       if (subregion.IsEmpty()) {
         continue;
       }
       // Bind textures.
       TextureImage::ScopedBindTexture texBind(mTexImage, LOCAL_GL_TEXTURE0);
       TextureImage::ScopedBindTexture texOnWhiteBind(mTexImageOnWhite, LOCAL_GL_TEXTURE1);
 
       nsIntRegionRectIterator iter(subregion);
       while (const nsIntRect *iterRect = iter.Next()) {
-        nsIntRect screenRect = *iterRect;
+        nsIntRect regionRect = *iterRect;  // one rectangle of this texture's region
+        // translate into the correct place for this texture sub-region
+        nsIntRect screenRect = regionRect;
+        screenRect.MoveBy(origin);
         program->SetLayerQuadRect(screenRect);
 
-        nsIntRect textureCoord = *iterRect;  // one rectangle of this texture's region
-        textureCoord.MoveBy(-mTexImage->GetTileRect().TopLeft()); // get region of tile
-        textureCoord.MoveBy(-origin); // get region of tile
-
-        aManager->BindAndDrawQuadWithTextureRect(program, textureCoord,
+        regionRect.MoveBy(-mTexImage->GetTileRect().TopLeft()); // get region of tile
+        aManager->BindAndDrawQuadWithTextureRect(program, regionRect,
                                                  textureRect.Size(),
                                                  mTexImage->GetWrapMode());
       }
     } while (mTexImage->NextTile());
-
   }
 
   if (mTexImageOnWhite) {
     // Restore defaults
     gl()->fBlendFuncSeparate(LOCAL_GL_ONE, LOCAL_GL_ONE_MINUS_SRC_ALPHA,
                              LOCAL_GL_ONE, LOCAL_GL_ONE);
   }
 }
@@ -269,20 +268,16 @@ public:
   {
     NS_ASSERTION(gfxASurface::CONTENT_ALPHA != aType,"ThebesBuffer has color");
 
     mTexImage = CreateClampOrRepeatTextureImage(gl(), aSize, aType, aFlags);
     return mTexImage ? mTexImage->GetBackingSurface() : nsnull;
   }
 
 protected:
-  virtual nsIntRect GetBufferRect() {
-    return BufferRect();
-  }
-
   virtual nsIntPoint GetOriginOffset() {
     return BufferRect().TopLeft() - BufferRotation();
   }
 };
 
 
 // This implementation is (currently) the slow-path for when we can't
 // implement pixel retaining using thebes.  This implementation and
@@ -305,20 +300,16 @@ protected:
   enum XSide {
     LEFT, RIGHT
   };
   enum YSide {
     TOP, BOTTOM
   };
   nsIntRect GetQuadrantRectangle(XSide aXSide, YSide aYSide);
 
-  virtual nsIntRect GetBufferRect() {
-    return mBufferRect;
-  }
-
   virtual nsIntPoint GetOriginOffset() {
     return mBufferRect.TopLeft() - mBufferRotation;
   }
 
 private:
   nsIntRect mBufferRect;
   nsIntPoint mBufferRotation;
 };
@@ -768,20 +759,16 @@ public:
     NS_RUNTIMEABORT("can't BeginPaint for a shadow layer");
     return PaintState();
   }
 
   void Upload(gfxASurface* aUpdate, const nsIntRegion& aUpdated,
               const nsIntRect& aRect, const nsIntPoint& aRotation);
 
 protected:
-  virtual nsIntRect GetBufferRect() {
-    return mBufferRect;
-  }
-
   virtual nsIntPoint GetOriginOffset() {
     return mBufferRect.TopLeft() - mBufferRotation;
   }
 
 private:
   nsIntRect mBufferRect;
   nsIntPoint mBufferRotation;
 };