Bug 709230 - Part 1: annotate by hand the JNI entry points not covered by the code generator. r=rnewman
authorChris Kitching <ckitching@mozilla.com>
Thu, 21 Nov 2013 14:44:00 -0800
changeset 158056 17739416c67edaba311aebc725adc6714b618bb5
parent 158055 de713c4fc4e104dab3fbee1219feba5327ed5fa0
child 158057 83e497d2b2beb01798a51fdb10ef3dcdc4c13a7a
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersrnewman
bugs709230
milestone28.0a1
Bug 709230 - Part 1: annotate by hand the JNI entry points not covered by the code generator. r=rnewman
mobile/android/base/GeckoAppShell.java
mobile/android/base/GeckoEvent.java
mobile/android/base/Tabs.java
mobile/android/base/gfx/LayerRenderer.java
mobile/android/base/moz.build
mobile/android/base/mozglue/JNITarget.java
--- a/mobile/android/base/GeckoAppShell.java
+++ b/mobile/android/base/GeckoAppShell.java
@@ -5,16 +5,17 @@
 
 package org.mozilla.gecko;
 
 import org.mozilla.gecko.favicons.OnFaviconLoadedListener;
 import org.mozilla.gecko.gfx.BitmapUtils;
 import org.mozilla.gecko.gfx.GeckoLayerClient;
 import org.mozilla.gecko.gfx.LayerView;
 import org.mozilla.gecko.gfx.PanZoomController;
+import org.mozilla.gecko.mozglue.JNITarget;
 import org.mozilla.gecko.mozglue.generatorannotations.OptionalGeneratedParameter;
 import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
 import org.mozilla.gecko.prompts.PromptService;
 import org.mozilla.gecko.mozglue.GeckoLoader;
 import org.mozilla.gecko.util.EventDispatcher;
 import org.mozilla.gecko.util.GeckoEventListener;
 import org.mozilla.gecko.util.HardwareUtils;
 import org.mozilla.gecko.util.ThreadUtils;
@@ -854,16 +855,17 @@ public class GeckoAppShell
                 }
 
                 // then nuke the profile
                 GeckoProfile.removeProfile(getContext(), "webapp" + index);
             }
         });
     }
 
+    @JNITarget
     static public int getPreferredIconSize() {
         if (android.os.Build.VERSION.SDK_INT >= 11) {
             ActivityManager am = (ActivityManager)getContext().getSystemService(Context.ACTIVITY_SERVICE);
             return am.getLauncherLargeIconSize();
         } else {
             switch (getDpi()) {
                 case DisplayMetrics.DENSITY_MEDIUM:
                     return 48;
--- a/mobile/android/base/GeckoEvent.java
+++ b/mobile/android/base/GeckoEvent.java
@@ -2,16 +2,17 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko;
 
 import org.mozilla.gecko.gfx.DisplayPortMetrics;
 import org.mozilla.gecko.gfx.ImmutableViewportMetrics;
+import org.mozilla.gecko.mozglue.JNITarget;
 import org.mozilla.gecko.mozglue.generatorannotations.GeneratorOptions;
 import org.mozilla.gecko.mozglue.generatorannotations.WrapEntireClassForJNI;
 
 import android.content.res.Resources;
 import android.graphics.Point;
 import android.graphics.PointF;
 import android.graphics.Rect;
 import android.hardware.Sensor;
@@ -31,21 +32,23 @@ import java.nio.ByteBuffer;
 /* We're not allowed to hold on to most events given to us
  * so we save the parts of the events we want to use in GeckoEvent.
  * Fields have different meanings depending on the event type.
  */
 
 /* This class is referenced by Robocop via reflection; use care when
  * modifying the signature.
  */
+@JNITarget
 public class GeckoEvent {
     private static final String LOGTAG = "GeckoEvent";
 
     // Make sure to keep these values in sync with the enum in
     // AndroidGeckoEvent in widget/android/AndroidJavaWrapper.h
+    @JNITarget
     private enum NativeGeckoEvent {
         NATIVE_POKE(0),
         KEY_EVENT(1),
         MOTION_EVENT(2),
         SENSOR_EVENT(3),
         LOCATION_EVENT(5),
         IME_EVENT(6),
         DRAW(7),
@@ -98,16 +101,17 @@ public class GeckoEvent {
         public final int value;
 
         private DomKeyLocation(int value) {
             this.value = value;
         }
     }
 
     // Encapsulation of common IME actions.
+    @JNITarget
     public enum ImeAction {
         IME_SYNCHRONIZE(0),
         IME_REPLACE_TEXT(1),
         IME_SET_SELECTION(2),
         IME_ADD_COMPOSITION_RANGE(3),
         IME_UPDATE_COMPOSITION(4),
         IME_REMOVE_COMPOSITION(5),
         IME_ACKNOWLEDGE_FOCUS(6);
--- a/mobile/android/base/Tabs.java
+++ b/mobile/android/base/Tabs.java
@@ -3,16 +3,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko;
 
 import org.mozilla.gecko.db.BrowserDB;
 import org.mozilla.gecko.favicons.Favicons;
 import org.mozilla.gecko.home.HomePager;
+import org.mozilla.gecko.mozglue.JNITarget;
 import org.mozilla.gecko.sync.setup.SyncAccounts;
 import org.mozilla.gecko.util.GeckoEventListener;
 import org.mozilla.gecko.util.ThreadUtils;
 
 import org.json.JSONObject;
 
 import android.accounts.Account;
 import android.accounts.AccountManager;
@@ -792,15 +793,14 @@ public class Tabs implements GeckoEventL
             parentId = selectedTab.getId();
         }
 
         loadUrl(url, null, parentId, LOADURL_NEW_TAB);
     }
 
     /**
      * Gets the next tab ID.
-     *
-     * This method is invoked via JNI.
      */
+    @JNITarget
     public static int getNextTabId() {
         return sTabId.getAndIncrement();
     }
 }
--- a/mobile/android/base/gfx/LayerRenderer.java
+++ b/mobile/android/base/gfx/LayerRenderer.java
@@ -20,16 +20,17 @@ import android.graphics.Canvas;
 import android.graphics.Color;
 import android.graphics.Matrix;
 import android.graphics.PointF;
 import android.graphics.Rect;
 import android.graphics.RectF;
 import android.opengl.GLES20;
 import android.os.SystemClock;
 import android.util.Log;
+import org.mozilla.gecko.mozglue.JNITarget;
 
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.nio.FloatBuffer;
 import java.nio.IntBuffer;
 import java.util.concurrent.CopyOnWriteArrayList;
 
 import javax.microedition.khronos.egl.EGLConfig;
@@ -484,16 +485,17 @@ public class LayerRenderer implements Ta
             Rect scissorRect = new Rect(left, screenSize.height - bottom, right,
                                         (screenSize.height - bottom) + (bottom - top));
             scissorRect.offset(Math.round(-mRenderOffset.x), Math.round(-mRenderOffset.y));
 
             return scissorRect;
         }
 
         /** This function is invoked via JNI; be careful when modifying signature. */
+        @JNITarget
         public void beginDrawing() {
             mFrameStartTime = System.nanoTime();
 
             TextureReaper.get().reap();
             TextureGenerator.get().fill();
 
             mUpdated = true;
 
@@ -573,16 +575,17 @@ public class LayerRenderer implements Ta
                                 0.0f);
             // The bits set here need to match up with those used
             // in gfx/layers/opengl/LayerManagerOGL.cpp.
             GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT |
                            GLES20.GL_DEPTH_BUFFER_BIT);
         }
 
         /** This function is invoked via JNI; be careful when modifying signature. */
