Skip to content
Permalink
Browse files

Parent tiles fast rendering option (#1102)

  • Loading branch information...
cpt1gl0 authored and devemux86 committed Feb 19, 2019
1 parent 6a1b229 commit 8245d0f86b96eb1a9481e14230661042a0b5c722
@@ -29,6 +29,9 @@

void drawBitmap(Bitmap bitmap, Matrix matrix, Filter filter);

void drawBitmap(Bitmap bitmap, int srcLeft, int srcTop, int srcRight, int srcBottom,
int dstLeft, int dstTop, int dstRight, int dstBottom, Filter filter);

void drawCircle(int x, int y, int radius, Paint paint);

void drawLine(int x1, int y1, int x2, int y2, Paint paint);
@@ -136,6 +136,21 @@ public void drawBitmap(Bitmap bitmap, Matrix matrix, Filter filter) {
}
}

@Override
public void drawBitmap(Bitmap bitmap, int srcLeft, int srcTop, int srcRight, int srcBottom,
int dstLeft, int dstTop, int dstRight, int dstBottom, Filter filter) {
applyFilter(filter);

this.canvas.drawBitmap(AndroidGraphicFactory.getBitmap(bitmap),
new Rect(srcLeft, srcTop, srcRight, srcBottom),
new Rect(dstLeft, dstTop, dstRight, dstBottom),
this.bitmapPaint);

if (filter != Filter.NONE) {
this.bitmapPaint.setColorFilter(null);
}
}

@Override
public void drawCircle(int x, int y, int radius, Paint paint) {
if (paint.isTransparent()) {
@@ -182,6 +182,15 @@ public void drawBitmap(Bitmap bitmap, Matrix matrix, Filter filter) {
this.graphics2D.drawRenderedImage(applyFilter(AwtGraphicFactory.getBitmap(bitmap), filter), AwtGraphicFactory.getAffineTransform(matrix));
}

@Override
public void drawBitmap(Bitmap bitmap, int srcLeft, int srcTop, int srcRight, int srcBottom,
int dstLeft, int dstTop, int dstRight, int dstBottom, Filter filter) {
this.graphics2D.drawImage(applyFilter(AwtGraphicFactory.getBitmap(bitmap), filter),
dstLeft, dstTop, dstRight, dstBottom,
srcLeft, srcTop, srcRight, srcBottom,
null);
}

@Override
public void drawCircle(int x, int y, int radius, Paint paint) {
if (paint.isTransparent()) {
@@ -166,24 +166,28 @@ private void drawParentTileBitmap(Canvas canvas, Point point, Tile tile) {
int x = (int) Math.round(point.x);
int y = (int) Math.round(point.y);

this.matrix.reset();
this.matrix.translate(x - translateX, y - translateY);
this.matrix.scale(scaleFactor, scaleFactor);

boolean antiAlias = canvas.isAntiAlias();
boolean filterBitmap = canvas.isFilterBitmap();
if (Parameters.PARENT_TILES_RENDERING == Parameters.ParentTilesRendering.SPEED) {
boolean antiAlias = canvas.isAntiAlias();
boolean filterBitmap = canvas.isFilterBitmap();

canvas.setAntiAlias(false);
canvas.setFilterBitmap(false);
}

canvas.setClip(x, y, this.displayModel.getTileSize(), this.displayModel.getTileSize());
canvas.drawBitmap(bitmap, this.matrix, this.displayModel.getFilter());
canvas.resetClip();
canvas.drawBitmap(bitmap,
(int) (translateX / scaleFactor), (int) (translateY / scaleFactor), (int) ((translateX + tileSize) / scaleFactor), (int) ((translateY + tileSize) / scaleFactor),
x, y, x + tileSize, y + tileSize,
this.displayModel.getFilter());

if (Parameters.PARENT_TILES_RENDERING == Parameters.ParentTilesRendering.SPEED) {
canvas.setAntiAlias(antiAlias);
canvas.setFilterBitmap(filterBitmap);
} else {
this.matrix.reset();
this.matrix.translate(x - translateX, y - translateY);
this.matrix.scale(scaleFactor, scaleFactor);

canvas.setClip(x, y, this.displayModel.getTileSize(), this.displayModel.getTileSize());
canvas.drawBitmap(bitmap, this.matrix, this.displayModel.getFilter());
canvas.resetClip();
}

bitmap.decrementRefCount();

0 comments on commit 8245d0f

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.