Bug 913985 - Part 2: add annotations to all remaining JNI entry points, marking them for generations. r=kats

This commit is contained in:
Chris Kitching 2013-11-12 10:41:00 -08:00
parent 9f05737a52
commit 5734802900
12 changed files with 74 additions and 15 deletions

View File

@ -7,6 +7,8 @@ package org.mozilla.gecko;
import org.mozilla.gecko.gfx.DisplayPortMetrics;
import org.mozilla.gecko.gfx.ImmutableViewportMetrics;
import org.mozilla.gecko.mozglue.generatorannotations.GeneratorOptions;
import org.mozilla.gecko.mozglue.generatorannotations.WrapEntireClassForJNI;
import android.content.res.Resources;
import android.graphics.Point;
@ -83,6 +85,8 @@ public class GeckoEvent {
* The DomKeyLocation enum encapsulates the DOM KeyboardEvent's constants.
* @see https://developer.mozilla.org/en-US/docs/DOM/KeyboardEvent#Key_location_constants
*/
@GeneratorOptions(generatedClassName = "JavaDomKeyLocation")
@WrapEntireClassForJNI
public enum DomKeyLocation {
DOM_KEY_LOCATION_STANDARD(0),
DOM_KEY_LOCATION_LEFT(1),

View File

@ -4,8 +4,11 @@
package org.mozilla.gecko;
import org.mozilla.gecko.mozglue.generatorannotations.WrapEntireClassForJNI;
import java.nio.ByteBuffer;
@WrapEntireClassForJNI
public class SurfaceBits {
public int width;
public int height;

View File

@ -5,6 +5,7 @@
package org.mozilla.gecko.gfx;
import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
import org.mozilla.gecko.util.FloatUtils;
import android.graphics.RectF;
@ -18,13 +19,16 @@ import android.graphics.RectF;
* subsection of that with compositor scaling.
*/
public final class DisplayPortMetrics {
@WrapElementForJNI
public final float resolution;
@WrapElementForJNI
private final RectF mPosition;
public DisplayPortMetrics() {
this(0, 0, 0, 0, 1);
}
@WrapElementForJNI
public DisplayPortMetrics(float left, float top, float right, float bottom, float resolution) {
this.resolution = resolution;
mPosition = new RectF(left, top, right, bottom);

View File

@ -11,6 +11,7 @@ import org.mozilla.gecko.GeckoEvent;
import org.mozilla.gecko.Tab;
import org.mozilla.gecko.Tabs;
import org.mozilla.gecko.ZoomConstraints;
import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
import org.mozilla.gecko.util.EventDispatcher;
import org.mozilla.gecko.util.FloatUtils;
import org.mozilla.gecko.util.ThreadUtils;
@ -413,7 +414,7 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
return mDisplayPort;
}
/* This is invoked by JNI on the gecko thread */
@WrapElementForJNI
DisplayPortMetrics getDisplayPort(boolean pageSizeUpdate, boolean isBrowserContentDisplayed, int tabId, ImmutableViewportMetrics metrics) {
Tabs tabs = Tabs.getInstance();
if (isBrowserContentDisplayed && tabs.isSelectedTabId(tabId)) {
@ -430,12 +431,12 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
}
}
/* This is invoked by JNI on the gecko thread */
@WrapElementForJNI
void contentDocumentChanged() {
mContentDocumentIsDisplayed = false;
}
/* This is invoked by JNI on the gecko thread */
@WrapElementForJNI
boolean isContentDocumentDisplayed() {
return mContentDocumentIsDisplayed;
}
@ -445,6 +446,7 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
// to abort the current update and continue with any subsequent ones. This
// is useful for slow-to-render pages when the display-port starts lagging
// behind enough that continuing to draw it is wasted effort.
@WrapElementForJNI(allowMultithread = true)
public ProgressiveUpdateData progressiveUpdateCallback(boolean aHasPendingNewThebesContent,
float x, float y, float width, float height,
float resolution, boolean lowPrecision) {
@ -552,13 +554,13 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
}
}
/** This function is invoked by Gecko via JNI; be careful when modifying signature.
* The compositor invokes this function just before compositing a frame where the document
/** The compositor invokes this function just before compositing a frame where the document
* is different from the document composited on the last frame. In these cases, the viewport
* information we have in Java is no longer valid and needs to be replaced with the new
* viewport information provided. setPageRect will never be invoked on the same frame that
* this function is invoked on; and this function will always be called prior to syncViewportInfo.
*/
@WrapElementForJNI(allowMultithread = true)
public void setFirstPaintViewport(float offsetX, float offsetY, float zoom,
float cssPageLeft, float cssPageTop, float cssPageRight, float cssPageBottom) {
synchronized (getLock()) {
@ -611,12 +613,12 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
mContentDocumentIsDisplayed = true;
}
/** This function is invoked by Gecko via JNI; be careful when modifying signature.
* The compositor invokes this function whenever it determines that the page rect
/** The compositor invokes this function whenever it determines that the page rect
* has changed (based on the information it gets from layout). If setFirstPaintViewport
* is invoked on a frame, then this function will not be. For any given frame, this
* function will be invoked before syncViewportInfo.
*/
@WrapElementForJNI(allowMultithread = true)
public void setPageRect(float cssPageLeft, float cssPageTop, float cssPageRight, float cssPageBottom) {
synchronized (getLock()) {
RectF cssPageRect = new RectF(cssPageLeft, cssPageTop, cssPageRight, cssPageBottom);
@ -629,8 +631,7 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
}
}
/** This function is invoked by Gecko via JNI; be careful when modifying signature.
* The compositor invokes this function on every frame to figure out what part of the
/** The compositor invokes this function on every frame to figure out what part of the
* page to display, and to inform Java of the current display port. Since it is called
* on every frame, it needs to be ultra-fast.
* It avoids taking any locks or allocating any objects. We keep around a
@ -638,6 +639,7 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
* everytime we're called. NOTE: we might be able to return a ImmutableViewportMetrics
* which would avoid the copy into mCurrentViewTransform.
*/
@WrapElementForJNI(allowMultithread = true)
public ViewTransform syncViewportInfo(int x, int y, int width, int height, float resolution, boolean layersUpdated) {
// getViewportMetrics is thread safe so we don't need to synchronize.
// We save the viewport metrics here, so we later use it later in
@ -691,7 +693,7 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
return mCurrentViewTransform;
}
/* Invoked by JNI from the compositor thread */
@WrapElementForJNI(allowMultithread = true)
public ViewTransform syncFrameMetrics(float offsetX, float offsetY, float zoom,
float cssPageLeft, float cssPageTop, float cssPageRight, float cssPageBottom,
boolean layersUpdated, int x, int y, int width, int height, float resolution,
@ -705,7 +707,7 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
return syncViewportInfo(x, y, width, height, resolution, layersUpdated);
}
/** This function is invoked by Gecko via JNI; be careful when modifying signature. */
@WrapElementForJNI(allowMultithread = true)
public LayerRenderer.Frame createFrame() {
// Create the shaders and textures if necessary.
if (!mLayerRendererInitialized) {
@ -717,12 +719,12 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
return mLayerRenderer.createFrame(mFrameMetrics);
}
/** This function is invoked by Gecko via JNI; be careful when modifying signature. */
@WrapElementForJNI(allowMultithread = true)
public void activateProgram() {
mLayerRenderer.activateDefaultProgram();
}
/** This function is invoked by Gecko via JNI; be careful when modifying signature. */
@WrapElementForJNI(allowMultithread = true)
public void deactivateProgram() {
mLayerRenderer.deactivateDefaultProgram();
}

View File

@ -5,6 +5,7 @@
package org.mozilla.gecko.gfx;
import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
import org.mozilla.gecko.util.FloatUtils;
import android.graphics.PointF;
@ -52,7 +53,8 @@ public class ImmutableViewportMetrics {
/** This constructor is used by native code in AndroidJavaWrappers.cpp, be
* careful when modifying the signature.
*/
private ImmutableViewportMetrics(float aPageRectLeft, float aPageRectTop,
@WrapElementForJNI(allowMultithread = true)
public ImmutableViewportMetrics(float aPageRectLeft, float aPageRectTop,
float aPageRectRight, float aPageRectBottom, float aCssPageRectLeft,
float aCssPageRectTop, float aCssPageRectRight, float aCssPageRectBottom,
float aViewportRectLeft, float aViewportRectTop, float aViewportRectRight,

View File

@ -12,6 +12,8 @@ import org.mozilla.gecko.Tabs;
import org.mozilla.gecko.gfx.Layer.RenderContext;
import org.mozilla.gecko.gfx.RenderTask;
import org.mozilla.gecko.mozglue.DirectBufferAllocator;
import org.mozilla.gecko.mozglue.generatorannotations.GeneratorOptions;
import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
import android.content.Context;
import android.content.SharedPreferences;
@ -19,7 +21,6 @@ import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
@ -437,6 +438,7 @@ public class LayerRenderer implements Tabs.OnTabsChangedListener {
}
}
@GeneratorOptions(generatedClassName = "LayerRendererFrame")
public class Frame {
// The timestamp recording the start of this frame.
private long mFrameStartTime;
@ -490,6 +492,7 @@ public class LayerRenderer implements Tabs.OnTabsChangedListener {
}
/** This function is invoked via JNI; be careful when modifying signature. */
@WrapElementForJNI(allowMultithread = true)
public void beginDrawing() {
mFrameStartTime = System.nanoTime();
@ -579,6 +582,7 @@ public class LayerRenderer implements Tabs.OnTabsChangedListener {
}
/** This function is invoked via JNI; be careful when modifying signature. */
@WrapElementForJNI(allowMultithread = true)
public void drawBackground() {
// Any GL state which is changed here must be restored in
// CompositorOGL::RestoreState
@ -614,6 +618,7 @@ public class LayerRenderer implements Tabs.OnTabsChangedListener {
}
/** This function is invoked via JNI; be careful when modifying signature. */
@WrapElementForJNI(allowMultithread = true)
public void drawForeground() {
// Any GL state which is changed here must be restored in
// CompositorOGL::RestoreState
@ -667,6 +672,7 @@ public class LayerRenderer implements Tabs.OnTabsChangedListener {
}
/** This function is invoked via JNI; be careful when modifying signature. */
@WrapElementForJNI(allowMultithread = true)
public void endDrawing() {
// If a layer update requires further work, schedule another redraw
if (!mUpdated)

View File

@ -5,12 +5,15 @@
package org.mozilla.gecko.gfx;
import org.mozilla.gecko.mozglue.generatorannotations.WrapEntireClassForJNI;
/**
* This is the data structure that's returned by the progressive tile update
* callback function. It encompasses the current viewport and a boolean value
* representing whether the front-end is interested in the current progressive
* update continuing.
*/
@WrapEntireClassForJNI
public class ProgressiveUpdateData {
public float x;
public float y;

View File

@ -5,6 +5,9 @@
package org.mozilla.gecko.gfx;
import org.mozilla.gecko.mozglue.generatorannotations.WrapEntireClassForJNI;
@WrapEntireClassForJNI
public class ViewTransform {
public float x;
public float y;

View File

@ -5,6 +5,8 @@
package org.mozilla.gecko.mozglue;
import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.util.zip.Inflater;
@ -68,6 +70,7 @@ public class NativeZip implements NativeReference {
private static native void _release(long obj);
private native InputStream _getInputStream(long obj, String path);
@WrapElementForJNI
private InputStream createInputStream(ByteBuffer buffer, int compression) {
if (compression != STORE && compression != DEFLATE) {
throw new IllegalArgumentException("Unexpected compression: " + compression);

View File

@ -17,6 +17,8 @@
package org.mozilla.gecko.sqlite;
import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
import android.database.AbstractCursor;
import android.database.CursorIndexOutOfBoundsException;
@ -50,6 +52,7 @@ public class MatrixBlobCursor extends AbstractCursor {
* determines column ordering elsewhere in this cursor
* @param initialCapacity in rows
*/
@WrapElementForJNI
public MatrixBlobCursor(String[] columnNames, int initialCapacity) {
this.columnNames = columnNames;
this.columnCount = columnNames.length;
@ -67,6 +70,7 @@ public class MatrixBlobCursor extends AbstractCursor {
* @param columnNames names of the columns, the ordering of which
* determines column ordering elsewhere in this cursor
*/
@WrapElementForJNI
public MatrixBlobCursor(String[] columnNames) {
this(columnNames, 16);
}
@ -112,6 +116,7 @@ public class MatrixBlobCursor extends AbstractCursor {
* @param columnValues in the same order as the the column names specified
* at cursor construction time
*/
@WrapElementForJNI
public void addRow(Object[] columnValues) {
if (columnValues.length != columnCount) {
throw new IllegalArgumentException("columnNames.length = "
@ -133,6 +138,7 @@ public class MatrixBlobCursor extends AbstractCursor {
* @param columnValues in the same order as the the column names specified
* at cursor construction time
*/
@WrapElementForJNI
public void addRow(Iterable<?> columnValues) {
int start = rowCount * columnCount;
int end = start + columnCount;
@ -165,6 +171,7 @@ public class MatrixBlobCursor extends AbstractCursor {
}
/** Optimization for {@link ArrayList}. */
@WrapElementForJNI
private void addRow(ArrayList<?> columnValues, int start) {
int size = columnValues.size();
if (size != columnCount) {

View File

@ -5,6 +5,9 @@
package org.mozilla.gecko.sqlite;
import org.mozilla.gecko.mozglue.generatorannotations.WrapEntireClassForJNI;
@WrapEntireClassForJNI
public class SQLiteBridgeException extends RuntimeException {
static final long serialVersionUID = 1L;

View File

@ -79,6 +79,25 @@ public final class Clipboard {
});
}
/**
* Returns true if the clipboard is nonempty, false otherwise.
*
* @return true if the clipboard is nonempty, false otherwise.
*/
@WrapElementForJNI
public static boolean hasText() {
String text = getText();
return text != null;
}
/**
* Deletes all text from the clipboard.
*/
@WrapElementForJNI
public static void clearText() {
setText(null);
}
private static android.content.ClipboardManager getClipboardManager11(Context context) {
// In API Level 11 and above, CLIPBOARD_SERVICE returns android.content.ClipboardManager,
// which is a subclass of android.text.ClipboardManager.