From d3af20fe4df75414481e545847b53f8032abe2de Mon Sep 17 00:00:00 2001 From: seven332 Date: Fri, 24 Jul 2015 16:39:33 +0800 Subject: [PATCH] Fix alpha in TiledTexture --- .../gallery/glrenderer/TiledTexture.java | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/hippo/ehviewer/gallery/glrenderer/TiledTexture.java b/app/src/main/java/com/hippo/ehviewer/gallery/glrenderer/TiledTexture.java index 4e98210e0..779da0d02 100644 --- a/app/src/main/java/com/hippo/ehviewer/gallery/glrenderer/TiledTexture.java +++ b/app/src/main/java/com/hippo/ehviewer/gallery/glrenderer/TiledTexture.java @@ -139,7 +139,6 @@ public class TiledTexture implements Texture { int r = localBitmapRef.getWidth() + x; int b = localBitmapRef.getHeight() + y; sCanvas.drawBitmap(localBitmapRef, x, y, sBitmapPaint); - localBitmapRef = null; // draw borders if need if (x > 0) sCanvas.drawLine(x - 1, 0, x - 1, TILE_SIZE, sPaint); @@ -155,6 +154,11 @@ public class TiledTexture implements Texture { protected void onFreeBitmap(Bitmap bitmap) { // do nothing } + + @Override + public boolean isOpaque() { + return false; + } } private static void freeTile(Tile tile) { @@ -290,6 +294,30 @@ public class TiledTexture implements Texture { } } + public void drawMixed(GLCanvas canvas, int color, float ratio, + RectF source, RectF target) { + RectF src = mSrcRect; + RectF dest = mDestRect; + float x0 = source.left; + float y0 = source.top; + float x = target.left; + float y = target.top; + float scaleX = target.width() / source.width(); + float scaleY = target.height() / source.height(); + + synchronized (mTiles) { + for (int i = 0, n = mTiles.length; i < n; ++i) { + Tile t = mTiles[i]; + src.set(0, 0, t.contentWidth, t.contentHeight); + src.offset(t.offsetX, t.offsetY); + if (!src.intersect(source)) continue; + mapRect(dest, src, x0, y0, x, y, scaleX, scaleY); + src.offset(BORDER_SIZE - t.offsetX, BORDER_SIZE - t.offsetY); + canvas.drawMixed(t, color, ratio, mSrcRect, mDestRect); + } + } + } + // Draws the texture on to the specified rectangle. @Override public void draw(GLCanvas canvas, int x, int y, int width, int height) {