android/source/src/java/org/mozilla/gecko/gfx/TextLayer.java | 69 --- android/source/src/java/org/mozilla/gecko/gfx/TileLayer.java | 2 android/source/src/java/org/mozilla/gecko/gfx/ViewportMetrics.java | 173 ---------- 3 files changed, 1 insertion(+), 243 deletions(-)
New commits: commit 2546dd1b28855c97fde9994925cf4279371de672 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Jul 19 07:32:28 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Jul 19 18:32:09 2024 +0200 android: Drop unused ViewportMetrics class There's still the `ImmutableViewportMetrics` class that actually gets used. Change-Id: I4645a33812441a2de36d666423742b164da76bda Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170766 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/android/source/src/java/org/mozilla/gecko/gfx/ViewportMetrics.java b/android/source/src/java/org/mozilla/gecko/gfx/ViewportMetrics.java deleted file mode 100644 index f8b5c2e055dc..000000000000 --- a/android/source/src/java/org/mozilla/gecko/gfx/ViewportMetrics.java +++ /dev/null @@ -1,173 +0,0 @@ -/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -package org.mozilla.gecko.gfx; - -import android.graphics.PointF; -import android.graphics.RectF; -import android.util.DisplayMetrics; - -import org.json.JSONException; -import org.json.JSONObject; - -/** - * ViewportMetrics manages state and contains some utility functions related to - * the page viewport for the Gecko layer client to use. - */ -public class ViewportMetrics { - private static final String LOGTAG = "GeckoViewportMetrics"; - - private RectF mPageRect; - private RectF mCssPageRect; - private RectF mViewportRect; - private float mZoomFactor; - - public ViewportMetrics(DisplayMetrics metrics) { - mPageRect = new RectF(0, 0, metrics.widthPixels, metrics.heightPixels); - mCssPageRect = new RectF(0, 0, metrics.widthPixels, metrics.heightPixels); - mViewportRect = new RectF(0, 0, metrics.widthPixels, metrics.heightPixels); - mZoomFactor = 1.0f; - } - - public ViewportMetrics(ViewportMetrics viewport) { - mPageRect = new RectF(viewport.getPageRect()); - mCssPageRect = new RectF(viewport.getCssPageRect()); - mViewportRect = new RectF(viewport.getViewport()); - mZoomFactor = viewport.getZoomFactor(); - } - - public ViewportMetrics(ImmutableViewportMetrics viewport) { - mPageRect = new RectF(viewport.pageRectLeft, - viewport.pageRectTop, - viewport.pageRectRight, - viewport.pageRectBottom); - mCssPageRect = new RectF(viewport.cssPageRectLeft, - viewport.cssPageRectTop, - viewport.cssPageRectRight, - viewport.cssPageRectBottom); - mViewportRect = new RectF(viewport.viewportRectLeft, - viewport.viewportRectTop, - viewport.viewportRectRight, - viewport.viewportRectBottom); - mZoomFactor = viewport.zoomFactor; - } - - public ViewportMetrics(JSONObject json) throws JSONException { - float x = (float)json.getDouble("x"); - float y = (float)json.getDouble("y"); - float width = (float)json.getDouble("width"); - float height = (float)json.getDouble("height"); - float pageLeft = (float)json.getDouble("pageLeft"); - float pageTop = (float)json.getDouble("pageTop"); - float pageRight = (float)json.getDouble("pageRight"); - float pageBottom = (float)json.getDouble("pageBottom"); - float cssPageLeft = (float)json.getDouble("cssPageLeft"); - float cssPageTop = (float)json.getDouble("cssPageTop"); - float cssPageRight = (float)json.getDouble("cssPageRight"); - float cssPageBottom = (float)json.getDouble("cssPageBottom"); - float zoom = (float)json.getDouble("zoom"); - - mPageRect = new RectF(pageLeft, pageTop, pageRight, pageBottom); - mCssPageRect = new RectF(cssPageLeft, cssPageTop, cssPageRight, cssPageBottom); - mViewportRect = new RectF(x, y, x + width, y + height); - mZoomFactor = zoom; - } - - public ViewportMetrics(float x, float y, float width, float height, - float pageLeft, float pageTop, float pageRight, float pageBottom, - float cssPageLeft, float cssPageTop, float cssPageRight, float cssPageBottom, - float zoom) { - mPageRect = new RectF(pageLeft, pageTop, pageRight, pageBottom); - mCssPageRect = new RectF(cssPageLeft, cssPageTop, cssPageRight, cssPageBottom); - mViewportRect = new RectF(x, y, x + width, y + height); - mZoomFactor = zoom; - } - - public PointF getOrigin() { - return new PointF(mViewportRect.left, mViewportRect.top); - } - - public FloatSize getSize() { - return new FloatSize(mViewportRect.width(), mViewportRect.height()); - } - - public RectF getViewport() { - return mViewportRect; - } - - public RectF getCssViewport() { - return RectUtils.scale(mViewportRect, 1/mZoomFactor); - } - - public RectF getPageRect() { - return mPageRect; - } - - public RectF getCssPageRect() { - return mCssPageRect; - } - - public float getZoomFactor() { - return mZoomFactor; - } - - public void setPageRect(RectF pageRect, RectF cssPageRect) { - mPageRect = pageRect; - mCssPageRect = cssPageRect; - } - - public void setViewport(RectF viewport) { - mViewportRect = viewport; - } - - public void setOrigin(PointF origin) { - mViewportRect.set(origin.x, origin.y, - origin.x + mViewportRect.width(), - origin.y + mViewportRect.height()); - } - - public void setSize(FloatSize size) { - mViewportRect.right = mViewportRect.left + size.width; - mViewportRect.bottom = mViewportRect.top + size.height; - } - - public void setZoomFactor(float zoomFactor) { - mZoomFactor = zoomFactor; - } - - public String toJSON() { - // Round off height and width. Since the height and width are the size of the screen, it - // makes no sense to send non-integer coordinates to Gecko. - int height = Math.round(mViewportRect.height()); - int width = Math.round(mViewportRect.width()); - - StringBuffer sb = new StringBuffer(512); - sb.append("{ \"x\" : ").append(mViewportRect.left) - .append(", \"y\" : ").append(mViewportRect.top) - .append(", \"width\" : ").append(width) - .append(", \"height\" : ").append(height) - .append(", \"pageLeft\" : ").append(mPageRect.left) - .append(", \"pageTop\" : ").append(mPageRect.top) - .append(", \"pageRight\" : ").append(mPageRect.right) - .append(", \"pageBottom\" : ").append(mPageRect.bottom) - .append(", \"cssPageLeft\" : ").append(mCssPageRect.left) - .append(", \"cssPageTop\" : ").append(mCssPageRect.top) - .append(", \"cssPageRight\" : ").append(mCssPageRect.right) - .append(", \"cssPageBottom\" : ").append(mCssPageRect.bottom) - .append(", \"zoom\" : ").append(mZoomFactor) - .append(" }"); - return sb.toString(); - } - - @Override - public String toString() { - StringBuffer buff = new StringBuffer(256); - buff.append("v=").append(mViewportRect.toString()) - .append(" p=").append(mPageRect.toString()) - .append(" c=").append(mCssPageRect.toString()) - .append(" z=").append(mZoomFactor); - return buff.toString(); - } -} commit f1a130a87a24ee5da37b51c7ab68c461d736ed37 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Jul 19 07:29:57 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Jul 19 18:32:00 2024 +0200 android: Drop unnecessary semicolon Change-Id: I6e47003e4c890da9c09b23f64a0e2eac24d2e6bd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170765 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/android/source/src/java/org/mozilla/gecko/gfx/TileLayer.java b/android/source/src/java/org/mozilla/gecko/gfx/TileLayer.java index 3d0ff1fede66..2ce47b2dcf95 100644 --- a/android/source/src/java/org/mozilla/gecko/gfx/TileLayer.java +++ b/android/source/src/java/org/mozilla/gecko/gfx/TileLayer.java @@ -28,7 +28,7 @@ public abstract class TileLayer extends Layer { return mImage; } - public enum PaintMode { NORMAL, REPEAT, STRETCH }; + public enum PaintMode { NORMAL, REPEAT, STRETCH } private PaintMode mPaintMode; public TileLayer(CairoImage image, PaintMode paintMode) { commit 2180a868ccfaeb376ad13f8cff8dbdd3b0c5a5cf Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Jul 19 07:28:46 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Jul 19 18:31:54 2024 +0200 android: Drop unused TextLayer class Change-Id: Id4be67dc7c3ac7ad7a820fca6af730c776ec88f8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170764 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/android/source/src/java/org/mozilla/gecko/gfx/TextLayer.java b/android/source/src/java/org/mozilla/gecko/gfx/TextLayer.java deleted file mode 100644 index 023433a888c3..000000000000 --- a/android/source/src/java/org/mozilla/gecko/gfx/TextLayer.java +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -package org.mozilla.gecko.gfx; - -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.Typeface; - -import org.libreoffice.kit.DirectBufferAllocator; - -import java.nio.ByteBuffer; - -/** - * Draws text on a layer. This is used for the frame rate meter. - */ -public class TextLayer extends SingleTileLayer { - private final ByteBuffer mBuffer; // this buffer is owned by the BufferedCairoImage - private final IntSize mSize; - - /* - * This awkward pattern is necessary due to Java's restrictions on when one can call superclass - * constructors. - */ - private TextLayer(ByteBuffer buffer, BufferedCairoImage image, IntSize size, String text) { - super(false, image); - mBuffer = buffer; - mSize = size; - renderText(text); - } - - public static TextLayer create(IntSize size, String text) { - ByteBuffer buffer = DirectBufferAllocator.allocate(size.width * size.height * 4); - BufferedCairoImage image = new BufferedCairoImage(buffer, size.width, size.height, - CairoImage.FORMAT_ARGB32); - return new TextLayer(buffer, image, size, text); - } - - public void setText(String text) { - renderText(text); - invalidate(); - } - - private void renderText(String text) { - Bitmap bitmap = Bitmap.createBitmap(mSize.width, mSize.height, Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(bitmap); - - Paint textPaint = new Paint(); - textPaint.setAntiAlias(true); - textPaint.setColor(Color.WHITE); - textPaint.setFakeBoldText(true); - textPaint.setTextSize(18.0f); - textPaint.setTypeface(Typeface.DEFAULT_BOLD); - float width = textPaint.measureText(text) + 18.0f; - - Paint backgroundPaint = new Paint(); - backgroundPaint.setColor(Color.argb(127, 0, 0, 0)); - canvas.drawRect(0.0f, 0.0f, width, 18.0f + 6.0f, backgroundPaint); - - canvas.drawText(text, 6.0f, 18.0f, textPaint); - - bitmap.copyPixelsToBuffer(mBuffer.asIntBuffer()); - } -} -