diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2014-07-02 11:11:56 +0200 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2014-07-02 11:14:17 +0200 |
commit | b8ce647194c3c0f715296bee540ff18cfefa3497 (patch) | |
tree | c8c04ac5deb9f2f209c26f1d0cdbfd7ce338cfc5 /android/experimental | |
parent | c5777b4edd971463b7ccf667a448015f6bb17b3f (diff) |
LOAndroid3: add tiled rendering from document - one tile first
Change-Id: Ib9c27cc8fcc9aee8670c217a4a5ab84bd3035577
Diffstat (limited to 'android/experimental')
10 files changed, 236 insertions, 631 deletions
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java index ea3472b8c52c..abcbe650071e 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java @@ -6,6 +6,7 @@ import android.graphics.Color; import android.graphics.Paint; import android.graphics.Rect; import android.util.JsonWriter; +import android.util.Log; import org.mozilla.gecko.gfx.ViewportMetrics; @@ -15,72 +16,110 @@ import java.nio.ByteBuffer; import java.util.Random; import java.util.concurrent.ConcurrentLinkedQueue; +import org.libreoffice.kit.LibreOfficeKit; +import org.libreoffice.kit.Office; +import org.libreoffice.kit.Document; + public class LOKitThread extends Thread { private static final String LOGTAG = "GeckoThread"; + private static final int TILE_SIZE = 256; + + public Office mOffice; + public Document mDocument; public ConcurrentLinkedQueue<LOEvent> gEvents = new ConcurrentLinkedQueue<LOEvent>(); private ViewportMetrics mViewportMetrics; - private Random rand = new Random(); LOKitThread() { } - private boolean draw() throws InterruptedException { + private void openDocument() { + // enable debugging messages as the first thing + LibreOfficeKit.putenv("SAL_LOG=+WARN+INFO-INFO.legacy.osl-INFO.i18nlangtag"); + LibreOfficeKit.init(LibreOfficeMainActivity.mAppContext); + + mOffice = new Office(LibreOfficeKit.getLibreOfficeKitHandle()); + String input = "/assets/test1.odt"; + mDocument = mOffice.documentLoad(input); + } + + private synchronized boolean draw() throws InterruptedException { final LibreOfficeMainActivity application = LibreOfficeMainActivity.mAppContext; - Bitmap bitmap = application.getLayerClient().getLayerController().getDrawable("docu"); - //bitmap = convert(bitmap, Bitmap.Config.ARGB_8888); + openDocument(); + + long height = mDocument.getDocumentHeight(); + long width = mDocument.getDocumentWidth(); + + Log.e(LOGTAG, "Document Size: " + width + " " + height); + + int pageWidth = 1024; + int pageHeight = 1024; + + String metadata = createJson(0, 0, 256, 256, pageWidth, pageHeight, 0, 0, 1.0); + + Rect bufferRect = application.getLayerClient().beginDrawing(256, 256, TILE_SIZE, TILE_SIZE, metadata); + + /*if (bufferRect == null) { + Log.e(LOGTAG, "beginDrawing - false"); + return false; + }*/ + + Log.e(LOGTAG, "Filling tiles.."); + + ByteBuffer buffer = ByteBuffer.allocateDirect(TILE_SIZE * TILE_SIZE * 4); + + Log.e(LOGTAG, "PaintTile.."); + + mDocument.paintTile(buffer, 256, 256, 1024, 1024, 4096, 4096); + + Log.e(LOGTAG, "EndPaintTile.."); - StringWriter stringWriter = new StringWriter(); + Bitmap bitmap = Bitmap.createBitmap(TILE_SIZE, TILE_SIZE, Bitmap.Config.ARGB_8888); + bitmap.copyPixelsFromBuffer(buffer); + application.getLayerClient().addTile(bitmap, 0, 0); + + Log.e(LOGTAG, "EndDrawing.."); + application.getLayerClient().endDrawing(0, 0, 256, 256); + + return true; + } + + private String createJson(ViewportMetrics viewportMetrics) { + return createJson( + (int) viewportMetrics.getOrigin().x, + (int) viewportMetrics.getOrigin().y, + (int) viewportMetrics.getSize().width, + (int) viewportMetrics.getSize().height, + (int) viewportMetrics.getPageSize().width, + (int) viewportMetrics.getPageSize().height, + (int) viewportMetrics.getViewportOffset().x, + (int) viewportMetrics.getViewportOffset().y, + viewportMetrics.getZoomFactor()); + } + + private String createJson(int x, int y, int width, int height, int pageWidth, int pageHeight, int offsetX, int offsetY, double zoom) { try { + StringWriter stringWriter = new StringWriter(); JsonWriter writer = new JsonWriter(stringWriter); writer.beginObject(); - if (mViewportMetrics == null) { - writer.name("x").value(0); - writer.name("y").value(0); - writer.name("width").value(bitmap.getWidth()); - writer.name("height").value(bitmap.getHeight()); - writer.name("pageWidth").value(bitmap.getWidth()); - writer.name("pageHeight").value(bitmap.getHeight()); - writer.name("offsetX").value(0); - writer.name("offsetY").value(0); - writer.name("zoom").value(0.5); - } else { - writer.name("x").value(mViewportMetrics.getOrigin().x); - writer.name("y").value(mViewportMetrics.getOrigin().y); - writer.name("width").value(mViewportMetrics.getSize().width); - writer.name("height").value(mViewportMetrics.getSize().height); - writer.name("pageWidth").value(mViewportMetrics.getPageSize().width); - writer.name("pageHeight").value(mViewportMetrics.getPageSize().height); - writer.name("offsetX").value(mViewportMetrics.getViewportOffset().x); - writer.name("offsetY").value(mViewportMetrics.getViewportOffset().y); - writer.name("zoom").value(mViewportMetrics.getZoomFactor()); - } + writer.name("x").value(x); + writer.name("y").value(y); + writer.name("width").value(width); + writer.name("height").value(height); + writer.name("pageWidth").value(pageWidth); + writer.name("pageHeight").value(pageHeight); + writer.name("offsetX").value(offsetX); + writer.name("offsetY").value(offsetY); + writer.name("zoom").value(zoom); writer.name("backgroundColor").value("rgb(255,255,255)"); writer.endObject(); writer.close(); + return stringWriter.toString(); } catch (IOException ex) { } - - Rect bufferRect = application.getLayerClient().beginDrawing(bitmap.getWidth(), bitmap.getHeight(), 256, 256, stringWriter.toString(), false); - - if (bufferRect == null) { - return false; - } - ByteBuffer buffer = application.getLayerClient().lockBuffer(); - bitmap.copyPixelsToBuffer(buffer.asIntBuffer()); - application.getLayerClient().unlockBuffer(); - - application.getLayerClient().endDrawing(0, 0, bitmap.getWidth(), bitmap.getHeight()); - - application.runOnUiThread(new Runnable() { - @Override - public void run() { - application.getLayerClient().handleMessage("Viewport:UpdateLater", null); - } - }); - return true; + return null; } private short convertTo16Bit(int color) { @@ -111,14 +150,15 @@ public class LOKitThread extends Thread { if (!drawn) { drawn = draw(); } - Thread.sleep(100L); + Thread.sleep(2000L); } } } catch (InterruptedException ex) { + } } - private void processEvent(LOEvent event) throws InterruptedException { + private synchronized void processEvent(LOEvent event) throws InterruptedException { switch (event.mType) { case LOEvent.VIEWPORT: mViewportMetrics = event.getViewport(); diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java index dc5242e80a95..a3144e16440e 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java @@ -18,15 +18,6 @@ import org.mozilla.gecko.gfx.GeckoSoftwareLayerClient; import org.mozilla.gecko.gfx.LayerController; import org.mozilla.gecko.gfx.LayerView; -import org.libreoffice.kit.LibreOfficeKit; -import org.libreoffice.kit.Office; -import org.libreoffice.kit.Document; - -import com.sun.star.frame.XComponentLoader; -import com.sun.star.lang.XMultiComponentFactory; -import com.sun.star.uno.XComponentContext; -import com.sun.star.uno.UnoRuntime; - public class LibreOfficeMainActivity extends Activity { private static final String LOGTAG = "LibreOfficeMainActivity"; @@ -37,10 +28,6 @@ public class LibreOfficeMainActivity extends Activity { private static GeckoSoftwareLayerClient mLayerClient; private static LOKitThread sLOKitThread; - private XComponentContext context; - private XMultiComponentFactory mcf; - private XComponentLoader componentLoader; - public static LibreOfficeMainActivity mAppContext; @Override @@ -77,26 +64,6 @@ public class LibreOfficeMainActivity extends Activity { super.onCreate(savedInstanceState); - try { - // enable debugging messages as the first thing - LibreOfficeKit.putenv("SAL_LOG=+WARN+INFO-INFO.legacy.osl-INFO.i18nlangtag"); - LibreOfficeKit.init(this); - - Office office = new Office(LibreOfficeKit.getLibreOfficeKitHandle()); - - //File file = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS); - //String input = file.getPath() + "/test.odt"; - String input = "/assets/test1.odt"; - Document document = office.documentLoad(input); - if (document == null) { - Log.w(LOGTAG, "LOK Document error:" + office.getErrorNative()); - } - - } catch (Exception e) { - e.printStackTrace(System.err); - finish(); - } - setContentView(R.layout.activity_main); Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - onCreate"); diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/BufferedCairoImage.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/BufferedCairoImage.java index b6c397767619..2ffe11329f85 100644 --- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/BufferedCairoImage.java +++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/BufferedCairoImage.java @@ -71,7 +71,7 @@ public class BufferedCairoImage extends CairoImage { mSize = new IntSize(bitmap.getWidth(), bitmap.getHeight()); mNeedToFreeBuffer = true; // XXX Why is this * 4? Shouldn't it depend on mFormat? - mBuffer = /*GeckoAppShell*/LOKitShell.allocateDirectBuffer(mSize.getArea() * 4); + mBuffer = LOKitShell.allocateDirectBuffer(mSize.getArea() * 4); bitmap.copyPixelsToBuffer(mBuffer.asIntBuffer()); } @@ -79,7 +79,7 @@ public class BufferedCairoImage extends CairoImage { protected void finalize() throws Throwable { try { if (mNeedToFreeBuffer && mBuffer != null) - /*GeckoAppShell*/ LOKitShell.freeDirectBuffer(mBuffer); + LOKitShell.freeDirectBuffer(mBuffer); mNeedToFreeBuffer = false; mBuffer = null; } finally { diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoGLLayerClient.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoGLLayerClient.java deleted file mode 100644 index 9e4f376e7ad2..000000000000 --- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoGLLayerClient.java +++ /dev/null @@ -1,265 +0,0 @@ -/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Android code. - * - * The Initial Developer of the Original Code is Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2009-2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Patrick Walton <pcwalton@mozilla.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -package org.mozilla.gecko.gfx; - - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.Point; -import android.graphics.PointF; -import android.graphics.Rect; -import android.util.Log; -import android.view.View; - -import org.libreoffice.LOEvent; -import org.libreoffice.LOKitShell; - -public class GeckoGLLayerClient extends GeckoLayerClient - implements FlexibleGLSurfaceView.Listener, VirtualLayer.Listener { - private static final String LOGTAG = "GeckoGLLayerClient"; - - private LayerRenderer mLayerRenderer; - private boolean mLayerRendererInitialized; - - public GeckoGLLayerClient(Context context) { - super(context); - } - - @Override - public Rect beginDrawing(int width, int height, int tileWidth, int tileHeight, - String metadata, boolean hasDirectTexture) { - Rect bufferRect = super.beginDrawing(width, height, tileWidth, tileHeight, - metadata, hasDirectTexture); - if (bufferRect == null) { - return null; - } - - // Be sure to adjust the buffer size; if it's not at least as large as the viewport size, - // ViewportMetrics.getOptimumViewportOffset() gets awfully confused and severe display - // corruption results! - if (mBufferSize.width != width || mBufferSize.height != height) { - mBufferSize = new IntSize(width, height); - } - - return bufferRect; - } - - @Override - protected boolean handleDirectTextureChange(boolean hasDirectTexture) { - Log.e(LOGTAG, "### handleDirectTextureChange"); - if (mTileLayer != null) { - return false; - } - - Log.e(LOGTAG, "### Creating virtual layer"); - VirtualLayer virtualLayer = new VirtualLayer(); - virtualLayer.setListener(this); - virtualLayer.setSize(getBufferSize()); - getLayerController().setRoot(virtualLayer); - mTileLayer = virtualLayer; - - sendResizeEventIfNecessary(true); - return true; - } - - @Override - public void setLayerController(LayerController layerController) { - super.setLayerController(layerController); - - LayerView view = layerController.getView(); - view.setListener(this); - - mLayerRenderer = new LayerRenderer(view); - } - - @Override - protected boolean shouldDrawProceed(int tileWidth, int tileHeight) { - Log.e(LOGTAG, "### shouldDrawProceed"); - // Always draw. - return true; - } - - @Override - protected void updateLayerAfterDraw(Rect updatedRect) { - Log.e(LOGTAG, "### updateLayerAfterDraw"); - // Nothing to do. - } - - @Override - protected IntSize getBufferSize() { - View view = (View) getLayerController().getView(); - IntSize size = new IntSize(view.getWidth(), view.getHeight()); - Log.e(LOGTAG, "### getBufferSize " + size); - return size; - } - - @Override - protected IntSize getTileSize() { - Log.e(LOGTAG, "### getTileSize " + getBufferSize()); - return getBufferSize(); - } - - @Override - protected void tileLayerUpdated() { - // Set the new origin and resolution instantly. - mTileLayer.performUpdates(null); - } - - @Override - public Bitmap getBitmap() { - Log.e(LOGTAG, "### getBitmap"); - IntSize size = getBufferSize(); - try { - return Bitmap.createBitmap(size.width, size.height, Bitmap.Config.RGB_565); - } catch (OutOfMemoryError oom) { - Log.e(LOGTAG, "Unable to create bitmap", oom); - return null; - } - } - - @Override - public int getType() { - Log.e(LOGTAG, "### getType"); - return LAYER_CLIENT_TYPE_GL; - } - - public void dimensionsChanged(Point newOrigin, float newResolution) { - Log.e(LOGTAG, "### dimensionsChanged " + newOrigin + " " + newResolution); - } - - /* Informs Gecko that the screen size has changed. */ - @Override - protected void sendResizeEventIfNecessary(boolean force) { - Log.e(LOGTAG, "### sendResizeEventIfNecessary " + force); - - IntSize newSize = getBufferSize(); - if (!force && mScreenSize != null && mScreenSize.equals(newSize)) { - return; - } - - mScreenSize = newSize; - - Log.e(LOGTAG, "### Screen-size changed to " + mScreenSize); - //GeckoEvent event = GeckoEvent.createSizeChangedEvent(mScreenSize.width, mScreenSize.height, - // mScreenSize.width, mScreenSize.height, - // mScreenSize.width, mScreenSize.height); - //GeckoAppShell.sendEventToGecko(event); - LOEvent event = LOEvent.sizeChanged(mScreenSize.width, mScreenSize.height, - mScreenSize.width, mScreenSize.height, - mScreenSize.width, mScreenSize.height); - LOKitShell.sendEvent(event); - - } - - /** - * For Gecko to use. - */ - public ViewTransform getViewTransform() { - Log.e(LOGTAG, "### getViewTransform()"); - - // NB: We don't begin a transaction here because this can be called in a synchronous - // manner between beginDrawing() and endDrawing(), and that will cause a deadlock. - - LayerController layerController = getLayerController(); - synchronized (layerController) { - ViewportMetrics viewportMetrics = layerController.getViewportMetrics(); - PointF viewportOrigin = viewportMetrics.getOrigin(); - Point tileOrigin = mTileLayer.getOrigin(); - float scrollX = viewportOrigin.x; - float scrollY = viewportOrigin.y; - float zoomFactor = viewportMetrics.getZoomFactor(); - Log.e(LOGTAG, "### Viewport metrics = " + viewportMetrics + " tile reso = " + - mTileLayer.getResolution()); - return new ViewTransform(scrollX, scrollY, zoomFactor); - } - } - - public void renderRequested() { - Log.e(LOGTAG, "### Render requested, scheduling composite"); - LOKitShell.scheduleComposite(); - } - - public void compositionPauseRequested() { - Log.e(LOGTAG, "### Scheduling PauseComposition"); - LOKitShell.schedulePauseComposition(); - } - - public void compositionResumeRequested() { - Log.e(LOGTAG, "### Scheduling ResumeComposition"); - LOKitShell.scheduleResumeComposition(); - } - - public void surfaceChanged(int width, int height) { - compositionPauseRequested(); - LayerController layerController = getLayerController(); - layerController.setViewportSize(new FloatSize(width, height)); - compositionResumeRequested(); - renderRequested(); - } - - /** - * For Gecko to use. - */ - public LayerRenderer.Frame createFrame() { - // Create the shaders and textures if necessary. - if (!mLayerRendererInitialized) { - mLayerRenderer.createProgram(); - mLayerRendererInitialized = true; - } - - // Build the contexts and create the frame. - Layer.RenderContext pageContext = mLayerRenderer.createPageContext(); - Layer.RenderContext screenContext = mLayerRenderer.createScreenContext(); - return mLayerRenderer.createFrame(pageContext, screenContext); - } - - /** - * For Gecko to use. - */ - public void activateProgram() { - mLayerRenderer.activateProgram(); - } - - /** - * For Gecko to use. - */ - public void deactivateProgram() { - mLayerRenderer.deactivateProgram(); - } -} - diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java index 09349b4eea07..134c40628d0b 100644 --- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java +++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java @@ -38,16 +38,6 @@ package org.mozilla.gecko.gfx; -import org.libreoffice.LOEvent; -import org.libreoffice.LOKitShell; -import org.libreoffice.LibreOfficeMainActivity; -import org.mozilla.gecko.util.FloatUtils; -//import org.mozilla.gecko.GeckoApp; -//import org.mozilla.gecko.GeckoAppShell; -//import org.mozilla.gecko.GeckoEvent; -import org.mozilla.gecko.GeckoEventListener; -import org.json.JSONException; -import org.json.JSONObject; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Color; @@ -57,28 +47,36 @@ import android.graphics.RectF; import android.os.SystemClock; import android.util.DisplayMetrics; import android.util.Log; + +import org.json.JSONException; +import org.json.JSONObject; +import org.libreoffice.LOEvent; +import org.libreoffice.LOKitShell; +import org.libreoffice.LibreOfficeMainActivity; +import org.mozilla.gecko.GeckoEventListener; +import org.mozilla.gecko.util.FloatUtils; + import java.util.regex.Matcher; import java.util.regex.Pattern; -public abstract class GeckoLayerClient extends LayerClient implements GeckoEventListener { - private static final String LOGTAG = "GeckoLayerClient"; +//import org.mozilla.gecko.GeckoApp; +//import org.mozilla.gecko.GeckoAppShell; +//import org.mozilla.gecko.GeckoEvent; +public abstract class GeckoLayerClient extends LayerClient implements GeckoEventListener { public static final int LAYER_CLIENT_TYPE_NONE = 0; public static final int LAYER_CLIENT_TYPE_SOFTWARE = 1; public static final int LAYER_CLIENT_TYPE_GL = 2; + private static final String LOGTAG = "GeckoLayerClient"; + private static final long MIN_VIEWPORT_CHANGE_DELAY = 25L; + private static Pattern sColorPattern; protected IntSize mScreenSize; - protected IntSize mBufferSize; - protected Layer mTileLayer; - /* The viewport that Gecko is currently displaying. */ protected ViewportMetrics mGeckoViewport; - /* The viewport that Gecko will display when drawing is finished */ protected ViewportMetrics mNewGeckoViewport; - - private static final long MIN_VIEWPORT_CHANGE_DELAY = 25L; private long mLastViewportChangeTime; private boolean mPendingViewportAdjust; private boolean mViewportSizeChanged; @@ -89,29 +87,51 @@ public abstract class GeckoLayerClient extends LayerClient implements GeckoEvent // just the page size. this boolean should always be accessed from // inside a transaction, so no synchronization is needed. private boolean mUpdateViewportOnEndDraw; - private String mLastCheckerboardColor; - - private static Pattern sColorPattern; - /* Used by robocop for testing purposes */ private DrawListener mDrawListener; - protected abstract boolean handleDirectTextureChange(boolean hasDirectTexture); + public GeckoLayerClient(Context context) { + mScreenSize = new IntSize(0, 0); + } + + // Parses a color from an RGB triple of the form "rgb([0-9]+, [0-9]+, [0-9]+)". If the color + // cannot be parsed, returns white. + private static int parseColorFromGecko(String string) { + if (sColorPattern == null) { + sColorPattern = Pattern.compile("rgb\\((\\d+),\\s*(\\d+),\\s*(\\d+)\\)"); + } + + Matcher matcher = sColorPattern.matcher(string); + if (!matcher.matches()) { + return Color.WHITE; + } + + int r = Integer.parseInt(matcher.group(1)); + int g = Integer.parseInt(matcher.group(2)); + int b = Integer.parseInt(matcher.group(3)); + return Color.rgb(r, g, b); + } + + protected abstract boolean setupLayer(); + protected abstract boolean shouldDrawProceed(int tileWidth, int tileHeight); + protected abstract void updateLayerAfterDraw(Rect updatedRect); + protected abstract IntSize getBufferSize(); + protected abstract IntSize getTileSize(); + protected abstract void tileLayerUpdated(); + public abstract Bitmap getBitmap(); - public abstract int getType(); - public GeckoLayerClient(Context context) { - mScreenSize = new IntSize(0, 0); - mBufferSize = new IntSize(0, 0); - } + public abstract int getType(); - /** Attaches the root layer to the layer controller so that Gecko appears. */ + /** + * Attaches the root layer to the layer controller so that Gecko appears. + */ @Override public void setLayerController(LayerController layerController) { super.setLayerController(layerController); @@ -121,20 +141,15 @@ public abstract class GeckoLayerClient extends LayerClient implements GeckoEvent layerController.setViewportMetrics(mGeckoViewport); } - //GeckoAppShell.registerGeckoEventListener("Viewport:UpdateAndDraw", this); - //GeckoAppShell.registerGeckoEventListener("Viewport:UpdateLater", this); - sendResizeEventIfNecessary(); } - public Rect beginDrawing(int width, int height, int tileWidth, int tileHeight, - String metadata, boolean hasDirectTexture) { - Log.e(LOGTAG, "### beginDrawing " + width + " " + height + " " + tileWidth + " " + - tileHeight + " " + hasDirectTexture); + public Rect beginDrawing(int width, int height, int tileWidth, int tileHeight, String metadata) { - // If we've changed surface types, cancel this draw - if (handleDirectTextureChange(hasDirectTexture)) { - Log.e(LOGTAG, "### Cancelling draw due to direct texture change"); + Log.e(LOGTAG, "### beginDrawing " + width + " " + height + " " + tileWidth + " " + tileHeight); + + if (setupLayer()) { + Log.e(LOGTAG, "### Cancelling due to layer setup"); return null; } @@ -162,7 +177,6 @@ public abstract class GeckoLayerClient extends LayerClient implements GeckoEvent return null; } - // Make sure we don't spend time painting areas we aren't interested in. // Only do this if the Gecko viewport isn't going to override our viewport. Rect bufferRect = new Rect(0, 0, width, height); @@ -187,6 +201,7 @@ public abstract class GeckoLayerClient extends LayerClient implements GeckoEvent // Take the intersection of the two as the area we're interested in rendering. + if (!bufferRect.intersect(currentRect)) { // If there's no intersection, we have no need to render anything, // but make sure to update the viewport size. @@ -244,15 +259,14 @@ public abstract class GeckoLayerClient extends LayerClient implements GeckoEvent mTileLayer.setResolution(mGeckoViewport.getZoomFactor()); this.tileLayerUpdated(); - Log.e(LOGTAG, "### updateViewport onlyUpdatePageSize=" + onlyUpdatePageSize + - " getTileViewport " + mGeckoViewport); + Log.e(LOGTAG, "### updateViewport onlyUpdatePageSize=" + onlyUpdatePageSize + " getTileViewport " + mGeckoViewport); if (onlyUpdatePageSize) { // Don't adjust page size when zooming unless zoom levels are // approximately equal. - if (FloatUtils.fuzzyEquals(controller.getZoomFactor(), - mGeckoViewport.getZoomFactor())) + if (FloatUtils.fuzzyEquals(controller.getZoomFactor(), mGeckoViewport.getZoomFactor())) { controller.setPageSize(mGeckoViewport.getPageSize()); + } } else { controller.setViewportMetrics(mGeckoViewport); controller.abortPanZoomAnimation(); @@ -264,15 +278,14 @@ public abstract class GeckoLayerClient extends LayerClient implements GeckoEvent Log.e(LOGTAG, "### sendResizeEventIfNecessary " + force); DisplayMetrics metrics = new DisplayMetrics(); - /*GeckoApp*/LibreOfficeMainActivity.mAppContext.getWindowManager().getDefaultDisplay().getMetrics(metrics); + LibreOfficeMainActivity.mAppContext.getWindowManager().getDefaultDisplay().getMetrics(metrics); // Return immediately if the screen size hasn't changed or the viewport // size is zero (which indicates that the rendering surface hasn't been // allocated yet). - boolean screenSizeChanged = (metrics.widthPixels != mScreenSize.width || - metrics.heightPixels != mScreenSize.height); - boolean viewportSizeValid = (getLayerController() != null && - getLayerController().getViewportSize().isPositive()); + boolean screenSizeChanged = (metrics.widthPixels != mScreenSize.width || metrics.heightPixels != mScreenSize.height); + boolean viewportSizeValid = (getLayerController() != null && getLayerController().getViewportSize().isPositive()); + if (!(force || (screenSizeChanged && viewportSizeValid))) { return; } @@ -281,31 +294,11 @@ public abstract class GeckoLayerClient extends LayerClient implements GeckoEvent IntSize bufferSize = getBufferSize(), tileSize = getTileSize(); Log.e(LOGTAG, "### Screen-size changed to " + mScreenSize); - //GeckoEvent event = GeckoEvent.createSizeChangedEvent(bufferSize.width, bufferSize.height, - // metrics.widthPixels, metrics.heightPixels, - // tileSize.width, tileSize.height); - //GeckoAppShell.sendEventToGecko(event); - LOEvent event = LOEvent.sizeChanged(bufferSize.width, bufferSize.height, - metrics.widthPixels, metrics.heightPixels, - tileSize.width, tileSize.height); - } - - // Parses a color from an RGB triple of the form "rgb([0-9]+, [0-9]+, [0-9]+)". If the color - // cannot be parsed, returns white. - private static int parseColorFromGecko(String string) { - if (sColorPattern == null) { - sColorPattern = Pattern.compile("rgb\\((\\d+),\\s*(\\d+),\\s*(\\d+)\\)"); - } - - Matcher matcher = sColorPattern.matcher(string); - if (!matcher.matches()) { - return Color.WHITE; - } - int r = Integer.parseInt(matcher.group(1)); - int g = Integer.parseInt(matcher.group(2)); - int b = Integer.parseInt(matcher.group(3)); - return Color.rgb(r, g, b); + LOEvent event = LOEvent.sizeChanged(bufferSize.width, bufferSize.height, + metrics.widthPixels, metrics.heightPixels, + tileSize.width, tileSize.height); + LOKitShell.sendEvent(event); } @Override @@ -328,7 +321,8 @@ public abstract class GeckoLayerClient extends LayerClient implements GeckoEvent mPendingViewportAdjust = false; adjustViewport(); } - }, MIN_VIEWPORT_CHANGE_DELAY - timeDelta); + }, MIN_VIEWPORT_CHANGE_DELAY - timeDelta + ); mPendingViewportAdjust = true; return; } @@ -342,18 +336,15 @@ public abstract class GeckoLayerClient extends LayerClient implements GeckoEvent } private void adjustViewport() { - ViewportMetrics viewportMetrics = - new ViewportMetrics(getLayerController().getViewportMetrics()); + ViewportMetrics viewportMetrics = new ViewportMetrics(getLayerController().getViewportMetrics()); - PointF viewportOffset = viewportMetrics.getOptimumViewportOffset(mBufferSize); + PointF viewportOffset = viewportMetrics.getOptimumViewportOffset(getBufferSize()); viewportMetrics.setViewportOffset(viewportOffset); viewportMetrics.setViewport(viewportMetrics.getClampedViewport()); - //GeckoAppShell.sendEventToGecko(GeckoEvent.createViewportEvent(viewportMetrics)); LOKitShell.sendEvent(LOEvent.viewport(viewportMetrics)); if (mViewportSizeChanged) { mViewportSizeChanged = false; - //GeckoAppShell.viewSizeChanged(); LOKitShell.viewSizeChanged(); } @@ -366,8 +357,8 @@ public abstract class GeckoLayerClient extends LayerClient implements GeckoEvent mUpdateViewportOnEndDraw = true; // Redraw everything. - Rect rect = new Rect(0, 0, mBufferSize.width, mBufferSize.height); - //GeckoAppShell.sendEventToGecko(GeckoEvent.createDrawEvent(rect)); + IntSize bufferSize = getBufferSize(); + Rect rect = new Rect(0, 0, bufferSize.width, bufferSize.height); LOKitShell.sendEvent(LOEvent.draw(rect)); } else if ("Viewport:UpdateLater".equals(event)) { Log.e(LOGTAG, "### Java side Viewport:UpdateLater()!"); @@ -377,21 +368,11 @@ public abstract class GeckoLayerClient extends LayerClient implements GeckoEvent @Override public void geometryChanged() { - /* Let Gecko know if the screensize has changed */ sendResizeEventIfNecessary(); render(); } - public int getWidth() { - return mBufferSize.width; - } - - public int getHeight() { - return mBufferSize.height; - } - public ViewportMetrics getGeckoViewportMetrics() { - // Return a copy, as we modify this inside the Gecko thread if (mGeckoViewport != null) return new ViewportMetrics(mGeckoViewport); return null; @@ -401,14 +382,17 @@ public abstract class GeckoLayerClient extends LayerClient implements GeckoEvent sendResizeEventIfNecessary(false); } - /** Used by robocop for testing purposes. Not for production use! This is called via reflection by robocop. */ + /** + * Used by robocop for testing purposes. Not for production use! This is called via reflection by robocop. + */ public void setDrawListener(DrawListener listener) { mDrawListener = listener; } - /** Used by robocop for testing purposes. Not for production use! This is used via reflection by robocop. */ + /** + * Used by robocop for testing purposes. Not for production use! This is used via reflection by robocop. + */ public interface DrawListener { public void drawFinished(int x, int y, int width, int height); } -} - +}
\ No newline at end of file diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoSoftwareLayerClient.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoSoftwareLayerClient.java index fa1d5adb3c70..de8076aed4d2 100644 --- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoSoftwareLayerClient.java +++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoSoftwareLayerClient.java @@ -68,31 +68,16 @@ public class GeckoSoftwareLayerClient extends GeckoLayerClient { private int mFormat; private IntSize mViewportSize; - private ByteBuffer mBuffer; - - private CairoImage mCairoImage; - + private IntSize mBufferSize; private static final IntSize TILE_SIZE = new IntSize(256, 256); - // Whether or not the last paint we got used direct texturing - private boolean mHasDirectTexture; - public GeckoSoftwareLayerClient(Context context) { super(context); - + mBufferSize = new IntSize(0,0); mFormat = CairoImage.FORMAT_ARGB32; - - mCairoImage = new CairoImage() { - @Override - public ByteBuffer getBuffer() { return mBuffer; } - @Override - public IntSize getSize() { return mBufferSize; } - @Override - public int getFormat() { return mFormat; } - }; } - protected void finalize() throws Throwable { + /*protected void finalize() throws Throwable { try { if (mBuffer != null) LOKitShell.freeDirectBuffer(mBuffer); @@ -100,7 +85,7 @@ public class GeckoSoftwareLayerClient extends GeckoLayerClient { } finally { super.finalize(); } - } + }*/ public void setLayerController(LayerController layerController) { super.setLayerController(layerController); @@ -110,28 +95,14 @@ public class GeckoSoftwareLayerClient extends GeckoLayerClient { layerController.setViewportMetrics(mGeckoViewport); } - //GeckoAppShell.registerGeckoEventListener("Viewport:UpdateAndDraw", this); - //GeckoAppShell.registerGeckoEventListener("Viewport:UpdateLater", this); - //GeckoAppShell.registerGeckoEventListener("Checkerboard:Toggle", this); - - // XXX: Review pcwalton. This signature changed on m-c, should force = false here? sendResizeEventIfNecessary(false); } @Override - protected boolean handleDirectTextureChange(boolean hasDirectTexture) { - if (mTileLayer != null && hasDirectTexture == mHasDirectTexture) - return false; - - mHasDirectTexture = hasDirectTexture; - - if (mHasDirectTexture) { - Log.i(LOGTAG, "Creating WidgetTileLayer"); - mTileLayer = new WidgetTileLayer(mCairoImage); - } else { - Log.i(LOGTAG, "Creating MultiTileLayer"); - mTileLayer = new MultiTileLayer(mCairoImage, TILE_SIZE); - } + protected boolean setupLayer() { + Log.i(LOGTAG, "Creating MultiTileLayer"); + if(mTileLayer == null) + mTileLayer = new MultiTileLayer(TILE_SIZE); getLayerController().setRoot(mTileLayer); @@ -139,35 +110,24 @@ public class GeckoSoftwareLayerClient extends GeckoLayerClient { // are different depending on what tile system we're using sendResizeEventIfNecessary(true); - return true; + return false; } @Override protected boolean shouldDrawProceed(int tileWidth, int tileHeight) { // Make sure the tile-size matches. If it doesn't, we could crash trying // to access invalid memory. - if (mHasDirectTexture) { - if (tileWidth != 0 || tileHeight != 0) { - Log.e(LOGTAG, "Aborting draw, incorrect tile size of " + tileWidth + "x" + - tileHeight); - return false; - } - } else { - if (tileWidth != TILE_SIZE.width || tileHeight != TILE_SIZE.height) { - Log.e(LOGTAG, "Aborting draw, incorrect tile size of " + tileWidth + "x" + - tileHeight); - return false; - } + if (tileWidth != TILE_SIZE.width || tileHeight != TILE_SIZE.height) { + Log.e(LOGTAG, "Aborting draw, incorrect tile size of " + tileWidth + "x" + tileHeight); + return false; } - return true; } @Override - public Rect beginDrawing(int width, int height, int tileWidth, int tileHeight, - String metadata, boolean hasDirectTexture) { - Rect bufferRect = super.beginDrawing(width, height, tileWidth, tileHeight, - metadata, hasDirectTexture); + public Rect beginDrawing(int width, int height, int tileWidth, int tileHeight, String metadata) { + Rect bufferRect = super.beginDrawing(width, height, tileWidth, tileHeight, metadata); + if (bufferRect == null) { return bufferRect; } @@ -175,21 +135,6 @@ public class GeckoSoftwareLayerClient extends GeckoLayerClient { // If the window size has changed, reallocate the buffer to match. if (mBufferSize.width != width || mBufferSize.height != height) { mBufferSize = new IntSize(width, height); - - // Reallocate the buffer if necessary - if (mTileLayer instanceof MultiTileLayer) { - int bpp = CairoUtils.bitsPerPixelForCairoFormat(mFormat) / 8; - int size = mBufferSize.getArea() * bpp; - if (mBuffer == null || mBuffer.capacity() != size) { - // Free the old buffer - if (mBuffer != null) { - LOKitShell.freeDirectBuffer(mBuffer); - mBuffer = null; - } - - mBuffer = LOKitShell.allocateDirectBuffer(size); - } - } } return bufferRect; @@ -197,14 +142,12 @@ public class GeckoSoftwareLayerClient extends GeckoLayerClient { @Override protected void updateLayerAfterDraw(Rect updatedRect) { - if (!(mTileLayer instanceof MultiTileLayer)) { - return; + if (mTileLayer instanceof MultiTileLayer) { + ((MultiTileLayer)mTileLayer).invalidate(updatedRect); } - - ((MultiTileLayer)mTileLayer).invalidate(updatedRect); } - private void copyPixelsFromMultiTileLayer(Bitmap target) { + /*private void copyPixelsFromMultiTileLayer(Bitmap target) { Canvas c = new Canvas(target); ByteBuffer tileBuffer = mBuffer.slice(); int bpp = CairoUtils.bitsPerPixelForCairoFormat(mFormat) / 8; @@ -229,7 +172,7 @@ public class GeckoSoftwareLayerClient extends GeckoLayerClient { tileBuffer = tileBuffer.slice(); } } - } + }*/ @Override protected void tileLayerUpdated() { @@ -243,7 +186,7 @@ public class GeckoSoftwareLayerClient extends GeckoLayerClient { // Begin a tile transaction, otherwise the buffer can be destroyed while // we're reading from it. - beginTransaction(mTileLayer); + /*beginTransaction(mTileLayer); try { if (mBuffer == null || mBufferSize.width <= 0 || mBufferSize.height <= 0) return null; @@ -251,8 +194,7 @@ public class GeckoSoftwareLayerClient extends GeckoLayerClient { Bitmap b = null; if (mTileLayer instanceof MultiTileLayer) { - b = Bitmap.createBitmap(mBufferSize.width, mBufferSize.height, - CairoUtils.cairoFormatTobitmapConfig(mFormat)); + b = Bitmap.createBitmap(mBufferSize.width, mBufferSize.height,CairoUtils.cairoFormatTobitmapConfig(mFormat)); copyPixelsFromMultiTileLayer(b); } else { Log.w(LOGTAG, "getBitmap() called on a layer (" + mTileLayer + ") we don't know how to get a bitmap from"); @@ -265,20 +207,9 @@ public class GeckoSoftwareLayerClient extends GeckoLayerClient { } } finally { endTransaction(mTileLayer); - } - } - - /** Returns the back buffer. This function is for Gecko to use. */ - public ByteBuffer lockBuffer() { - return mBuffer; - } + }*/ - /** - * Gecko calls this function to signal that it is done with the back buffer. After this call, - * it is forbidden for Gecko to touch the buffer. - */ - public void unlockBuffer() { - /* no-op */ + return null; } @Override @@ -288,35 +219,19 @@ public class GeckoSoftwareLayerClient extends GeckoLayerClient { @Override protected IntSize getBufferSize() { - // Round up depending on layer implementation to remove texture wastage - if (!mHasDirectTexture) { - // Round to the next multiple of the tile size - return new IntSize(((mScreenSize.width + LayerController.MIN_BUFFER.width - 1) / - TILE_SIZE.width + 1) * TILE_SIZE.width, - ((mScreenSize.height + LayerController.MIN_BUFFER.height - 1) / - TILE_SIZE.height + 1) * TILE_SIZE.height); - } - - int maxSize = getLayerController().getView().getMaxTextureSize(); - - // XXX Integrate gralloc/tiling work to circumvent this - if (mScreenSize.width > maxSize || mScreenSize.height > maxSize) { - throw new RuntimeException("Screen size of " + mScreenSize + - " larger than maximum texture size of " + maxSize); - } - - // Round to next power of two until we have NPOT texture support, respecting maximum - // texture size - return new IntSize(Math.min(maxSize, IntSize.nextPowerOfTwo(mScreenSize.width + - LayerController.MIN_BUFFER.width)), - Math.min(maxSize, IntSize.nextPowerOfTwo(mScreenSize.height + - LayerController.MIN_BUFFER.height))); + return new IntSize( + ((mScreenSize.width + LayerController.MIN_BUFFER.width - 1) / TILE_SIZE.width + 1) * TILE_SIZE.width, + ((mScreenSize.height + LayerController.MIN_BUFFER.height - 1) / TILE_SIZE.height + 1) * TILE_SIZE.height); } @Override protected IntSize getTileSize() { - // Round up depending on layer implementation to remove texture wastage - return !mHasDirectTexture ? TILE_SIZE : new IntSize(0, 0); + return TILE_SIZE; } -} + public void addTile(Bitmap bitmap, int x, int y) { + if (mTileLayer instanceof MultiTileLayer) { + ((MultiTileLayer)mTileLayer).addTile(bitmap, x, y); + } + } +} diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/Layer.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/Layer.java index 2dd3316f0016..40786532a303 100644 --- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/Layer.java +++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/Layer.java @@ -121,8 +121,8 @@ public abstract class Layer { * This function may block, so you should never call this on the main UI thread. */ public void beginTransaction(LayerView aView) { - if (mTransactionLock.isHeldByCurrentThread()) - throw new RuntimeException("Nested transactions are not supported"); + //if (mTransactionLock.isHeldByCurrentThread()) + // throw new RuntimeException("Nested transactions are not supported"); mTransactionLock.lock(); mView = aView; mInTransaction = true; diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerRenderer.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerRenderer.java index 6690aad8ec16..095a6f497ef7 100644 --- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerRenderer.java +++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerRenderer.java @@ -50,7 +50,6 @@ import org.mozilla.gecko.gfx.TextureReaper; import org.mozilla.gecko.gfx.TextureGenerator; import org.mozilla.gecko.gfx.TextLayer; import org.mozilla.gecko.gfx.TileLayer; -//import org.mozilla.gecko.GeckoAppShell; import android.content.Context; import android.content.SharedPreferences; import android.graphics.Point; diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/MultiTileLayer.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/MultiTileLayer.java index 3514b4207461..a958a54eb303 100644 --- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/MultiTileLayer.java +++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/MultiTileLayer.java @@ -38,11 +38,16 @@ package org.mozilla.gecko.gfx; +import android.graphics.Bitmap; import android.graphics.Point; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.Region; +import android.util.Log; +import org.libreoffice.LOKitShell; + +import java.nio.Buffer; import java.nio.ByteBuffer; import java.util.ArrayList; @@ -54,18 +59,15 @@ import java.util.ArrayList; public class MultiTileLayer extends Layer { private static final String LOGTAG = "GeckoMultiTileLayer"; - private final CairoImage mImage; private final ArrayList<SubTile> mTiles; private IntSize mTileSize; - private IntSize mBufferSize; + private IntSize mSize; - public MultiTileLayer(CairoImage image, IntSize tileSize) { + public MultiTileLayer(IntSize tileSize) { super(); - - mImage = image; mTileSize = tileSize; - mBufferSize = new IntSize(0, 0); mTiles = new ArrayList<SubTile>(); + mSize = new IntSize(0,0); } public void invalidate(Rect dirtyRect) { @@ -90,67 +92,20 @@ public class MultiTileLayer extends Layer { } } + public void setSize(IntSize size) { + mSize = size; + } + @Override public IntSize getSize() { - return mImage.getSize(); + return mSize; } private void validateTiles() { - IntSize size = getSize(); - - if (size.equals(mBufferSize)) { - return; - } - - // Regenerate tiles - mTiles.clear(); - int offset = 0; - final int format = mImage.getFormat(); - final ByteBuffer buffer = mImage.getBuffer().slice(); - final int bpp = CairoUtils.bitsPerPixelForCairoFormat(format) / 8; - for (int y = 0; y < size.height; y += mTileSize.height) { - for (int x = 0; x < size.width; x += mTileSize.width) { - // Create a CairoImage implementation that returns a - // tile from the parent CairoImage. It's assumed that - // the tiles are stored in series. - final IntSize layerSize = - new IntSize(Math.min(mTileSize.width, size.width - x), - Math.min(mTileSize.height, size.height - y)); - final int tileOffset = offset; - - CairoImage subImage = new CairoImage() { - @Override - public ByteBuffer getBuffer() { - // Create a ByteBuffer that shares the data of the original - // buffer, but is positioned and limited so that only the - // tile data is accessible. - buffer.position(tileOffset); - ByteBuffer tileBuffer = buffer.slice(); - tileBuffer.limit(layerSize.getArea() * bpp); - - return tileBuffer; - } - - @Override - public IntSize getSize() { - return layerSize; - } - - @Override - public int getFormat() { - return format; - } - }; - - mTiles.add(new SubTile(subImage, x, y)); - offset += layerSize.getArea() * bpp; - } - } + Log.i(LOGTAG, "validateTiles()"); // Set tile origins and resolution refreshTileMetrics(getOrigin(), getResolution(), false); - - mBufferSize = size; } @Override @@ -286,15 +241,10 @@ public class MultiTileLayer extends Layer { return validRegion; } - class SubTile extends SingleTileLayer { - public int x; - public int y; - - public SubTile(CairoImage mImage, int mX, int mY) { - super(mImage); - x = mX; - y = mY; - } + public void addTile(Bitmap bitmap, int x, int y) { + SubTile tile = new SubTile(new BufferedCairoImage(bitmap), x,y); + tile.beginTransaction(); + mTiles.add(tile); } } diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/SubTile.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/SubTile.java new file mode 100644 index 000000000000..0c40c3c1b7df --- /dev/null +++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/SubTile.java @@ -0,0 +1,15 @@ +package org.mozilla.gecko.gfx; + +/** +* Created by quikee on 29.6.2014. +*/ +public class SubTile extends SingleTileLayer { + public int x; + public int y; + + public SubTile(CairoImage mImage, int mX, int mY) { + super(mImage); + x = mX; + y = mY; + } +} |