Permalink
Browse files

Workaround double blit failure

An issue occurs on Stingray where calling glTexSubImage2d in order to blit an
update to a texture fails silently if the texture has already been updated this
frame.

With this change, we now draw the tile off-screen to work around the issue just
before the second blit is required. This way, the second blit succeeds.

bug:6630040

Change-Id: I07213954669b0f3d3f5b87a748a591e532b097b4
  • Loading branch information...
1 parent 7fc1c09 commit 0c274b96c2dfb5a83b12a99f1ca9069378f73bdb @ChrisCraik ChrisCraik committed Jun 12, 2012
@@ -420,6 +420,14 @@ bool Surface::blitFromContents(Tile* tile)
if (!singleLayer() || !tile || !getFirstLayer() || !getFirstLayer()->content())
return false;
+ if (tile->frontTexture() != tile->lastDrawnTexture()) {
+ // the below works around an issue where glTexSubImage2d can't update a
+ // texture that hasn't drawn yet by drawing it off screen.
+ // glFlush() and glFinish() work also, but are likely more wasteful.
+ SkRect rect = SkRect::MakeXYWH(-100, -100, 0, 0);
+ FloatRect fillPortion(0, 0, 0, 0);
+ tile->frontTexture()->drawGL(false, rect, 1.0f, 0, false, true, fillPortion);
+ }
LayerContent* content = getFirstLayer()->content();
// Extract the dirty rect from the region. Note that this is *NOT* constrained
// to this tile
@@ -52,6 +52,7 @@ Tile::Tile(bool isLayerTile)
, m_y(-1)
, m_frontTexture(0)
, m_backTexture(0)
+ , m_lastDrawnTexture(0)
, m_scale(1)
, m_dirty(true)
, m_repaintsPending(0)
@@ -242,6 +243,7 @@ bool Tile::drawGL(float opacity, const SkRect& rect, float scale,
m_frontTexture->drawGL(isLayerTile(), rect, opacity, transform,
forceBlending, usePointSampling, fillPortion);
+ m_lastDrawnTexture = m_frontTexture;
return true;
}
@@ -127,6 +127,7 @@ class Tile : public TextureOwner {
int y() const { return m_y; }
TileTexture* frontTexture() { return m_frontTexture; }
TileTexture* backTexture() { return m_backTexture; }
+ TileTexture* lastDrawnTexture() { return m_lastDrawnTexture; }
// only used for prioritization - the higher, the more relevant the tile is
unsigned long long drawCount() { return m_drawCount; }
@@ -151,6 +152,7 @@ class Tile : public TextureOwner {
TileTexture* m_frontTexture;
TileTexture* m_backTexture;
+ TileTexture* m_lastDrawnTexture;
float m_scale;
// used to signal that the that the tile is out-of-date and needs to be

0 comments on commit 0c274b9

Please sign in to comment.