Bug 730033 - Rip out WidgetTileLayer and associated gunk. r=snorp

This commit is contained in:
Kartikaya Gupta 2012-02-23 14:55:15 -05:00
Родитель 5a1faf48cb
Коммит 1f8e580c79
9 изменённых файлов: 10 добавлений и 266 удалений

Просмотреть файл

@ -177,7 +177,6 @@ public class GeckoAppShell
public static native ByteBuffer allocateDirectBuffer(long size);
public static native void freeDirectBuffer(ByteBuffer buf);
public static native void bindWidgetTexture();
public static native void scheduleComposite();
public static native void schedulePauseComposition();
public static native void scheduleResumeComposition();

Просмотреть файл

@ -134,7 +134,6 @@ FENNEC_JAVA_FILES = \
gfx/ViewTransform.java \
gfx/ViewportMetrics.java \
gfx/VirtualLayer.java \
gfx/WidgetTileLayer.java \
ui/Axis.java \
ui/PanZoomController.java \
ui/SimpleScaleGestureDetector.java \

Просмотреть файл

@ -127,9 +127,8 @@ public class GeckoLayerClient implements GeckoEventListener,
/** This function is invoked by Gecko via JNI; be careful when modifying signature. */
public Rect beginDrawing(int width, int height, int tileWidth, int tileHeight,
String metadata, boolean hasDirectTexture) {
Log.e(LOGTAG, "### beginDrawing " + width + " " + height + " " + tileWidth + " " +
tileHeight + " " + hasDirectTexture);
String metadata) {
Log.e(LOGTAG, "### beginDrawing " + width + " " + height + " " + tileWidth + " " + tileHeight);
// If the viewport has changed but we still don't have the latest viewport
// from Gecko, ignore the viewport passed to us from Gecko since that is going
@ -140,8 +139,8 @@ public class GeckoLayerClient implements GeckoEventListener,
mFirstPaint = false;
// If we've changed surface types, cancel this draw
if (handleDirectTextureChange(hasDirectTexture)) {
Log.e(LOGTAG, "### Cancelling draw due to direct texture change");
if (initializeVirtualLayer()) {
Log.e(LOGTAG, "### Cancelling draw due to virtual layer initialization");
return null;
}
@ -318,7 +317,7 @@ public class GeckoLayerClient implements GeckoEventListener,
return Color.rgb(r, g, b);
}
private boolean handleDirectTextureChange(boolean hasDirectTexture) {
private boolean initializeVirtualLayer() {
if (mTileLayer != null) {
return false;
}

Просмотреть файл

@ -1,159 +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):
* James Willcox <jwillcox@mozilla.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 ***** */
package org.mozilla.gecko.gfx;
import org.mozilla.gecko.gfx.LayerController;
import org.mozilla.gecko.gfx.SingleTileLayer;
import org.mozilla.gecko.GeckoAppShell;
import android.graphics.RectF;
import android.util.Log;
import android.opengl.GLES20;
import java.nio.FloatBuffer;
/**
* Encapsulates the logic needed to draw the single-tiled Gecko texture
*/
public class WidgetTileLayer extends Layer {
private static final String LOGTAG = "WidgetTileLayer";
private int[] mTextureIDs;
private CairoImage mImage;
public WidgetTileLayer(CairoImage image) {
mImage = image;
}
protected boolean initialized() { return mTextureIDs != null; }
@Override
public IntSize getSize() { return mImage.getSize(); }
protected void bindAndSetGLParameters() {
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureIDs[0]);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
}
@Override
protected void finalize() throws Throwable {
if (mTextureIDs != null)
TextureReaper.get().add(mTextureIDs);
}
@Override
protected boolean performUpdates(RenderContext context) {
super.performUpdates(context);
if (mTextureIDs == null) {
mTextureIDs = new int[1];
GLES20.glGenTextures(1, mTextureIDs, 0);
}
bindAndSetGLParameters();
GeckoAppShell.bindWidgetTexture();
return true;
}
@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;
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureIDs[0]);
RectF bounds;
int[] cropRect;
IntSize size = getSize();
RectF viewport = context.viewport;
bounds = getBounds(context, new FloatSize(size));
cropRect = new int[] { 0, 0, size.width, size.height };
bounds.offset(-viewport.left, -viewport.top);
float top = viewport.height() - (bounds.top + bounds.height());
// There may be errors from a previous GL call, so clear them first because
// we want to check for one below
while (GLES20.glGetError() != GLES20.GL_NO_ERROR);
float[] coords = {
//x, y, z, texture_x, texture_y
bounds.left/viewport.width(), top/viewport.height(), 0,
cropRect[0]/size.width, cropRect[1]/size.height,
bounds.left/viewport.width(), (top+bounds.height())/viewport.height(), 0,
cropRect[0]/size.width, cropRect[3]/size.height,
(bounds.left+bounds.width())/viewport.width(), top/viewport.height(), 0,
cropRect[2]/size.width, cropRect[1]/size.height,
(bounds.left+bounds.width())/viewport.width(), (top+bounds.height())/viewport.height(),
0,
cropRect[2]/size.width, cropRect[3]/size.height
};
// Get the buffer and handles from the context
FloatBuffer coordBuffer = context.coordBuffer;
int positionHandle = context.positionHandle;
int textureHandle = context.textureHandle;
// Make sure we are at position zero in the buffer in case other draw methods did not clean
// up after themselves
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);
int error = GLES20.glGetError();
if (error != GLES20.GL_NO_ERROR) {
Log.i(LOGTAG, "Failed to draw texture: " + error);
}
}
}

