summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-09-24 13:18:03 +0200
committerTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-09-24 20:43:04 +0200
commit0455b3d4b874db06a205d1133f48bcd323665911 (patch)
tree7f68c07da06ecb69ea63cf4733343f46f7e7fa73 /android
parent2550cb0124f19269521cecfba39afa4ac4023431 (diff)
android: update LayerRenderer to newer Fennec code
Change-Id: Idc7c49351c17dc9953d55ee7f1b42e497074c85a
Diffstat (limited to 'android')
-rw-r--r--android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java2
-rw-r--r--android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerRenderer.java92
-rw-r--r--android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java4
3 files changed, 32 insertions, 66 deletions
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
index 506c57eed0f1..bdcfb1d77346 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
@@ -152,7 +152,7 @@ public class LOKitThread extends Thread {
Log.i(LOGTAG, "Done generate thumbnail!");
if (bitmap != null) {
Log.i(LOGTAG, "Setting checkboard image!");
- mApplication.getLayerController().getView().changeCheckerboardBitmap(bitmap);
+ mApplication.getLayerController().getView().changeCheckerboardBitmap(bitmap, mTileProvider.getPageWidth(), mTileProvider.getPageHeight());
Log.i(LOGTAG, "Done setting checkboard image!!");
mCheckboardImageSet = 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 ade6a462509a..5146b229bdf8 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
@@ -1,41 +1,7 @@
/* -*- 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>
- * Chris Lord <chrislord.net@gmail.com>
- * Arkady Blyakher <rkadyb@mit.edu>
- *
- * 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 ***** */
+ * 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;
@@ -88,7 +54,8 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
private final ScrollbarLayer mHorizScrollLayer;
private final ScrollbarLayer mVertScrollLayer;
private final FadeRunnable mFadeRunnable;
- private final FloatBuffer mCoordBuffer;
+ private ByteBuffer mCoordByteBuffer;
+ private FloatBuffer mCoordBuffer;
private RenderContext mLastPageContext;
private int mMaxTextureSize;
private int mBackgroundColor;
@@ -153,20 +120,26 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
" gl_FragColor = texture2D(sTexture, vec2(vTexCoord.x, 1.0 - vTexCoord.y));\n" +
"}\n";
- public void setCheckerboardBitmap(Bitmap bitmap) {
+ public void setCheckerboardBitmap(Bitmap bitmap, float pageWidth, float pageHeight) {
mCheckerboardLayer.setBitmap(bitmap);
mCheckerboardLayer.beginTransaction();
try {
+ mCheckerboardLayer.setPosition(new Rect(0, 0, Math.round(pageWidth),
+ Math.round(pageHeight)));
mCheckerboardLayer.invalidate();
} finally {
mCheckerboardLayer.endTransaction();
}
}
- public void updateCheckerboardBitmap(Bitmap bitmap, float x, float y, float width, float height) {
+ public void updateCheckerboardBitmap(Bitmap bitmap, float x, float y,
+ float width, float height,
+ float pageWidth, float pageHeight) {
mCheckerboardLayer.updateBitmap(bitmap, x, y, width, height);
mCheckerboardLayer.beginTransaction();
try {
+ mCheckerboardLayer.setPosition(new Rect(0, 0, Math.round(pageWidth),
+ Math.round(pageHeight)));
mCheckerboardLayer.invalidate();
} finally {
mCheckerboardLayer.endTransaction();
@@ -175,12 +148,6 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
public void resetCheckerboard() {
mCheckerboardLayer.reset();
- mCheckerboardLayer.beginTransaction();
- try {
- mCheckerboardLayer.invalidate();
- } finally {
- mCheckerboardLayer.endTransaction();
- }
}
public LayerRenderer(LayerView view) {
@@ -205,9 +172,22 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
// Initialize the FloatBuffer that will be used to store all vertices and texture
// coordinates in draw() commands.
- ByteBuffer byteBuffer = DirectBufferAllocator.allocate(COORD_BUFFER_SIZE * 4);
- byteBuffer.order(ByteOrder.nativeOrder());
- mCoordBuffer = byteBuffer.asFloatBuffer();
+ mCoordByteBuffer = DirectBufferAllocator.allocate(COORD_BUFFER_SIZE * 4);
+ mCoordByteBuffer.order(ByteOrder.nativeOrder());
+ mCoordBuffer = mCoordByteBuffer.asFloatBuffer();
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ try {
+ if (mCoordByteBuffer != null) {
+ DirectBufferAllocator.free(mCoordByteBuffer);
+ mCoordByteBuffer = null;
+ mCoordBuffer = null;
+ }
+ } finally {
+ super.finalize();
+ }
}
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
@@ -408,20 +388,6 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
}).start();
}
- private void updateCheckerboardImage() {
- int checkerboardColor = mView.getController().getCheckerboardColor();
- boolean showChecks = mView.getController().checkerboardShouldShowChecks();
-
- mCheckerboardLayer.beginTransaction(); // called on compositor thread
- try {
- if (mCheckerboardLayer.updateBackground(showChecks, checkerboardColor))
- mCheckerboardLayer.invalidate();
- } finally {
- mCheckerboardLayer.endTransaction();
- }
-
- }
-
/*
* create a vertex shader type (GLES20.GL_VERTEX_SHADER)
* or a fragment shader type (GLES20.GL_FRAGMENT_SHADER)
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 62a26bf48cab..f981667486be 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
@@ -348,8 +348,8 @@ public class LayerView extends SurfaceView implements SurfaceHolder.Callback {
}
}
- public void changeCheckerboardBitmap(Bitmap bitmap) {
+ public void changeCheckerboardBitmap(Bitmap bitmap, float pageWidth, float pageHeight) {
mRenderer.resetCheckerboard();
- mRenderer.setCheckerboardBitmap(bitmap);
+ mRenderer.setCheckerboardBitmap(bitmap, pageWidth, pageHeight);
}
}