Bug 666385 - Fix tiled scrolling on Android; r=roc
--- a/gfx/layers/opengl/ThebesLayerOGL.cpp
+++ b/gfx/layers/opengl/ThebesLayerOGL.cpp
@@ -111,16 +111,17 @@ 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;
};
@@ -192,45 +193,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)
-
do {
nsIntRect textureRect = mTexImage->GetTileRect();
- textureRect.MoveBy(region.GetBounds().x, region.GetBounds().y);
nsIntRegion subregion(region);
- subregion.And(region, textureRect); // region this texture is visible in
+ textureRect.MoveBy(GetBufferRect().TopLeft());
+ subregion.And(subregion, 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 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);
+ nsIntRect screenRect = *iterRect;
program->SetLayerQuadRect(screenRect);
- regionRect.MoveBy(-mTexImage->GetTileRect().TopLeft()); // get region of tile
- aManager->BindAndDrawQuadWithTextureRect(program, regionRect,
+ 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,
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);
}
}
@@ -268,16 +269,20 @@ 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
@@ -300,16 +305,20 @@ 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;
};
@@ -759,16 +768,20 @@ 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;
};