Merge "Tag HardwareRenderers with a name to help debugging"
This commit is contained in:
@@ -144,6 +144,14 @@ class GLES20Canvas extends HardwareCanvas {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
super.setName(name);
|
||||
nSetName(mRenderer, name);
|
||||
}
|
||||
|
||||
private static native void nSetName(int renderer, String name);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Hardware layers
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -43,7 +43,7 @@ class GLES20RecordingCanvas extends GLES20Canvas {
|
||||
private GLES20DisplayList mDisplayList;
|
||||
|
||||
private GLES20RecordingCanvas() {
|
||||
super(true /*record*/, true /*translucent*/);
|
||||
super(true, true);
|
||||
}
|
||||
|
||||
static GLES20RecordingCanvas obtain(GLES20DisplayList displayList) {
|
||||
|
||||
@@ -27,6 +27,8 @@ import android.graphics.Rect;
|
||||
* @hide
|
||||
*/
|
||||
public abstract class HardwareCanvas extends Canvas {
|
||||
private String mName;
|
||||
|
||||
@Override
|
||||
public boolean isHardwareAccelerated() {
|
||||
return true;
|
||||
@@ -36,7 +38,30 @@ public abstract class HardwareCanvas extends Canvas {
|
||||
public void setBitmap(Bitmap bitmap) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Specifies the name of this canvas. Naming the canvas is entirely
|
||||
* optional but can be useful for debugging purposes.
|
||||
*
|
||||
* @param name The name of the canvas, can be null
|
||||
*
|
||||
* @see #getName()
|
||||
*/
|
||||
public void setName(String name) {
|
||||
mName = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of this canvas.
|
||||
*
|
||||
* @return The name of the canvas or null
|
||||
*
|
||||
* @see #setName(String)
|
||||
*/
|
||||
public String getName() {
|
||||
return mName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked before any drawing operation is performed in this canvas.
|
||||
*
|
||||
|
||||
@@ -542,6 +542,13 @@ public abstract class HardwareRenderer {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional, sets the name of the renderer. Useful for debugging purposes.
|
||||
*
|
||||
* @param name The name of this renderer, can be null
|
||||
*/
|
||||
abstract void setName(String name);
|
||||
|
||||
/**
|
||||
* Creates a hardware renderer using OpenGL.
|
||||
*
|
||||
@@ -756,6 +763,8 @@ public abstract class HardwareRenderer {
|
||||
GL mGl;
|
||||
HardwareCanvas mCanvas;
|
||||
|
||||
String mName;
|
||||
|
||||
long mFrameCount;
|
||||
Paint mDebugPaint;
|
||||
|
||||
@@ -963,6 +972,7 @@ public abstract class HardwareRenderer {
|
||||
} else {
|
||||
if (mCanvas == null) {
|
||||
mCanvas = createCanvas();
|
||||
mCanvas.setName(mName);
|
||||
}
|
||||
if (mCanvas != null) {
|
||||
setEnabled(true);
|
||||
@@ -1277,6 +1287,11 @@ public abstract class HardwareRenderer {
|
||||
return mCanvas;
|
||||
}
|
||||
|
||||
@Override
|
||||
void setName(String name) {
|
||||
mName = name;
|
||||
}
|
||||
|
||||
boolean canDraw() {
|
||||
return mGl != null && mCanvas != null;
|
||||
}
|
||||
|
||||
@@ -739,6 +739,7 @@ public final class ViewRootImpl implements ViewParent,
|
||||
|
||||
final boolean translucent = attrs.format != PixelFormat.OPAQUE;
|
||||
mAttachInfo.mHardwareRenderer = HardwareRenderer.createGlRenderer(2, translucent);
|
||||
mAttachInfo.mHardwareRenderer.setName(attrs.getTitle().toString());
|
||||
mAttachInfo.mHardwareAccelerated = mAttachInfo.mHardwareAccelerationRequested
|
||||
= mAttachInfo.mHardwareRenderer != null;
|
||||
|
||||
|
||||
@@ -156,6 +156,17 @@ static jint android_view_GLES20Canvas_getStencilSize(JNIEnv* env, jobject clazz)
|
||||
return Stencil::getStencilSize();
|
||||
}
|
||||
|
||||
static void android_view_GLES20Canvas_setName(JNIEnv* env,
|
||||
jobject clazz, OpenGLRenderer* renderer, jstring name) {
|
||||
if (name != NULL) {
|
||||
const char* textArray = env->GetStringUTFChars(name, NULL);
|
||||
renderer->setName(textArray);
|
||||
env->ReleaseStringUTFChars(name, textArray);
|
||||
} else {
|
||||
renderer->setName(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Functor
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -949,6 +960,8 @@ static JNINativeMethod gMethods[] = {
|
||||
{ "nPrepare", "(IZ)I", (void*) android_view_GLES20Canvas_prepare },
|
||||
{ "nPrepareDirty", "(IIIIIZ)I", (void*) android_view_GLES20Canvas_prepareDirty },
|
||||
{ "nFinish", "(I)V", (void*) android_view_GLES20Canvas_finish },
|
||||
{ "nSetName", "(ILjava/lang/String;)V",
|
||||
(void*) android_view_GLES20Canvas_setName },
|
||||
|
||||
{ "nGetStencilSize", "()I", (void*) android_view_GLES20Canvas_getStencilSize },
|
||||
|
||||
|
||||
@@ -215,7 +215,7 @@ public:
|
||||
bool disableScissor();
|
||||
void setScissorEnabled(bool enabled);
|
||||
|
||||
void startTiling(GLuint x, GLuint y, GLuint width, GLuint height, bool preserve);
|
||||
void startTiling(GLuint x, GLuint y, GLuint width, GLuint height, bool discard);
|
||||
void endTiling();
|
||||
|
||||
/**
|
||||
|
||||
@@ -142,6 +142,18 @@ void OpenGLRenderer::initProperties() {
|
||||
// Setup
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void OpenGLRenderer::setName(const char* name) {
|
||||
if (name) {
|
||||
mName.setTo(name);
|
||||
} else {
|
||||
mName.clear();
|
||||
}
|
||||
}
|
||||
|
||||
const char* OpenGLRenderer::getName() const {
|
||||
return mName.string();
|
||||
}
|
||||
|
||||
bool OpenGLRenderer::isDeferred() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -63,6 +63,19 @@ public:
|
||||
ANDROID_API OpenGLRenderer();
|
||||
virtual ~OpenGLRenderer();
|
||||
|
||||
/**
|
||||
* Sets the name of this renderer. The name is optional and
|
||||
* empty by default. If the pointer is null the name is set
|
||||
* to the empty string.
|
||||
*/
|
||||
ANDROID_API void setName(const char* name);
|
||||
|
||||
/**
|
||||
* Returns the name of this renderer as UTF8 string.
|
||||
* The returned pointer is never null.
|
||||
*/
|
||||
ANDROID_API const char* getName() const;
|
||||
|
||||
/**
|
||||
* Read externally defined properties to control the behavior
|
||||
* of the renderer.
|
||||
@@ -904,6 +917,9 @@ private:
|
||||
// No-ops start/endTiling when set
|
||||
bool mSuppressTiling;
|
||||
|
||||
// Optional name of the renderer
|
||||
String8 mName;
|
||||
|
||||
friend class DisplayListRenderer;
|
||||
|
||||
}; // class OpenGLRenderer
|
||||
|
||||
Reference in New Issue
Block a user