mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 717283 - Store sub-tile metrics on the tile object. r=pcwalton
Instead of deriving sub-tile metrics on each iteration, create a SingleTileLayer sub-class and store them there.
This commit is contained in:
parent
15262f5688
commit
e089f6c80c
@ -59,7 +59,7 @@ public class MultiTileLayer extends Layer {
|
|||||||
private final CairoImage mImage;
|
private final CairoImage mImage;
|
||||||
private IntSize mTileSize;
|
private IntSize mTileSize;
|
||||||
private IntSize mBufferSize;
|
private IntSize mBufferSize;
|
||||||
private final ArrayList<SingleTileLayer> mTiles;
|
private final ArrayList<SubTile> mTiles;
|
||||||
|
|
||||||
public MultiTileLayer(CairoImage image, IntSize tileSize) {
|
public MultiTileLayer(CairoImage image, IntSize tileSize) {
|
||||||
super();
|
super();
|
||||||
@ -67,33 +67,26 @@ public class MultiTileLayer extends Layer {
|
|||||||
mImage = image;
|
mImage = image;
|
||||||
mTileSize = tileSize;
|
mTileSize = tileSize;
|
||||||
mBufferSize = new IntSize(0, 0);
|
mBufferSize = new IntSize(0, 0);
|
||||||
mTiles = new ArrayList<SingleTileLayer>();
|
mTiles = new ArrayList<SubTile>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void invalidate(Rect dirtyRect) {
|
public void invalidate(Rect dirtyRect) {
|
||||||
if (!inTransaction())
|
if (!inTransaction())
|
||||||
throw new RuntimeException("invalidate() is only valid inside a transaction");
|
throw new RuntimeException("invalidate() is only valid inside a transaction");
|
||||||
|
|
||||||
int x = 0, y = 0;
|
for (SubTile layer : mTiles) {
|
||||||
IntSize size = getSize();
|
IntSize tileSize = layer.getSize();
|
||||||
for (SingleTileLayer layer : mTiles) {
|
Rect tileRect = new Rect(layer.x, layer.y, layer.x + tileSize.width, layer.y + tileSize.height);
|
||||||
Rect tileRect = new Rect(x, y, x + mTileSize.width, y + mTileSize.height);
|
|
||||||
|
|
||||||
if (tileRect.intersect(dirtyRect)) {
|
if (tileRect.intersect(dirtyRect)) {
|
||||||
tileRect.offset(-x, -y);
|
tileRect.offset(-layer.x, -layer.y);
|
||||||
layer.invalidate(tileRect);
|
layer.invalidate(tileRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
x += mTileSize.width;
|
|
||||||
if (x >= size.width) {
|
|
||||||
x = 0;
|
|
||||||
y += mTileSize.height;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void invalidate() {
|
public void invalidate() {
|
||||||
for (SingleTileLayer layer : mTiles)
|
for (SubTile layer : mTiles)
|
||||||
layer.invalidate();
|
layer.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +141,7 @@ public class MultiTileLayer extends Layer {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
mTiles.add(new SingleTileLayer(subImage));
|
mTiles.add(new SubTile(subImage, x, y));
|
||||||
offset += layerSize.getArea() * bpp;
|
offset += layerSize.getArea() * bpp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -168,8 +161,8 @@ public class MultiTileLayer extends Layer {
|
|||||||
// Iterate over the tiles and decide which ones we'll be drawing
|
// Iterate over the tiles and decide which ones we'll be drawing
|
||||||
int dirtyTiles = 0;
|
int dirtyTiles = 0;
|
||||||
boolean screenUpdateDone = false;
|
boolean screenUpdateDone = false;
|
||||||
SingleTileLayer firstDirtyTile = null;
|
SubTile firstDirtyTile = null;
|
||||||
for (SingleTileLayer layer : mTiles) {
|
for (SubTile layer : mTiles) {
|
||||||
// First do a non-texture update to make sure coordinates are
|
// First do a non-texture update to make sure coordinates are
|
||||||
// up-to-date.
|
// up-to-date.
|
||||||
boolean invalid = layer.getSkipTextureUpdate();
|
boolean invalid = layer.getSkipTextureUpdate();
|
||||||
@ -216,25 +209,18 @@ public class MultiTileLayer extends Layer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void refreshTileMetrics(Point origin, float resolution, boolean inTransaction) {
|
private void refreshTileMetrics(Point origin, float resolution, boolean inTransaction) {
|
||||||
int x = 0, y = 0;
|
|
||||||
IntSize size = getSize();
|
IntSize size = getSize();
|
||||||
for (SingleTileLayer layer : mTiles) {
|
for (SubTile layer : mTiles) {
|
||||||
if (!inTransaction)
|
if (!inTransaction)
|
||||||
layer.beginTransaction(null);
|
layer.beginTransaction(null);
|
||||||
|
|
||||||
if (origin != null)
|
if (origin != null)
|
||||||
layer.setOrigin(new Point(origin.x + x, origin.y + y));
|
layer.setOrigin(new Point(origin.x + layer.x, origin.y + layer.y));
|
||||||
if (resolution >= 0.0f)
|
if (resolution >= 0.0f)
|
||||||
layer.setResolution(resolution);
|
layer.setResolution(resolution);
|
||||||
|
|
||||||
if (!inTransaction)
|
if (!inTransaction)
|
||||||
layer.endTransaction();
|
layer.endTransaction();
|
||||||
|
|
||||||
x += mTileSize.width;
|
|
||||||
if (x >= size.width) {
|
|
||||||
x = 0;
|
|
||||||
y += mTileSize.height;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,13 +240,13 @@ public class MultiTileLayer extends Layer {
|
|||||||
public void beginTransaction(LayerView aView) {
|
public void beginTransaction(LayerView aView) {
|
||||||
super.beginTransaction(aView);
|
super.beginTransaction(aView);
|
||||||
|
|
||||||
for (SingleTileLayer layer : mTiles)
|
for (SubTile layer : mTiles)
|
||||||
layer.beginTransaction(aView);
|
layer.beginTransaction(aView);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void endTransaction() {
|
public void endTransaction() {
|
||||||
for (SingleTileLayer layer : mTiles)
|
for (SubTile layer : mTiles)
|
||||||
layer.endTransaction();
|
layer.endTransaction();
|
||||||
|
|
||||||
super.endTransaction();
|
super.endTransaction();
|
||||||
@ -268,7 +254,7 @@ public class MultiTileLayer extends Layer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(RenderContext context) {
|
public void draw(RenderContext context) {
|
||||||
for (SingleTileLayer layer : mTiles) {
|
for (SubTile layer : mTiles) {
|
||||||
// We use the SkipTextureUpdate flag as a validity flag. If it's false,
|
// We use the SkipTextureUpdate flag as a validity flag. If it's false,
|
||||||
// the contents of this tile are invalid and we shouldn't draw it.
|
// the contents of this tile are invalid and we shouldn't draw it.
|
||||||
if (layer.getSkipTextureUpdate())
|
if (layer.getSkipTextureUpdate())
|
||||||
@ -280,5 +266,16 @@ public class MultiTileLayer extends Layer {
|
|||||||
layer.draw(context);
|
layer.draw(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class SubTile extends SingleTileLayer {
|
||||||
|
public int x;
|
||||||
|
public int y;
|
||||||
|
|
||||||
|
public SubTile(CairoImage mImage, int mX, int mY) {
|
||||||
|
super(mImage);
|
||||||
|
x = mX;
|
||||||
|
y = mY;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user