diff options
author | Romain Guy <romainguy@android.com> | 2010-06-25 13:46:18 -0700 |
---|---|---|
committer | Romain Guy <romainguy@android.com> | 2010-06-25 13:46:18 -0700 |
commit | 7ae7ac48aa2b53453c9805075171ecd5bcafd7de (patch) | |
tree | a1d496162615bc915bf7642acc5c94bcc98cef53 | |
parent | 1b6333863962ba637be394cb0ba17a12ca62ce61 (diff) | |
download | frameworks_base-7ae7ac48aa2b53453c9805075171ecd5bcafd7de.zip frameworks_base-7ae7ac48aa2b53453c9805075171ecd5bcafd7de.tar.gz frameworks_base-7ae7ac48aa2b53453c9805075171ecd5bcafd7de.tar.bz2 |
Convert tabs to spaces.
Change-Id: I5d3ae48af79b19b6d293deff0521e4bb57d5114b
-rw-r--r-- | core/jni/android_view_GLES20Canvas.cpp | 28 | ||||
-rw-r--r-- | libs/hwui/Matrix.cpp | 190 | ||||
-rw-r--r-- | libs/hwui/Matrix.h | 94 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 224 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.h | 96 | ||||
-rw-r--r-- | libs/hwui/Rect.h | 210 | ||||
-rw-r--r-- | libs/hwui/shaders/drawColor.vert | 4 |
7 files changed, 423 insertions, 423 deletions
diff --git a/core/jni/android_view_GLES20Canvas.cpp b/core/jni/android_view_GLES20Canvas.cpp index aca63e8..d3b6558 100644 --- a/core/jni/android_view_GLES20Canvas.cpp +++ b/core/jni/android_view_GLES20Canvas.cpp @@ -36,8 +36,8 @@ using namespace uirenderer; // ---------------------------------------------------------------------------- static struct { - jclass clazz; - jmethodID set; + jclass clazz; + jmethodID set; } gRectClassInfo; // ---------------------------------------------------------------------------- @@ -114,12 +114,12 @@ static bool android_view_GLES20Renderer_clipRect(JNIEnv* env, jobject canvas, static bool android_view_GLES20Renderer_getClipBounds(JNIEnv* env, jobject canvas, OpenGLRenderer* renderer, jobject rect) { - const android::uirenderer::Rect& bounds(renderer->getClipBounds()); + const android::uirenderer::Rect& bounds(renderer->getClipBounds()); - env->CallVoidMethod(rect, gRectClassInfo.set, - int(bounds.left), int(bounds.top), int(bounds.right), int(bounds.bottom)); + env->CallVoidMethod(rect, gRectClassInfo.set, + int(bounds.left), int(bounds.top), int(bounds.right), int(bounds.bottom)); - return !bounds.isEmpty(); + return !bounds.isEmpty(); } // ---------------------------------------------------------------------------- @@ -128,32 +128,32 @@ static bool android_view_GLES20Renderer_getClipBounds(JNIEnv* env, jobject canva static void android_view_GLES20Renderer_translate(JNIEnv* env, jobject canvas, OpenGLRenderer* renderer, jfloat dx, jfloat dy) { - renderer->translate(dx, dy); + renderer->translate(dx, dy); } static void android_view_GLES20Renderer_rotate(JNIEnv* env, jobject canvas, OpenGLRenderer* renderer, jfloat degrees) { - renderer->rotate(degrees); + renderer->rotate(degrees); } static void android_view_GLES20Renderer_scale(JNIEnv* env, jobject canvas, OpenGLRenderer* renderer, jfloat sx, jfloat sy) { - renderer->scale(sx, sy); + renderer->scale(sx, sy); } static void android_view_GLES20Renderer_setMatrix(JNIEnv* env, jobject canvas, OpenGLRenderer* renderer, SkMatrix* matrix) { - renderer->setMatrix(matrix); + renderer->setMatrix(matrix); } static void android_view_GLES20Renderer_getMatrix(JNIEnv* env, jobject canvas, OpenGLRenderer* renderer, SkMatrix* matrix) { - renderer->getMatrix(matrix); + renderer->getMatrix(matrix); } static void android_view_GLES20Renderer_concatMatrix(JNIEnv* env, jobject canvas, OpenGLRenderer* renderer, SkMatrix* matrix) { - renderer->concatMatrix(matrix); + renderer->concatMatrix(matrix); } // ---------------------------------------------------------------------------- @@ -217,8 +217,8 @@ static JNINativeMethod gMethods[] = { LOG_FATAL_IF(! var, "Unable to find method " methodName); int register_android_view_GLES20Canvas(JNIEnv* env) { - FIND_CLASS(gRectClassInfo.clazz, "android/graphics/Rect"); - GET_METHOD_ID(gRectClassInfo.set, gRectClassInfo.clazz, "set", "(IIII)V"); + FIND_CLASS(gRectClassInfo.clazz, "android/graphics/Rect"); + GET_METHOD_ID(gRectClassInfo.set, gRectClassInfo.clazz, "set", "(IIII)V"); return AndroidRuntime::registerNativeMethods(env, kClassPathName, gMethods, NELEM(gMethods)); } diff --git a/libs/hwui/Matrix.cpp b/libs/hwui/Matrix.cpp index 59b7fef..c772f00 100644 --- a/libs/hwui/Matrix.cpp +++ b/libs/hwui/Matrix.cpp @@ -30,118 +30,118 @@ namespace android { namespace uirenderer { void Matrix4::loadIdentity() { - data[0] = 1.0f; - data[1] = 0.0f; - data[2] = 0.0f; - data[3] = 0.0f; - - data[4] = 0.0f; - data[5] = 1.0f; - data[6] = 0.0f; - data[7] = 0.0f; - - data[8] = 0.0f; - data[9] = 0.0f; - data[10] = 1.0f; - data[11] = 0.0f; - - data[12] = 0.0f; - data[13] = 0.0f; - data[14] = 0.0f; - data[15] = 1.0f; + data[0] = 1.0f; + data[1] = 0.0f; + data[2] = 0.0f; + data[3] = 0.0f; + + data[4] = 0.0f; + data[5] = 1.0f; + data[6] = 0.0f; + data[7] = 0.0f; + + data[8] = 0.0f; + data[9] = 0.0f; + data[10] = 1.0f; + data[11] = 0.0f; + + data[12] = 0.0f; + data[13] = 0.0f; + data[14] = 0.0f; + data[15] = 1.0f; } void Matrix4::load(const float* v) { - memcpy(data, v, sizeof(data)); + memcpy(data, v, sizeof(data)); } void Matrix4::load(const Matrix4& v) { - memcpy(data, v.data, sizeof(data)); + memcpy(data, v.data, sizeof(data)); } void Matrix4::load(const SkMatrix& v) { - memset(data, 0, sizeof(data)); + memset(data, 0, sizeof(data)); - data[0] = v[SkMatrix::kMScaleX]; - data[4] = v[SkMatrix::kMSkewX]; - data[12] = v[SkMatrix::kMTransX]; + data[0] = v[SkMatrix::kMScaleX]; + data[4] = v[SkMatrix::kMSkewX]; + data[12] = v[SkMatrix::kMTransX]; - data[1] = v[SkMatrix::kMSkewY]; - data[5] = v[SkMatrix::kMScaleY]; - data[13] = v[SkMatrix::kMTransY]; + data[1] = v[SkMatrix::kMSkewY]; + data[5] = v[SkMatrix::kMScaleY]; + data[13] = v[SkMatrix::kMTransY]; - data[3] = v[SkMatrix::kMPersp0]; - data[7] = v[SkMatrix::kMPersp1]; - data[15] = v[SkMatrix::kMPersp2]; + data[3] = v[SkMatrix::kMPersp0]; + data[7] = v[SkMatrix::kMPersp1]; + data[15] = v[SkMatrix::kMPersp2]; - data[10] = 1.0f; + data[10] = 1.0f; } void Matrix4::copyTo(SkMatrix& v) const { - v.reset(); + v.reset(); - v.set(SkMatrix::kMScaleX, data[0]); - v.set(SkMatrix::kMSkewX, data[4]); - v.set(SkMatrix::kMTransX, data[12]); + v.set(SkMatrix::kMScaleX, data[0]); + v.set(SkMatrix::kMSkewX, data[4]); + v.set(SkMatrix::kMTransX, data[12]); - v.set(SkMatrix::kMSkewY, data[1]); - v.set(SkMatrix::kMScaleY, data[5]); - v.set(SkMatrix::kMTransY, data[13]); + v.set(SkMatrix::kMSkewY, data[1]); + v.set(SkMatrix::kMScaleY, data[5]); + v.set(SkMatrix::kMTransY, data[13]); - v.set(SkMatrix::kMPersp0, data[3]); - v.set(SkMatrix::kMPersp1, data[7]); - v.set(SkMatrix::kMPersp2, data[15]); + v.set(SkMatrix::kMPersp0, data[3]); + v.set(SkMatrix::kMPersp1, data[7]); + v.set(SkMatrix::kMPersp2, data[15]); } void Matrix4::copyTo(float* v) const { - memcpy(v, data, sizeof(data)); + memcpy(v, data, sizeof(data)); } void Matrix4::loadTranslate(float x, float y, float z) { - loadIdentity(); - data[12] = x; - data[13] = y; - data[14] = z; + loadIdentity(); + data[12] = x; + data[13] = y; + data[14] = z; } void Matrix4::loadScale(float sx, float sy, float sz) { - loadIdentity(); - data[0] = sx; - data[5] = sy; - data[10] = sz; + loadIdentity(); + data[0] = sx; + data[5] = sy; + data[10] = sz; } void Matrix4::loadRotate(float angle, float x, float y, float z) { - data[3] = 0.0f; - data[7] = 0.0f; - data[11] = 0.0f; - data[12] = 0.0f; - data[13] = 0.0f; - data[14] = 0.0f; - data[15] = 1.0f; - - angle *= float(M_PI / 180.0f); - float c = cosf(angle); - float s = sinf(angle); - - const float length = sqrtf(x * x + y * y + z * z); - const float nc = 1.0f - c; - const float xy = x * y; - const float yz = y * z; - const float zx = z * x; - const float xs = x * s; - const float ys = y * s; - const float zs = z * s; - - data[0] = x * x * nc + c; - data[4] = xy * nc - zs; - data[8] = zx * nc + ys; - data[1] = xy * nc + zs; - data[5] = y * y * nc + c; - data[9] = yz * nc - xs; - data[2] = zx * nc - ys; - data[6] = yz * nc + xs; - data[10] = z * z * nc + c; + data[3] = 0.0f; + data[7] = 0.0f; + data[11] = 0.0f; + data[12] = 0.0f; + data[13] = 0.0f; + data[14] = 0.0f; + data[15] = 1.0f; + + angle *= float(M_PI / 180.0f); + float c = cosf(angle); + float s = sinf(angle); + + const float length = sqrtf(x * x + y * y + z * z); + const float nc = 1.0f - c; + const float xy = x * y; + const float yz = y * z; + const float zx = z * x; + const float xs = x * s; + const float ys = y * s; + const float zs = z * s; + + data[0] = x * x * nc + c; + data[4] = xy * nc - zs; + data[8] = zx * nc + ys; + data[1] = xy * nc + zs; + data[5] = y * y * nc + c; + data[9] = yz * nc - xs; + data[2] = zx * nc - ys; + data[6] = yz * nc + xs; + data[10] = z * z * nc + c; } void Matrix4::loadMultiply(const Matrix4& u, const Matrix4& v) { @@ -179,25 +179,25 @@ void Matrix4::loadOrtho(float left, float right, float bottom, float top, float #define MUL_ADD_STORE(a, b, c) a = (a) * (b) + (c) void Matrix4::mapRect(Rect& r) const { - const float sx = data[0]; - const float sy = data[5]; + const float sx = data[0]; + const float sy = data[5]; - const float tx = data[12]; - const float ty = data[13]; + const float tx = data[12]; + const float ty = data[13]; - MUL_ADD_STORE(r.left, sx, tx); - MUL_ADD_STORE(r.right, sx, tx); - MUL_ADD_STORE(r.top, sy, ty); - MUL_ADD_STORE(r.bottom, sy, ty); + MUL_ADD_STORE(r.left, sx, tx); + MUL_ADD_STORE(r.right, sx, tx); + MUL_ADD_STORE(r.top, sy, ty); + MUL_ADD_STORE(r.bottom, sy, ty); } void Matrix4::dump() const { - LOGD("Matrix4["); - LOGD(" %f %f %f %f", data[0], data[4], data[ 8], data[12]); - LOGD(" %f %f %f %f", data[1], data[5], data[ 9], data[13]); - LOGD(" %f %f %f %f", data[2], data[6], data[10], data[14]); - LOGD(" %f %f %f %f", data[3], data[7], data[11], data[15]); - LOGD("]"); + LOGD("Matrix4["); + LOGD(" %f %f %f %f", data[0], data[4], data[ 8], data[12]); + LOGD(" %f %f %f %f", data[1], data[5], data[ 9], data[13]); + LOGD(" %f %f %f %f", data[2], data[6], data[10], data[14]); + LOGD(" %f %f %f %f", data[3], data[7], data[11], data[15]); + LOGD("]"); } }; // namespace uirenderer diff --git a/libs/hwui/Matrix.h b/libs/hwui/Matrix.h index 8fa5e4d..fa9638b 100644 --- a/libs/hwui/Matrix.h +++ b/libs/hwui/Matrix.h @@ -30,67 +30,67 @@ namespace uirenderer { class Matrix4 { public: - float data[16]; + float data[16]; - Matrix4() { - loadIdentity(); - } + Matrix4() { + loadIdentity(); + } - Matrix4(const float* v) { - load(v); - } + Matrix4(const float* v) { + load(v); + } - Matrix4(const Matrix4& v) { - load(v); - } + Matrix4(const Matrix4& v) { + load(v); + } - Matrix4(const SkMatrix& v) { - load(v); - } + Matrix4(const SkMatrix& v) { + load(v); + } - void loadIdentity(); + void loadIdentity(); - void load(const float* v); - void load(const Matrix4& v); - void load(const SkMatrix& v); + void load(const float* v); + void load(const Matrix4& v); + void load(const SkMatrix& v); - void loadTranslate(float x, float y, float z); - void loadScale(float sx, float sy, float sz); - void loadRotate(float angle, float x, float y, float z); - void loadMultiply(const Matrix4& u, const Matrix4& v); + void loadTranslate(float x, float y, float z); + void loadScale(float sx, float sy, float sz); + void loadRotate(float angle, float x, float y, float z); + void loadMultiply(const Matrix4& u, const Matrix4& v); - void loadOrtho(float left, float right, float bottom, float top, float near, float far); + void loadOrtho(float left, float right, float bottom, float top, float near, float far); - void multiply(const Matrix4& v) { - Matrix4 u; - u.loadMultiply(*this, v); - load(u); - } + void multiply(const Matrix4& v) { + Matrix4 u; + u.loadMultiply(*this, v); + load(u); + } - void translate(float x, float y, float z) { - Matrix4 u; - u.loadTranslate(x, y, z); - multiply(u); - } + void translate(float x, float y, float z) { + Matrix4 u; + u.loadTranslate(x, y, z); + multiply(u); + } - void scale(float sx, float sy, float sz) { - Matrix4 u; - u.loadScale(sx, sy, sz); - multiply(u); - } + void scale(float sx, float sy, float sz) { + Matrix4 u; + u.loadScale(sx, sy, sz); + multiply(u); + } - void rotate(float angle, float x, float y, float z) { - Matrix4 u; - u.loadRotate(angle, x, y, z); - multiply(u); - } + void rotate(float angle, float x, float y, float z) { + Matrix4 u; + u.loadRotate(angle, x, y, z); + multiply(u); + } - void copyTo(float* v) const; - void copyTo(SkMatrix& v) const; + void copyTo(float* v) const; + void copyTo(SkMatrix& v) const; - void mapRect(Rect& r) const; + void mapRect(Rect& r) const; - void dump() const; + void dump() const; private: inline float get(int i, int j) const { @@ -98,7 +98,7 @@ private: } inline void set(int i, int j, float v) { - data[i * 4 + j] = v; + data[i * 4 + j] = v; } }; // class Matrix4 diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 2ebd7cd..830e0c3 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -47,10 +47,10 @@ namespace uirenderer { /////////////////////////////////////////////////////////////////////////////// const SimpleVertex gDrawColorVertices[] = { - V(0.0f, 0.0f), - V(1.0f, 0.0f), - V(0.0f, 1.0f), - V(1.0f, 1.0f) + V(0.0f, 0.0f), + V(1.0f, 0.0f), + V(0.0f, 1.0f), + V(1.0f, 1.0f) }; const GLsizei gDrawColorVertexStride = sizeof(SimpleVertex); const GLsizei gDrawColorVertexCount = 4; @@ -65,93 +65,93 @@ const GLsizei gDrawColorVertexCount = 4; #include "shaders/drawColor.frag" Program::Program(const char* vertex, const char* fragment) { - vertexShader = buildShader(vertex, GL_VERTEX_SHADER); - fragmentShader = buildShader(fragment, GL_FRAGMENT_SHADER); - - id = glCreateProgram(); - glAttachShader(id, vertexShader); - glAttachShader(id, fragmentShader); - glLinkProgram(id); - - GLint status; - glGetProgramiv(id, GL_LINK_STATUS, &status); - if (status != GL_TRUE) { - GLint infoLen = 0; - glGetProgramiv(id, GL_INFO_LOG_LENGTH, &infoLen); - if (infoLen > 1) { - char* log = (char*) malloc(sizeof(char) * infoLen); - glGetProgramInfoLog(id, infoLen, 0, log); - LOGE("Error while linking shaders: %s", log); - delete log; - } - glDeleteProgram(id); - } + vertexShader = buildShader(vertex, GL_VERTEX_SHADER); + fragmentShader = buildShader(fragment, GL_FRAGMENT_SHADER); + + id = glCreateProgram(); + glAttachShader(id, vertexShader); + glAttachShader(id, fragmentShader); + glLinkProgram(id); + + GLint status; + glGetProgramiv(id, GL_LINK_STATUS, &status); + if (status != GL_TRUE) { + GLint infoLen = 0; + glGetProgramiv(id, GL_INFO_LOG_LENGTH, &infoLen); + if (infoLen > 1) { + char* log = (char*) malloc(sizeof(char) * infoLen); + glGetProgramInfoLog(id, infoLen, 0, log); + LOGE("Error while linking shaders: %s", log); + delete log; + } + glDeleteProgram(id); + } } Program::~Program() { - glDeleteShader(vertexShader); - glDeleteShader(fragmentShader); - glDeleteProgram(id); + glDeleteShader(vertexShader); + glDeleteShader(fragmentShader); + glDeleteProgram(id); } void Program::use() { - glUseProgram(id); + glUseProgram(id); } int Program::addAttrib(const char* name) { - int slot = glGetAttribLocation(id, name); - attributes.add(name, slot); - return slot; + int slot = glGetAttribLocation(id, name); + attributes.add(name, slot); + return slot; } int Program::getAttrib(const char* name) { - return attributes.valueFor(name); + return attributes.valueFor(name); } int Program::addUniform(const char* name) { - int slot = glGetUniformLocation(id, name); - uniforms.add(name, slot); - return slot; + int slot = glGetUniformLocation(id, name); + uniforms.add(name, slot); + return slot; } int Program::getUniform(const char* name) { - return uniforms.valueFor(name); + return uniforms.valueFor(name); } GLuint Program::buildShader(const char* source, GLenum type) { - GLuint shader = glCreateShader(type); - glShaderSource(shader, 1, &source, 0); - glCompileShader(shader); + GLuint shader = glCreateShader(type); + glShaderSource(shader, 1, &source, 0); + glCompileShader(shader); - GLint status; - glGetShaderiv(shader, GL_COMPILE_STATUS, &status); - if (status != GL_TRUE) { - // Some drivers return wrong values for GL_INFO_LOG_LENGTH - // use a fixed size instead - GLchar log[512]; - glGetShaderInfoLog(shader, sizeof(log), 0, &log[0]); - LOGE("Error while compiling shader: %s", log); - glDeleteShader(shader); - } + GLint status; + glGetShaderiv(shader, GL_COMPILE_STATUS, &status); + if (status != GL_TRUE) { + // Some drivers return wrong values for GL_INFO_LOG_LENGTH + // use a fixed size instead + GLchar log[512]; + glGetShaderInfoLog(shader, sizeof(log), 0, &log[0]); + LOGE("Error while compiling shader: %s", log); + glDeleteShader(shader); + } - return shader; + return shader; } DrawColorProgram::DrawColorProgram(): - Program(gDrawColorVertexShader, gDrawColorFragmentShader) { - position = addAttrib("position"); - color = addAttrib("color"); - projection = addUniform("projection"); - modelView = addUniform("modelView"); - transform = addUniform("transform"); + Program(gDrawColorVertexShader, gDrawColorFragmentShader) { + position = addAttrib("position"); + color = addAttrib("color"); + projection = addUniform("projection"); + modelView = addUniform("modelView"); + transform = addUniform("transform"); } void DrawColorProgram::use(const GLfloat* projectionMatrix, const GLfloat* modelViewMatrix, const GLfloat* transformMatrix) { - Program::use(); - glUniformMatrix4fv(projection, 1, GL_FALSE, projectionMatrix); - glUniformMatrix4fv(modelView, 1, GL_FALSE, modelViewMatrix); - glUniformMatrix4fv(transform, 1, GL_FALSE, transformMatrix); + Program::use(); + glUniformMatrix4fv(projection, 1, GL_FALSE, projectionMatrix); + glUniformMatrix4fv(modelView, 1, GL_FALSE, modelViewMatrix); + glUniformMatrix4fv(transform, 1, GL_FALSE, transformMatrix); } /////////////////////////////////////////////////////////////////////////////// @@ -159,12 +159,12 @@ void DrawColorProgram::use(const GLfloat* projectionMatrix, const GLfloat* model /////////////////////////////////////////////////////////////////////////////// const Rect& Snapshot::getMappedClip() { - if (flags & kFlagDirtyTransform) { - flags &= ~kFlagDirtyTransform; - mappedClip.set(clipRect); - transform.mapRect(mappedClip); - } - return mappedClip; + if (flags & kFlagDirtyTransform) { + flags &= ~kFlagDirtyTransform; + mappedClip.set(clipRect); + transform.mapRect(mappedClip); + } + return mappedClip; } /////////////////////////////////////////////////////////////////////////////// @@ -197,8 +197,8 @@ void OpenGLRenderer::setViewport(int width, int height) { } void OpenGLRenderer::prepare() { - mSnapshot = &mFirstSnapshot; - mSaveCount = 0; + mSnapshot = &mFirstSnapshot; + mSaveCount = 0; glDisable(GL_SCISSOR_TEST); @@ -216,50 +216,50 @@ void OpenGLRenderer::prepare() { /////////////////////////////////////////////////////////////////////////////// int OpenGLRenderer::getSaveCount() const { - return mSaveCount; + return mSaveCount; } int OpenGLRenderer::save(int flags) { - return saveSnapshot(); + return saveSnapshot(); } void OpenGLRenderer::restore() { - if (mSaveCount == 0) return; + if (mSaveCount == 0) return; - if (restoreSnapshot()) { - setScissorFromClip(); - } + if (restoreSnapshot()) { + setScissorFromClip(); + } } void OpenGLRenderer::restoreToCount(int saveCount) { - if (saveCount <= 0 || saveCount > mSaveCount) return; + if (saveCount <= 0 || saveCount > mSaveCount) return; - bool restoreClip = false; + bool restoreClip = false; - while (mSaveCount != saveCount - 1) { - restoreClip |= restoreSnapshot(); - } + while (mSaveCount != saveCount - 1) { + restoreClip |= restoreSnapshot(); + } - if (restoreClip) { - setScissorFromClip(); - } + if (restoreClip) { + setScissorFromClip(); + } } int OpenGLRenderer::saveSnapshot() { - mSnapshot = new Snapshot(mSnapshot); - return ++mSaveCount; + mSnapshot = new Snapshot(mSnapshot); + return ++mSaveCount; } bool OpenGLRenderer::restoreSnapshot() { - bool restoreClip = mSnapshot->flags & Snapshot::kFlagClipSet; + bool restoreClip = mSnapshot->flags & Snapshot::kFlagClipSet; - mSaveCount--; + mSaveCount--; - // Do not merge these two lines! - sp<Snapshot> previous = mSnapshot->previous; - mSnapshot = previous; + // Do not merge these two lines! + sp<Snapshot> previous = mSnapshot->previous; + mSnapshot = previous; - return restoreClip; + return restoreClip; } /////////////////////////////////////////////////////////////////////////////// @@ -267,33 +267,33 @@ bool OpenGLRenderer::restoreSnapshot() { /////////////////////////////////////////////////////////////////////////////// void OpenGLRenderer::translate(float dx, float dy) { - mSnapshot->transform.translate(dx, dy, 0.0f); - mSnapshot->flags |= Snapshot::kFlagDirtyTransform; + mSnapshot->transform.translate(dx, dy, 0.0f); + mSnapshot->flags |= Snapshot::kFlagDirtyTransform; } void OpenGLRenderer::rotate(float degrees) { - mSnapshot->transform.rotate(degrees, 0.0f, 0.0f, 1.0f); - mSnapshot->flags |= Snapshot::kFlagDirtyTransform; + mSnapshot->transform.rotate(degrees, 0.0f, 0.0f, 1.0f); + mSnapshot->flags |= Snapshot::kFlagDirtyTransform; } void OpenGLRenderer::scale(float sx, float sy) { - mSnapshot->transform.scale(sx, sy, 1.0f); - mSnapshot->flags |= Snapshot::kFlagDirtyTransform; + mSnapshot->transform.scale(sx, sy, 1.0f); + mSnapshot->flags |= Snapshot::kFlagDirtyTransform; } void OpenGLRenderer::setMatrix(SkMatrix* matrix) { - mSnapshot->transform.load(*matrix); - mSnapshot->flags |= Snapshot::kFlagDirtyTransform; + mSnapshot->transform.load(*matrix); + mSnapshot->flags |= Snapshot::kFlagDirtyTransform; } void OpenGLRenderer::getMatrix(SkMatrix* matrix) { - mSnapshot->transform.copyTo(*matrix); + mSnapshot->transform.copyTo(*matrix); } void OpenGLRenderer::concatMatrix(SkMatrix* matrix) { - mat4 m(*matrix); - mSnapshot->transform.multiply(m); - mSnapshot->flags |= Snapshot::kFlagDirtyTransform; + mat4 m(*matrix); + mSnapshot->transform.multiply(m); + mSnapshot->flags |= Snapshot::kFlagDirtyTransform; } /////////////////////////////////////////////////////////////////////////////// @@ -301,12 +301,12 @@ void OpenGLRenderer::concatMatrix(SkMatrix* matrix) { /////////////////////////////////////////////////////////////////////////////// void OpenGLRenderer::setScissorFromClip() { - const Rect& clip = mSnapshot->getMappedClip(); - glScissor(clip.left, mHeight - clip.bottom, clip.getWidth(), clip.getHeight()); + const Rect& clip = mSnapshot->getMappedClip(); + glScissor(clip.left, mHeight - clip.bottom, clip.getWidth(), clip.getHeight()); } const Rect& OpenGLRenderer::getClipBounds() { - return mSnapshot->clipRect; + return mSnapshot->clipRect; } bool OpenGLRenderer::quickReject(float left, float top, float right, float bottom) { @@ -328,12 +328,12 @@ bool OpenGLRenderer::quickReject(float left, float top, float right, float botto } bool OpenGLRenderer::clipRect(float left, float top, float right, float bottom) { - bool clipped = mSnapshot->clipRect.intersect(left, top, right, bottom); - if (clipped) { - mSnapshot->flags |= Snapshot::kFlagClipSet; - setScissorFromClip(); - } - return clipped; + bool clipped = mSnapshot->clipRect.intersect(left, top, right, bottom); + if (clipped) { + mSnapshot->flags |= Snapshot::kFlagClipSet; + setScissorFromClip(); + } + return clipped; } /////////////////////////////////////////////////////////////////////////////// diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h index bef4193..6f6b997 100644 --- a/libs/hwui/OpenGLRenderer.h +++ b/libs/hwui/OpenGLRenderer.h @@ -38,88 +38,88 @@ namespace uirenderer { class Snapshot: public LightRefBase<Snapshot> { public: - Snapshot() { - } + Snapshot() { + } - Snapshot(const sp<Snapshot> s): - transform(s->transform), - clipRect(s->clipRect), - flags(kFlagDirtyTransform), - previous(s) { - } + Snapshot(const sp<Snapshot> s): + transform(s->transform), + clipRect(s->clipRect), + flags(kFlagDirtyTransform), + previous(s) { + } - enum Flags { - kFlagClipSet = 0x1, - kFlagDirtyTransform = 0x2, - }; + enum Flags { + kFlagClipSet = 0x1, + kFlagDirtyTransform = 0x2, + }; - const Rect& getMappedClip(); + const Rect& getMappedClip(); - // Local transformations - mat4 transform; + // Local transformations + mat4 transform; - // Clipping rectangle at the time of this snapshot - Rect clipRect; + // Clipping rectangle at the time of this snapshot + Rect clipRect; - // Dirty flags - int flags; + // Dirty flags + int flags; - // Previous snapshot in the frames stack - sp<Snapshot> previous; + // Previous snapshot in the frames stack + sp<Snapshot> previous; private: - // Clipping rectangle mapped with the transform - Rect mappedClip; + // Clipping rectangle mapped with the transform + Rect mappedClip; }; // class Snapshot struct SimpleVertex { - float position[2]; + float position[2]; }; // struct SimpleVertex typedef char* shader; class Program: public LightRefBase<Program> { public: - Program(const char* vertex, const char* fragment); - ~Program(); + Program(const char* vertex, const char* fragment); + ~Program(); - void use(); + void use(); protected: - int addAttrib(const char* name); - int getAttrib(const char* name); + int addAttrib(const char* name); + int getAttrib(const char* name); - int addUniform(const char* name); - int getUniform(const char* name); + int addUniform(const char* name); + int getUniform(const char* name); private: - GLuint buildShader(const char* source, GLenum type); + GLuint buildShader(const char* source, GLenum type); - // Handle of the OpenGL program - GLuint id; + // Handle of the OpenGL program + GLuint id; - // Handles of the shaders - GLuint vertexShader; - GLuint fragmentShader; + // Handles of the shaders + GLuint vertexShader; + GLuint fragmentShader; - // Keeps track of attributes and uniforms slots - KeyedVector<const char*, int> attributes; - KeyedVector<const char*, int> uniforms; + // Keeps track of attributes and uniforms slots + KeyedVector<const char*, int> attributes; + KeyedVector<const char*, int> uniforms; }; // class Program class DrawColorProgram: public Program { public: - DrawColorProgram(); + DrawColorProgram(); - void use(const GLfloat* projectionMatrix, const GLfloat* modelViewMatrix, - const GLfloat* transformMatrix); + void use(const GLfloat* projectionMatrix, const GLfloat* modelViewMatrix, + const GLfloat* transformMatrix); - int position; - int color; + int position; + int color; - int projection; - int modelView; - int transform; + int projection; + int modelView; + int transform; }; /////////////////////////////////////////////////////////////////////////////// diff --git a/libs/hwui/Rect.h b/libs/hwui/Rect.h index fcf11e9..b382dc3 100644 --- a/libs/hwui/Rect.h +++ b/libs/hwui/Rect.h @@ -25,111 +25,111 @@ namespace uirenderer { /////////////////////////////////////////////////////////////////////////////// struct Rect { - float left; - float top; - float right; - float bottom; - - Rect(): - left(0), - top(0), - right(0), - bottom(0) { - } - - Rect(float left, float top, float right, float bottom): - left(left), - top(top), - right(right), - bottom(bottom) { - } - - Rect(const Rect& r) { - set(r); - } - - Rect(Rect& r) { - set(r); - } - - Rect& operator=(const Rect& r) { - set(r); - return *this; - } - - Rect& operator=(Rect& r) { - set(r); - return *this; - } - - friend int operator==(const Rect& a, const Rect& b) { - return !memcmp(&a, &b, sizeof(a)); - } - - friend int operator!=(const Rect& a, const Rect& b) { - return memcmp(&a, &b, sizeof(a)); - } - - bool isEmpty() const { - return left >= right || top >= bottom; - } - - void setEmpty() { - memset(this, 0, sizeof(*this)); - } - - void set(float left, float top, float right, float bottom) { - this->left = left; - this->right = right; - this->top = top; - this->bottom = bottom; - } - - void set(const Rect& r) { - set(r.left, r.top, r.right, r.bottom); - } - - float getWidth() const { - return right - left; - } - - float getHeight() const { - return bottom - top; - } - - bool intersects(float left, float top, float right, float bottom) const { - return left < right && top < bottom && - this->left < this->right && this->top < this->bottom && - this->left < right && left < this->right && - this->top < bottom && top < this->bottom; - } - - bool intersects(const Rect& r) const { - return intersects(r.left, r.top, r.right, r.bottom); - } - - bool intersect(float left, float top, float right, float bottom) { - if (left < right && top < bottom && !this->isEmpty() && - this->left < right && left < this->right && - this->top < bottom && top < this->bottom) { - - if (this->left < left) this->left = left; - if (this->top < top) this->top = top; - if (this->right > right) this->right = right; - if (this->bottom > bottom) this->bottom = bottom; - - return true; - } - return false; - } - - bool intersect(const Rect& r) { - return intersect(r.left, r.top, r.right, r.bottom); - } - - void dump() const { - LOGD("Rect[l=%f t=%f r=%f b=%f]", left, top, right, bottom); - } + float left; + float top; + float right; + float bottom; + + Rect(): + left(0), + top(0), + right(0), + bottom(0) { + } + + Rect(float left, float top, float right, float bottom): + left(left), + top(top), + right(right), + bottom(bottom) { + } + + Rect(const Rect& r) { + set(r); + } + + Rect(Rect& r) { + set(r); + } + + Rect& operator=(const Rect& r) { + set(r); + return *this; + } + + Rect& operator=(Rect& r) { + set(r); + return *this; + } + + friend int operator==(const Rect& a, const Rect& b) { + return !memcmp(&a, &b, sizeof(a)); + } + + friend int operator!=(const Rect& a, const Rect& b) { + return memcmp(&a, &b, sizeof(a)); + } + + bool isEmpty() const { + return left >= right || top >= bottom; + } + + void setEmpty() { + memset(this, 0, sizeof(*this)); + } + + void set(float left, float top, float right, float bottom) { + this->left = left; + this->right = right; + this->top = top; + this->bottom = bottom; + } + + void set(const Rect& r) { + set(r.left, r.top, r.right, r.bottom); + } + + float getWidth() const { + return right - left; + } + + float getHeight() const { + return bottom - top; + } + + bool intersects(float left, float top, float right, float bottom) const { + return left < right && top < bottom && + this->left < this->right && this->top < this->bottom && + this->left < right && left < this->right && + this->top < bottom && top < this->bottom; + } + + bool intersects(const Rect& r) const { + return intersects(r.left, r.top, r.right, r.bottom); + } + + bool intersect(float left, float top, float right, float bottom) { + if (left < right && top < bottom && !this->isEmpty() && + this->left < right && left < this->right && + this->top < bottom && top < this->bottom) { + + if (this->left < left) this->left = left; + if (this->top < top) this->top = top; + if (this->right > right) this->right = right; + if (this->bottom > bottom) this->bottom = bottom; + + return true; + } + return false; + } + + bool intersect(const Rect& r) { + return intersect(r.left, r.top, r.right, r.bottom); + } + + void dump() const { + LOGD("Rect[l=%f t=%f r=%f b=%f]", left, top, right, bottom); + } }; // struct Rect diff --git a/libs/hwui/shaders/drawColor.vert b/libs/hwui/shaders/drawColor.vert index 4b7f883..cef6e49 100644 --- a/libs/hwui/shaders/drawColor.vert +++ b/libs/hwui/shaders/drawColor.vert @@ -10,8 +10,8 @@ uniform mat4 transform; varying vec4 outColor; void main(void) { - outColor = color; - gl_Position = projection * transform * modelView * position; + outColor = color; + gl_Position = projection * transform * modelView * position; } ); |