mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Add a virtual layer and GL layer client implementation
This commit is contained in:
parent
3235b71537
commit
d6e3afde17
@ -41,6 +41,7 @@
|
||||
package org.mozilla.gecko;
|
||||
|
||||
import org.mozilla.gecko.gfx.FloatSize;
|
||||
import org.mozilla.gecko.gfx.GeckoGLLayerClient;
|
||||
import org.mozilla.gecko.gfx.GeckoLayerClient;
|
||||
import org.mozilla.gecko.gfx.GeckoSoftwareLayerClient;
|
||||
import org.mozilla.gecko.gfx.IntSize;
|
||||
@ -1591,8 +1592,12 @@ abstract public class GeckoApp
|
||||
/*
|
||||
* Create a layer client so that Gecko will have a buffer to draw into, but don't hook
|
||||
* it up to the layer controller yet.
|
||||
*
|
||||
* TODO: Switch between software and GL appropriately.
|
||||
*/
|
||||
mLayerClient = new GeckoSoftwareLayerClient(this);
|
||||
Log.e(LOGTAG, "### Creating GeckoGLLayerClient");
|
||||
mLayerClient = new GeckoGLLayerClient(this);
|
||||
Log.e(LOGTAG, "### Done creating GeckoGLLayerClient");
|
||||
|
||||
/*
|
||||
* Hook a placeholder layer client up to the layer controller so that the user can pan
|
||||
|
@ -110,6 +110,7 @@ FENNEC_JAVA_FILES = \
|
||||
gfx/CheckerboardImage.java \
|
||||
gfx/FlexibleGLSurfaceView.java \
|
||||
gfx/FloatSize.java \
|
||||
gfx/GeckoGLLayerClient.java \
|
||||
gfx/GeckoLayerClient.java \
|
||||
gfx/GeckoSoftwareLayerClient.java \
|
||||
gfx/GLController.java \
|
||||
@ -133,6 +134,7 @@ FENNEC_JAVA_FILES = \
|
||||
gfx/TextureReaper.java \
|
||||
gfx/TileLayer.java \
|
||||
gfx/ViewportMetrics.java \
|
||||
gfx/VirtualLayer.java \
|
||||
gfx/WidgetTileLayer.java \
|
||||
ui/Axis.java \
|
||||
ui/PanZoomController.java \
|
||||
|
@ -122,12 +122,17 @@ public abstract class GeckoLayerClient extends LayerClient implements GeckoEvent
|
||||
|
||||
public boolean beginDrawing(int width, int height, int tileWidth, int tileHeight,
|
||||
String metadata, boolean hasDirectTexture) {
|
||||
Log.e(LOGTAG, "### beginDrawing " + width + " " + height + " " + tileWidth + " " +
|
||||
tileHeight + " " + hasDirectTexture);
|
||||
|
||||
// If we've changed surface types, cancel this draw
|
||||
if (handleDirectTextureChange(hasDirectTexture)) {
|
||||
Log.e(LOGTAG, "### Cancelling draw due to direct texture change");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!shouldDrawProceed(tileWidth, tileHeight)) {
|
||||
Log.e(LOGTAG, "### Cancelling draw due to shouldDrawProceed()");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -202,6 +207,8 @@ public abstract class GeckoLayerClient extends LayerClient implements GeckoEvent
|
||||
|
||||
/* Informs Gecko that the screen size has changed. */
|
||||
protected void sendResizeEventIfNecessary(boolean force) {
|
||||
Log.e(LOGTAG, "### sendResizeEventIfNecessary " + force);
|
||||
|
||||
DisplayMetrics metrics = new DisplayMetrics();
|
||||
GeckoApp.mAppContext.getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
||||
|
||||
@ -219,7 +226,7 @@ public abstract class GeckoLayerClient extends LayerClient implements GeckoEvent
|
||||
mScreenSize = new IntSize(metrics.widthPixels, metrics.heightPixels);
|
||||
IntSize bufferSize = getBufferSize(), tileSize = getTileSize();
|
||||
|
||||
Log.i(LOGTAG, "Screen-size changed to " + mScreenSize);
|
||||
Log.e(LOGTAG, "### Screen-size changed to " + mScreenSize);
|
||||
GeckoEvent event = new GeckoEvent(GeckoEvent.SIZE_CHANGED,
|
||||
bufferSize.width, bufferSize.height,
|
||||
metrics.widthPixels, metrics.heightPixels,
|
||||
|
@ -186,6 +186,10 @@ public abstract class Layer {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean dimensionChangesPending() {
|
||||
return (mNewOrigin != null) || (mNewResolution != 0.0f);
|
||||
}
|
||||
|
||||
public static class RenderContext {
|
||||
public final RectF viewport;
|
||||
public final FloatSize pageSize;
|
||||
|
@ -966,12 +966,9 @@ AndroidBridge::SetLayerClient(jobject obj, jint type)
|
||||
break;
|
||||
}
|
||||
case LAYER_CLIENT_TYPE_GL: {
|
||||
// TODO: Implement.
|
||||
#if 0
|
||||
AndroidGeckoGLLayerClient *client = new AndroidGeckoGLLayerClient();
|
||||
client->Init(obj);
|
||||
mLayerClient = client;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -117,6 +117,8 @@ jmethodID AndroidGeckoSoftwareLayerClient::jLockBufferMethod = 0;
|
||||
jmethodID AndroidGeckoSoftwareLayerClient::jUnlockBufferMethod = 0;
|
||||
jmethodID AndroidGeckoSoftwareLayerClient::jGetRenderOffsetMethod = 0;
|
||||
|
||||
jclass AndroidGeckoGLLayerClient::jGeckoGLLayerClientClass = 0;
|
||||
|
||||
jclass AndroidGeckoSurfaceView::jGeckoSurfaceViewClass = 0;
|
||||
jmethodID AndroidGeckoSurfaceView::jBeginDrawingMethod = 0;
|
||||
jmethodID AndroidGeckoSurfaceView::jEndDrawingMethod = 0;
|
||||
@ -351,6 +353,16 @@ AndroidGeckoSoftwareLayerClient::InitGeckoSoftwareLayerClientClass(JNIEnv *jEnv)
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
AndroidGeckoGLLayerClient::InitGeckoGLLayerClientClass(JNIEnv *jEnv)
|
||||
{
|
||||
#ifdef MOZ_JAVA_COMPOSITOR
|
||||
initInit();
|
||||
|
||||
jGeckoGLLayerClientClass = getClassGlobalRef("org/mozilla/gecko/gfx/GeckoGLLayerClient");
|
||||
#endif
|
||||
}
|
||||
|
||||
#undef initInit
|
||||
#undef initClassGlobalRef
|
||||
#undef getField
|
||||
@ -608,6 +620,13 @@ AndroidGeckoSoftwareLayerClient::Init(jobject jobj)
|
||||
wrapped_obj = jobj;
|
||||
}
|
||||
|
||||
void
|
||||
AndroidGeckoGLLayerClient::Init(jobject jobj)
|
||||
{
|
||||
NS_ASSERTION(wrapped_obj == nsnull, "Init called on non-null wrapped_obj!");
|
||||
wrapped_obj = jobj;
|
||||
}
|
||||
|
||||
void
|
||||
AndroidGeckoSurfaceView::Init(jobject jobj)
|
||||
{
|
||||
|
@ -193,6 +193,19 @@ protected:
|
||||
static jmethodID jGetRenderOffsetMethod;
|
||||
};
|
||||
|
||||
class AndroidGeckoGLLayerClient : public AndroidGeckoLayerClient {
|
||||
public:
|
||||
static void InitGeckoGLLayerClientClass(JNIEnv *jEnv);
|
||||
|
||||
void Init(jobject jobj);
|
||||
|
||||
AndroidGeckoGLLayerClient() {}
|
||||
AndroidGeckoGLLayerClient(jobject jobj) { Init(jobj); }
|
||||
|
||||
private:
|
||||
static jclass jGeckoGLLayerClientClass;
|
||||
};
|
||||
|
||||
class AndroidGeckoSurfaceView : public WrappedJavaObject
|
||||
{
|
||||
public:
|
||||
|
@ -1200,13 +1200,18 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
|
||||
return;
|
||||
}
|
||||
|
||||
__android_log_print(ANDROID_LOG_ERROR, "Gecko", "### OnDraw()");
|
||||
|
||||
nsRefPtr<nsWindow> kungFuDeathGrip(this);
|
||||
|
||||
AndroidBridge::AutoLocalJNIFrame jniFrame;
|
||||
#ifdef MOZ_JAVA_COMPOSITOR
|
||||
// We haven't been given a window-size yet, so do nothing
|
||||
if (gAndroidBounds.width <= 0 || gAndroidBounds.height <= 0)
|
||||
if (gAndroidBounds.width <= 0 || gAndroidBounds.height <= 0) {
|
||||
__android_log_print(ANDROID_LOG_ERROR, "Gecko",
|
||||
"### No window size yet -- skipping draw!");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check to see whether the presentation shell corresponding to the document on the screen
|
||||
@ -1221,6 +1226,7 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
|
||||
metadataProvider->PaintingSuppressed(&paintingSuppressed);
|
||||
}
|
||||
if (paintingSuppressed) {
|
||||
__android_log_print(ANDROID_LOG_ERROR, "Gecko", "### Painting suppressed!");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1267,6 +1273,7 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
|
||||
if (!client.BeginDrawing(gAndroidBounds.width, gAndroidBounds.height,
|
||||
gAndroidTileSize.width, gAndroidTileSize.height,
|
||||
metadata, HasDirectTexture())) {
|
||||
__android_log_print(ANDROID_LOG_ERROR, "Gecko", "### BeginDrawing returned false!");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1276,6 +1283,7 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
|
||||
|
||||
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);
|
||||
@ -1283,14 +1291,17 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
|
||||
|
||||
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");
|
||||
} else if (targetSurface->CairoStatus()) {
|
||||
}
|
||||
}
|
||||
|
||||
if (targetSurface->CairoStatus()) {
|
||||
ALOG("### Failed to create a valid surface from the bitmap");
|
||||
} else {
|
||||
} else if (bits || layerClientType == AndroidBridge::LAYER_CLIENT_TYPE_GL) {
|
||||
__android_log_print(ANDROID_LOG_ERROR, "Gecko", "### Calling DrawTo()!");
|
||||
DrawTo(targetSurface, dirtyRect);
|
||||
}
|
||||
|
||||
@ -1300,6 +1311,7 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
|
||||
((AndroidGeckoSoftwareLayerClient &)client).UnlockBuffer();
|
||||
}
|
||||
|
||||
__android_log_print(ANDROID_LOG_ERROR, "Gecko", "### Calling EndDrawing()!");
|
||||
client.EndDrawing(dirtyRect);
|
||||
return;
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user