am 8e586f61
: Merge "Add support for a new developer setting: overdraw debugging" into jb-mr1-dev
* commit '8e586f61dd4f7fa53b01e63ac779ffc7cde05bdd': Add support for a new developer setting: overdraw debugging
This commit is contained in:
@ -148,6 +148,17 @@ public abstract class HardwareRenderer {
|
|||||||
public static final String DEBUG_SHOW_LAYERS_UPDATES_PROPERTY =
|
public static final String DEBUG_SHOW_LAYERS_UPDATES_PROPERTY =
|
||||||
"debug.hwui.show_layers_updates";
|
"debug.hwui.show_layers_updates";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turn on to show overdraw level.
|
||||||
|
*
|
||||||
|
* Possible values:
|
||||||
|
* "true", to enable overdraw debugging
|
||||||
|
* "false", to disable overdraw debugging
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static final String DEBUG_SHOW_OVERDRAW_PROPERTY = "debug.hwui.show_overdraw";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A process can set this flag to false to prevent the use of hardware
|
* A process can set this flag to false to prevent the use of hardware
|
||||||
* rendering.
|
* rendering.
|
||||||
@ -649,6 +660,7 @@ public abstract class HardwareRenderer {
|
|||||||
int mProfileCurrentFrame = -PROFILE_FRAME_DATA_COUNT;
|
int mProfileCurrentFrame = -PROFILE_FRAME_DATA_COUNT;
|
||||||
|
|
||||||
final boolean mDebugDirtyRegions;
|
final boolean mDebugDirtyRegions;
|
||||||
|
final boolean mShowOverdraw;
|
||||||
|
|
||||||
final int mGlVersion;
|
final int mGlVersion;
|
||||||
final boolean mTranslucent;
|
final boolean mTranslucent;
|
||||||
@ -698,6 +710,9 @@ public abstract class HardwareRenderer {
|
|||||||
if (mDebugDirtyRegions) {
|
if (mDebugDirtyRegions) {
|
||||||
Log.d(LOG_TAG, "Debugging dirty regions");
|
Log.d(LOG_TAG, "Debugging dirty regions");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mShowOverdraw = SystemProperties.getBoolean(
|
||||||
|
HardwareRenderer.DEBUG_SHOW_OVERDRAW_PROPERTY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1414,7 +1429,8 @@ public abstract class HardwareRenderer {
|
|||||||
EGL_BLUE_SIZE, 8,
|
EGL_BLUE_SIZE, 8,
|
||||||
EGL_ALPHA_SIZE, 8,
|
EGL_ALPHA_SIZE, 8,
|
||||||
EGL_DEPTH_SIZE, 0,
|
EGL_DEPTH_SIZE, 0,
|
||||||
EGL_STENCIL_SIZE, GLES20Canvas.getStencilSize(),
|
// TODO: Find a better way to choose the stencil size
|
||||||
|
EGL_STENCIL_SIZE, mShowOverdraw ? GLES20Canvas.getStencilSize() : 0,
|
||||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT |
|
EGL_SURFACE_TYPE, EGL_WINDOW_BIT |
|
||||||
(dirtyRegions ? EGL_SWAP_BEHAVIOR_PRESERVED_BIT : 0),
|
(dirtyRegions ? EGL_SWAP_BEHAVIOR_PRESERVED_BIT : 0),
|
||||||
EGL_NONE
|
EGL_NONE
|
||||||
|
@ -131,6 +131,13 @@ void Caches::initProperties() {
|
|||||||
} else {
|
} else {
|
||||||
debugLayersUpdates = false;
|
debugLayersUpdates = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (property_get(PROPERTY_DEBUG_OVERDRAW, property, NULL) > 0) {
|
||||||
|
INIT_LOGD(" Overdraw debug enabled: %s", property);
|
||||||
|
debugOverdraw = !strcmp(property, "true");
|
||||||
|
} else {
|
||||||
|
debugOverdraw = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Caches::terminate() {
|
void Caches::terminate() {
|
||||||
@ -429,7 +436,9 @@ void Caches::resetScissor() {
|
|||||||
|
|
||||||
void Caches::startTiling(GLuint x, GLuint y, GLuint width, GLuint height, bool opaque) {
|
void Caches::startTiling(GLuint x, GLuint y, GLuint width, GLuint height, bool opaque) {
|
||||||
if (extensions.hasTiledRendering()) {
|
if (extensions.hasTiledRendering()) {
|
||||||
glStartTilingQCOM(x, y, width, height, opaque ? GL_NONE : GL_COLOR_BUFFER_BIT0_QCOM);
|
glStartTilingQCOM(x, y, width, height,
|
||||||
|
(opaque ? GL_NONE : GL_COLOR_BUFFER_BIT0_QCOM) |
|
||||||
|
(debugOverdraw ? GL_STENCIL_BUFFER_BIT0_QCOM : 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,6 +242,7 @@ public:
|
|||||||
// Misc
|
// Misc
|
||||||
GLint maxTextureSize;
|
GLint maxTextureSize;
|
||||||
bool debugLayersUpdates;
|
bool debugLayersUpdates;
|
||||||
|
bool debugOverdraw;
|
||||||
|
|
||||||
TextureCache textureCache;
|
TextureCache textureCache;
|
||||||
LayerCache layerCache;
|
LayerCache layerCache;
|
||||||
|
@ -194,6 +194,8 @@ int OpenGLRenderer::prepareDirty(float left, float top, float right, float botto
|
|||||||
mTilingSnapshot = mSnapshot;
|
mTilingSnapshot = mSnapshot;
|
||||||
startTiling(mTilingSnapshot, true);
|
startTiling(mTilingSnapshot, true);
|
||||||
|
|
||||||
|
debugOverdraw(true, true);
|
||||||
|
|
||||||
if (!opaque) {
|
if (!opaque) {
|
||||||
mCaches.enableScissor();
|
mCaches.enableScissor();
|
||||||
mCaches.setScissor(left, mSnapshot->height - bottom, right - left, bottom - top);
|
mCaches.setScissor(left, mSnapshot->height - bottom, right - left, bottom - top);
|
||||||
@ -231,6 +233,7 @@ void OpenGLRenderer::endTiling() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLRenderer::finish() {
|
void OpenGLRenderer::finish() {
|
||||||
|
renderOverdraw();
|
||||||
endTiling();
|
endTiling();
|
||||||
|
|
||||||
if (!suppressErrorChecks()) {
|
if (!suppressErrorChecks()) {
|
||||||
@ -265,6 +268,40 @@ void OpenGLRenderer::finish() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OpenGLRenderer::debugOverdraw(bool enable, bool clear) {
|
||||||
|
if (mCaches.debugOverdraw && getTargetFbo() == 0) {
|
||||||
|
if (clear) {
|
||||||
|
mCaches.disableScissor();
|
||||||
|
mCaches.stencil.clear();
|
||||||
|
}
|
||||||
|
if (enable) {
|
||||||
|
mCaches.stencil.enableDebugWrite();
|
||||||
|
} else {
|
||||||
|
mCaches.stencil.disable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenGLRenderer::renderOverdraw() {
|
||||||
|
if (mCaches.debugOverdraw && getTargetFbo() == 0) {
|
||||||
|
const Rect* clip = mTilingSnapshot->clipRect;
|
||||||
|
|
||||||
|
mCaches.enableScissor();
|
||||||
|
mCaches.setScissor(clip->left, mTilingSnapshot->height - clip->bottom,
|
||||||
|
clip->right - clip->left, clip->bottom - clip->top);
|
||||||
|
|
||||||
|
mCaches.stencil.enableDebugTest(2);
|
||||||
|
drawColor(0x2f0000ff, SkXfermode::kSrcOver_Mode);
|
||||||
|
mCaches.stencil.enableDebugTest(3);
|
||||||
|
drawColor(0x2f00ff00, SkXfermode::kSrcOver_Mode);
|
||||||
|
mCaches.stencil.enableDebugTest(4);
|
||||||
|
drawColor(0x3fff0000, SkXfermode::kSrcOver_Mode);
|
||||||
|
mCaches.stencil.enableDebugTest(4, true);
|
||||||
|
drawColor(0x7fff0000, SkXfermode::kSrcOver_Mode);
|
||||||
|
mCaches.stencil.disable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void OpenGLRenderer::interrupt() {
|
void OpenGLRenderer::interrupt() {
|
||||||
if (mCaches.currentProgram) {
|
if (mCaches.currentProgram) {
|
||||||
if (mCaches.currentProgram->isInUse()) {
|
if (mCaches.currentProgram->isInUse()) {
|
||||||
@ -276,12 +313,14 @@ void OpenGLRenderer::interrupt() {
|
|||||||
mCaches.unbindIndicesBuffer();
|
mCaches.unbindIndicesBuffer();
|
||||||
mCaches.resetVertexPointers();
|
mCaches.resetVertexPointers();
|
||||||
mCaches.disbaleTexCoordsVertexArray();
|
mCaches.disbaleTexCoordsVertexArray();
|
||||||
|
debugOverdraw(false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLRenderer::resume() {
|
void OpenGLRenderer::resume() {
|
||||||
sp<Snapshot> snapshot = (mSnapshot != NULL) ? mSnapshot : mFirstSnapshot;
|
sp<Snapshot> snapshot = (mSnapshot != NULL) ? mSnapshot : mFirstSnapshot;
|
||||||
glViewport(0, 0, snapshot->viewport.getWidth(), snapshot->viewport.getHeight());
|
glViewport(0, 0, snapshot->viewport.getWidth(), snapshot->viewport.getHeight());
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, snapshot->fbo);
|
glBindFramebuffer(GL_FRAMEBUFFER, snapshot->fbo);
|
||||||
|
debugOverdraw(true, false);
|
||||||
|
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
@ -302,6 +341,7 @@ void OpenGLRenderer::resumeAfterLayer() {
|
|||||||
sp<Snapshot> snapshot = (mSnapshot != NULL) ? mSnapshot : mFirstSnapshot;
|
sp<Snapshot> snapshot = (mSnapshot != NULL) ? mSnapshot : mFirstSnapshot;
|
||||||
glViewport(0, 0, snapshot->viewport.getWidth(), snapshot->viewport.getHeight());
|
glViewport(0, 0, snapshot->viewport.getWidth(), snapshot->viewport.getHeight());
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, snapshot->fbo);
|
glBindFramebuffer(GL_FRAMEBUFFER, snapshot->fbo);
|
||||||
|
debugOverdraw(true, false);
|
||||||
|
|
||||||
mCaches.resetScissor();
|
mCaches.resetScissor();
|
||||||
dirtyClip();
|
dirtyClip();
|
||||||
@ -407,7 +447,10 @@ bool OpenGLRenderer::updateLayer(Layer* layer, bool inFrame) {
|
|||||||
OpenGLRenderer* renderer = layer->renderer;
|
OpenGLRenderer* renderer = layer->renderer;
|
||||||
Rect& dirty = layer->dirtyRect;
|
Rect& dirty = layer->dirtyRect;
|
||||||
|
|
||||||
if (inFrame) endTiling();
|
if (inFrame) {
|
||||||
|
endTiling();
|
||||||
|
debugOverdraw(false, false);
|
||||||
|
}
|
||||||
|
|
||||||
renderer->setViewport(layer->layer.getWidth(), layer->layer.getHeight());
|
renderer->setViewport(layer->layer.getWidth(), layer->layer.getHeight());
|
||||||
renderer->prepareDirty(dirty.left, dirty.top, dirty.right, dirty.bottom, !layer->isBlend());
|
renderer->prepareDirty(dirty.left, dirty.top, dirty.right, dirty.bottom, !layer->isBlend());
|
||||||
@ -724,6 +767,7 @@ bool OpenGLRenderer::createFboLayer(Layer* layer, Rect& bounds, Rect& clip, GLui
|
|||||||
mSnapshot->orthoMatrix.load(mOrthoMatrix);
|
mSnapshot->orthoMatrix.load(mOrthoMatrix);
|
||||||
|
|
||||||
endTiling();
|
endTiling();
|
||||||
|
debugOverdraw(false, false);
|
||||||
// Bind texture to FBO
|
// Bind texture to FBO
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, layer->getFbo());
|
glBindFramebuffer(GL_FRAMEBUFFER, layer->getFbo());
|
||||||
layer->bindTexture();
|
layer->bindTexture();
|
||||||
@ -772,6 +816,7 @@ void OpenGLRenderer::composeLayer(sp<Snapshot> current, sp<Snapshot> previous) {
|
|||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
|
||||||
// Unbind current FBO and restore previous one
|
// Unbind current FBO and restore previous one
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, previous->fbo);
|
glBindFramebuffer(GL_FRAMEBUFFER, previous->fbo);
|
||||||
|
debugOverdraw(true, false);
|
||||||
|
|
||||||
startTiling(previous);
|
startTiling(previous);
|
||||||
}
|
}
|
||||||
|
@ -723,6 +723,9 @@ private:
|
|||||||
*/
|
*/
|
||||||
void drawRegionRects(const Region& region);
|
void drawRegionRects(const Region& region);
|
||||||
|
|
||||||
|
void debugOverdraw(bool enable, bool clear);
|
||||||
|
void renderOverdraw();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should be invoked every time the glScissor is modified.
|
* Should be invoked every time the glScissor is modified.
|
||||||
*/
|
*/
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
// Defines the size in bits of the stencil buffer
|
// Defines the size in bits of the stencil buffer
|
||||||
// Note: Only 1 bit is required for clipping but more bits are required
|
// Note: Only 1 bit is required for clipping but more bits are required
|
||||||
// to properly implement the winding fill rule when rasterizing paths
|
// to properly implement the winding fill rule when rasterizing paths
|
||||||
#define STENCIL_BUFFER_SIZE 0
|
#define STENCIL_BUFFER_SIZE 8
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Debug level for app developers. The value is a numeric value defined
|
* Debug level for app developers. The value is a numeric value defined
|
||||||
@ -56,11 +56,17 @@ enum DebugLevel {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to enable/disbale layers update debugging. The accepted values are
|
* Used to enable/disable layers update debugging. The accepted values are
|
||||||
* "true" and "false". The default value is "false".
|
* "true" and "false". The default value is "false".
|
||||||
*/
|
*/
|
||||||
#define PROPERTY_DEBUG_LAYERS_UPDATES "debug.hwui.show_layers_updates"
|
#define PROPERTY_DEBUG_LAYERS_UPDATES "debug.hwui.show_layers_updates"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to enable/disable overdraw debugging. The accepted values are
|
||||||
|
* "true" and "false". The default value is "false".
|
||||||
|
*/
|
||||||
|
#define PROPERTY_DEBUG_OVERDRAW "debug.hwui.show_overdraw"
|
||||||
|
|
||||||
// These properties are defined in mega-bytes
|
// These properties are defined in mega-bytes
|
||||||
#define PROPERTY_TEXTURE_CACHE_SIZE "ro.hwui.texture_cache_size"
|
#define PROPERTY_TEXTURE_CACHE_SIZE "ro.hwui.texture_cache_size"
|
||||||
#define PROPERTY_LAYER_CACHE_SIZE "ro.hwui.layer_cache_size"
|
#define PROPERTY_LAYER_CACHE_SIZE "ro.hwui.layer_cache_size"
|
||||||
|
@ -37,7 +37,7 @@ void Stencil::clear() {
|
|||||||
void Stencil::enableTest() {
|
void Stencil::enableTest() {
|
||||||
if (mState != kTest) {
|
if (mState != kTest) {
|
||||||
enable();
|
enable();
|
||||||
glStencilFunc(GL_EQUAL, 0x0, 0x1);
|
glStencilFunc(GL_EQUAL, 0x1, 0x1);
|
||||||
// We only want to test, let's keep everything
|
// We only want to test, let's keep everything
|
||||||
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
|
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
|
||||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||||
@ -56,8 +56,27 @@ void Stencil::enableWrite() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Stencil::enableDebugTest(GLint value, bool greater) {
|
||||||
|
enable();
|
||||||
|
glStencilFunc(greater ? GL_LESS : GL_EQUAL, value, 0xffffffff);
|
||||||
|
// We only want to test, let's keep everything
|
||||||
|
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
|
||||||
|
mState = kTest;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Stencil::enableDebugWrite() {
|
||||||
|
if (mState != kWrite) {
|
||||||
|
enable();
|
||||||
|
glStencilFunc(GL_ALWAYS, 0x1, 0xffffffff);
|
||||||
|
// The test always passes so the first two values are meaningless
|
||||||
|
glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
|
||||||
|
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||||
|
mState = kWrite;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Stencil::enable() {
|
void Stencil::enable() {
|
||||||
if (!mState == kDisabled) {
|
if (mState == kDisabled) {
|
||||||
glEnable(GL_STENCIL_TEST);
|
glEnable(GL_STENCIL_TEST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,16 @@ public:
|
|||||||
*/
|
*/
|
||||||
void enableWrite();
|
void enableWrite();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The test passes only when equal to the specified value.
|
||||||
|
*/
|
||||||
|
void enableDebugTest(GLint value, bool greater = false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used for debugging. The stencil test always passes and increments.
|
||||||
|
*/
|
||||||
|
void enableDebugWrite();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disables stencil test and write.
|
* Disables stencil test and write.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user