Просмотреть файл

@ -104,7 +104,6 @@ extern "C" {
NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_notifyReadingMessageListFailed(JNIEnv* jenv, jclass, jint, jint, jlong);
#ifdef MOZ_JAVA_COMPOSITOR
NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_bindWidgetTexture(JNIEnv* jenv, jclass);
NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_scheduleComposite(JNIEnv* jenv, jclass);
NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_schedulePauseComposition(JNIEnv* jenv, jclass);
NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_scheduleResumeComposition(JNIEnv* jenv, jclass);
@ -892,12 +891,6 @@ Java_org_mozilla_gecko_GeckoAppShell_notifyReadingMessageListFailed(JNIEnv* jenv
#ifdef MOZ_JAVA_COMPOSITOR
NS_EXPORT void JNICALL
Java_org_mozilla_gecko_GeckoAppShell_bindWidgetTexture(JNIEnv* jenv, jclass)
{
nsWindow::BindToTexture();
}
NS_EXPORT void JNICALL
Java_org_mozilla_gecko_GeckoAppShell_scheduleComposite(JNIEnv*, jclass)
{

Просмотреть файл

@ -347,7 +347,7 @@ AndroidGeckoLayerClient::InitGeckoLayerClientClass(JNIEnv *jEnv)
jGeckoLayerClientClass = getClassGlobalRef("org/mozilla/gecko/gfx/GeckoLayerClient");
jBeginDrawingMethod = getMethod("beginDrawing", "(IIIILjava/lang/String;Z)Landroid/graphics/Rect;");
jBeginDrawingMethod = getMethod("beginDrawing", "(IIIILjava/lang/String;)Landroid/graphics/Rect;");
jEndDrawingMethod = getMethod("endDrawing", "(IIII)V");
jGetViewTransformMethod = getMethod("getViewTransform",
"()Lorg/mozilla/gecko/gfx/ViewTransform;");
@ -765,7 +765,7 @@ AndroidGeckoSurfaceView::Draw2D(jobject buffer, int stride)
bool
AndroidGeckoLayerClient::BeginDrawing(int aWidth, int aHeight, int aTileWidth, int aTileHeight,
nsIntRect &aDirtyRect, const nsAString &aMetadata, bool aHasDirectTexture)
nsIntRect &aDirtyRect, const nsAString &aMetadata)
{
NS_ASSERTION(!isNull(), "BeginDrawing() called on null layer client!");
JNIEnv *env = AndroidBridge::GetJNIEnv();
@ -777,7 +777,7 @@ AndroidGeckoLayerClient::BeginDrawing(int aWidth, int aHeight, int aTileWidth, i
jobject rectObject = env->CallObjectMethod(wrapped_obj, jBeginDrawingMethod,
aWidth, aHeight, aTileWidth, aTileHeight,
jMetadata, aHasDirectTexture);
jMetadata);
if (rectObject == nsnull)
return false;

Просмотреть файл

@ -225,7 +225,7 @@ public:
: mViewTransformGetter(*this) { Init(jobj); }
bool BeginDrawing(int aWidth, int aHeight, int aTileWidth, int aTileHeight,
nsIntRect &aDirtyRect, const nsAString &aMetadata, bool aHasDirectTexture);
nsIntRect &aDirtyRect, const nsAString &aMetadata);
void EndDrawing(const nsIntRect &aRect);
void GetViewTransform(AndroidViewTransform& aViewTransform);
void CreateFrame(AndroidLayerRendererFrame& aFrame);

Просмотреть файл

@ -98,12 +98,6 @@ bool nsWindow::sAccessibilityEnabled = false;
#ifdef MOZ_JAVA_COMPOSITOR
#include "mozilla/Mutex.h"
#include "nsThreadUtils.h"
#include "AndroidDirectTexture.h"
static AndroidDirectTexture* sDirectTexture = new AndroidDirectTexture(2048, 2048,
AndroidGraphicBuffer::UsageSoftwareWrite | AndroidGraphicBuffer::UsageTexture,
gfxASurface::ImageFormatRGB16_565);
#endif
@ -842,71 +836,6 @@ nsWindow::GetThebesSurface()
return new gfxImageSurface(gfxIntSize(5,5), gfxImageSurface::ImageFormatRGB24);
}
#ifdef MOZ_JAVA_COMPOSITOR
void
nsWindow::BindToTexture()
{
sDirectTexture->Bind();
}
bool
nsWindow::HasDirectTexture()
{
// XXX: Checking fix me
// This is currently causes some crashes so disable it for now
if (true)
return false;
static bool sTestedDirectTexture = false;
static bool sHasDirectTexture = false;
// If we already tested, return early
if (sTestedDirectTexture)
return sHasDirectTexture;
sTestedDirectTexture = true;
nsAutoString board;
AndroidGraphicBuffer* buffer = NULL;
unsigned char* bits = NULL;
if (AndroidGraphicBuffer::IsBlacklisted()) {
ALOG("device is blacklisted for direct texture");
goto cleanup;
}
buffer = new AndroidGraphicBuffer(512, 512,
AndroidGraphicBuffer::UsageSoftwareWrite | AndroidGraphicBuffer::UsageTexture,
gfxASurface::ImageFormatRGB16_565);
if (buffer->Lock(AndroidGraphicBuffer::UsageSoftwareWrite, &bits) != 0 || !bits) {
ALOG("failed to lock graphic buffer");
buffer->Unlock();
goto cleanup;
}
if (buffer->Unlock() != 0) {
ALOG("failed to unlock graphic buffer");
goto cleanup;
}
if (!buffer->Reallocate(1024, 1024, gfxASurface::ImageFormatRGB16_565)) {
ALOG("failed to reallocate graphic buffer");
goto cleanup;
}
sHasDirectTexture = true;
cleanup:
if (buffer)
delete buffer;
return sHasDirectTexture;
}
#endif
void
nsWindow::OnGlobalAndroidEvent(AndroidGeckoEvent *ae)
{
@ -1288,21 +1217,12 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
AndroidGeckoLayerClient &client = AndroidBridge::Bridge()->GetLayerClient();
if (!client.BeginDrawing(gAndroidBounds.width, gAndroidBounds.height,
gAndroidTileSize.width, gAndroidTileSize.height,
dirtyRect, metadata, HasDirectTexture())) {
dirtyRect, metadata)) {
__android_log_print(ANDROID_LOG_ERROR, "Gecko", "### BeginDrawing returned false!");
return;
}
unsigned char *bits = NULL;
if (HasDirectTexture()) {
__android_log_print(ANDROID_LOG_ERROR, "Gecko", "### Have direct texture!");
if (sDirectTexture->Width() != gAndroidBounds.width ||
sDirectTexture->Height() != gAndroidBounds.height) {
sDirectTexture->Reallocate(gAndroidBounds.width, gAndroidBounds.height);
}
sDirectTexture->Lock(AndroidGraphicBuffer::UsageSoftwareWrite, dirtyRect, &bits);
}
if (targetSurface->CairoStatus()) {
ALOG("### Failed to create a valid surface from the bitmap");
@ -1311,10 +1231,6 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
DrawTo(targetSurface, dirtyRect);
}
if (HasDirectTexture()) {
sDirectTexture->Unlock();
}
__android_log_print(ANDROID_LOG_ERROR, "Gecko", "### Calling EndDrawing()!");
client.EndDrawing(dirtyRect);
return;

Просмотреть файл

@ -182,9 +182,6 @@ public:
#endif
#ifdef MOZ_JAVA_COMPOSITOR
static void BindToTexture();
static bool HasDirectTexture();
virtual void DrawWindowUnderlay(LayerManager* aManager, nsIntRect aRect);
virtual void DrawWindowOverlay(LayerManager* aManager, nsIntRect aRect);
#endif