Rip out unused GeckoSoftwareLayerClient since we've committed to GL layers.
This commit is contained in:
@@ -44,7 +44,6 @@ import org.mozilla.gecko.db.BrowserDB;
|
|||||||
import org.mozilla.gecko.gfx.FloatSize;
|
import org.mozilla.gecko.gfx.FloatSize;
|
||||||
import org.mozilla.gecko.gfx.GeckoGLLayerClient;
|
import org.mozilla.gecko.gfx.GeckoGLLayerClient;
|
||||||
import org.mozilla.gecko.gfx.GeckoLayerClient;
|
import org.mozilla.gecko.gfx.GeckoLayerClient;
|
||||||
import org.mozilla.gecko.gfx.GeckoSoftwareLayerClient;
|
|
||||||
import org.mozilla.gecko.gfx.IntSize;
|
import org.mozilla.gecko.gfx.IntSize;
|
||||||
import org.mozilla.gecko.gfx.Layer;
|
import org.mozilla.gecko.gfx.Layer;
|
||||||
import org.mozilla.gecko.gfx.LayerController;
|
import org.mozilla.gecko.gfx.LayerController;
|
||||||
|
|||||||
@@ -112,7 +112,6 @@ FENNEC_JAVA_FILES = \
|
|||||||
gfx/FloatSize.java \
|
gfx/FloatSize.java \
|
||||||
gfx/GeckoGLLayerClient.java \
|
gfx/GeckoGLLayerClient.java \
|
||||||
gfx/GeckoLayerClient.java \
|
gfx/GeckoLayerClient.java \
|
||||||
gfx/GeckoSoftwareLayerClient.java \
|
|
||||||
gfx/GLController.java \
|
gfx/GLController.java \
|
||||||
gfx/GLThread.java \
|
gfx/GLThread.java \
|
||||||
gfx/InputConnectionHandler.java \
|
gfx/InputConnectionHandler.java \
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ public abstract class GeckoLayerClient extends LayerClient implements GeckoEvent
|
|||||||
private static final String LOGTAG = "GeckoLayerClient";
|
private static final String LOGTAG = "GeckoLayerClient";
|
||||||
|
|
||||||
public static final int LAYER_CLIENT_TYPE_NONE = 0;
|
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;
|
public static final int LAYER_CLIENT_TYPE_GL = 2;
|
||||||
|
|
||||||
protected IntSize mScreenSize;
|
protected IntSize mScreenSize;
|
||||||
|
|||||||
@@ -1,321 +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>
|
|
||||||
* Chris Lord <chrislord.net@gmail.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 org.mozilla.gecko.gfx.CairoImage;
|
|
||||||
import org.mozilla.gecko.gfx.IntSize;
|
|
||||||
import org.mozilla.gecko.gfx.LayerClient;
|
|
||||||
import org.mozilla.gecko.gfx.LayerController;
|
|
||||||
import org.mozilla.gecko.gfx.LayerRenderer;
|
|
||||||
import org.mozilla.gecko.gfx.MultiTileLayer;
|
|
||||||
import org.mozilla.gecko.gfx.PointUtils;
|
|
||||||
import org.mozilla.gecko.gfx.WidgetTileLayer;
|
|
||||||
import org.mozilla.gecko.GeckoAppShell;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.Point;
|
|
||||||
import android.graphics.Rect;
|
|
||||||
import android.graphics.RectF;
|
|
||||||
import android.util.Log;
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Transfers a software-rendered Gecko to an ImageLayer so that it can be rendered by our
|
|
||||||
* compositor.
|
|
||||||
*
|
|
||||||
* TODO: Throttle down Gecko's priority when we pan and zoom.
|
|
||||||
*/
|
|
||||||
public class GeckoSoftwareLayerClient extends GeckoLayerClient {
|
|
||||||
private static final String LOGTAG = "GeckoSoftwareLayerClient";
|
|
||||||
|
|
||||||
private int mFormat;
|
|
||||||
private IntSize mViewportSize;
|
|
||||||
private ByteBuffer mBuffer;
|
|
||||||
|
|
||||||
private CairoImage mCairoImage;
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
mFormat = CairoImage.FORMAT_RGB16_565;
|
|
||||||
|
|
||||||
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 {
|
|
||||||
try {
|
|
||||||
if (mBuffer != null)
|
|
||||||
GeckoAppShell.freeDirectBuffer(mBuffer);
|
|
||||||
mBuffer = null;
|
|
||||||
} finally {
|
|
||||||
super.finalize();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLayerController(LayerController layerController) {
|
|
||||||
super.setLayerController(layerController);
|
|
||||||
|
|
||||||
layerController.setRoot(mTileLayer);
|
|
||||||
if (mGeckoViewport != null) {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
getLayerController().setRoot(mTileLayer);
|
|
||||||
|
|
||||||
// Force a resize event to be sent because the results of this
|
|
||||||
// are different depending on what tile system we're using
|
|
||||||
sendResizeEventIfNecessary(true);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
if (bufferRect == null) {
|
|
||||||
return bufferRect;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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) {
|
|
||||||
GeckoAppShell.freeDirectBuffer(mBuffer);
|
|
||||||
mBuffer = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
mBuffer = GeckoAppShell.allocateDirectBuffer(size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return bufferRect;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void updateLayerAfterDraw(Rect updatedRect) {
|
|
||||||
if (!(mTileLayer instanceof MultiTileLayer)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
((MultiTileLayer)mTileLayer).invalidate(updatedRect);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void copyPixelsFromMultiTileLayer(Bitmap target) {
|
|
||||||
Canvas c = new Canvas(target);
|
|
||||||
ByteBuffer tileBuffer = mBuffer.slice();
|
|
||||||
int bpp = CairoUtils.bitsPerPixelForCairoFormat(mFormat) / 8;
|
|
||||||
|
|
||||||
for (int y = 0; y < mBufferSize.height; y += TILE_SIZE.height) {
|
|
||||||
for (int x = 0; x < mBufferSize.width; x += TILE_SIZE.width) {
|
|
||||||
// Calculate tile size
|
|
||||||
IntSize tileSize = new IntSize(Math.min(mBufferSize.width - x, TILE_SIZE.width),
|
|
||||||
Math.min(mBufferSize.height - y, TILE_SIZE.height));
|
|
||||||
|
|
||||||
// Create a Bitmap from this tile
|
|
||||||
Bitmap tile = Bitmap.createBitmap(tileSize.width, tileSize.height,
|
|
||||||
CairoUtils.cairoFormatTobitmapConfig(mFormat));
|
|
||||||
tile.copyPixelsFromBuffer(tileBuffer.asIntBuffer());
|
|
||||||
|
|
||||||
// Copy the tile to the master Bitmap and recycle it
|
|
||||||
c.drawBitmap(tile, x, y, null);
|
|
||||||
tile.recycle();
|
|
||||||
|
|
||||||
// Progress the buffer to the next tile
|
|
||||||
tileBuffer.position(tileSize.getArea() * bpp);
|
|
||||||
tileBuffer = tileBuffer.slice();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void tileLayerUpdated() {
|
|
||||||
/* No-op. */
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Bitmap getBitmap() {
|
|
||||||
if (mTileLayer == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
// Begin a tile transaction, otherwise the buffer can be destroyed while
|
|
||||||
// we're reading from it.
|
|
||||||
beginTransaction(mTileLayer);
|
|
||||||
try {
|
|
||||||
if (mBuffer == null || mBufferSize.width <= 0 || mBufferSize.height <= 0)
|
|
||||||
return null;
|
|
||||||
try {
|
|
||||||
Bitmap b = null;
|
|
||||||
|
|
||||||
if (mTileLayer instanceof MultiTileLayer) {
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
|
|
||||||
return b;
|
|
||||||
} catch (OutOfMemoryError oom) {
|
|
||||||
Log.w(LOGTAG, "Unable to create bitmap", oom);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
} 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 */
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getType() {
|
|
||||||
return LAYER_CLIENT_TYPE_SOFTWARE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@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)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected IntSize getTileSize() {
|
|
||||||
// Round up depending on layer implementation to remove texture wastage
|
|
||||||
return !mHasDirectTexture ? TILE_SIZE : new IntSize(0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -991,12 +991,6 @@ void
|
|||||||
AndroidBridge::SetLayerClient(jobject obj, jint type)
|
AndroidBridge::SetLayerClient(jobject obj, jint type)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case LAYER_CLIENT_TYPE_SOFTWARE: {
|
|
||||||
AndroidGeckoSoftwareLayerClient *client = new AndroidGeckoSoftwareLayerClient();
|
|
||||||
client->Init(obj);
|
|
||||||
mLayerClient = client;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case LAYER_CLIENT_TYPE_GL: {
|
case LAYER_CLIENT_TYPE_GL: {
|
||||||
AndroidGeckoGLLayerClient *client = new AndroidGeckoGLLayerClient();
|
AndroidGeckoGLLayerClient *client = new AndroidGeckoGLLayerClient();
|
||||||
client->Init(obj);
|
client->Init(obj);
|
||||||
|
|||||||
@@ -122,7 +122,6 @@ public:
|
|||||||
|
|
||||||
enum {
|
enum {
|
||||||
LAYER_CLIENT_TYPE_NONE = 0,
|
LAYER_CLIENT_TYPE_NONE = 0,
|
||||||
LAYER_CLIENT_TYPE_SOFTWARE = 1, // AndroidGeckoSoftwareLayerClient
|
|
||||||
LAYER_CLIENT_TYPE_GL = 2 // AndroidGeckoGLLayerClient
|
LAYER_CLIENT_TYPE_GL = 2 // AndroidGeckoGLLayerClient
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -113,11 +113,6 @@ jclass AndroidGeckoLayerClient::jGeckoLayerClientClass = 0;
|
|||||||
jmethodID AndroidGeckoLayerClient::jBeginDrawingMethod = 0;
|
jmethodID AndroidGeckoLayerClient::jBeginDrawingMethod = 0;
|
||||||
jmethodID AndroidGeckoLayerClient::jEndDrawingMethod = 0;
|
jmethodID AndroidGeckoLayerClient::jEndDrawingMethod = 0;
|
||||||
|
|
||||||
jclass AndroidGeckoSoftwareLayerClient::jGeckoSoftwareLayerClientClass = 0;
|
|
||||||
jmethodID AndroidGeckoSoftwareLayerClient::jLockBufferMethod = 0;
|
|
||||||
jmethodID AndroidGeckoSoftwareLayerClient::jUnlockBufferMethod = 0;
|
|
||||||
jmethodID AndroidGeckoSoftwareLayerClient::jGetRenderOffsetMethod = 0;
|
|
||||||
|
|
||||||
jclass AndroidGeckoGLLayerClient::jGeckoGLLayerClientClass = 0;
|
jclass AndroidGeckoGLLayerClient::jGeckoGLLayerClientClass = 0;
|
||||||
jmethodID AndroidGeckoGLLayerClient::jGetViewTransformMethod = 0;
|
jmethodID AndroidGeckoGLLayerClient::jGetViewTransformMethod = 0;
|
||||||
jmethodID AndroidGeckoGLLayerClient::jCreateFrameMethod = 0;
|
jmethodID AndroidGeckoGLLayerClient::jCreateFrameMethod = 0;
|
||||||
@@ -135,9 +130,6 @@ jfieldID AndroidViewTransform::jXField = 0;
|
|||||||
jfieldID AndroidViewTransform::jYField = 0;
|
jfieldID AndroidViewTransform::jYField = 0;
|
||||||
jfieldID AndroidViewTransform::jScaleField = 0;
|
jfieldID AndroidViewTransform::jScaleField = 0;
|
||||||
|
|
||||||
jmethodID AndroidGeckoSoftwareLayerClient::jBeginDrawingMethod = 0;
|
|
||||||
jmethodID AndroidGeckoSoftwareLayerClient::jEndDrawingMethod = 0;
|
|
||||||
|
|
||||||
jclass AndroidGeckoSurfaceView::jGeckoSurfaceViewClass = 0;
|
jclass AndroidGeckoSurfaceView::jGeckoSurfaceViewClass = 0;
|
||||||
jmethodID AndroidGeckoSurfaceView::jBeginDrawingMethod = 0;
|
jmethodID AndroidGeckoSurfaceView::jBeginDrawingMethod = 0;
|
||||||
jmethodID AndroidGeckoSurfaceView::jEndDrawingMethod = 0;
|
jmethodID AndroidGeckoSurfaceView::jEndDrawingMethod = 0;
|
||||||
@@ -169,7 +161,6 @@ mozilla::InitAndroidJavaWrappers(JNIEnv *jEnv)
|
|||||||
AndroidAddress::InitAddressClass(jEnv);
|
AndroidAddress::InitAddressClass(jEnv);
|
||||||
AndroidRect::InitRectClass(jEnv);
|
AndroidRect::InitRectClass(jEnv);
|
||||||
AndroidGeckoLayerClient::InitGeckoLayerClientClass(jEnv);
|
AndroidGeckoLayerClient::InitGeckoLayerClientClass(jEnv);
|
||||||
AndroidGeckoSoftwareLayerClient::InitGeckoSoftwareLayerClientClass(jEnv);
|
|
||||||
AndroidGeckoGLLayerClient::InitGeckoGLLayerClientClass(jEnv);
|
AndroidGeckoGLLayerClient::InitGeckoGLLayerClientClass(jEnv);
|
||||||
AndroidLayerRendererFrame::InitLayerRendererFrameClass(jEnv);
|
AndroidLayerRendererFrame::InitLayerRendererFrameClass(jEnv);
|
||||||
AndroidViewTransform::InitViewTransformClass(jEnv);
|
AndroidViewTransform::InitViewTransformClass(jEnv);
|
||||||
@@ -361,22 +352,6 @@ AndroidGeckoLayerClient::InitGeckoLayerClientClass(JNIEnv *jEnv)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
AndroidGeckoSoftwareLayerClient::InitGeckoSoftwareLayerClientClass(JNIEnv *jEnv)
|
|
||||||
{
|
|
||||||
#ifdef MOZ_JAVA_COMPOSITOR
|
|
||||||
initInit();
|
|
||||||
|
|
||||||
jGeckoSoftwareLayerClientClass =
|
|
||||||
getClassGlobalRef("org/mozilla/gecko/gfx/GeckoSoftwareLayerClient");
|
|
||||||
|
|
||||||
jLockBufferMethod = getMethod("lockBuffer", "()Ljava/nio/ByteBuffer;");
|
|
||||||
jUnlockBufferMethod = getMethod("unlockBuffer", "()V");
|
|
||||||
jBeginDrawingMethod = getMethod("beginDrawing", "(IIIILjava/lang/String;Z)Landroid/graphics/Rect;");
|
|
||||||
jEndDrawingMethod = getMethod("endDrawing", "(IIII)V");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AndroidGeckoGLLayerClient::InitGeckoGLLayerClientClass(JNIEnv *jEnv)
|
AndroidGeckoGLLayerClient::InitGeckoGLLayerClientClass(JNIEnv *jEnv)
|
||||||
{
|
{
|
||||||
@@ -685,13 +660,6 @@ AndroidPoint::Init(JNIEnv *jenv, jobject jobj)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
AndroidGeckoSoftwareLayerClient::Init(jobject jobj)
|
|
||||||
{
|
|
||||||
NS_ASSERTION(wrapped_obj == nsnull, "Init called on non-null wrapped_obj!");
|
|
||||||
wrapped_obj = jobj;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AndroidGeckoGLLayerClient::Init(jobject jobj)
|
AndroidGeckoGLLayerClient::Init(jobject jobj)
|
||||||
{
|
{
|
||||||
@@ -820,98 +788,6 @@ AndroidGeckoLayerClient::EndDrawing(const nsIntRect &aRect)
|
|||||||
aRect.height);
|
aRect.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
jobject
|
|
||||||
AndroidGeckoSoftwareLayerClient::LockBuffer()
|
|
||||||
{
|
|
||||||
NS_ASSERTION(!isNull(), "LockBuffer() called on null software layer client!");
|
|
||||||
|
|
||||||
JNIEnv *env = AndroidBridge::GetJNIEnv();
|
|
||||||
if (!env)
|
|
||||||
return nsnull;
|
|
||||||
|
|
||||||
AndroidBridge::AutoLocalJNIFrame(env, 1);
|
|
||||||
return env->CallObjectMethod(wrapped_obj, jLockBufferMethod);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned char *
|
|
||||||
AndroidGeckoSoftwareLayerClient::LockBufferBits()
|
|
||||||
{
|
|
||||||
JNIEnv *env = AndroidBridge::GetJNIEnv();
|
|
||||||
if (!env)
|
|
||||||
return nsnull;
|
|
||||||
|
|
||||||
AndroidBridge::AutoLocalJNIFrame(env, 1);
|
|
||||||
jobject bufferObject = LockBuffer();
|
|
||||||
|
|
||||||
if (bufferObject != nsnull)
|
|
||||||
return reinterpret_cast<unsigned char *>(env->GetDirectBufferAddress(bufferObject));
|
|
||||||
|
|
||||||
return nsnull;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
AndroidGeckoSoftwareLayerClient::UnlockBuffer()
|
|
||||||
{
|
|
||||||
NS_ASSERTION(!isNull(), "UnlockBuffer() called on null software layer client!");
|
|
||||||
JNIEnv *env = AndroidBridge::GetJNIEnv();
|
|
||||||
if (!env)
|
|
||||||
return;
|
|
||||||
|
|
||||||
AndroidBridge::AutoLocalJNIFrame(env, 1);
|
|
||||||
env->CallVoidMethod(wrapped_obj, jUnlockBufferMethod);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
AndroidGeckoSoftwareLayerClient::BeginDrawing(int aWidth, int aHeight, int aTileWidth, int aTileHeight, nsIntRect &aDirtyRect, const nsAString &aMetadata, bool aHasDirectTexture)
|
|
||||||
{
|
|
||||||
NS_ASSERTION(!isNull(), "BeginDrawing() called on null software layer client!");
|
|
||||||
JNIEnv *env = AndroidBridge::GetJNIEnv();
|
|
||||||
if (!env)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
AndroidBridge::AutoLocalJNIFrame(env, 1);
|
|
||||||
jstring jMetadata = env->NewString(nsPromiseFlatString(aMetadata).get(), aMetadata.Length());
|
|
||||||
|
|
||||||
jobject rectObject = env->CallObjectMethod(wrapped_obj, jBeginDrawingMethod,
|
|
||||||
aWidth, aHeight, aTileWidth, aTileHeight,
|
|
||||||
jMetadata, aHasDirectTexture);
|
|
||||||
|
|
||||||
if (rectObject == nsnull)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
AndroidRect rect(env, rectObject);
|
|
||||||
nsIntRect newDirtyRect = aDirtyRect.Intersect(nsIntRect(rect.Top(), rect.Left(),
|
|
||||||
rect.Width(), rect.Height()));
|
|
||||||
aDirtyRect.SetRect(newDirtyRect.x, newDirtyRect.y, newDirtyRect.width, newDirtyRect.height);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
AndroidGeckoSoftwareLayerClient::EndDrawing(const nsIntRect &aRect)
|
|
||||||
{
|
|
||||||
NS_ASSERTION(!isNull(), "EndDrawing() called on null software layer client!");
|
|
||||||
|
|
||||||
JNIEnv *env = AndroidBridge::GetJNIEnv();
|
|
||||||
if (!env)
|
|
||||||
return;
|
|
||||||
|
|
||||||
AndroidBridge::AutoLocalJNIFrame(env, 1);
|
|
||||||
return env->CallVoidMethod(wrapped_obj, jEndDrawingMethod, aRect.x, aRect.y, aRect.width, aRect.height);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
AndroidGeckoSoftwareLayerClient::GetRenderOffset(nsIntPoint &aOffset)
|
|
||||||
{
|
|
||||||
JNIEnv *env = AndroidBridge::GetJNIEnv();
|
|
||||||
if (!env)
|
|
||||||
return;
|
|
||||||
|
|
||||||
AndroidPoint offset(env, env->CallObjectMethod(wrapped_obj, jGetRenderOffsetMethod));
|
|
||||||
aOffset.x = offset.X();
|
|
||||||
aOffset.y = offset.Y();
|
|
||||||
}
|
|
||||||
|
|
||||||
jobject
|
jobject
|
||||||
AndroidGeckoSurfaceView::GetSoftwareDrawBitmap()
|
AndroidGeckoSurfaceView::GetSoftwareDrawBitmap()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -174,33 +174,6 @@ protected:
|
|||||||
static jmethodID jEndDrawingMethod;
|
static jmethodID jEndDrawingMethod;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AndroidGeckoSoftwareLayerClient : public AndroidGeckoLayerClient {
|
|
||||||
public:
|
|
||||||
static void InitGeckoSoftwareLayerClientClass(JNIEnv *jEnv);
|
|
||||||
|
|
||||||
void Init(jobject jobj);
|
|
||||||
|
|
||||||
AndroidGeckoSoftwareLayerClient() {}
|
|
||||||
AndroidGeckoSoftwareLayerClient(jobject jobj) { Init(jobj); }
|
|
||||||
|
|
||||||
jobject LockBuffer();
|
|
||||||
unsigned char *LockBufferBits();
|
|
||||||
void UnlockBuffer();
|
|
||||||
void GetRenderOffset(nsIntPoint &aOffset);
|
|
||||||
bool BeginDrawing(int aWidth, int aHeight, int aTileWidth, int aTileHeight, nsIntRect &aDirtyRect, const nsAString &aMetadata, bool aHasDirectTexture);
|
|
||||||
void EndDrawing(const nsIntRect &aRect);
|
|
||||||
|
|
||||||
private:
|
|
||||||
static jclass jGeckoSoftwareLayerClientClass;
|
|
||||||
static jmethodID jLockBufferMethod;
|
|
||||||
static jmethodID jUnlockBufferMethod;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
static jmethodID jGetRenderOffsetMethod;
|
|
||||||
static jmethodID jBeginDrawingMethod;
|
|
||||||
static jmethodID jEndDrawingMethod;
|
|
||||||
};
|
|
||||||
|
|
||||||
/** A callback that retrieves the view transform. */
|
/** A callback that retrieves the view transform. */
|
||||||
class AndroidViewTransformGetter
|
class AndroidViewTransformGetter
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1310,12 +1310,6 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sDirectTexture->Lock(AndroidGraphicBuffer::UsageSoftwareWrite, dirtyRect, &bits);
|
sDirectTexture->Lock(AndroidGraphicBuffer::UsageSoftwareWrite, dirtyRect, &bits);
|
||||||
} else if (layerClientType == AndroidBridge::LAYER_CLIENT_TYPE_SOFTWARE) {
|
|
||||||
__android_log_print(ANDROID_LOG_ERROR, "Gecko", "### Software layer client!");
|
|
||||||
bits = ((AndroidGeckoSoftwareLayerClient &)client).LockBufferBits();
|
|
||||||
if (!bits) {
|
|
||||||
ALOG("### Failed to lock buffer");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetSurface->CairoStatus()) {
|
if (targetSurface->CairoStatus()) {
|
||||||
@@ -1327,8 +1321,6 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
|
|||||||
|
|
||||||
if (HasDirectTexture()) {
|
if (HasDirectTexture()) {
|
||||||
sDirectTexture->Unlock();
|
sDirectTexture->Unlock();
|
||||||
} else if (layerClientType == AndroidBridge::LAYER_CLIENT_TYPE_SOFTWARE) {
|
|
||||||
((AndroidGeckoSoftwareLayerClient &)client).UnlockBuffer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
__android_log_print(ANDROID_LOG_ERROR, "Gecko", "### Calling EndDrawing()!");
|
__android_log_print(ANDROID_LOG_ERROR, "Gecko", "### Calling EndDrawing()!");
|
||||||
|
|||||||
Reference in New Issue
Block a user