DdmServer: add controls for OpenGL tracing
Add a new JDWP packet to allow control of OpenGL tracing. Change-Id: Ic89e2f6299238a612df2f914581049f2cbba088c
This commit is contained in:
@@ -4277,7 +4277,7 @@ public final class ActivityThread {
|
||||
|
||||
// Enable OpenGL tracing if required
|
||||
if (data.enableOpenGlTrace) {
|
||||
GLUtils.enableTracing();
|
||||
GLUtils.setTracingLevel(1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
60
core/java/android/ddm/DdmHandleGlTracing.java
Normal file
60
core/java/android/ddm/DdmHandleGlTracing.java
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -51,6 +51,7 @@ public class DdmRegister {
|
||||
DdmHandleNativeHeap.register();
|
||||
DdmHandleProfiling.register();
|
||||
DdmHandleExit.register();
|
||||
DdmHandleGlTracing.register();
|
||||
|
||||
DdmServer.registrationComplete();
|
||||
}
|
||||
|
||||
@@ -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[] = {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user