[Libreoffice-commits] core.git: Branch 'feature/tiled-editing' - 3 commits - android/experimental
Tomaž Vajngerl
tomaz.vajngerl at collabora.co.uk
Mon Feb 16 04:13:15 PST 2015
android/experimental/LOAndroid3/src/java/org/libreoffice/LOAbout.java | 4
android/experimental/LOAndroid3/src/java/org/libreoffice/LOEventFactory.java | 39 -
android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java | 36 +
android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java | 6
android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java | 5
android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java | 4
android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerRenderer.java | 207 ----------
android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java | 26 -
android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ScreenshotLayer.java | 200 ---------
android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/SubTile.java | 2
10 files changed, 41 insertions(+), 488 deletions(-)
New commits:
commit c845452729f80dcb6f0c48204c10512353019b94
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Sun Feb 15 13:47:29 2015 +0900
android: cleanup LayerRenderer
Change-Id: I26f1819c801bb1930975b0be3f036748f843e4a4
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 d6110ac..e924bcf 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
@@ -36,7 +36,6 @@ import javax.microedition.khronos.opengles.GL10;
*/
public class LayerRenderer implements GLSurfaceView.Renderer {
private static final String LOGTAG = "GeckoLayerRenderer";
- private static final String PROFTAG = "GeckoLayerRendererProf";
/*
* The amount of time a frame is allowed to take to render before we declare it a dropped
@@ -44,9 +43,6 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
*/
private static final int MAX_FRAME_TIME = 16; /* 1000 ms / 60 FPS */
- private static final int FRAME_RATE_METER_WIDTH = 128;
- private static final int FRAME_RATE_METER_HEIGHT = 32;
-
private final LayerView mView;
private final SingleTileLayer mBackgroundLayer;
private final NinePatchTileLayer mShadowLayer;
@@ -61,16 +57,6 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
private CopyOnWriteArrayList<Layer> mExtraLayers = new CopyOnWriteArrayList<Layer>();
- // Dropped frames display
- private int[] mFrameTimings;
- private int mCurrentFrame, mFrameTimingsSum, mDroppedFrames;
-
- // Render profiling output
- private int mFramesRendered;
- private float mCompleteFramesRendered;
- private boolean mProfileRender;
- private long mProfileOutputTime;
-
/* Used by robocop for testing purposes */
private IntBuffer mPixelBuffer;
@@ -137,9 +123,6 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
mVertScrollLayer = ScrollbarLayer.create(this, true);
mFadeRunnable = new FadeRunnable();
- mFrameTimings = new int[60];
- mCurrentFrame = mFrameTimingsSum = mDroppedFrames = 0;
-
// Initialize the FloatBuffer that will be used to store all vertices and texture
// coordinates in draw() commands.
mCoordByteBuffer = DirectBufferAllocator.allocate(COORD_BUFFER_SIZE * 4);
@@ -253,27 +236,6 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
}
}
- private void printCheckerboardStats() {
- Log.d(PROFTAG, "Frames rendered over last 1000ms: " + mCompleteFramesRendered + "/" + mFramesRendered);
- mFramesRendered = 0;
- mCompleteFramesRendered = 0;
- }
-
- /** Used by robocop for testing purposes. Not for production use! */
- IntBuffer getPixels() {
- IntBuffer pixelBuffer = IntBuffer.allocate(mView.getWidth() * mView.getHeight());
- synchronized (pixelBuffer) {
- mPixelBuffer = pixelBuffer;
- mView.requestRender();
- try {
- pixelBuffer.wait();
- } catch (InterruptedException ie) {
- }
- mPixelBuffer = null;
- }
- return pixelBuffer;
- }
-
private RenderContext createScreenContext(ImmutableViewportMetrics metrics) {
RectF viewport = new RectF(0.0f, 0.0f, metrics.getWidth(), metrics.getHeight());
RectF pageRect = new RectF(metrics.getPageRect());
@@ -296,19 +258,6 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
GLES20.glViewport(0, 0, width, height);
}
- private void updateDroppedFrames(long frameStartTime) {
- int frameElapsedTime = (int)(SystemClock.uptimeMillis() - frameStartTime);
-
- /* Update the running statistics. */
- mFrameTimingsSum -= mFrameTimings[mCurrentFrame];
- mFrameTimingsSum += frameElapsedTime;
- mDroppedFrames -= (mFrameTimings[mCurrentFrame] + 1) / MAX_FRAME_TIME;
- mDroppedFrames += (frameElapsedTime + 1) / MAX_FRAME_TIME;
-
- mFrameTimings[mCurrentFrame] = frameElapsedTime;
- mCurrentFrame = (mCurrentFrame + 1) % mFrameTimings.length;
- }
-
/*
* create a vertex shader type (GLES20.GL_VERTEX_SHADER)
* or a fragment shader type (GLES20.GL_FRAGMENT_SHADER)
@@ -552,55 +501,6 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
/* Draw the horizontal scrollbar. */
if (mPageRect.width() > mFrameMetrics.getWidth())
mHorizScrollLayer.draw(mPageContext);
-
- /* Measure how much of the screen is checkerboarding */
- Layer rootLayer = mView.getLayerClient().getRoot();
- if ((rootLayer != null) &&
- (mProfileRender || PanningPerfAPI.isRecordingCheckerboard())) {
- // Find out how much of the viewport area is valid
- Rect viewport = RectUtils.round(mPageContext.viewport);
- Region validRegion = rootLayer.getValidRegion(mPageContext);
-
- /* restrict the viewport to page bounds so we don't
- * count overscroll as checkerboard */
- if (!viewport.intersect(mPageRect)) {
- /* if the rectangles don't intersect
- intersect() doesn't change viewport
- so we set it to empty by hand */
- viewport.setEmpty();
- }
- validRegion.op(viewport, Region.Op.INTERSECT);
-
- float checkerboard = 0.0f;
-
- int screenArea = viewport.width() * viewport.height();
- if (screenArea > 0 && !(validRegion.isRect() && validRegion.getBounds().equals(viewport))) {
- validRegion.op(viewport, Region.Op.REVERSE_DIFFERENCE);
-
- // XXX The assumption here is that a Region never has overlapping
- // rects. This is true, as evidenced by reading the SkRegion
- // source, but is not mentioned in the Android documentation,
- // and so is liable to change.
- // If it does change, this code will need to be reevaluated.
- Rect r = new Rect();
- int checkerboardArea = 0;
- for (RegionIterator i = new RegionIterator(validRegion); i.next(r);) {
- checkerboardArea += r.width() * r.height();
- }
-
- checkerboard = checkerboardArea / (float)screenArea;
- }
-
- PanningPerfAPI.recordCheckerboard(checkerboard);
-
- mCompleteFramesRendered += 1.0f - checkerboard;
- mFramesRendered ++;
-
- if (mFrameStartTime - mProfileOutputTime > 1000) {
- mProfileOutputTime = mFrameStartTime;
- printCheckerboardStats();
- }
- }
}
/** This function is invoked via JNI; be careful when modifying signature. */
@@ -609,8 +509,6 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
if (!mUpdated)
mView.requestRender();
- PanningPerfAPI.recordFrameTime();
-
/* Used by robocop for testing purposes */
IntBuffer pixelBuffer = mPixelBuffer;
if (mUpdated && pixelBuffer != null) {
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java
index 124aeff..1b94fc4 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java
@@ -266,11 +266,6 @@ public class LayerView extends FrameLayout {
return mRenderer.getMaxTextureSize();
}
- /** Used by robocop for testing purposes. Not for production use! This is called via reflection by robocop. */
- public IntBuffer getPixels() {
- return mRenderer.getPixels();
- }
-
public void setLayerRenderer(LayerRenderer renderer) {
mRenderer = renderer;
}
commit 3e3ae384bb90d063a737d072903a2c972fa3e9ec
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Sun Feb 15 12:20:51 2015 +0900
android: remove unneeded code from LayerRenderer and LayerView
Change-Id: I3a5a24eea62efdda435c5854c164216c91c4ab44
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 6fe97b8..d6110ac 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
@@ -49,9 +49,7 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
private final LayerView mView;
private final SingleTileLayer mBackgroundLayer;
- private final ScreenshotLayer mScreenshotLayer;
private final NinePatchTileLayer mShadowLayer;
- private TextLayer mFrameRateLayer;
private final ScrollbarLayer mHorizScrollLayer;
private final ScrollbarLayer mVertScrollLayer;
private final FadeRunnable mFadeRunnable;
@@ -126,44 +124,12 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
" gl_FragColor = texture2D(sTexture, vTexCoord);\n" +
"}\n";
- public void setCheckerboardBitmap(Bitmap bitmap, float pageWidth, float pageHeight) {
- mScreenshotLayer.setBitmap(bitmap);
- mScreenshotLayer.beginTransaction();
- try {
- mScreenshotLayer.setPosition(new Rect(0, 0, Math.round(pageWidth),
- Math.round(pageHeight)));
- mScreenshotLayer.invalidate();
- } finally {
- mScreenshotLayer.endTransaction();
- }
- }
-
- public void updateCheckerboardBitmap(Bitmap bitmap, float x, float y,
- float width, float height,
- float pageWidth, float pageHeight) {
- mScreenshotLayer.updateBitmap(bitmap, x, y, width, height);
- mScreenshotLayer.beginTransaction();
- try {
- mScreenshotLayer.setPosition(new Rect(0, 0, Math.round(pageWidth),
- Math.round(pageHeight)));
- mScreenshotLayer.invalidate();
- } finally {
- mScreenshotLayer.endTransaction();
- }
- }
-
- public void resetCheckerboard() {
- mScreenshotLayer.reset();
- }
-
public LayerRenderer(LayerView view) {
mView = view;
CairoImage backgroundImage = new BufferedCairoImage(view.getBackgroundPattern());
mBackgroundLayer = new SingleTileLayer(true, backgroundImage);
- mScreenshotLayer = ScreenshotLayer.create();
-
CairoImage shadowImage = new BufferedCairoImage(view.getShadowPattern());
mShadowLayer = new NinePatchTileLayer(shadowImage);
@@ -196,18 +162,13 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
DirectBufferAllocator.free(mCoordByteBuffer);
mCoordByteBuffer = null;
mCoordBuffer = null;
- mScreenshotLayer.destroy();
mBackgroundLayer.destroy();
mShadowLayer.destroy();
mHorizScrollLayer.destroy();
mVertScrollLayer.destroy();
- if (mFrameRateLayer != null) {
- mFrameRateLayer.destroy();
- }
}
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
- checkMonitoringEnabled();
createDefaultProgram();
activateDefaultProgram();
}
@@ -333,12 +294,6 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
public void onSurfaceChanged(GL10 gl, final int width, final int height) {
GLES20.glViewport(0, 0, width, height);
-
- if (mFrameRateLayer != null) {
- moveFrameRateLayer(width, height);
- }
-
- /* TODO: Throw away tile images? */
}
private void updateDroppedFrames(long frameStartTime) {
@@ -352,45 +307,6 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
mFrameTimings[mCurrentFrame] = frameElapsedTime;
mCurrentFrame = (mCurrentFrame + 1) % mFrameTimings.length;
-
- int averageTime = mFrameTimingsSum / mFrameTimings.length;
- mFrameRateLayer.beginTransaction(); // called on compositor thread
- try {
- mFrameRateLayer.setText(averageTime + " ms/" + mDroppedFrames);
- } finally {
- mFrameRateLayer.endTransaction();
- }
- }
-
- /* Given the new dimensions for the surface, moves the frame rate layer appropriately. */
- private void moveFrameRateLayer(int width, int height) {
- mFrameRateLayer.beginTransaction(); // called on compositor thread
- try {
- Rect position = new Rect(width - FRAME_RATE_METER_WIDTH - 8,
- height - FRAME_RATE_METER_HEIGHT + 8,
- width - 8,
- height + 8);
- mFrameRateLayer.setPosition(position);
- } finally {
- mFrameRateLayer.endTransaction();
- }
- }
-
- void checkMonitoringEnabled() {
- /* Do this I/O off the main thread to minimize its impact on startup time. */
- new Thread(new Runnable() {
- @Override
- public void run() {
- Context context = mView.getContext();
- SharedPreferences preferences = context.getSharedPreferences("GeckoApp", 0);
- if (preferences.getBoolean("showFrameRate", false)) {
- IntSize frameRateLayerSize = new IntSize(FRAME_RATE_METER_WIDTH, FRAME_RATE_METER_HEIGHT);
- mFrameRateLayer = TextLayer.create(frameRateLayerSize, "-- ms/--");
- moveFrameRateLayer(mView.getWidth(), mView.getHeight());
- }
- mProfileRender = Log.isLoggable(PROFTAG, Log.DEBUG);
- }
- }).start();
}
/*
@@ -519,8 +435,6 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
if (lowResLayer != null) mUpdated &= lowResLayer.update(mPageContext); // called on compositor thread
mUpdated &= mBackgroundLayer.update(mScreenContext); // called on compositor thread
mUpdated &= mShadowLayer.update(mPageContext); // called on compositor thread
- mUpdated &= mScreenshotLayer.update(mPageContext); // called on compositor thread
- if (mFrameRateLayer != null) mUpdated &= mFrameRateLayer.update(mScreenContext); // called on compositor thread
mUpdated &= mVertScrollLayer.update(mPageContext); // called on compositor thread
mUpdated &= mHorizScrollLayer.update(mPageContext); // called on compositor thread
@@ -687,15 +601,6 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
printCheckerboardStats();
}
}
-
- /* Draw the FPS. */
- if (mFrameRateLayer != null) {
- updateDroppedFrames(mFrameStartTime);
-
- GLES20.glEnable(GLES20.GL_BLEND);
- GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
- mFrameRateLayer.draw(mScreenContext);
- }
}
/** This function is invoked via JNI; be careful when modifying signature. */
@@ -717,16 +622,6 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
pixelBuffer.notify();
}
}
-
- // Remove white screen once we've painted
- /*if (mView.getPaintState() == LayerView.PAINT_BEFORE_FIRST) {
- GeckoAppShell.getMainHandler().postAtFrontOfQueue(new Runnable() {
- public void run() {
- mView.setBackgroundColor(android.graphics.Color.TRANSPARENT);
- }
- });
- mView.setPaintState(LayerView.PAINT_AFTER_FIRST);
- }*/
}
}
}
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java
index 345fa4d..124aeff 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java
@@ -50,8 +50,7 @@ public class LayerView extends FrameLayout {
private GLController mGLController;
private InputConnectionHandler mInputConnectionHandler;
private LayerRenderer mRenderer;
- private long mRenderTime;
- private boolean mRenderTimeReset;
+
/* Must be a PAINT_xxx constant */
private int mPaintState = PAINT_NONE;
private boolean mFullScreen = false;
@@ -253,13 +252,6 @@ public class LayerView extends FrameLayout {
if (mListener != null) {
mListener.renderRequested();
}
-
- synchronized(this) {
- if (!mRenderTimeReset) {
- mRenderTimeReset = true;
- mRenderTime = System.nanoTime();
- }
- }
}
public void addLayer(Layer layer) {
@@ -270,17 +262,6 @@ public class LayerView extends FrameLayout {
mRenderer.removeLayer(layer);
}
- /**
- * Returns the time elapsed between the first call of requestRender() after
- * the last call of getRenderTime(), in nanoseconds.
- */
- public long getRenderTime() {
- synchronized(this) {
- mRenderTimeReset = false;
- return System.nanoTime() - mRenderTime;
- }
- }
-
public int getMaxTextureSize() {
return mRenderer.getMaxTextureSize();
}
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ScreenshotLayer.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ScreenshotLayer.java
deleted file mode 100644
index c52b39b..0000000
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ScreenshotLayer.java
+++ /dev/null
@@ -1,200 +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.Paint;
-import android.graphics.Rect;
-import android.opengl.GLES20;
-
-import org.libreoffice.kit.DirectBufferAllocator;
-
-import java.nio.ByteBuffer;
-import java.nio.FloatBuffer;
-
-public class ScreenshotLayer extends SingleTileLayer {
- private static final int SCREENSHOT_SIZE_LIMIT = 1048576;
- private ScreenshotImage mImage;
- // Size of the image buffer
- private IntSize mBufferSize;
- // The size of the bitmap painted in the buffer
- // (may be smaller than mBufferSize due to power of 2 padding)
- private IntSize mImageSize;
- // Whether we have an up-to-date image to draw
- private boolean mHasImage;
-
- public static int getMaxNumPixels() {
- return SCREENSHOT_SIZE_LIMIT;
- }
-
- public void reset() {
- mHasImage = false;
- }
-
- void setBitmap(Bitmap bitmap) {
- mImageSize = new IntSize(bitmap.getWidth(), bitmap.getHeight());
- int width = IntSize.nextPowerOfTwo(bitmap.getWidth());
- int height = IntSize.nextPowerOfTwo(bitmap.getHeight());
- mBufferSize = new IntSize(width, height);
- mImage.setBitmap(bitmap, width, height, CairoImage.FORMAT_RGB16_565);
- mHasImage = true;
- }
-
- public void updateBitmap(Bitmap bitmap, float x, float y, float width, float height) {
- mImage.updateBitmap(bitmap, x, y, width, height);
- }
-
- public static ScreenshotLayer create() {
- return ScreenshotLayer.create(new IntSize(4, 4));
- }
-
- public static ScreenshotLayer create(IntSize size) {
- Bitmap bitmap = Bitmap.createBitmap(size.width, size.height, Bitmap.Config.RGB_565);
- ScreenshotLayer sl = create(bitmap);
- sl.reset();
- return sl;
- }
-
- public static ScreenshotLayer create(Bitmap bitmap) {
- IntSize size = new IntSize(bitmap.getWidth(), bitmap.getHeight());
- // allocate a buffer that can hold our max screenshot size
- ByteBuffer buffer = DirectBufferAllocator.allocate(SCREENSHOT_SIZE_LIMIT * 2);
- // construct the screenshot layer
- ScreenshotLayer sl = new ScreenshotLayer(new ScreenshotImage(buffer, size.width, size.height, CairoImage.FORMAT_RGB16_565), size);
- // paint the passed in bitmap into the buffer
- sl.setBitmap(bitmap);
- return sl;
- }
-
- private ScreenshotLayer(ScreenshotImage image, IntSize size) {
- super(image, TileLayer.PaintMode.NORMAL);
- mBufferSize = size;
- mImage = image;
- }
-
- @Override
- public void draw(RenderContext context) {
- // mTextureIDs may be null here during startup if Layer.java's draw method
- // failed to acquire the transaction lock and call performUpdates.
- if (!initialized())
- return;
-
- float txl, txr, txb, txt;
-
- Rect position = getPosition();
-
- float bw = mBufferSize.width;
- float bh = mBufferSize.height;
- float iw = mImageSize.width;
- float ih = mImageSize.height;
-
- float pw = context.pageRect.width();
- float ph = context.pageRect.height();
-
- float vl = context.viewport.left;
- float vr = context.viewport.right;
- float vt = context.viewport.top;
- float vb = context.viewport.bottom;
-
- float vw = vr - vl;
- float vh = vb - vt;
-
- txl = (iw/bw) * (vl / pw);
- txr = (iw/bw) * (vr / pw);
- txt = 1.0f - ((ih/bh) * (vt / ph));
- txb = 1.0f - ((ih/bh) * (vb / ph));
-
- float[] coords = {
- 0.0f, 0.0f, 0.0f, txl, txb,
- 0.0f, 1.0f, 0.0f, txl, txt,
- 1.0f, 0.0f, 0.0f, txr, txb,
- 1.0f, 1.0f, 0.0f, txr, txt,
- };
-
- FloatBuffer coordBuffer = context.coordBuffer;
- int positionHandle = context.positionHandle;
- int textureHandle = context.textureHandle;
-
- GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, getTextureID());
-
- // Make sure we are at position zero in the buffer
- coordBuffer.position(0);
- coordBuffer.put(coords);
-
- // Vertex coordinates are x,y,z starting at position 0 into the buffer.
- coordBuffer.position(0);
- GLES20.glVertexAttribPointer(positionHandle, 3, GLES20.GL_FLOAT, false, 20, coordBuffer);
-
- // Texture coordinates are texture_x, texture_y starting at position 3 into the buffer.
- coordBuffer.position(3);
- GLES20.glVertexAttribPointer(textureHandle, 2, GLES20.GL_FLOAT, false, 20, coordBuffer);
- GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
- }
-
- /** A Cairo image that simply saves a buffer of pixel data. */
- static class ScreenshotImage extends CairoImage {
- private ByteBuffer mBuffer;
- private IntSize mSize;
- private int mFormat;
-
- /** Creates a buffered Cairo image from a byte buffer. */
- public ScreenshotImage(ByteBuffer inBuffer, int inWidth, int inHeight, int inFormat) {
- mBuffer = inBuffer;
- mSize = new IntSize(inWidth, inHeight);
- mFormat = inFormat;
- }
-
- @Override
- protected void finalize() throws Throwable {
- try {
- if (mBuffer != null) {
- DirectBufferAllocator.free(mBuffer);
- mBuffer = null;
- }
- } finally {
- super.finalize();
- }
- }
-
- void setBitmap(Bitmap bitmap, int width, int height, int format) {
- Bitmap tmp;
- mSize = new IntSize(width, height);
- mFormat = format;
- if (width == bitmap.getWidth() && height == bitmap.getHeight()) {
- tmp = bitmap;
- } else {
- tmp = Bitmap.createBitmap(width, height, CairoUtils.cairoFormatTobitmapConfig(mFormat));
- new Canvas(tmp).drawBitmap(bitmap, 0.0f, 0.0f, new Paint());
- }
- tmp.copyPixelsToBuffer(mBuffer.asIntBuffer());
- }
-
- public void updateBitmap(Bitmap bitmap, float x, float y, float width, float height) {
- Bitmap tmp = Bitmap.createBitmap(mSize.width, mSize.height, CairoUtils.cairoFormatTobitmapConfig(mFormat));
- tmp.copyPixelsFromBuffer(mBuffer.asIntBuffer());
- Canvas c = new Canvas(tmp);
- c.drawBitmap(bitmap, x, y, new Paint());
- tmp.copyPixelsToBuffer(mBuffer.asIntBuffer());
- }
-
- @Override
- public ByteBuffer getBuffer() { return mBuffer; }
-
- @Override
- public void destroy() {
- if (mBuffer != null) {
- DirectBufferAllocator.free(mBuffer);
- mBuffer = null;
- }
- }
-
- @Override
- public IntSize getSize() { return mSize; }
- @Override
- public int getFormat() { return mFormat; }
- }
-}
commit 51f0f88304f8fcb88abe18b21fd91e2891337676
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Sun Feb 15 11:45:56 2015 +0900
android: remove LOEventFactory
Change-Id: I46809f24337e56b47a379eb4c482251b97337fd9
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOAbout.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOAbout.java
index b34b2c4..47ecddf 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOAbout.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOAbout.java
@@ -31,8 +31,8 @@ public abstract class LOAbout extends Activity {
i.setComponent(componentName);
startActivity(i);
} else {
- LOKitShell.sendEvent(LOEventFactory.close());
- LOKitShell.sendEvent(LOEventFactory.load(input));
+ LOKitShell.sendCloseEvent();
+ LOKitShell.sendLoadEvent(input);
}
}
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEventFactory.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEventFactory.java
deleted file mode 100644
index 71bceb2..0000000
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEventFactory.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package org.libreoffice;
-
-import org.mozilla.gecko.gfx.ComposedTileLayer;
-import org.mozilla.gecko.gfx.IntSize;
-
-
-public class LOEventFactory {
- public static LOEvent sizeChanged(int widthPixels, int heightPixels) {
- return new LOEvent(LOEvent.SIZE_CHANGED, widthPixels, heightPixels);
- }
-
- public static LOEvent tileSize(IntSize tileSize) {
- return new LOEvent(LOEvent.TILE_SIZE, tileSize);
- }
-
- public static LOEvent changePart(int part) {
- return new LOEvent(LOEvent.CHANGE_PART, part);
- }
-
- public static LOEvent load(String inputFile) {
- return new LOEvent(LOEvent.LOAD, inputFile);
- }
-
- public static LOEvent close() {
- return new LOEvent(LOEvent.CLOSE);
- }
-
- public static LOEvent redraw() {
- return new LOEvent(LOEvent.REDRAW);
- }
-
- public static LOEvent tileRequest(ComposedTileLayer composedTileLayer, TileIdentifier tileID, boolean forceRedraw) {
- return new LOEvent(LOEvent.TILE_REQUEST, composedTileLayer, tileID);
- }
-
- public static LOEvent thumbnail(ThumbnailCreator.ThumbnailCreationTask task) {
- return new LOEvent(LOEvent.THUMBNAIL, task);
- }
-}
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
index 401608e..fd54bbf 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
@@ -9,6 +9,7 @@ import android.util.DisplayMetrics;
import android.view.KeyEvent;
import android.view.MotionEvent;
+import org.mozilla.gecko.gfx.ComposedTileLayer;
import org.mozilla.gecko.gfx.LayerView;
@@ -57,6 +58,14 @@ public class LOKitShell {
return metrics;
}
+ public static boolean isEditingEnabled() {
+ return false;
+ }
+
+ public static LayerView getLayerView() {
+ return LibreOfficeMainActivity.mAppContext.getLayerClient().getView();
+ }
+
// EVENTS
/**
@@ -93,11 +102,30 @@ public class LOKitShell {
LOKitShell.sendEvent(new LOEvent(LOEvent.KEY_EVENT, "KeyRelease", event));
}
- public static boolean isEditingEnabled() {
- return false;
+ public static void sendSizeChangedEvent(int width, int height) {
+ LOKitShell.sendEvent(new LOEvent(LOEvent.SIZE_CHANGED, width, height));
}
- public static LayerView getLayerView() {
- return LibreOfficeMainActivity.mAppContext.getLayerClient().getView();
+ public static void sendChangePartEvent(int part) {
+ LOKitShell.sendEvent(new LOEvent(LOEvent.CHANGE_PART, part));
+ }
+
+ public static void sendLoadEvent(String inputFile) {
+ LOKitShell.sendEvent(new LOEvent(LOEvent.LOAD, inputFile));
+ }
+
+ public static void sendCloseEvent() {
+ LOKitShell.sendEvent(new LOEvent(LOEvent.CLOSE));
}
+
+ public static void sendRedrawEvent() {
+ LOKitShell.sendEvent(new LOEvent(LOEvent.REDRAW));
+ }
+
+ public static void sendTileRequestEvent(ComposedTileLayer composedTileLayer, TileIdentifier tileID, boolean forceRedraw, int priority) {
+ LOEvent event = new LOEvent(LOEvent.TILE_REQUEST, composedTileLayer, tileID);
+ event.mPriority = priority;
+ LOKitShell.sendEvent(event);
+ }
+
}
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
index ad4d920..0b87a59 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
@@ -192,13 +192,13 @@ public class LibreOfficeMainActivity extends LOAbout {
protected void onStart() {
Log.i(LOGTAG, "onStart..");
super.onStart();
- LOKitShell.sendEvent(LOEventFactory.load(mInputFile));
+ LOKitShell.sendLoadEvent(mInputFile);
}
@Override
protected void onStop() {
Log.i(LOGTAG, "onStop..");
- LOKitShell.sendEvent(LOEventFactory.close());
+ LOKitShell.sendCloseEvent();
super.onStop();
}
@@ -293,7 +293,7 @@ public class LibreOfficeMainActivity extends LOAbout {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
DocumentPartView partView = mDocumentPartViewListAdapter.getItem(position);
- LOKitShell.sendEvent(LOEventFactory.changePart(partView.partIndex));
+ LOKitShell.sendChangePartEvent(partView.partIndex);
mDrawerLayout.closeDrawer(mDrawerList);
}
}
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
index 02fa4fa..8bbcb2b 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
@@ -8,7 +8,6 @@ import android.graphics.Region;
import android.util.Log;
import org.libreoffice.LOEvent;
-import org.libreoffice.LOEventFactory;
import org.libreoffice.LOKitShell;
import org.libreoffice.TileIdentifier;
import org.mozilla.gecko.util.FloatUtils;
@@ -162,9 +161,7 @@ public abstract class ComposedTileLayer extends Layer implements ComponentCallba
}
if (!contains) {
TileIdentifier tileId = new TileIdentifier((int) x, (int) y, currentZoom, tileSize);
- LOEvent event = LOEventFactory.tileRequest(this, tileId, true);
- event.mPriority = getTilePriority();
- LOKitShell.sendEvent(event);
+ LOKitShell.sendTileRequestEvent(this, tileId, true, getTilePriority());
}
}
}
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 93beb3d..4c3f87a 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
@@ -13,7 +13,6 @@ import android.util.DisplayMetrics;
import android.util.Log;
import org.libreoffice.LOEvent;
-import org.libreoffice.LOEventFactory;
import org.libreoffice.LOKitShell;
import org.libreoffice.LOKitThread;
import org.mozilla.gecko.ZoomConstraints;
@@ -156,8 +155,7 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
mScreenSize = newScreenSize;
- LOEvent event = LOEventFactory.sizeChanged(mScreenSize.width, mScreenSize.height);
- LOKitShell.sendEvent(event);
+ LOKitShell.sendSizeChangedEvent(mScreenSize.width, mScreenSize.height);
}
/**
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
index 342dc3c..42750df 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/SubTile.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/SubTile.java
@@ -253,4 +253,4 @@ public class SubTile extends Layer {
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
}
}
-}
+}
\ No newline at end of file
More information about the Libreoffice-commits
mailing list