Add logging utility methods

Change-Id: I0f316830dcc0bbf438292a6d0fbe9f8154368500
This commit is contained in:
Chris Craik
2014-05-08 13:57:05 -07:00
parent a2604b738e
commit e4aa95e362
9 changed files with 120 additions and 32 deletions

View File

@@ -6,6 +6,7 @@ include $(CLEAR_VARS)
ifeq ($(USE_OPENGL_RENDERER),true)
LOCAL_SRC_FILES := \
utils/Blur.cpp \
utils/GLUtils.cpp \
utils/SortedListImpl.cpp \
thread/TaskManager.cpp \
font/CacheTexture.cpp \
@@ -53,7 +54,7 @@ ifeq ($(USE_OPENGL_RENDERER),true)
TextureCache.cpp \
TextDropShadowCache.cpp
# RenderThread stuff
# RenderThread stuff
LOCAL_SRC_FILES += \
renderthread/CanvasContext.cpp \
renderthread/DrawFrameTask.cpp \

View File

@@ -482,8 +482,8 @@ void Matrix4::decomposeScale(float& sx, float& sy) const {
sy = copysignf(sqrtf(len), data[mat4::kScaleY]);
}
void Matrix4::dump() const {
ALOGD("Matrix4[simple=%d, type=0x%x", isSimple(), getType());
void Matrix4::dump(const char* label) const {
ALOGD("%s[simple=%d, type=0x%x", label ? label : "Matrix4", isSimple(), getType());
ALOGD(" %f %f %f %f", data[kScaleX], data[kSkewX], data[8], data[kTranslateX]);
ALOGD(" %f %f %f %f", data[kSkewY], data[kScaleY], data[9], data[kTranslateY]);
ALOGD(" %f %f %f %f", data[2], data[6], data[kScaleZ], data[kTranslateZ]);

View File

@@ -209,7 +209,7 @@ public:
void decomposeScale(float& sx, float& sy) const;
void dump() const;
void dump(const char* label = NULL) const;
static const Matrix4& identity();

View File

@@ -37,6 +37,7 @@
#include "PathTessellator.h"
#include "Properties.h"
#include "ShadowTessellator.h"
#include "utils/GLUtils.h"
#include "Vector.h"
#include "VertexBuffer.h"
@@ -296,24 +297,7 @@ void OpenGLRenderer::finish() {
if (!suppressErrorChecks()) {
#if DEBUG_OPENGL
GLenum status = GL_NO_ERROR;
while ((status = glGetError()) != GL_NO_ERROR) {
ALOGD("GL error from OpenGLRenderer: 0x%x", status);
switch (status) {
case GL_INVALID_ENUM:
ALOGE(" GL_INVALID_ENUM");
break;
case GL_INVALID_VALUE:
ALOGE(" GL_INVALID_VALUE");
break;
case GL_INVALID_OPERATION:
ALOGE(" GL_INVALID_OPERATION");
break;
case GL_OUT_OF_MEMORY:
ALOGE(" Out of memory!");
break;
}
}
GLUtils::dumpGLErrors();
#endif
#if DEBUG_MEMORY_USAGE

View File

@@ -175,6 +175,10 @@ public:
bottom += dy;
}
void inset(float delta) {
outset(-delta);
}
void outset(float delta) {
left -= delta;
top -= delta;
@@ -230,8 +234,8 @@ public:
bottom = ceilf(bottom);
}
void dump() const {
ALOGD("Rect[l=%f t=%f r=%f b=%f]", left, top, right, bottom);
void dump(const char* label) const {
ALOGD("%s[l=%f t=%f r=%f b=%f]", label ? label : "Rect", left, top, right, bottom);
}
private:

View File

@@ -27,9 +27,15 @@ namespace uirenderer {
// Constructors
///////////////////////////////////////////////////////////////////////////////
Snapshot::Snapshot(): flags(0), previous(NULL), layer(NULL), fbo(0),
invisible(false), empty(false), alpha(1.0f) {
Snapshot::Snapshot()
: flags(0)
, previous(NULL)
, layer(NULL)
, fbo(0)
, invisible(false)
, empty(false)
, height(0)
, alpha(1.0f) {
transform = &mTransformRoot;
clipRect = &mClipRectRoot;
region = NULL;
@@ -40,10 +46,16 @@ Snapshot::Snapshot(): flags(0), previous(NULL), layer(NULL), fbo(0),
* Copies the specified snapshot/ The specified snapshot is stored as
* the previous snapshot.
*/
Snapshot::Snapshot(const sp<Snapshot>& s, int saveFlags):
flags(0), previous(s), layer(s->layer), fbo(s->fbo),
invisible(s->invisible), empty(false),
viewport(s->viewport), height(s->height), alpha(s->alpha) {
Snapshot::Snapshot(const sp<Snapshot>& s, int saveFlags)
: flags(0)
, previous(s)
, layer(s->layer)
, fbo(s->fbo)
, invisible(s->invisible)
, empty(false)
, viewport(s->viewport)
, height(s->height)
, alpha(s->alpha) {
if (saveFlags & SkCanvas::kMatrix_SaveFlag) {
mTransformRoot.load(*s->transform);

View File

@@ -0,0 +1,52 @@
/*
* Copyright (C) 2014 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.
*/
#define LOG_TAG "OpenGLRenderer"
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <utils/Log.h>
#include "GLUtils.h"
namespace android {
namespace uirenderer {
void GLUtils::dumpGLErrors() {
GLenum status = GL_NO_ERROR;
while ((status = glGetError()) != GL_NO_ERROR) {
switch (status) {
case GL_INVALID_ENUM:
ALOGE("GL error: GL_INVALID_ENUM");
break;
case GL_INVALID_VALUE:
ALOGE("GL error: GL_INVALID_VALUE");
break;
case GL_INVALID_OPERATION:
ALOGE("GL error: GL_INVALID_OPERATION");
break;
case GL_OUT_OF_MEMORY:
ALOGE("GL error: Out of memory!");
break;
default:
ALOGE("GL error: 0x%x", status);
}
}
}
}; // namespace uirenderer
}; // namespace android

35
libs/hwui/utils/GLUtils.h Normal file
View File

@@ -0,0 +1,35 @@
/*
* Copyright (C) 2014 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.
*/
#ifndef GLUTILS_H
#define GLUTILS_H
namespace android {
namespace uirenderer {
class GLUtils {
private:
public:
/**
* Print out any GL errors with ALOGE
*/
static void dumpGLErrors();
}; // class GLUtils
} /* namespace uirenderer */
} /* namespace android */
#endif /* GLUTILS_H */

View File

@@ -38,4 +38,4 @@ public:
} /* namespace uirenderer */
} /* namespace android */
#endif /* RENDERNODE_H */
#endif /* MATHUTILS_H */