+        @JNITarget
         public void drawBackground() {
             // Any GL state which is changed here must be restored in
             // CompositorOGL::RestoreState
 
             GLES20.glDisable(GLES20.GL_SCISSOR_TEST);
 
             // Draw the overscroll background area as a solid color
             clear(mOverscrollColor);
@@ -607,17 +610,17 @@ public class LayerRenderer implements Ta
             Layer rootLayer = mView.getLayerClient().getRoot();
             if (rootLayer == null) {
                 return;
             }
 
             rootLayer.draw(mPageContext);
         }
 
-        /** This function is invoked via JNI; be careful when modifying signature. */
+        @JNITarget
         public void drawForeground() {
             // Any GL state which is changed here must be restored in
             // CompositorOGL::RestoreState
 
             /* Draw any extra layers that were added (likely plugins) */
             if (mExtraLayers.size() > 0) {
                 for (Layer layer : mExtraLayers) {
                     layer.draw(mPageContext);
@@ -661,16 +664,17 @@ public class LayerRenderer implements Ta
 
                 GLES20.glEnable(GLES20.GL_BLEND);
                 GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
                 mFrameRateLayer.draw(mScreenContext);
             }
         }
 
         /** This function is invoked via JNI; be careful when modifying signature. */
+        @JNITarget
         public void endDrawing() {
             // If a layer update requires further work, schedule another redraw
             if (!mUpdated)
                 mView.requestRender();
 
             PanningPerfAPI.recordFrameTime();
 
             /* Used by robocop for testing purposes */
--- a/mobile/android/base/moz.build
+++ b/mobile/android/base/moz.build
@@ -13,16 +13,17 @@ thirdparty_source_dir = TOPSRCDIR + '/mo
 mgjar = add_java_jar('gecko-mozglue')
 mgjar.sources += [
     'mozglue/ByteBufferInputStream.java',
     'mozglue/DirectBufferAllocator.java',
     'mozglue/generatorannotations/GeneratorOptions.java',
     'mozglue/generatorannotations/OptionalGeneratedParameter.java',
     'mozglue/generatorannotations/WrapElementForJNI.java',
     'mozglue/generatorannotations/WrapEntireClassForJNI.java',
+    'mozglue/JNITarget.java',
     'mozglue/NativeReference.java',
     'mozglue/NativeZip.java',
 ]
 mgjar.generated_sources += [
     'org/mozilla/gecko/mozglue/GeckoLoader.java',
 ]
 mgjar.javac_flags += ['-Xlint:all']
 
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/mozglue/JNITarget.java
@@ -0,0 +1,11 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+package org.mozilla.gecko.mozglue;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.CLASS)
+public @interface JNITarget {}