diff options
author | Nicolas Roard <nicolas@android.com> | 2010-12-08 11:37:30 -0800 |
---|---|---|
committer | Nicolas Roard <nicolas@android.com> | 2010-12-16 13:41:16 -0800 |
commit | 8c3b4386c279f644e5e9d2c5769fe5a43c6cd0ca (patch) | |
tree | 91dbe20f39c9e0235f2f4f2e3fbf3b01430e7fe9 /WebCore | |
parent | 211482b53e73a386e2aabb0d3acb92e0e7ea22d4 (diff) | |
download | external_webkit-8c3b4386c279f644e5e9d2c5769fe5a43c6cd0ca.zip external_webkit-8c3b4386c279f644e5e9d2c5769fe5a43c6cd0ca.tar.gz external_webkit-8c3b4386c279f644e5e9d2c5769fe5a43c6cd0ca.tar.bz2 |
Cleanup pass to make files compliant with webkit style
Change-Id: I9234be0c1559d5cc11af73ebd8cc14f98f6a4c2e
Diffstat (limited to 'WebCore')
12 files changed, 203 insertions, 170 deletions
diff --git a/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.cpp b/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.cpp index 16e3045..12e0436 100644 --- a/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.cpp +++ b/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.cpp @@ -25,10 +25,11 @@ #include "config.h" #include "BackedDoubleBufferedTexture.h" + #include "BaseTile.h" #include "DeleteTextureOperation.h" -#include "TilesManager.h" #include "GLUtils.h" +#include "TilesManager.h" #define LOG_NDEBUG 1 #define LOG_TAG "BackedDoubleBufferedTexture.cpp" @@ -61,7 +62,7 @@ BackedDoubleBufferedTexture::~BackedDoubleBufferedTexture() void BackedDoubleBufferedTexture::destroyTextures(SharedTexture** textures) { int x = 0; - while (textures[x] != 0) { + while (textures[x]) { // We need to delete the source texture and EGLImage in the texture // generation thread. In theory we should be able to delete the EGLImage // from either thread, but it currently throws an error if not deleted diff --git a/WebCore/platform/graphics/android/GLUtils.cpp b/WebCore/platform/graphics/android/GLUtils.cpp index 739dafc..2200d05 100644 --- a/WebCore/platform/graphics/android/GLUtils.cpp +++ b/WebCore/platform/graphics/android/GLUtils.cpp @@ -45,7 +45,8 @@ using namespace android; // Matrix utilities ///////////////////////////////////////////////////////////////////////////////////////// -void GLUtils::toGLMatrix(GLfloat* flattened, const TransformationMatrix& m) { +void GLUtils::toGLMatrix(GLfloat* flattened, const TransformationMatrix& m) +{ flattened[0] = m.m11(); // scaleX flattened[1] = m.m12(); // skewY flattened[2] = m.m13(); @@ -64,7 +65,8 @@ void GLUtils::toGLMatrix(GLfloat* flattened, const TransformationMatrix& m) { flattened[15] = m.m44(); // persp2 } -void GLUtils::toSkMatrix(SkMatrix& matrix, const TransformationMatrix& m) { +void GLUtils::toSkMatrix(SkMatrix& matrix, const TransformationMatrix& m) +{ matrix[0] = m.m11(); // scaleX matrix[1] = m.m21(); // skewX matrix[2] = m.m41(); // transX @@ -77,7 +79,8 @@ void GLUtils::toSkMatrix(SkMatrix& matrix, const TransformationMatrix& m) { } void GLUtils::setOrthographicMatrix(TransformationMatrix& ortho, float left, float top, - float right, float bottom, float nearZ, float farZ) { + float right, float bottom, float nearZ, float farZ) +{ float deltaX = right - left; float deltaY = top - bottom; float deltaZ = farZ - nearZ; @@ -96,19 +99,19 @@ void GLUtils::setOrthographicMatrix(TransformationMatrix& ortho, float left, flo // GL & EGL error checks ///////////////////////////////////////////////////////////////////////////////////////// -void GLUtils::checkEglError(const char* op, EGLBoolean returnVal) { - if (returnVal != EGL_TRUE) { +void GLUtils::checkEglError(const char* op, EGLBoolean returnVal) +{ + if (returnVal != EGL_TRUE) XLOG("EGL ERROR - %s() returned %d\n", op, returnVal); - } else { + else XLOG("EGL OK - %s() returned %d\n", op, returnVal); - } - for (EGLint error = eglGetError(); error != EGL_SUCCESS; error = eglGetError()) { + for (EGLint error = eglGetError(); error != EGL_SUCCESS; error = eglGetError()) XLOG("after %s() eglError (0x%x)\n", op, error); - } } -bool GLUtils::checkGlError(const char* op) { +bool GLUtils::checkGlError(const char* op) +{ bool ret = false; for (GLint error = glGetError(); error; error = glGetError()) { XLOG("GL ERROR - after %s() glError (0x%x)\n", op, error); @@ -117,7 +120,8 @@ bool GLUtils::checkGlError(const char* op) { return ret; } -bool GLUtils::checkGlErrorOn(void* p, const char* op) { +bool GLUtils::checkGlErrorOn(void* p, const char* op) +{ bool ret = false; for (GLint error = glGetError(); error; error = glGetError()) { XLOG("GL ERROR on %x - after %s() glError (0x%x)\n", p, op, error); @@ -130,17 +134,19 @@ bool GLUtils::checkGlErrorOn(void* p, const char* op) { // GL & EGL extension checks ///////////////////////////////////////////////////////////////////////////////////////// -bool GLUtils::isEGLImageSupported() { +bool GLUtils::isEGLImageSupported() +{ const char* eglExtensions = eglQueryString(eglGetCurrentDisplay(), EGL_EXTENSIONS); const char* glExtensions = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)); - return eglExtensions && glExtensions && - strstr(eglExtensions, "EGL_KHR_image_base") && - strstr(eglExtensions, "EGL_KHR_gl_texture_2D_image") && - strstr(glExtensions, "GL_OES_EGL_image"); + return eglExtensions && glExtensions + && strstr(eglExtensions, "EGL_KHR_image_base") + && strstr(eglExtensions, "EGL_KHR_gl_texture_2D_image") + && strstr(glExtensions, "GL_OES_EGL_image"); } -bool GLUtils::isEGLFenceSyncSupported() { +bool GLUtils::isEGLFenceSyncSupported() +{ const char* eglExtensions = eglQueryString(eglGetCurrentDisplay(), EGL_EXTENSIONS); return eglExtensions && strstr(eglExtensions, "EGL_KHR_fence_sync"); } @@ -151,39 +157,40 @@ bool GLUtils::isEGLFenceSyncSupported() { static GLenum getInternalFormat(SkBitmap::Config config) { - switch(config) { - case SkBitmap::kA8_Config: - return GL_ALPHA; - case SkBitmap::kARGB_4444_Config: - return GL_RGBA; - case SkBitmap::kARGB_8888_Config: - return GL_RGBA; - case SkBitmap::kRGB_565_Config: - return GL_RGB; - default: - return -1; + switch (config) { + case SkBitmap::kA8_Config: + return GL_ALPHA; + case SkBitmap::kARGB_4444_Config: + return GL_RGBA; + case SkBitmap::kARGB_8888_Config: + return GL_RGBA; + case SkBitmap::kRGB_565_Config: + return GL_RGB; + default: + return -1; } } static GLenum getType(SkBitmap::Config config) { - switch(config) { - case SkBitmap::kA8_Config: - return GL_UNSIGNED_BYTE; - case SkBitmap::kARGB_4444_Config: - return GL_UNSIGNED_SHORT_4_4_4_4; - case SkBitmap::kARGB_8888_Config: - return GL_UNSIGNED_BYTE; - case SkBitmap::kIndex8_Config: - return -1; // No type for compressed data. - case SkBitmap::kRGB_565_Config: - return GL_UNSIGNED_SHORT_5_6_5; - default: - return -1; + switch (config) { + case SkBitmap::kA8_Config: + return GL_UNSIGNED_BYTE; + case SkBitmap::kARGB_4444_Config: + return GL_UNSIGNED_SHORT_4_4_4_4; + case SkBitmap::kARGB_8888_Config: + return GL_UNSIGNED_BYTE; + case SkBitmap::kIndex8_Config: + return -1; // No type for compressed data. + case SkBitmap::kRGB_565_Config: + return GL_UNSIGNED_SHORT_5_6_5; + default: + return -1; } } -static EGLConfig defaultPbufferConfig(EGLDisplay display) { +static EGLConfig defaultPbufferConfig(EGLDisplay display) +{ EGLConfig config; EGLint numConfigs; @@ -195,15 +202,15 @@ static EGLConfig defaultPbufferConfig(EGLDisplay display) { eglChooseConfig(display, configAttribs, &config, 1, &numConfigs); GLUtils::checkEglError("eglPbufferConfig"); - if(numConfigs != 1) { + if (numConfigs != 1) LOGI("eglPbufferConfig failed (%d)\n", numConfigs); - } return config; } static EGLSurface createPbufferSurface(EGLDisplay display, const EGLConfig& config, - EGLint* errorCode) { + EGLint* errorCode) +{ const EGLint attribList[] = { EGL_WIDTH, 1, EGL_HEIGHT, 1, @@ -222,7 +229,8 @@ static EGLSurface createPbufferSurface(EGLDisplay display, const EGLConfig& conf return surface; } -EGLContext GLUtils::createBackgroundContext(EGLContext sharedContext) { +EGLContext GLUtils::createBackgroundContext(EGLContext sharedContext) +{ checkEglError("<init>"); EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); checkEglError("eglGetDisplay"); @@ -246,8 +254,8 @@ EGLContext GLUtils::createBackgroundContext(EGLContext sharedContext) { EGLint surfaceConfigId; EGLBoolean success = eglGetConfigAttrib(display, config, EGL_CONFIG_ID, &surfaceConfigId); - EGLint context_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; - EGLContext context = eglCreateContext(display, config, sharedContext, context_attribs); + EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; + EGLContext context = eglCreateContext(display, config, sharedContext, contextAttribs); checkEglError("eglCreateContext"); if (context == EGL_NO_CONTEXT) { XLOG("eglCreateContext failed\n"); @@ -264,13 +272,15 @@ EGLContext GLUtils::createBackgroundContext(EGLContext sharedContext) { return context; } -void GLUtils::deleteTexture(GLuint* texture) { +void GLUtils::deleteTexture(GLuint* texture) +{ glDeleteTextures(1, texture); GLUtils::checkGlError("glDeleteTexture"); *texture = 0; } -GLuint GLUtils::createSampleTexture() { +GLuint GLUtils::createSampleTexture() +{ GLuint texture; glGenTextures(1, &texture); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); @@ -289,7 +299,8 @@ GLuint GLUtils::createSampleTexture() { return texture; } -void GLUtils::createTextureWithBitmap(GLuint texture, SkBitmap& bitmap, GLint filter) { +void GLUtils::createTextureWithBitmap(GLuint texture, SkBitmap& bitmap, GLint filter) +{ glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glBindTexture(GL_TEXTURE_2D, texture); GLUtils::checkGlError("glBindTexture"); @@ -305,7 +316,8 @@ void GLUtils::createTextureWithBitmap(GLuint texture, SkBitmap& bitmap, GLint fi glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); } -void GLUtils::updateTextureWithBitmap(GLuint texture, SkBitmap& bitmap, GLint filter) { +void GLUtils::updateTextureWithBitmap(GLuint texture, SkBitmap& bitmap, GLint filter) +{ glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glBindTexture(GL_TEXTURE_2D, texture); GLUtils::checkGlError("glBindTexture"); @@ -321,7 +333,8 @@ void GLUtils::updateTextureWithBitmap(GLuint texture, SkBitmap& bitmap, GLint fi glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); } -void GLUtils::createEGLImageFromTexture(GLuint texture, EGLImageKHR* image) { +void GLUtils::createEGLImageFromTexture(GLuint texture, EGLImageKHR* image) +{ EGLClientBuffer buffer = reinterpret_cast<EGLClientBuffer>(texture); static const EGLint attr[] = { EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE }; *image = eglCreateImageKHR(eglGetCurrentDisplay(), eglGetCurrentContext(), @@ -329,7 +342,8 @@ void GLUtils::createEGLImageFromTexture(GLuint texture, EGLImageKHR* image) { GLUtils::checkEglError("eglCreateImage", (*image != EGL_NO_IMAGE_KHR)); } -void GLUtils::createTextureFromEGLImage(GLuint texture, EGLImageKHR image, GLint filter) { +void GLUtils::createTextureFromEGLImage(GLuint texture, EGLImageKHR image, GLint filter) +{ glBindTexture(GL_TEXTURE_2D, texture); GLUtils::checkGlError("glBindTexture"); glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, (GLeglImageOES)image); diff --git a/WebCore/platform/graphics/android/GLUtils.h b/WebCore/platform/graphics/android/GLUtils.h index 1b2e823..3e7b800 100644 --- a/WebCore/platform/graphics/android/GLUtils.h +++ b/WebCore/platform/graphics/android/GLUtils.h @@ -23,50 +23,50 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef GLUTILS_H_ -#define GLUTILS_H_ +#ifndef GLUtils_h +#define GLUtils_h #if USE(ACCELERATED_COMPOSITING) -#include <GLES2/gl2.h> -#include <GLES2/gl2ext.h> -#include <EGL/egl.h> -#include <EGL/eglext.h> #include "SkBitmap.h" #include "SkMatrix.h" #include "TransformationMatrix.h" +#include <EGL/egl.h> +#include <EGL/eglext.h> +#include <GLES2/gl2.h> +#include <GLES2/gl2ext.h> namespace WebCore { class GLUtils { public: - // Matrix utilities - static void toGLMatrix(GLfloat* flattened, const TransformationMatrix& matrix); - static void toSkMatrix(SkMatrix& skmatrix, const TransformationMatrix& matrix); - static void setOrthographicMatrix(TransformationMatrix& ortho, float left, float top, - float right, float bottom, float nearZ, float farZ); + // Matrix utilities + static void toGLMatrix(GLfloat* flattened, const TransformationMatrix& matrix); + static void toSkMatrix(SkMatrix& skmatrix, const TransformationMatrix& matrix); + static void setOrthographicMatrix(TransformationMatrix& ortho, float left, float top, + float right, float bottom, float nearZ, float farZ); - // GL & EGL error checks - static void checkEglError(const char* op, EGLBoolean returnVal = EGL_TRUE); - static bool checkGlErrorOn(void* p, const char* op); - static bool checkGlError(const char* op); + // GL & EGL error checks + static void checkEglError(const char* op, EGLBoolean returnVal = EGL_TRUE); + static bool checkGlErrorOn(void* p, const char* op); + static bool checkGlError(const char* op); - // GL & EGL extension checks - static bool isEGLImageSupported(); - static bool isEGLFenceSyncSupported(); + // GL & EGL extension checks + static bool isEGLImageSupported(); + static bool isEGLFenceSyncSupported(); - // Texture utilities - static EGLContext createBackgroundContext(EGLContext sharedContext); - static void deleteTexture(GLuint* texture); - static GLuint createSampleTexture(); - static void createTextureWithBitmap(GLuint texture, SkBitmap& bitmap, GLint filter = GL_LINEAR); - static void updateTextureWithBitmap(GLuint texture, SkBitmap& bitmap, GLint filter = GL_LINEAR); - static void createEGLImageFromTexture(GLuint texture, EGLImageKHR* image); - static void createTextureFromEGLImage(GLuint texture, EGLImageKHR image, GLint filter = GL_LINEAR); + // Texture utilities + static EGLContext createBackgroundContext(EGLContext sharedContext); + static void deleteTexture(GLuint* texture); + static GLuint createSampleTexture(); + static void createTextureWithBitmap(GLuint texture, SkBitmap& bitmap, GLint filter = GL_LINEAR); + static void updateTextureWithBitmap(GLuint texture, SkBitmap& bitmap, GLint filter = GL_LINEAR); + static void createEGLImageFromTexture(GLuint texture, EGLImageKHR* image); + static void createTextureFromEGLImage(GLuint texture, EGLImageKHR image, GLint filter = GL_LINEAR); }; } // namespace WebCore #endif // USE(ACCELERATED_COMPOSITING) -#endif // GLUTILS_H_ +#endif // GLUtils_h diff --git a/WebCore/platform/graphics/android/GLWebViewState.h b/WebCore/platform/graphics/android/GLWebViewState.h index 698eb4a..3b6f1d1 100644 --- a/WebCore/platform/graphics/android/GLWebViewState.h +++ b/WebCore/platform/graphics/android/GLWebViewState.h @@ -170,7 +170,7 @@ public: unsigned int paintBaseLayerContent(SkCanvas* canvas); void setBaseLayer(BaseLayerAndroid* layer, const IntRect& rect); - void setExtra(BaseLayerAndroid* , SkPicture& , const IntRect& ); + void setExtra(BaseLayerAndroid*, SkPicture&, const IntRect&); void scheduleUpdate(const double& currentTime, const SkIRect& viewport, float scale); TiledPage* frontPage(); diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp index 35a8523..69822b5 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.cpp +++ b/WebCore/platform/graphics/android/LayerAndroid.cpp @@ -354,7 +354,8 @@ public: bool drewText() { return m_findCheck.drewText(); } - void setBest(const LayerAndroid* best, int x, int y) { + void setBest(const LayerAndroid* best, int x, int y) + { m_best = best; m_bestX = x; m_bestY = y; diff --git a/WebCore/platform/graphics/android/MediaPlayerPrivateAndroid.h b/WebCore/platform/graphics/android/MediaPlayerPrivateAndroid.h index 49aafec..e8e29bf 100644 --- a/WebCore/platform/graphics/android/MediaPlayerPrivateAndroid.h +++ b/WebCore/platform/graphics/android/MediaPlayerPrivateAndroid.h @@ -115,7 +115,7 @@ protected: MediaPlayer::ReadyState m_readyState; MediaPlayer::NetworkState m_networkState; - SkBitmap* m_poster; // not owned + SkBitmap* m_poster; // not owned String m_posterUrl; IntSize m_naturalSize; @@ -124,7 +124,7 @@ protected: bool m_isVisible; }; -} // namespace WebCore +} // namespace WebCore #endif diff --git a/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp b/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp index 7b40b8d..ca8f03c 100644 --- a/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp +++ b/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp @@ -5,10 +5,11 @@ namespace WebCore { -bool ScrollableLayerAndroid::scrollTo(int x, int y) { +bool ScrollableLayerAndroid::scrollTo(int x, int y) +{ SkIRect scrollBounds; getScrollRect(&scrollBounds); - if (scrollBounds.fRight == 0 && scrollBounds.fBottom == 0) + if (!scrollBounds.fRight && !scrollBounds.fBottom) return false; SkScalar newX = SkScalarPin(x, 0, scrollBounds.fRight); @@ -24,7 +25,8 @@ bool ScrollableLayerAndroid::scrollTo(int x, int y) { return true; } -void ScrollableLayerAndroid::getScrollRect(SkIRect* out) const { +void ScrollableLayerAndroid::getScrollRect(SkIRect* out) const +{ const SkPoint& pos = getPosition(); out->fLeft = m_scrollLimits.fLeft - pos.fX; out->fTop = m_scrollLimits.fTop - pos.fY; diff --git a/WebCore/platform/graphics/android/ScrollableLayerAndroid.h b/WebCore/platform/graphics/android/ScrollableLayerAndroid.h index 25f9900..697fe74 100644 --- a/WebCore/platform/graphics/android/ScrollableLayerAndroid.h +++ b/WebCore/platform/graphics/android/ScrollableLayerAndroid.h @@ -32,7 +32,8 @@ public: : LayerAndroid(layer) , m_scrollLimits(layer.m_scrollLimits) {} ScrollableLayerAndroid(const LayerAndroid& layer) - : LayerAndroid(layer) { + : LayerAndroid(layer) + { m_scrollLimits.setEmpty(); } virtual ~ScrollableLayerAndroid() {}; @@ -51,7 +52,8 @@ public: // fBottom = maxY void getScrollRect(SkIRect* out) const; - void setScrollLimits(float x, float y, float width, float height) { + void setScrollLimits(float x, float y, float width, float height) + { m_scrollLimits.set(x, y, x + width, y + height); } @@ -63,4 +65,4 @@ private: #endif // USE(ACCELERATED_COMPOSITING) -#endif // LayerAndroid_h +#endif // LayerAndroid_h diff --git a/WebCore/platform/graphics/android/ShaderProgram.cpp b/WebCore/platform/graphics/android/ShaderProgram.cpp index 2195bd4..ac6375d 100644 --- a/WebCore/platform/graphics/android/ShaderProgram.cpp +++ b/WebCore/platform/graphics/android/ShaderProgram.cpp @@ -28,9 +28,9 @@ #if USE(ACCELERATED_COMPOSITING) -#include <GLES2/gl2.h> #include "GLUtils.h" +#include <GLES2/gl2.h> #include <cutils/log.h> #include <wtf/CurrentTime.h> #include <wtf/text/CString.h> @@ -59,10 +59,11 @@ static const char gFragmentShader[] = " gl_FragColor.a *= alpha; " "}\n"; -GLuint ShaderProgram::loadShader(GLenum shaderType, const char* pSource) { +GLuint ShaderProgram::loadShader(GLenum shaderType, const char* pSource) +{ GLuint shader = glCreateShader(shaderType); if (shader) { - glShaderSource(shader, 1, &pSource, NULL); + glShaderSource(shader, 1, &pSource, 0); glCompileShader(shader); GLint compiled = 0; glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled); @@ -72,7 +73,7 @@ GLuint ShaderProgram::loadShader(GLenum shaderType, const char* pSource) { if (infoLen) { char* buf = (char*) malloc(infoLen); if (buf) { - glGetShaderInfoLog(shader, infoLen, NULL, buf); + glGetShaderInfoLog(shader, infoLen, 0, buf); XLOG("could not compile shader %d:\n%s\n", shaderType, buf); free(buf); } @@ -84,16 +85,15 @@ GLuint ShaderProgram::loadShader(GLenum shaderType, const char* pSource) { return shader; } -GLuint ShaderProgram::createProgram(const char* pVertexSource, const char* pFragmentSource) { +GLuint ShaderProgram::createProgram(const char* pVertexSource, const char* pFragmentSource) +{ GLuint vertexShader = loadShader(GL_VERTEX_SHADER, pVertexSource); - if (!vertexShader) { + if (!vertexShader) return 0; - } GLuint pixelShader = loadShader(GL_FRAGMENT_SHADER, pFragmentSource); - if (!pixelShader) { + if (!pixelShader) return 0; - } GLuint program = glCreateProgram(); if (program) { @@ -110,7 +110,7 @@ GLuint ShaderProgram::createProgram(const char* pVertexSource, const char* pFrag if (bufLength) { char* buf = (char*) malloc(bufLength); if (buf) { - glGetProgramInfoLog(program, bufLength, NULL, buf); + glGetProgramInfoLog(program, bufLength, 0, buf); XLOG("could not link program:\n%s\n", buf); free(buf); } @@ -122,7 +122,8 @@ GLuint ShaderProgram::createProgram(const char* pVertexSource, const char* pFrag return program; } -ShaderProgram::ShaderProgram() { +ShaderProgram::ShaderProgram() +{ m_program = createProgram(gVertexShader, gFragmentShader); m_hProjectionMatrix = glGetUniformLocation(m_program, "projectionMatrix"); @@ -130,10 +131,10 @@ ShaderProgram::ShaderProgram() { m_hTexSampler = glGetUniformLocation(m_program, "s_texture"); const GLfloat coord[] = { - 0.0f, 0.0f, //C - 1.0f, 0.0f, //D - 0.0f, 1.0f, //A - 1.0f, 1.0f //B + 0.0f, 0.0f, // C + 1.0f, 0.0f, // D + 0.0f, 1.0f, // A + 1.0f, 1.0f // B }; glGenBuffers(1, m_textureBuffer); @@ -145,14 +146,16 @@ ShaderProgram::ShaderProgram() { // Drawing ///////////////////////////////////////////////////////////////////////////////////////// -void ShaderProgram::setViewport(SkRect& viewport) { +void ShaderProgram::setViewport(SkRect& viewport) +{ TransformationMatrix ortho; GLUtils::setOrthographicMatrix(ortho, viewport.fLeft, viewport.fTop, viewport.fRight, viewport.fBottom, -1000, 1000); m_projectionMatrix = ortho; } -void ShaderProgram::setProjectionMatrix(SkRect& geometry) { +void ShaderProgram::setProjectionMatrix(SkRect& geometry) +{ TransformationMatrix translate; translate.translate3d(geometry.fLeft, geometry.fTop, 0.0); TransformationMatrix scale; @@ -167,7 +170,8 @@ void ShaderProgram::setProjectionMatrix(SkRect& geometry) { glUniformMatrix4fv(m_hProjectionMatrix, 1, GL_FALSE, projectionMatrix); } -void ShaderProgram::drawQuad(SkRect& geometry, int textureId, float opacity) { +void ShaderProgram::drawQuad(SkRect& geometry, int textureId, float opacity) +{ setProjectionMatrix(geometry); glActiveTexture(GL_TEXTURE0); @@ -185,7 +189,8 @@ void ShaderProgram::drawQuad(SkRect& geometry, int textureId, float opacity) { } void ShaderProgram::drawLayerQuad(const TransformationMatrix& drawMatrix, - SkRect& geometry, int textureId, float opacity) { + SkRect& geometry, int textureId, float opacity) +{ TransformationMatrix renderMatrix = drawMatrix; renderMatrix.scale3d(geometry.width(), geometry.height(), 1); diff --git a/WebCore/platform/graphics/android/ShaderProgram.h b/WebCore/platform/graphics/android/ShaderProgram.h index 93a6d4c..785b42d 100644 --- a/WebCore/platform/graphics/android/ShaderProgram.h +++ b/WebCore/platform/graphics/android/ShaderProgram.h @@ -14,48 +14,48 @@ * limitations under the License. */ -#ifndef SHADERPROGRAM_H_ -#define SHADERPROGRAM_H_ +#ifndef ShaderProgram_h +#define ShaderProgram_h #if USE(ACCELERATED_COMPOSITING) -#include <GLES2/gl2.h> #include "SkRect.h" #include "TransformationMatrix.h" +#include <GLES2/gl2.h> namespace WebCore { class ShaderProgram { public: - ShaderProgram(); - int projectionMatrix() { return m_hProjectionMatrix; } - int alpha() { return m_hAlpha; } - int textureSampler() { return m_hTexSampler; } - int program() { return m_program; } - - // Drawing - void setViewport(SkRect& viewport); - void drawQuad(SkRect& geometry, int textureId, float opacity); - void drawLayerQuad(const TransformationMatrix& drawMatrix, + ShaderProgram(); + int projectionMatrix() { return m_hProjectionMatrix; } + int alpha() { return m_hAlpha; } + int textureSampler() { return m_hTexSampler; } + int program() { return m_program; } + + // Drawing + void setViewport(SkRect& viewport); + void drawQuad(SkRect& geometry, int textureId, float opacity); + void drawLayerQuad(const TransformationMatrix& drawMatrix, SkRect& geometry, int textureId, float opacity); private: - GLuint loadShader(GLenum shaderType, const char* pSource); - GLuint createProgram(const char* vertexSource, const char* fragmentSource); - void setProjectionMatrix(SkRect& geometry); + GLuint loadShader(GLenum shaderType, const char* pSource); + GLuint createProgram(const char* vertexSource, const char* fragmentSource); + void setProjectionMatrix(SkRect& geometry); - int m_program; + int m_program; - TransformationMatrix m_projectionMatrix; - GLuint m_textureBuffer[1]; + TransformationMatrix m_projectionMatrix; + GLuint m_textureBuffer[1]; - // uniforms - int m_hProjectionMatrix; - int m_hAlpha; - int m_hTexSampler; + // uniforms + int m_hProjectionMatrix; + int m_hAlpha; + int m_hTexSampler; }; } // namespace WebCore #endif // USE(ACCELERATED_COMPOSITING) -#endif // SHADERPROGRAM_H_ +#endif // ShaderProgram_h diff --git a/WebCore/platform/graphics/android/SharedTexture.cpp b/WebCore/platform/graphics/android/SharedTexture.cpp index 16ec97f..76d6da0 100644 --- a/WebCore/platform/graphics/android/SharedTexture.cpp +++ b/WebCore/platform/graphics/android/SharedTexture.cpp @@ -25,6 +25,7 @@ #include "config.h" #include "SharedTexture.h" + #include "GLUtils.h" #define LOG_NDEBUG 1 @@ -33,30 +34,35 @@ namespace WebCore { -TextureInfo::TextureInfo() { +TextureInfo::TextureInfo() +{ m_textureId = GL_NO_TEXTURE; m_width = 0; m_height = 0; m_internalFormat = 0; } -bool TextureInfo::equalsAttributes(const TextureInfo* otherTexture) { - return otherTexture->m_width == m_width && - otherTexture->m_height == m_height && - otherTexture->m_internalFormat == m_internalFormat; +bool TextureInfo::equalsAttributes(const TextureInfo* otherTexture) +{ + return otherTexture->m_width == m_width + && otherTexture->m_height == m_height + && otherTexture->m_internalFormat == m_internalFormat; } -void TextureInfo::copyAttributes(const TextureInfo* sourceTexture) { +void TextureInfo::copyAttributes(const TextureInfo* sourceTexture) +{ m_width = sourceTexture->m_width; m_height = sourceTexture->m_height; m_internalFormat = sourceTexture->m_internalFormat; } -bool TextureInfo::operator==(const TextureInfo& otherTexture) { +bool TextureInfo::operator==(const TextureInfo& otherTexture) +{ return otherTexture.m_textureId == m_textureId && equalsAttributes(&otherTexture); } -SharedTexture::SharedTexture() { +SharedTexture::SharedTexture() +{ m_display = eglGetCurrentDisplay(); m_eglImage = EGL_NO_IMAGE_KHR; m_isNewImage = true; @@ -64,7 +70,7 @@ SharedTexture::SharedTexture() { m_supportsEGLImage = GLUtils::isEGLImageSupported(); m_supportsEGLFenceSyncKHR = GLUtils::isEGLFenceSyncSupported(); - //TODO temporarily disable fence sync until nvidia implementation is complete + // TODO temporarily disable fence sync until nvidia implementation is complete m_supportsEGLFenceSyncKHR = false; LOGI("imageEGL: %d syncKHR: %d", m_supportsEGLImage, m_supportsEGLFenceSyncKHR); @@ -74,28 +80,29 @@ SharedTexture::SharedTexture() { // terminated all providers. If EGLImages are used, the deletion of the // source texture and EGLImage is the responsibility of the caller. In the case // of double buffered textures this is handled in the onDestroy(...) method. -SharedTexture::~SharedTexture() { - if (m_supportsEGLImage) { +SharedTexture::~SharedTexture() +{ + if (m_supportsEGLImage) GLUtils::deleteTexture(&m_targetTexture.m_textureId); - } else { + else GLUtils::deleteTexture(&m_sourceTexture.m_textureId); - } } -void SharedTexture::initSourceTexture() { +void SharedTexture::initSourceTexture() +{ glGenTextures(1, &m_sourceTexture.m_textureId); } -TextureInfo* SharedTexture::lockSource() { +TextureInfo* SharedTexture::lockSource() +{ m_lock.lock(); if (m_supportsEGLFenceSyncKHR && m_syncObject != EGL_NO_SYNC_KHR) { EGLint status = eglClientWaitSyncKHR(m_display, m_syncObject, 0, 1000000); - if (status == EGL_TIMEOUT_EXPIRED_KHR) { + if (status == EGL_TIMEOUT_EXPIRED_KHR) LOGE("Sync timeout for shared texture (%d)", m_sourceTexture.m_textureId); - } eglDestroySyncKHR(m_display, m_syncObject); m_syncObject = EGL_NO_SYNC_KHR; @@ -104,8 +111,8 @@ TextureInfo* SharedTexture::lockSource() { return &m_sourceTexture; } -void SharedTexture::releaseSource() { - +void SharedTexture::releaseSource() +{ if (m_supportsEGLImage) { // delete the existing image if needed if (!m_sourceTexture.equalsAttributes(&m_targetTexture)) { @@ -138,19 +145,20 @@ void SharedTexture::releaseSource() { m_lock.unlock(); } -TextureInfo* SharedTexture::lockTarget() { +TextureInfo* SharedTexture::lockTarget() +{ m_lock.lock(); - if ((!m_supportsEGLImage && m_targetTexture.m_textureId == GL_NO_TEXTURE) || - (m_supportsEGLImage && m_eglImage == EGL_NO_IMAGE_KHR)) { + if ((!m_supportsEGLImage && m_targetTexture.m_textureId == GL_NO_TEXTURE) + || (m_supportsEGLImage && m_eglImage == EGL_NO_IMAGE_KHR)) { m_lock.unlock(); return 0; } if (m_supportsEGLImage && (m_isNewImage || m_targetTexture.m_textureId == GL_NO_TEXTURE)) { - if (m_targetTexture.m_textureId == GL_NO_TEXTURE) { + if (m_targetTexture.m_textureId == GL_NO_TEXTURE) glGenTextures(1, &m_targetTexture.m_textureId); - } + GLUtils::createTextureFromEGLImage(m_targetTexture.m_textureId, m_eglImage); LOGV("Generating Consumer Texture from 0x%x", m_eglImage); m_isNewImage = false; @@ -159,13 +167,13 @@ TextureInfo* SharedTexture::lockTarget() { return &m_targetTexture; } -void SharedTexture::releaseTarget() { +void SharedTexture::releaseTarget() +{ if (m_supportsEGLFenceSyncKHR) { - if (m_syncObject != EGL_NO_SYNC_KHR) { + if (m_syncObject != EGL_NO_SYNC_KHR) eglDestroySyncKHR(m_display, m_syncObject); - } - m_syncObject = eglCreateSyncKHR(m_display, EGL_SYNC_FENCE_KHR, NULL); + m_syncObject = eglCreateSyncKHR(m_display, EGL_SYNC_FENCE_KHR, 0); } else { // TODO the flush currently prevents the screen from getting partial // updates but the only way to guarantee this is to call glFinish. Until diff --git a/WebCore/platform/graphics/android/SharedTexture.h b/WebCore/platform/graphics/android/SharedTexture.h index 581ad77..e654c5c 100644 --- a/WebCore/platform/graphics/android/SharedTexture.h +++ b/WebCore/platform/graphics/android/SharedTexture.h @@ -23,14 +23,14 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SharedTexture__DEFINED -#define SharedTexture__DEFINED +#ifndef SharedTexture_h +#define SharedTexture_h -#include <utils/threads.h> -#include <GLES2/gl2.h> -#include <GLES2/gl2ext.h> #include <EGL/egl.h> #include <EGL/eglext.h> +#include <GLES2/gl2.h> +#include <GLES2/gl2ext.h> +#include <utils/threads.h> namespace WebCore { @@ -132,4 +132,4 @@ private: } // namespace WebCore -#endif // SharedTexture__DEFINED +#endif // SharedTexture_h |