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

View File

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

View File

@ -5,6 +5,7 @@
package org.mozilla.gecko.gfx; package org.mozilla.gecko.gfx;
import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
import org.mozilla.gecko.util.FloatUtils; import org.mozilla.gecko.util.FloatUtils;
import android.graphics.RectF; import android.graphics.RectF;
@ -18,13 +19,16 @@ import android.graphics.RectF;
* subsection of that with compositor scaling. * subsection of that with compositor scaling.
*/ */
public final class DisplayPortMetrics { public final class DisplayPortMetrics {
@WrapElementForJNI
public final float resolution; public final float resolution;
@WrapElementForJNI
private final RectF mPosition; private final RectF mPosition;
public DisplayPortMetrics() { public DisplayPortMetrics() {
this(0, 0, 0, 0, 1); this(0, 0, 0, 0, 1);
} }
@WrapElementForJNI
public DisplayPortMetrics(float left, float top, float right, float bottom, float resolution) { public DisplayPortMetrics(float left, float top, float right, float bottom, float resolution) {
this.resolution = resolution; this.resolution = resolution;
mPosition = new RectF(left, top, right, bottom); 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.Tab;
import org.mozilla.gecko.Tabs; import org.mozilla.gecko.Tabs;
import org.mozilla.gecko.ZoomConstraints; import org.mozilla.gecko.ZoomConstraints;
import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
import org.mozilla.gecko.util.EventDispatcher; import org.mozilla.gecko.util.EventDispatcher;
import org.mozilla.gecko.util.FloatUtils; import org.mozilla.gecko.util.FloatUtils;
import org.mozilla.gecko.util.ThreadUtils; import org.mozilla.gecko.util.ThreadUtils;
@ -413,7 +414,7 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
return mDisplayPort; return mDisplayPort;
} }
/* This is invoked by JNI on the gecko thread */ @WrapElementForJNI
DisplayPortMetrics getDisplayPort(boolean pageSizeUpdate, boolean isBrowserContentDisplayed, int tabId, ImmutableViewportMetrics metrics) { DisplayPortMetrics getDisplayPort(boolean pageSizeUpdate, boolean isBrowserContentDisplayed, int tabId, ImmutableViewportMetrics metrics) {
Tabs tabs = Tabs.getInstance(); Tabs tabs = Tabs.getInstance();
if (isBrowserContentDisplayed && tabs.isSelectedTabId(tabId)) { 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() { void contentDocumentChanged() {
mContentDocumentIsDisplayed = false; mContentDocumentIsDisplayed = false;
} }
/* This is invoked by JNI on the gecko thread */ @WrapElementForJNI
boolean isContentDocumentDisplayed() { boolean isContentDocumentDisplayed() {
return mContentDocumentIsDisplayed; 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 // 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 // is useful for slow-to-render pages when the display-port starts lagging
// behind enough that continuing to draw it is wasted effort. // behind enough that continuing to draw it is wasted effort.
@WrapElementForJNI(allowMultithread = true)
public ProgressiveUpdateData progressiveUpdateCallback(boolean aHasPendingNewThebesContent, public ProgressiveUpdateData progressiveUpdateCallback(boolean aHasPendingNewThebesContent,
float x, float y, float width, float height, float x, float y, float width, float height,
float resolution, boolean lowPrecision) { 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 * 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 * 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 * 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. * 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, public void setFirstPaintViewport(float offsetX, float offsetY, float zoom,
float cssPageLeft, float cssPageTop, float cssPageRight, float cssPageBottom) { float cssPageLeft, float cssPageTop, float cssPageRight, float cssPageBottom) {
synchronized (getLock()) { synchronized (getLock()) {
@ -611,12 +613,12 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
mContentDocumentIsDisplayed = true; 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 * 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 * is invoked on a frame, then this function will not be. For any given frame, this
* function will be invoked before syncViewportInfo. * function will be invoked before syncViewportInfo.
*/ */
@WrapElementForJNI(allowMultithread = true)
public void setPageRect(float cssPageLeft, float cssPageTop, float cssPageRight, float cssPageBottom) { public void setPageRect(float cssPageLeft, float cssPageTop, float cssPageRight, float cssPageBottom) {
synchronized (getLock()) { synchronized (getLock()) {
RectF cssPageRect = new RectF(cssPageLeft, cssPageTop, cssPageRight, cssPageBottom); 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 * 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. * on every frame, it needs to be ultra-fast.
* It avoids taking any locks or allocating any objects. We keep around a * 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 * everytime we're called. NOTE: we might be able to return a ImmutableViewportMetrics
* which would avoid the copy into mCurrentViewTransform. * 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) { 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. // getViewportMetrics is thread safe so we don't need to synchronize.
// We save the viewport metrics here, so we later use it later in // 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; return mCurrentViewTransform;
} }
/* Invoked by JNI from the compositor thread */ @WrapElementForJNI(allowMultithread = true)
public ViewTransform syncFrameMetrics(float offsetX, float offsetY, float zoom, public ViewTransform syncFrameMetrics(float offsetX, float offsetY, float zoom,
float cssPageLeft, float cssPageTop, float cssPageRight, float cssPageBottom, float cssPageLeft, float cssPageTop, float cssPageRight, float cssPageBottom,
boolean layersUpdated, int x, int y, int width, int height, float resolution, 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); 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() { public LayerRenderer.Frame createFrame() {
// Create the shaders and textures if necessary. // Create the shaders and textures if necessary.
if (!mLayerRendererInitialized) { if (!mLayerRendererInitialized) {
@ -717,12 +719,12 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
return mLayerRenderer.createFrame(mFrameMetrics); return mLayerRenderer.createFrame(mFrameMetrics);
} }
/** This function is invoked by Gecko via JNI; be careful when modifying signature. */ @WrapElementForJNI(allowMultithread = true)
public void activateProgram() { public void activateProgram() {
mLayerRenderer.activateDefaultProgram(); mLayerRenderer.activateDefaultProgram();
} }
/** This function is invoked by Gecko via JNI; be careful when modifying signature. */ @WrapElementForJNI(allowMultithread = true)
public void deactivateProgram() { public void deactivateProgram() {
mLayerRenderer.deactivateDefaultProgram(); mLayerRenderer.deactivateDefaultProgram();
} }

View File

@ -5,6 +5,7 @@
package org.mozilla.gecko.gfx; package org.mozilla.gecko.gfx;
import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
import org.mozilla.gecko.util.FloatUtils; import org.mozilla.gecko.util.FloatUtils;
import android.graphics.PointF; import android.graphics.PointF;
@ -52,7 +53,8 @@ public class ImmutableViewportMetrics {
/** This constructor is used by native code in AndroidJavaWrappers.cpp, be /** This constructor is used by native code in AndroidJavaWrappers.cpp, be
* careful when modifying the signature. * 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 aPageRectRight, float aPageRectBottom, float aCssPageRectLeft,
float aCssPageRectTop, float aCssPageRectRight, float aCssPageRectBottom, float aCssPageRectTop, float aCssPageRectRight, float aCssPageRectBottom,
float aViewportRectLeft, float aViewportRectTop, float aViewportRectRight, 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.Layer.RenderContext;
import org.mozilla.gecko.gfx.RenderTask; import org.mozilla.gecko.gfx.RenderTask;
import org.mozilla.gecko.mozglue.DirectBufferAllocator; 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.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
@ -19,7 +21,6 @@ import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Matrix; import android.graphics.Matrix;
import android.graphics.Point;
import android.graphics.PointF; import android.graphics.PointF;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.RectF; import android.graphics.RectF;
@ -437,6 +438,7 @@ public class LayerRenderer implements Tabs.OnTabsChangedListener {
} }
} }
@GeneratorOptions(generatedClassName = "LayerRendererFrame")
public class Frame { public class Frame {
// The timestamp recording the start of this frame. // The timestamp recording the start of this frame.
private long mFrameStartTime; private long mFrameStartTime;
@ -490,6 +492,7 @@ public class LayerRenderer implements Tabs.OnTabsChangedListener {
} }
/** This function is invoked via JNI; be careful when modifying signature. */ /** This function is invoked via JNI; be careful when modifying signature. */
@WrapElementForJNI(allowMultithread = true)
public void beginDrawing() { public void beginDrawing() {
mFrameStartTime = System.nanoTime(); mFrameStartTime = System.nanoTime();
@ -579,6 +582,7 @@ public class LayerRenderer implements Tabs.OnTabsChangedListener {
} }
/** This function is invoked via JNI; be careful when modifying signature. */ /** This function is invoked via JNI; be careful when modifying signature. */
@WrapElementForJNI(allowMultithread = true)
public void drawBackground() { public void drawBackground() {
// Any GL state which is changed here must be restored in // Any GL state which is changed here must be restored in
// CompositorOGL::RestoreState // CompositorOGL::RestoreState
@ -614,6 +618,7 @@ public class LayerRenderer implements Tabs.OnTabsChangedListener {
} }
/** This function is invoked via JNI; be careful when modifying signature. */ /** This function is invoked via JNI; be careful when modifying signature. */
@WrapElementForJNI(allowMultithread = true)
public void drawForeground() { public void drawForeground() {
// Any GL state which is changed here must be restored in // Any GL state which is changed here must be restored in
// CompositorOGL::RestoreState // CompositorOGL::RestoreState
@ -667,6 +672,7 @@ public class LayerRenderer implements Tabs.OnTabsChangedListener {
} }
/** This function is invoked via JNI; be careful when modifying signature. */ /** This function is invoked via JNI; be careful when modifying signature. */
@WrapElementForJNI(allowMultithread = true)
public void endDrawing() { public void endDrawing() {
// If a layer update requires further work, schedule another redraw // If a layer update requires further work, schedule another redraw
if (!mUpdated) if (!mUpdated)

View File

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

View File

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

View File

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

View File

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

View File

@ -5,6 +5,9 @@
package org.mozilla.gecko.sqlite; package org.mozilla.gecko.sqlite;
import org.mozilla.gecko.mozglue.generatorannotations.WrapEntireClassForJNI;
@WrapEntireClassForJNI
public class SQLiteBridgeException extends RuntimeException { public class SQLiteBridgeException extends RuntimeException {
static final long serialVersionUID = 1L; 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) { private static android.content.ClipboardManager getClipboardManager11(Context context) {
// In API Level 11 and above, CLIPBOARD_SERVICE returns android.content.ClipboardManager, // In API Level 11 and above, CLIPBOARD_SERVICE returns android.content.ClipboardManager,
// which is a subclass of android.text.ClipboardManager. // which is a subclass of android.text.ClipboardManager.