summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSiva Velusamy <vsiva@google.com>2012-12-14 17:09:06 -0800
committerSiva Velusamy <vsiva@google.com>2012-12-19 16:31:56 -0800
commit0c1761bd37815c3776608a19c8e11d862b3e910c (patch)
tree79ba5b10c39459913dad480243e0211b63ed41b0
parent0490f02eb72adcfd652f5e8373bf0a6c99592d54 (diff)
downloadframeworks_base-0c1761bd37815c3776608a19c8e11d862b3e910c.zip
frameworks_base-0c1761bd37815c3776608a19c8e11d862b3e910c.tar.gz
frameworks_base-0c1761bd37815c3776608a19c8e11d862b3e910c.tar.bz2
DdmServer: add controls for OpenGL tracing
Add a new JDWP packet to allow control of OpenGL tracing. Change-Id: Ic89e2f6299238a612df2f914581049f2cbba088c
-rw-r--r--core/java/android/app/ActivityThread.java2
-rw-r--r--core/java/android/ddm/DdmHandleGlTracing.java60
-rw-r--r--core/java/android/ddm/DdmHandleHello.java23
-rw-r--r--core/java/android/ddm/DdmRegister.java1
-rw-r--r--core/jni/android/opengl/util.cpp6
-rw-r--r--opengl/java/android/opengl/GLUtils.java7
6 files changed, 82 insertions, 17 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index d880817..60d4363 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -4277,7 +4277,7 @@ public final class ActivityThread {
// Enable OpenGL tracing if required
if (data.enableOpenGlTrace) {
- GLUtils.enableTracing();
+ GLUtils.setTracingLevel(1);
}
/**
diff --git a/core/java/android/ddm/DdmHandleGlTracing.java b/core/java/android/ddm/DdmHandleGlTracing.java
new file mode 100644
index 0000000..511cf44
--- /dev/null
+++ b/core/java/android/ddm/DdmHandleGlTracing.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.ddm;
+
+import android.opengl.GLUtils;
+
+import org.apache.harmony.dalvik.ddmc.Chunk;
+import org.apache.harmony.dalvik.ddmc.ChunkHandler;
+import org.apache.harmony.dalvik.ddmc.DdmServer;
+
+import java.nio.ByteBuffer;
+
+public class DdmHandleGlTracing extends ChunkHandler {
+ /** GL TRace control packets. Packet data controls starting/stopping the trace. */
+ public static final int CHUNK_GLTR = type("GLTR");
+
+ private static final DdmHandleGlTracing sInstance = new DdmHandleGlTracing();
+
+ /** singleton, do not instantiate. */
+ private DdmHandleGlTracing() {}
+
+ public static void register() {
+ DdmServer.registerHandler(CHUNK_GLTR, sInstance);
+ }
+
+ @Override
+ public void connected() {
+ }
+
+ @Override
+ public void disconnected() {
+ }
+
+ @Override
+ public Chunk handleChunk(Chunk request) {
+ int type = request.type;
+
+ if (type != CHUNK_GLTR) {
+ throw new RuntimeException("Unknown packet " + ChunkHandler.name(type));
+ }
+
+ ByteBuffer in = wrapChunk(request);
+ GLUtils.setTracingLevel(in.getInt());
+ return null; // empty response
+ }
+}
diff --git a/core/java/android/ddm/DdmHandleHello.java b/core/java/android/ddm/DdmHandleHello.java
index e99fa92..70ad648 100644
--- a/core/java/android/ddm/DdmHandleHello.java
+++ b/core/java/android/ddm/DdmHandleHello.java
@@ -36,6 +36,7 @@ public class DdmHandleHello extends ChunkHandler {
private static DdmHandleHello mInstance = new DdmHandleHello();
+ private static final String[] NATIVE_FEATURES = new String[] { "opengl-tracing" };
/* singleton, do not instantiate */
private DdmHandleHello() {}
@@ -149,21 +150,27 @@ public class DdmHandleHello extends ChunkHandler {
private Chunk handleFEAT(Chunk request) {
// TODO: query the VM to ensure that support for these features
// is actually compiled in
- final String[] features = Debug.getVmFeatureList();
+ final String[] vmFeatures = Debug.getVmFeatureList();
if (false)
Log.v("ddm-heap", "Got feature list request");
- int size = 4 + 4 * features.length;
- for (int i = features.length-1; i >= 0; i--)
- size += features[i].length() * 2;
+ int size = 4 + 4 * (vmFeatures.length + NATIVE_FEATURES.length);
+ for (int i = vmFeatures.length-1; i >= 0; i--)
+ size += vmFeatures[i].length() * 2;
+ for (int i = NATIVE_FEATURES.length-1; i>= 0; i--)
+ size += NATIVE_FEATURES[i].length() * 2;
ByteBuffer out = ByteBuffer.allocate(size);
out.order(ChunkHandler.CHUNK_ORDER);
- out.putInt(features.length);
- for (int i = features.length-1; i >= 0; i--) {
- out.putInt(features[i].length());
- putString(out, features[i]);
+ out.putInt(vmFeatures.length + NATIVE_FEATURES.length);
+ for (int i = vmFeatures.length-1; i >= 0; i--) {
+ out.putInt(vmFeatures[i].length());
+ putString(out, vmFeatures[i]);
+ }
+ for (int i = NATIVE_FEATURES.length-1; i >= 0; i--) {
+ out.putInt(NATIVE_FEATURES[i].length());
+ putString(out, NATIVE_FEATURES[i]);
}
return new Chunk(CHUNK_FEAT, out);
diff --git a/core/java/android/ddm/DdmRegister.java b/core/java/android/ddm/DdmRegister.java
index ecd450d..2c82967 100644
--- a/core/java/android/ddm/DdmRegister.java
+++ b/core/java/android/ddm/DdmRegister.java
@@ -51,6 +51,7 @@ public class DdmRegister {
DdmHandleNativeHeap.register();
DdmHandleProfiling.register();
DdmHandleExit.register();
+ DdmHandleGlTracing.register();
DdmServer.registrationComplete();
}
diff --git a/core/jni/android/opengl/util.cpp b/core/jni/android/opengl/util.cpp
index 634efa6..44af199 100644
--- a/core/jni/android/opengl/util.cpp
+++ b/core/jni/android/opengl/util.cpp
@@ -557,9 +557,9 @@ void nativeUtilsClassInit(JNIEnv *env, jclass clazz)
}
extern void setGLDebugLevel(int level);
-void nativeEnableTracing(JNIEnv *env, jclass clazz)
+void setTracingLevel(JNIEnv *env, jclass clazz, jint level)
{
- setGLDebugLevel(1);
+ setGLDebugLevel(level);
}
static int checkFormat(SkBitmap::Config config, int format, int type)
@@ -1032,7 +1032,7 @@ static JNINativeMethod gUtilsMethods[] = {
{ "native_getType", "(Landroid/graphics/Bitmap;)I", (void*) util_getType },
{ "native_texImage2D", "(IIILandroid/graphics/Bitmap;II)I", (void*)util_texImage2D },
{ "native_texSubImage2D", "(IIIILandroid/graphics/Bitmap;II)I", (void*)util_texSubImage2D },
- { "native_enableTracing", "()V", (void*)nativeEnableTracing },
+ { "setTracingLevel", "(I)V", (void*)setTracingLevel },
};
static JNINativeMethod gEtc1Methods[] = {
diff --git a/opengl/java/android/opengl/GLUtils.java b/opengl/java/android/opengl/GLUtils.java
index 1527f22..a9d33dd 100644
--- a/opengl/java/android/opengl/GLUtils.java
+++ b/opengl/java/android/opengl/GLUtils.java
@@ -270,12 +270,10 @@ public final class GLUtils {
}
/**
- * Enable tracing of OpenGL functions for this application.
+ * Set OpenGL Tracing level for this application.
* @hide
*/
- public static void enableTracing() {
- native_enableTracing();
- }
+ native public static void setTracingLevel(int level);
native private static void nativeClassInit();
@@ -285,5 +283,4 @@ public final class GLUtils {
Bitmap bitmap, int type, int border);
native private static int native_texSubImage2D(int target, int level, int xoffset, int yoffset,
Bitmap bitmap, int format, int type);
- native private static void native_enableTracing();
}