surfaceflinger: run clang-format on RenderEngine
Run clang-format on all files. In Program constructor, use mat4()
instead of manually construct a 4x4 identity matrix.
Test: builds
Change-Id: I84e5eec06d103383c715b1f03c521bbcca5bd92c
diff --git a/services/surfaceflinger/RenderEngine/Description.cpp b/services/surfaceflinger/RenderEngine/Description.cpp
index 706960c..e014406 100644
--- a/services/surfaceflinger/RenderEngine/Description.cpp
+++ b/services/surfaceflinger/RenderEngine/Description.cpp
@@ -33,8 +33,7 @@
mColorMatrixEnabled = false;
}
-Description::~Description() {
-}
+Description::~Description() {}
void Description::setPremultipliedAlpha(bool premultipliedAlpha) {
mPremultipliedAlpha = premultipliedAlpha;
diff --git a/services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp b/services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp
index 3ae7042..3161888 100644
--- a/services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp
+++ b/services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp
@@ -33,15 +33,15 @@
#include <gui/ISurfaceComposer.h>
#include <math.h>
+#include "Description.h"
#include "GLES20RenderEngine.h"
+#include "Mesh.h"
#include "Program.h"
#include "ProgramCache.h"
-#include "Description.h"
-#include "Mesh.h"
#include "Texture.h"
-#include <sstream>
#include <fstream>
+#include <sstream>
// ---------------------------------------------------------------------------
bool checkGlError(const char* op, int lineNumber) {
@@ -107,34 +107,31 @@
namespace android {
// ---------------------------------------------------------------------------
-GLES20RenderEngine::GLES20RenderEngine(uint32_t featureFlags) :
- mVpWidth(0),
- mVpHeight(0),
- mPlatformHasWideColor((featureFlags & WIDE_COLOR_SUPPORT) != 0) {
-
+GLES20RenderEngine::GLES20RenderEngine(uint32_t featureFlags)
+ : mVpWidth(0), mVpHeight(0), mPlatformHasWideColor((featureFlags & WIDE_COLOR_SUPPORT) != 0) {
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize);
glGetIntegerv(GL_MAX_VIEWPORT_DIMS, mMaxViewportDims);
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
glPixelStorei(GL_PACK_ALIGNMENT, 4);
- const uint16_t protTexData[] = { 0 };
+ const uint16_t protTexData[] = {0};
glGenTextures(1, &mProtectedTexName);
glBindTexture(GL_TEXTURE_2D, mProtectedTexName);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0,
- GL_RGB, GL_UNSIGNED_SHORT_5_6_5, protTexData);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, protTexData);
- //mColorBlindnessCorrection = M;
+ // mColorBlindnessCorrection = M;
if (mPlatformHasWideColor) {
// Compute sRGB to DisplayP3 color transform
// NOTE: For now, we are limiting wide-color support to
// Display-P3 only.
- mat3 srgbToP3 = ColorSpaceConnector(ColorSpace::sRGB(), ColorSpace::DisplayP3()).getTransform();
+ mat3 srgbToP3 =
+ ColorSpaceConnector(ColorSpace::sRGB(), ColorSpace::DisplayP3()).getTransform();
// color transform needs to be expanded to 4x4 to be what the shader wants
// mat has an initializer that expands mat3 to mat4, but
@@ -144,24 +141,19 @@
}
}
-GLES20RenderEngine::~GLES20RenderEngine() {
-}
-
+GLES20RenderEngine::~GLES20RenderEngine() {}
size_t GLES20RenderEngine::getMaxTextureSize() const {
return mMaxTextureSize;
}
size_t GLES20RenderEngine::getMaxViewportDims() const {
- return
- mMaxViewportDims[0] < mMaxViewportDims[1] ?
- mMaxViewportDims[0] : mMaxViewportDims[1];
+ return mMaxViewportDims[0] < mMaxViewportDims[1] ? mMaxViewportDims[0] : mMaxViewportDims[1];
}
-void GLES20RenderEngine::setViewportAndProjection(
- size_t vpw, size_t vph, Rect sourceCrop, size_t hwh, bool yswap,
- Transform::orientation_flags rotation) {
-
+void GLES20RenderEngine::setViewportAndProjection(size_t vpw, size_t vph, Rect sourceCrop,
+ size_t hwh, bool yswap,
+ Transform::orientation_flags rotation) {
size_t l = sourceCrop.left;
size_t r = sourceCrop.right;
@@ -182,13 +174,13 @@
case Transform::ROT_0:
break;
case Transform::ROT_90:
- m = mat4::rotate(rot90InRadians, vec3(0,0,1)) * m;
+ m = mat4::rotate(rot90InRadians, vec3(0, 0, 1)) * m;
break;
case Transform::ROT_180:
- m = mat4::rotate(rot90InRadians * 2.0f, vec3(0,0,1)) * m;
+ m = mat4::rotate(rot90InRadians * 2.0f, vec3(0, 0, 1)) * m;
break;
case Transform::ROT_270:
- m = mat4::rotate(rot90InRadians * 3.0f, vec3(0,0,1)) * m;
+ m = mat4::rotate(rot90InRadians * 3.0f, vec3(0, 0, 1)) * m;
break;
default:
break;
@@ -200,8 +192,8 @@
mVpHeight = vph;
}
-void GLES20RenderEngine::setupLayerBlending(bool premultipliedAlpha,
- bool opaque, bool disableTexture, const half4& color) {
+void GLES20RenderEngine::setupLayerBlending(bool premultipliedAlpha, bool opaque,
+ bool disableTexture, const half4& color) {
mState.setPremultipliedAlpha(premultipliedAlpha);
mState.setOpaque(opaque);
mState.setColor(color);
@@ -288,9 +280,8 @@
glDisable(GL_BLEND);
}
-
-void GLES20RenderEngine::bindImageAsFramebuffer(EGLImageKHR image,
- uint32_t* texName, uint32_t* fbName, uint32_t* status) {
+void GLES20RenderEngine::bindImageAsFramebuffer(EGLImageKHR image, uint32_t* texName,
+ uint32_t* fbName, uint32_t* status) {
GLuint tname, name;
// turn our EGLImage into a texture
glGenTextures(1, &tname);
@@ -322,21 +313,14 @@
}
void GLES20RenderEngine::drawMesh(const Mesh& mesh) {
-
if (mesh.getTexCoordsSize()) {
glEnableVertexAttribArray(Program::texCoords);
- glVertexAttribPointer(Program::texCoords,
- mesh.getTexCoordsSize(),
- GL_FLOAT, GL_FALSE,
- mesh.getByteStride(),
- mesh.getTexCoords());
+ glVertexAttribPointer(Program::texCoords, mesh.getTexCoordsSize(), GL_FLOAT, GL_FALSE,
+ mesh.getByteStride(), mesh.getTexCoords());
}
- glVertexAttribPointer(Program::position,
- mesh.getVertexSize(),
- GL_FLOAT, GL_FALSE,
- mesh.getByteStride(),
- mesh.getPositions());
+ glVertexAttribPointer(Program::position, mesh.getVertexSize(), GL_FLOAT, GL_FALSE,
+ mesh.getByteStride(), mesh.getPositions());
if (usesWideColor()) {
Description wideColorState = mState;
diff --git a/services/surfaceflinger/RenderEngine/GLES20RenderEngine.h b/services/surfaceflinger/RenderEngine/GLES20RenderEngine.h
index 84aa63c..5ee9326 100644
--- a/services/surfaceflinger/RenderEngine/GLES20RenderEngine.h
+++ b/services/surfaceflinger/RenderEngine/GLES20RenderEngine.h
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-
#ifndef SF_GLES20RENDERENGINE_H_
#define SF_GLES20RENDERENGINE_H_
@@ -24,9 +23,9 @@
#include <GLES2/gl2.h>
#include <Transform.h>
-#include "RenderEngine.h"
-#include "ProgramCache.h"
#include "Description.h"
+#include "ProgramCache.h"
+#include "RenderEngine.h"
// ---------------------------------------------------------------------------
namespace android {
@@ -54,8 +53,8 @@
Description mState;
Vector<Group> mGroupStack;
- virtual void bindImageAsFramebuffer(EGLImageKHR image,
- uint32_t* texName, uint32_t* fbName, uint32_t* status);
+ virtual void bindImageAsFramebuffer(EGLImageKHR image, uint32_t* texName, uint32_t* fbName,
+ uint32_t* status);
virtual void unbindFramebuffer(uint32_t texName, uint32_t fbName);
public:
@@ -63,13 +62,11 @@
virtual ~GLES20RenderEngine();
protected:
-
virtual void dump(String8& result);
- virtual void setViewportAndProjection(size_t vpw, size_t vph,
- Rect sourceCrop, size_t hwh, bool yswap,
- Transform::orientation_flags rotation);
- virtual void setupLayerBlending(bool premultipliedAlpha, bool opaque,
- bool disableTexture, const half4& color) override;
+ virtual void setViewportAndProjection(size_t vpw, size_t vph, Rect sourceCrop, size_t hwh,
+ bool yswap, Transform::orientation_flags rotation);
+ virtual void setupLayerBlending(bool premultipliedAlpha, bool opaque, bool disableTexture,
+ const half4& color) override;
// Color management related functions and state
void setColorMode(android_color_mode mode);
diff --git a/services/surfaceflinger/RenderEngine/GLExtensions.cpp b/services/surfaceflinger/RenderEngine/GLExtensions.cpp
index 76bbcc1..7ffcc96 100644
--- a/services/surfaceflinger/RenderEngine/GLExtensions.cpp
+++ b/services/surfaceflinger/RenderEngine/GLExtensions.cpp
@@ -14,42 +14,35 @@
* limitations under the License.
*/
-#include <stdlib.h>
-#include <stdio.h>
#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
#include "GLExtensions.h"
namespace android {
// ---------------------------------------------------------------------------
-ANDROID_SINGLETON_STATIC_INSTANCE( GLExtensions )
+ANDROID_SINGLETON_STATIC_INSTANCE(GLExtensions)
-GLExtensions::GLExtensions()
- : mHaveFramebufferObject(false)
-{
-}
+GLExtensions::GLExtensions() : mHaveFramebufferObject(false) {}
-void GLExtensions::initWithGLStrings(
- GLubyte const* vendor,
- GLubyte const* renderer,
- GLubyte const* version,
- GLubyte const* extensions)
-{
- mVendor = (char const*)vendor;
- mRenderer = (char const*)renderer;
- mVersion = (char const*)version;
+void GLExtensions::initWithGLStrings(GLubyte const* vendor, GLubyte const* renderer,
+ GLubyte const* version, GLubyte const* extensions) {
+ mVendor = (char const*)vendor;
+ mRenderer = (char const*)renderer;
+ mVersion = (char const*)version;
mExtensions = (char const*)extensions;
char const* curr = (char const*)extensions;
char const* head = curr;
do {
head = strchr(curr, ' ');
- String8 s(curr, head ? head-curr : strlen(curr));
+ String8 s(curr, head ? head - curr : strlen(curr));
if (s.length()) {
mExtensionList.add(s);
}
- curr = head+1;
+ curr = head + 1;
} while (head);
if (hasExtension("GL_OES_framebuffer_object")) {
@@ -57,8 +50,7 @@
}
}
-bool GLExtensions::hasExtension(char const* extension) const
-{
+bool GLExtensions::hasExtension(char const* extension) const {
const String8 s(extension);
return mExtensionList.indexOf(s) >= 0;
}
diff --git a/services/surfaceflinger/RenderEngine/GLExtensions.h b/services/surfaceflinger/RenderEngine/GLExtensions.h
index d81ed2a..ee7b446 100644
--- a/services/surfaceflinger/RenderEngine/GLExtensions.h
+++ b/services/surfaceflinger/RenderEngine/GLExtensions.h
@@ -20,9 +20,9 @@
#include <stdint.h>
#include <sys/types.h>
-#include <utils/String8.h>
-#include <utils/SortedVector.h>
#include <utils/Singleton.h>
+#include <utils/SortedVector.h>
+#include <utils/String8.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
@@ -32,8 +32,7 @@
namespace android {
// ---------------------------------------------------------------------------
-class GLExtensions : public Singleton<GLExtensions>
-{
+class GLExtensions : public Singleton<GLExtensions> {
friend class Singleton<GLExtensions>;
bool mHaveFramebufferObject : 1;
@@ -45,22 +44,16 @@
SortedVector<String8> mExtensionList;
GLExtensions(const GLExtensions&);
- GLExtensions& operator = (const GLExtensions&);
+ GLExtensions& operator=(const GLExtensions&);
protected:
GLExtensions();
public:
+ inline bool haveFramebufferObject() const { return mHaveFramebufferObject; }
- inline bool haveFramebufferObject() const {
- return mHaveFramebufferObject;
- }
-
- void initWithGLStrings(
- GLubyte const* vendor,
- GLubyte const* renderer,
- GLubyte const* version,
- GLubyte const* extensions);
+ void initWithGLStrings(GLubyte const* vendor, GLubyte const* renderer, GLubyte const* version,
+ GLubyte const* extensions);
char const* getVendor() const;
char const* getRenderer() const;
@@ -70,7 +63,6 @@
bool hasExtension(char const* extension) const;
};
-
// ---------------------------------------------------------------------------
}; // namespace android
diff --git a/services/surfaceflinger/RenderEngine/Mesh.cpp b/services/surfaceflinger/RenderEngine/Mesh.cpp
index ffd9be2..6a62b1d 100644
--- a/services/surfaceflinger/RenderEngine/Mesh.cpp
+++ b/services/surfaceflinger/RenderEngine/Mesh.cpp
@@ -21,9 +21,10 @@
namespace android {
Mesh::Mesh(Primitive primitive, size_t vertexCount, size_t vertexSize, size_t texCoordSize)
- : mVertexCount(vertexCount), mVertexSize(vertexSize), mTexCoordsSize(texCoordSize),
- mPrimitive(primitive)
-{
+ : mVertexCount(vertexCount),
+ mVertexSize(vertexSize),
+ mTexCoordsSize(texCoordSize),
+ mPrimitive(primitive) {
if (vertexCount == 0) {
mVertices = new float[1];
mVertices[0] = 0.0f;
@@ -37,8 +38,7 @@
// either vertexSize or texCoordSize, it must have overflowed. remainder
// will be equal to stride as long as stride * vertexCount doesn't overflow.
if ((stride < vertexSize) || (remainder != stride)) {
- ALOGE("Overflow in Mesh(..., %zu, %zu, %zu)", vertexCount, vertexSize,
- texCoordSize);
+ ALOGE("Overflow in Mesh(..., %zu, %zu, %zu)", vertexCount, vertexSize, texCoordSize);
mVertices = new float[1];
mVertices[0] = 0.0f;
mVertexCount = 0;
@@ -53,14 +53,13 @@
}
Mesh::~Mesh() {
- delete [] mVertices;
+ delete[] mVertices;
}
Mesh::Primitive Mesh::getPrimitive() const {
return mPrimitive;
}
-
float const* Mesh::getPositions() const {
return mVertices;
}
@@ -75,7 +74,6 @@
return mVertices + mVertexSize;
}
-
size_t Mesh::getVertexCount() const {
return mVertexCount;
}
@@ -89,7 +87,7 @@
}
size_t Mesh::getByteStride() const {
- return mStride*sizeof(float);
+ return mStride * sizeof(float);
}
size_t Mesh::getStride() const {
diff --git a/services/surfaceflinger/RenderEngine/Mesh.h b/services/surfaceflinger/RenderEngine/Mesh.h
index b6d42b0..d0a9ac0 100644
--- a/services/surfaceflinger/RenderEngine/Mesh.h
+++ b/services/surfaceflinger/RenderEngine/Mesh.h
@@ -24,9 +24,9 @@
class Mesh {
public:
enum Primitive {
- TRIANGLES = 0x0004, // GL_TRIANGLES
- TRIANGLE_STRIP = 0x0005, // GL_TRIANGLE_STRIP
- TRIANGLE_FAN = 0x0006 // GL_TRIANGLE_FAN
+ TRIANGLES = 0x0004, // GL_TRIANGLES
+ TRIANGLE_STRIP = 0x0005, // GL_TRIANGLE_STRIP
+ TRIANGLE_FAN = 0x0006 // GL_TRIANGLE_FAN
};
Mesh(Primitive primitive, size_t vertexCount, size_t vertexSize, size_t texCoordsSize = 0);
@@ -40,21 +40,24 @@
friend class Mesh;
float* mData;
size_t mStride;
- VertexArray(float* data, size_t stride) : mData(data), mStride(stride) { }
+ VertexArray(float* data, size_t stride) : mData(data), mStride(stride) {}
+
public:
- TYPE& operator[](size_t index) {
- return *reinterpret_cast<TYPE*>(&mData[index*mStride]);
- }
+ TYPE& operator[](size_t index) { return *reinterpret_cast<TYPE*>(&mData[index * mStride]); }
TYPE const& operator[](size_t index) const {
- return *reinterpret_cast<TYPE const*>(&mData[index*mStride]);
+ return *reinterpret_cast<TYPE const*>(&mData[index * mStride]);
}
};
template <typename TYPE>
- VertexArray<TYPE> getPositionArray() { return VertexArray<TYPE>(getPositions(), mStride); }
+ VertexArray<TYPE> getPositionArray() {
+ return VertexArray<TYPE>(getPositions(), mStride);
+ }
template <typename TYPE>
- VertexArray<TYPE> getTexCoordArray() { return VertexArray<TYPE>(getTexCoords(), mStride); }
+ VertexArray<TYPE> getTexCoordArray() {
+ return VertexArray<TYPE>(getTexCoords(), mStride);
+ }
Primitive getPrimitive() const;
@@ -81,8 +84,8 @@
private:
Mesh(const Mesh&);
- Mesh& operator = (const Mesh&);
- Mesh const& operator = (const Mesh&) const;
+ Mesh& operator=(const Mesh&);
+ Mesh const& operator=(const Mesh&) const;
float* getPositions();
float* getTexCoords();
@@ -94,6 +97,5 @@
Primitive mPrimitive;
};
-
} /* namespace android */
#endif /* SF_RENDER_ENGINE_MESH_H */
diff --git a/services/surfaceflinger/RenderEngine/Program.cpp b/services/surfaceflinger/RenderEngine/Program.cpp
index bd2188b..baf92eb 100644
--- a/services/surfaceflinger/RenderEngine/Program.cpp
+++ b/services/surfaceflinger/RenderEngine/Program.cpp
@@ -19,15 +19,15 @@
#include <log/log.h>
#include <utils/String8.h>
+#include <math/mat4.h>
+#include "Description.h"
#include "Program.h"
#include "ProgramCache.h"
-#include "Description.h"
-#include <math/mat4.h>
namespace android {
Program::Program(const ProgramCache::Key& /*needs*/, const char* vertex, const char* fragment)
- : mInitialized(false) {
+ : mInitialized(false) {
GLuint vertexId = buildShader(vertex, GL_VERTEX_SHADER);
GLuint fragmentId = buildShader(fragment, GL_FRAGMENT_SHADER);
GLuint programId = glCreateProgram();
@@ -67,14 +67,12 @@
// set-up the default values for our uniforms
glUseProgram(programId);
- const GLfloat m[16] = {1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1 };
- glUniformMatrix4fv(mProjectionMatrixLoc, 1, GL_FALSE, m);
+ glUniformMatrix4fv(mProjectionMatrixLoc, 1, GL_FALSE, mat4().asArray());
glEnableVertexAttribArray(0);
}
}
-Program::~Program() {
-}
+Program::~Program() {}
bool Program::isValid() const {
return mInitialized;
@@ -119,12 +117,11 @@
char* src = new char[l];
glGetShaderSource(shader, l, NULL, src);
result.append(src);
- delete [] src;
+ delete[] src;
return result;
}
void Program::setUniforms(const Description& desc) {
-
// TODO: we should have a mechanism here to not always reset uniforms that
// didn't change for this program.
diff --git a/services/surfaceflinger/RenderEngine/Program.h b/services/surfaceflinger/RenderEngine/Program.h
index a2ae2ee..6e57fdd 100644
--- a/services/surfaceflinger/RenderEngine/Program.h
+++ b/services/surfaceflinger/RenderEngine/Program.h
@@ -34,7 +34,7 @@
class Program {
public:
// known locations for position and texture coordinates
- enum { position=0, texCoords=1 };
+ enum { position = 0, texCoords = 1 };
Program(const ProgramCache::Key& needs, const char* vertex, const char* fragment);
~Program();
@@ -54,7 +54,6 @@
/* set-up uniforms from the description */
void setUniforms(const Description& desc);
-
private:
GLuint buildShader(const char* source, GLenum type);
String8& dumpShader(String8& result, GLenum type);
@@ -83,7 +82,6 @@
GLint mColorLoc;
};
-
} /* namespace android */
#endif /* SF_RENDER_ENGINE_PROGRAM_H */
diff --git a/services/surfaceflinger/RenderEngine/ProgramCache.cpp b/services/surfaceflinger/RenderEngine/ProgramCache.cpp
index b437545..4f138dc 100644
--- a/services/surfaceflinger/RenderEngine/ProgramCache.cpp
+++ b/services/surfaceflinger/RenderEngine/ProgramCache.cpp
@@ -19,14 +19,13 @@
#include <utils/String8.h>
-#include "ProgramCache.h"
-#include "Program.h"
#include "Description.h"
+#include "Program.h"
+#include "ProgramCache.h"
namespace android {
// -----------------------------------------------------------------------------------------------
-
/*
* A simple formatter class to automatically add the endl and
* manage the indentation.
@@ -42,23 +41,22 @@
typedef Formatter& (*FormaterManipFunc)(Formatter&);
friend Formatter& indent(Formatter& f);
friend Formatter& dedent(Formatter& f);
+
public:
Formatter() : mIndent(0) {}
- String8 getString() const {
- return mString;
- }
+ String8 getString() const { return mString; }
- friend Formatter& operator << (Formatter& out, const char* in) {
- for (int i=0 ; i<out.mIndent ; i++) {
+ friend Formatter& operator<<(Formatter& out, const char* in) {
+ for (int i = 0; i < out.mIndent; i++) {
out.mString.append(" ");
}
out.mString.append(in);
out.mString.append("\n");
return out;
}
- friend inline Formatter& operator << (Formatter& out, const String8& in) {
- return operator << (out, in.string());
+ friend inline Formatter& operator<<(Formatter& out, const String8& in) {
+ return operator<<(out, in.string());
}
friend inline Formatter& operator<<(Formatter& to, FormaterManipFunc func) {
return (*func)(to);
@@ -83,13 +81,11 @@
primeCache();
}
-ProgramCache::~ProgramCache() {
-}
+ProgramCache::~ProgramCache() {}
void ProgramCache::primeCache() {
uint32_t shaderCount = 0;
- uint32_t keyMask = Key::BLEND_MASK | Key::OPACITY_MASK |
- Key::ALPHA_MASK | Key::TEXTURE_MASK;
+ uint32_t keyMask = Key::BLEND_MASK | Key::OPACITY_MASK | Key::ALPHA_MASK | Key::TEXTURE_MASK;
// Prime the cache for all combinations of the above masks,
// leaving off the experimental color matrix mask options.
@@ -98,9 +94,7 @@
Key shaderKey;
shaderKey.set(keyMask, keyVal);
uint32_t tex = shaderKey.getTextureTarget();
- if (tex != Key::TEXTURE_OFF &&
- tex != Key::TEXTURE_EXT &&
- tex != Key::TEXTURE_2D) {
+ if (tex != Key::TEXTURE_OFF && tex != Key::TEXTURE_EXT && tex != Key::TEXTURE_2D) {
continue;
}
Program* program = mCache.valueFor(shaderKey);
@@ -118,34 +112,36 @@
ProgramCache::Key ProgramCache::computeKey(const Description& description) {
Key needs;
needs.set(Key::TEXTURE_MASK,
- !description.mTextureEnabled ? Key::TEXTURE_OFF :
- description.mTexture.getTextureTarget() == GL_TEXTURE_EXTERNAL_OES ? Key::TEXTURE_EXT :
- description.mTexture.getTextureTarget() == GL_TEXTURE_2D ? Key::TEXTURE_2D :
- Key::TEXTURE_OFF)
- .set(Key::ALPHA_MASK,
- (description.mColor.a < 1) ? Key::ALPHA_LT_ONE : Key::ALPHA_EQ_ONE)
- .set(Key::BLEND_MASK,
- description.mPremultipliedAlpha ? Key::BLEND_PREMULT : Key::BLEND_NORMAL)
- .set(Key::OPACITY_MASK,
- description.mOpaque ? Key::OPACITY_OPAQUE : Key::OPACITY_TRANSLUCENT)
- .set(Key::COLOR_MATRIX_MASK,
- description.mColorMatrixEnabled ? Key::COLOR_MATRIX_ON : Key::COLOR_MATRIX_OFF)
- .set(Key::WIDE_GAMUT_MASK,
- description.mIsWideGamut ? Key::WIDE_GAMUT_ON : Key::WIDE_GAMUT_OFF);
+ !description.mTextureEnabled
+ ? Key::TEXTURE_OFF
+ : description.mTexture.getTextureTarget() == GL_TEXTURE_EXTERNAL_OES
+ ? Key::TEXTURE_EXT
+ : description.mTexture.getTextureTarget() == GL_TEXTURE_2D
+ ? Key::TEXTURE_2D
+ : Key::TEXTURE_OFF)
+ .set(Key::ALPHA_MASK,
+ (description.mColor.a < 1) ? Key::ALPHA_LT_ONE : Key::ALPHA_EQ_ONE)
+ .set(Key::BLEND_MASK,
+ description.mPremultipliedAlpha ? Key::BLEND_PREMULT : Key::BLEND_NORMAL)
+ .set(Key::OPACITY_MASK,
+ description.mOpaque ? Key::OPACITY_OPAQUE : Key::OPACITY_TRANSLUCENT)
+ .set(Key::COLOR_MATRIX_MASK,
+ description.mColorMatrixEnabled ? Key::COLOR_MATRIX_ON : Key::COLOR_MATRIX_OFF)
+ .set(Key::WIDE_GAMUT_MASK,
+ description.mIsWideGamut ? Key::WIDE_GAMUT_ON : Key::WIDE_GAMUT_OFF);
return needs;
}
String8 ProgramCache::generateVertexShader(const Key& needs) {
Formatter vs;
if (needs.isTexturing()) {
- vs << "attribute vec4 texCoords;"
- << "varying vec2 outTexCoords;";
+ vs << "attribute vec4 texCoords;"
+ << "varying vec2 outTexCoords;";
}
vs << "attribute vec4 position;"
<< "uniform mat4 projection;"
<< "uniform mat4 texture;"
- << "void main(void) {" << indent
- << "gl_Position = projection * position;";
+ << "void main(void) {" << indent << "gl_Position = projection * position;";
if (needs.isTexturing()) {
vs << "outTexCoords = (texture * texCoords).st;";
}
@@ -272,11 +268,10 @@
}
void ProgramCache::useProgram(const Description& description) {
-
// generate the key for the shader based on the description
Key needs(computeKey(description));
- // look-up the program in the cache
+ // look-up the program in the cache
Program* program = mCache.valueFor(needs);
if (program == NULL) {
// we didn't find our program, so generate one...
@@ -285,7 +280,7 @@
mCache.add(needs, program);
time += systemTime();
- //ALOGD(">>> generated new program: needs=%08X, time=%u ms (%d programs)",
+ // ALOGD(">>> generated new program: needs=%08X, time=%u ms (%d programs)",
// needs.mNeeds, uint32_t(ns2ms(time)), mCache.size());
}
@@ -296,5 +291,4 @@
}
}
-
} /* namespace android */
diff --git a/services/surfaceflinger/RenderEngine/ProgramCache.h b/services/surfaceflinger/RenderEngine/ProgramCache.h
index ff5cf0f..54d3722 100644
--- a/services/surfaceflinger/RenderEngine/ProgramCache.h
+++ b/services/surfaceflinger/RenderEngine/ProgramCache.h
@@ -19,8 +19,8 @@
#include <GLES2/gl2.h>
-#include <utils/Singleton.h>
#include <utils/KeyedVector.h>
+#include <utils/Singleton.h>
#include <utils/TypeHelpers.h>
#include "Description.h"
@@ -47,63 +47,50 @@
friend class ProgramCache;
typedef uint32_t key_t;
key_t mKey;
+
public:
enum {
- BLEND_PREMULT = 0x00000001,
- BLEND_NORMAL = 0x00000000,
- BLEND_MASK = 0x00000001,
+ BLEND_PREMULT = 0x00000001,
+ BLEND_NORMAL = 0x00000000,
+ BLEND_MASK = 0x00000001,
- OPACITY_OPAQUE = 0x00000002,
- OPACITY_TRANSLUCENT = 0x00000000,
- OPACITY_MASK = 0x00000002,
+ OPACITY_OPAQUE = 0x00000002,
+ OPACITY_TRANSLUCENT = 0x00000000,
+ OPACITY_MASK = 0x00000002,
- ALPHA_LT_ONE = 0x00000004,
- ALPHA_EQ_ONE = 0x00000000,
- ALPHA_MASK = 0x00000004,
+ ALPHA_LT_ONE = 0x00000004,
+ ALPHA_EQ_ONE = 0x00000000,
+ ALPHA_MASK = 0x00000004,
- TEXTURE_OFF = 0x00000000,
- TEXTURE_EXT = 0x00000008,
- TEXTURE_2D = 0x00000010,
- TEXTURE_MASK = 0x00000018,
+ TEXTURE_OFF = 0x00000000,
+ TEXTURE_EXT = 0x00000008,
+ TEXTURE_2D = 0x00000010,
+ TEXTURE_MASK = 0x00000018,
- COLOR_MATRIX_OFF = 0x00000000,
- COLOR_MATRIX_ON = 0x00000020,
- COLOR_MATRIX_MASK = 0x00000020,
+ COLOR_MATRIX_OFF = 0x00000000,
+ COLOR_MATRIX_ON = 0x00000020,
+ COLOR_MATRIX_MASK = 0x00000020,
- WIDE_GAMUT_OFF = 0x00000000,
- WIDE_GAMUT_ON = 0x00000040,
- WIDE_GAMUT_MASK = 0x00000040,
+ WIDE_GAMUT_OFF = 0x00000000,
+ WIDE_GAMUT_ON = 0x00000040,
+ WIDE_GAMUT_MASK = 0x00000040,
};
- inline Key() : mKey(0) { }
- inline Key(const Key& rhs) : mKey(rhs.mKey) { }
+ inline Key() : mKey(0) {}
+ inline Key(const Key& rhs) : mKey(rhs.mKey) {}
inline Key& set(key_t mask, key_t value) {
mKey = (mKey & ~mask) | value;
return *this;
}
- inline bool isTexturing() const {
- return (mKey & TEXTURE_MASK) != TEXTURE_OFF;
- }
- inline int getTextureTarget() const {
- return (mKey & TEXTURE_MASK);
- }
- inline bool isPremultiplied() const {
- return (mKey & BLEND_MASK) == BLEND_PREMULT;
- }
- inline bool isOpaque() const {
- return (mKey & OPACITY_MASK) == OPACITY_OPAQUE;
- }
- inline bool hasAlpha() const {
- return (mKey & ALPHA_MASK) == ALPHA_LT_ONE;
- }
- inline bool hasColorMatrix() const {
- return (mKey & COLOR_MATRIX_MASK) == COLOR_MATRIX_ON;
- }
- inline bool isWideGamut() const {
- return (mKey & WIDE_GAMUT_MASK) == WIDE_GAMUT_ON;
- }
+ inline bool isTexturing() const { return (mKey & TEXTURE_MASK) != TEXTURE_OFF; }
+ inline int getTextureTarget() const { return (mKey & TEXTURE_MASK); }
+ inline bool isPremultiplied() const { return (mKey & BLEND_MASK) == BLEND_PREMULT; }
+ inline bool isOpaque() const { return (mKey & OPACITY_MASK) == OPACITY_OPAQUE; }
+ inline bool hasAlpha() const { return (mKey & ALPHA_MASK) == ALPHA_LT_ONE; }
+ inline bool hasColorMatrix() const { return (mKey & COLOR_MATRIX_MASK) == COLOR_MATRIX_ON; }
+ inline bool isWideGamut() const { return (mKey & WIDE_GAMUT_MASK) == WIDE_GAMUT_ON; }
// this is the definition of a friend function -- not a method of class Needs
friend inline int strictly_order_type(const Key& lhs, const Key& rhs) {
@@ -135,7 +122,6 @@
DefaultKeyedVector<Key, Program*> mCache;
};
-
ANDROID_BASIC_TYPES_TRAITS(ProgramCache::Key)
} /* namespace android */
diff --git a/services/surfaceflinger/RenderEngine/RenderEngine.cpp b/services/surfaceflinger/RenderEngine/RenderEngine.cpp
index 994d857..883ae26 100644
--- a/services/surfaceflinger/RenderEngine/RenderEngine.cpp
+++ b/services/surfaceflinger/RenderEngine/RenderEngine.cpp
@@ -18,13 +18,13 @@
#include <ui/Rect.h>
#include <ui/Region.h>
-#include "RenderEngine.h"
#include "GLES20RenderEngine.h"
#include "GLExtensions.h"
#include "Mesh.h"
+#include "RenderEngine.h"
-#include <vector>
#include <SurfaceFlinger.h>
+#include <vector>
extern "C" EGLAPI const char* eglQueryStringImplementationANDROID(EGLDisplay dpy, EGLint name);
@@ -33,14 +33,12 @@
// ---------------------------------------------------------------------------
static bool findExtension(const char* exts, const char* name) {
- if (!exts)
- return false;
+ if (!exts) return false;
size_t len = strlen(name);
const char* pos = exts;
while ((pos = strstr(pos, name)) != NULL) {
- if (pos[len] == '\0' || pos[len] == ' ')
- return true;
+ if (pos[len] == '\0' || pos[len] == ' ') return true;
pos += len;
}
@@ -76,8 +74,7 @@
EGLint renderableType = 0;
if (config == EGL_NO_CONFIG) {
renderableType = EGL_OPENGL_ES2_BIT;
- } else if (!eglGetConfigAttrib(display, config,
- EGL_RENDERABLE_TYPE, &renderableType)) {
+ } else if (!eglGetConfigAttrib(display, config, EGL_RENDERABLE_TYPE, &renderableType)) {
LOG_ALWAYS_FATAL("can't query EGLConfig RENDERABLE_TYPE");
}
EGLint contextClientVersion = 0;
@@ -102,12 +99,10 @@
contextAttributes.push_back(EGL_NONE);
contextAttributes.push_back(EGL_NONE);
- EGLContext ctxt = eglCreateContext(display, config, NULL,
- contextAttributes.data());
+ EGLContext ctxt = eglCreateContext(display, config, NULL, contextAttributes.data());
// if can't create a GL context, we can only abort.
- LOG_ALWAYS_FATAL_IF(ctxt==EGL_NO_CONTEXT, "EGLContext creation failed");
-
+ LOG_ALWAYS_FATAL_IF(ctxt == EGL_NO_CONTEXT, "EGLContext creation failed");
// now figure out what version of GL did we actually get
// NOTE: a dummy surface is not needed if KHR_create_context is supported
@@ -116,33 +111,30 @@
if (dummyConfig == EGL_NO_CONFIG) {
dummyConfig = chooseEglConfig(display, hwcFormat, /*logConfig*/ true);
}
- EGLint attribs[] = { EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE, EGL_NONE };
+ EGLint attribs[] = {EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE, EGL_NONE};
EGLSurface dummy = eglCreatePbufferSurface(display, dummyConfig, attribs);
- LOG_ALWAYS_FATAL_IF(dummy==EGL_NO_SURFACE, "can't create dummy pbuffer");
+ LOG_ALWAYS_FATAL_IF(dummy == EGL_NO_SURFACE, "can't create dummy pbuffer");
EGLBoolean success = eglMakeCurrent(display, dummy, dummy, ctxt);
LOG_ALWAYS_FATAL_IF(!success, "can't make dummy pbuffer current");
GLExtensions& extensions(GLExtensions::getInstance());
- extensions.initWithGLStrings(
- glGetString(GL_VENDOR),
- glGetString(GL_RENDERER),
- glGetString(GL_VERSION),
- glGetString(GL_EXTENSIONS));
+ extensions.initWithGLStrings(glGetString(GL_VENDOR), glGetString(GL_RENDERER),
+ glGetString(GL_VERSION), glGetString(GL_EXTENSIONS));
- GlesVersion version = parseGlesVersion( extensions.getVersion() );
+ GlesVersion version = parseGlesVersion(extensions.getVersion());
// initialize the renderer while GL is current
std::unique_ptr<RenderEngine> engine;
switch (version) {
- case GLES_VERSION_1_0:
- case GLES_VERSION_1_1:
- LOG_ALWAYS_FATAL("SurfaceFlinger requires OpenGL ES 2.0 minimum to run.");
- break;
- case GLES_VERSION_2_0:
- case GLES_VERSION_3_0:
- engine = std::make_unique<GLES20RenderEngine>(featureFlags);
- break;
+ case GLES_VERSION_1_0:
+ case GLES_VERSION_1_1:
+ LOG_ALWAYS_FATAL("SurfaceFlinger requires OpenGL ES 2.0 minimum to run.");
+ break;
+ case GLES_VERSION_2_0:
+ case GLES_VERSION_3_0:
+ engine = std::make_unique<GLES20RenderEngine>(featureFlags);
+ break;
}
engine->setEGLHandles(display, config, ctxt);
@@ -160,9 +152,8 @@
return engine;
}
-RenderEngine::RenderEngine() : mEGLDisplay(EGL_NO_DISPLAY), mEGLConfig(NULL),
- mEGLContext(EGL_NO_CONTEXT) {
-}
+RenderEngine::RenderEngine()
+ : mEGLDisplay(EGL_NO_DISPLAY), mEGLConfig(NULL), mEGLContext(EGL_NO_CONTEXT) {}
RenderEngine::~RenderEngine() {
eglMakeCurrent(mEGLDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
@@ -204,8 +195,7 @@
do {
// there could be more than one error flag
GLenum error = glGetError();
- if (error == GL_NO_ERROR)
- break;
+ if (error == GL_NO_ERROR) break;
ALOGE("GL error 0x%04x", int(error));
} while (true);
}
@@ -228,25 +218,25 @@
return GLES_VERSION_1_0;
}
-void RenderEngine::fillRegionWithColor(const Region& region, uint32_t height,
- float red, float green, float blue, float alpha) {
+void RenderEngine::fillRegionWithColor(const Region& region, uint32_t height, float red,
+ float green, float blue, float alpha) {
size_t c;
Rect const* r = region.getArray(&c);
- Mesh mesh(Mesh::TRIANGLES, c*6, 2);
+ Mesh mesh(Mesh::TRIANGLES, c * 6, 2);
Mesh::VertexArray<vec2> position(mesh.getPositionArray<vec2>());
- for (size_t i=0 ; i<c ; i++, r++) {
- position[i*6 + 0].x = r->left;
- position[i*6 + 0].y = height - r->top;
- position[i*6 + 1].x = r->left;
- position[i*6 + 1].y = height - r->bottom;
- position[i*6 + 2].x = r->right;
- position[i*6 + 2].y = height - r->bottom;
- position[i*6 + 3].x = r->left;
- position[i*6 + 3].y = height - r->top;
- position[i*6 + 4].x = r->right;
- position[i*6 + 4].y = height - r->bottom;
- position[i*6 + 5].x = r->right;
- position[i*6 + 5].y = height - r->top;
+ for (size_t i = 0; i < c; i++, r++) {
+ position[i * 6 + 0].x = r->left;
+ position[i * 6 + 0].y = height - r->top;
+ position[i * 6 + 1].x = r->left;
+ position[i * 6 + 1].y = height - r->bottom;
+ position[i * 6 + 2].x = r->right;
+ position[i * 6 + 2].y = height - r->bottom;
+ position[i * 6 + 3].x = r->left;
+ position[i * 6 + 3].y = height - r->top;
+ position[i * 6 + 4].x = r->right;
+ position[i * 6 + 4].y = height - r->bottom;
+ position[i * 6 + 5].x = r->right;
+ position[i * 6 + 5].y = height - r->top;
}
setupFillWithColor(red, green, blue, alpha);
drawMesh(mesh);
@@ -282,14 +272,13 @@
// fallback or explicit wait
sync = eglCreateSyncKHR(mEGLDisplay, EGL_SYNC_FENCE_KHR, NULL);
if (sync != EGL_NO_SYNC_KHR) {
- EGLint result = eglClientWaitSyncKHR(mEGLDisplay, sync,
- EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, 2000000000 /*2 sec*/);
+ EGLint result = eglClientWaitSyncKHR(mEGLDisplay, sync, EGL_SYNC_FLUSH_COMMANDS_BIT_KHR,
+ 2000000000 /*2 sec*/);
EGLint eglErr = eglGetError();
if (result == EGL_TIMEOUT_EXPIRED_KHR) {
ALOGW("fence wait timed out");
} else {
- ALOGW_IF(eglErr != EGL_SUCCESS,
- "error waiting on EGL fence: %#x", eglErr);
+ ALOGW_IF(eglErr != EGL_SUCCESS, "error waiting on EGL fence: %#x", eglErr);
}
eglDestroySyncKHR(mEGLDisplay, sync);
} else {
@@ -304,8 +293,7 @@
glClear(GL_COLOR_BUFFER_BIT);
}
-void RenderEngine::setScissor(
- uint32_t left, uint32_t bottom, uint32_t right, uint32_t top) {
+void RenderEngine::setScissor(uint32_t left, uint32_t bottom, uint32_t right, uint32_t top) {
glScissor(left, bottom, right, top);
glEnable(GL_SCISSOR_TEST);
}
@@ -328,25 +316,22 @@
void RenderEngine::dump(String8& result) {
result.appendFormat("EGL implementation : %s\n",
- eglQueryStringImplementationANDROID(mEGLDisplay, EGL_VERSION));
- result.appendFormat("%s\n",
- eglQueryStringImplementationANDROID(mEGLDisplay, EGL_EXTENSIONS));
+ eglQueryStringImplementationANDROID(mEGLDisplay, EGL_VERSION));
+ result.appendFormat("%s\n", eglQueryStringImplementationANDROID(mEGLDisplay, EGL_EXTENSIONS));
const GLExtensions& extensions(GLExtensions::getInstance());
- result.appendFormat("GLES: %s, %s, %s\n",
- extensions.getVendor(),
- extensions.getRenderer(),
- extensions.getVersion());
+ result.appendFormat("GLES: %s, %s, %s\n", extensions.getVendor(), extensions.getRenderer(),
+ extensions.getVersion());
result.appendFormat("%s\n", extensions.getExtension());
}
// ---------------------------------------------------------------------------
RenderEngine::BindNativeBufferAsFramebuffer::BindNativeBufferAsFramebuffer(
- RenderEngine& engine, ANativeWindowBuffer* buffer) : mEngine(engine)
-{
- mImage = eglCreateImageKHR(mEngine.mEGLDisplay, EGL_NO_CONTEXT,
- EGL_NATIVE_BUFFER_ANDROID, buffer, NULL);
+ RenderEngine& engine, ANativeWindowBuffer* buffer)
+ : mEngine(engine) {
+ mImage = eglCreateImageKHR(mEngine.mEGLDisplay, EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID,
+ buffer, NULL);
if (mImage == EGL_NO_IMAGE_KHR) {
mStatus = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
return;
@@ -354,8 +339,8 @@
mEngine.bindImageAsFramebuffer(mImage, &mTexName, &mFbName, &mStatus);
- ALOGE_IF(mStatus != GL_FRAMEBUFFER_COMPLETE_OES,
- "glCheckFramebufferStatusOES error %d", mStatus);
+ ALOGE_IF(mStatus != GL_FRAMEBUFFER_COMPLETE_OES, "glCheckFramebufferStatusOES error %d",
+ mStatus);
}
RenderEngine::BindNativeBufferAsFramebuffer::~BindNativeBufferAsFramebuffer() {
@@ -374,8 +359,8 @@
// ---------------------------------------------------------------------------
-static status_t selectConfigForAttribute(EGLDisplay dpy, EGLint const* attrs,
- EGLint attribute, EGLint wanted, EGLConfig* outConfig) {
+static status_t selectConfigForAttribute(EGLDisplay dpy, EGLint const* attrs, EGLint attribute,
+ EGLint wanted, EGLConfig* outConfig) {
EGLint numConfigs = -1, n = 0;
eglGetConfigs(dpy, NULL, 0, &numConfigs);
EGLConfig* const configs = new EGLConfig[numConfigs];
@@ -383,23 +368,23 @@
if (n) {
if (attribute != EGL_NONE) {
- for (int i=0 ; i<n ; i++) {
+ for (int i = 0; i < n; i++) {
EGLint value = 0;
eglGetConfigAttrib(dpy, configs[i], attribute, &value);
if (wanted == value) {
*outConfig = configs[i];
- delete [] configs;
+ delete[] configs;
return NO_ERROR;
}
}
} else {
// just pick the first one
*outConfig = configs[0];
- delete [] configs;
+ delete[] configs;
return NO_ERROR;
}
}
- delete [] configs;
+ delete[] configs;
return NAME_NOT_FOUND;
}
@@ -409,10 +394,10 @@
friend class Adder;
KeyedVector<Attribute, EGLint> mList;
struct Attribute {
- Attribute() : v(0) {};
- explicit Attribute(EGLint v) : v(v) { }
+ Attribute() : v(0){};
+ explicit Attribute(EGLint v) : v(v) {}
EGLint v;
- bool operator < (const Attribute& other) const {
+ bool operator<(const Attribute& other) const {
// this places EGL_NONE at the end
EGLint lhs(v);
EGLint rhs(other.v);
@@ -425,39 +410,32 @@
friend class EGLAttributeVector;
EGLAttributeVector& v;
EGLint attribute;
- Adder(EGLAttributeVector& v, EGLint attribute)
- : v(v), attribute(attribute) {
- }
+ Adder(EGLAttributeVector& v, EGLint attribute) : v(v), attribute(attribute) {}
+
public:
- void operator = (EGLint value) {
+ void operator=(EGLint value) {
if (attribute != EGL_NONE) {
v.mList.add(Attribute(attribute), value);
}
}
- operator EGLint () const { return v.mList[attribute]; }
+ operator EGLint() const { return v.mList[attribute]; }
};
+
public:
- EGLAttributeVector() {
- mList.add(Attribute(EGL_NONE), EGL_NONE);
- }
+ EGLAttributeVector() { mList.add(Attribute(EGL_NONE), EGL_NONE); }
void remove(EGLint attribute) {
if (attribute != EGL_NONE) {
mList.removeItem(Attribute(attribute));
}
}
- Adder operator [] (EGLint attribute) {
- return Adder(*this, attribute);
- }
- EGLint operator [] (EGLint attribute) const {
- return mList[attribute];
- }
+ Adder operator[](EGLint attribute) { return Adder(*this, attribute); }
+ EGLint operator[](EGLint attribute) const { return mList[attribute]; }
// cast-operator to (EGLint const*)
- operator EGLint const* () const { return &mList.keyAt(0).v; }
+ operator EGLint const*() const { return &mList.keyAt(0).v; }
};
-
-static status_t selectEGLConfig(EGLDisplay display, EGLint format,
- EGLint renderableType, EGLConfig* config) {
+static status_t selectEGLConfig(EGLDisplay display, EGLint format, EGLint renderableType,
+ EGLConfig* config) {
// select our EGLConfig. It must support EGL_RECORDABLE_ANDROID if
// it is to be used with WIFI displays
status_t err;
@@ -466,24 +444,23 @@
EGLAttributeVector attribs;
if (renderableType) {
- attribs[EGL_RENDERABLE_TYPE] = renderableType;
- attribs[EGL_RECORDABLE_ANDROID] = EGL_TRUE;
- attribs[EGL_SURFACE_TYPE] = EGL_WINDOW_BIT|EGL_PBUFFER_BIT;
+ attribs[EGL_RENDERABLE_TYPE] = renderableType;
+ attribs[EGL_RECORDABLE_ANDROID] = EGL_TRUE;
+ attribs[EGL_SURFACE_TYPE] = EGL_WINDOW_BIT | EGL_PBUFFER_BIT;
attribs[EGL_FRAMEBUFFER_TARGET_ANDROID] = EGL_TRUE;
- attribs[EGL_RED_SIZE] = 8;
- attribs[EGL_GREEN_SIZE] = 8;
- attribs[EGL_BLUE_SIZE] = 8;
- attribs[EGL_ALPHA_SIZE] = 8;
- wantedAttribute = EGL_NONE;
- wantedAttributeValue = EGL_NONE;
+ attribs[EGL_RED_SIZE] = 8;
+ attribs[EGL_GREEN_SIZE] = 8;
+ attribs[EGL_BLUE_SIZE] = 8;
+ attribs[EGL_ALPHA_SIZE] = 8;
+ wantedAttribute = EGL_NONE;
+ wantedAttributeValue = EGL_NONE;
} else {
// if no renderable type specified, fallback to a simplified query
- wantedAttribute = EGL_NATIVE_VISUAL_ID;
- wantedAttributeValue = format;
+ wantedAttribute = EGL_NATIVE_VISUAL_ID;
+ wantedAttributeValue = format;
}
- err = selectConfigForAttribute(display, attribs,
- wantedAttribute, wantedAttributeValue, config);
+ err = selectConfigForAttribute(display, attribs, wantedAttribute, wantedAttributeValue, config);
if (err == NO_ERROR) {
EGLint caveat;
if (eglGetConfigAttrib(display, *config, EGL_CONFIG_CAVEAT, &caveat))
@@ -493,8 +470,7 @@
return err;
}
-EGLConfig RenderEngine::chooseEglConfig(EGLDisplay display, int format,
- bool logConfig) {
+EGLConfig RenderEngine::chooseEglConfig(EGLDisplay display, int format, bool logConfig) {
status_t err;
EGLConfig config;
@@ -517,23 +493,22 @@
if (logConfig) {
// print some debugging info
- EGLint r,g,b,a;
- eglGetConfigAttrib(display, config, EGL_RED_SIZE, &r);
+ EGLint r, g, b, a;
+ eglGetConfigAttrib(display, config, EGL_RED_SIZE, &r);
eglGetConfigAttrib(display, config, EGL_GREEN_SIZE, &g);
- eglGetConfigAttrib(display, config, EGL_BLUE_SIZE, &b);
+ eglGetConfigAttrib(display, config, EGL_BLUE_SIZE, &b);
eglGetConfigAttrib(display, config, EGL_ALPHA_SIZE, &a);
ALOGI("EGL information:");
ALOGI("vendor : %s", eglQueryString(display, EGL_VENDOR));
ALOGI("version : %s", eglQueryString(display, EGL_VERSION));
ALOGI("extensions: %s", eglQueryString(display, EGL_EXTENSIONS));
- ALOGI("Client API: %s", eglQueryString(display, EGL_CLIENT_APIS)?:"Not Supported");
+ ALOGI("Client API: %s", eglQueryString(display, EGL_CLIENT_APIS) ?: "Not Supported");
ALOGI("EGLSurface: %d-%d-%d-%d, config=%p", r, g, b, a, config);
}
return config;
}
-
void RenderEngine::primeCache() const {
// Getting the ProgramCache instance causes it to prime its shader cache,
// which is performed in its constructor
diff --git a/services/surfaceflinger/RenderEngine/RenderEngine.h b/services/surfaceflinger/RenderEngine/RenderEngine.h
index ff5d33a..3847347 100644
--- a/services/surfaceflinger/RenderEngine/RenderEngine.h
+++ b/services/surfaceflinger/RenderEngine/RenderEngine.h
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-
#ifndef SF_RENDERENGINE_H_
#define SF_RENDERENGINE_H_
@@ -25,9 +24,9 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>
-#include <math/mat4.h>
#include <Transform.h>
#include <gui/SurfaceControl.h>
+#include <math/mat4.h>
#define EGL_NO_CONFIG ((EGLConfig)0)
@@ -49,10 +48,10 @@
class RenderEngine {
enum GlesVersion {
- GLES_VERSION_1_0 = 0x10000,
- GLES_VERSION_1_1 = 0x10001,
- GLES_VERSION_2_0 = 0x20000,
- GLES_VERSION_3_0 = 0x30000,
+ GLES_VERSION_1_0 = 0x10000,
+ GLES_VERSION_1_1 = 0x10001,
+ GLES_VERSION_2_0 = 0x20000,
+ GLES_VERSION_3_0 = 0x30000,
};
static GlesVersion parseGlesVersion(const char* str);
@@ -61,7 +60,8 @@
EGLContext mEGLContext;
void setEGLHandles(EGLDisplay display, EGLConfig config, EGLContext ctxt);
- virtual void bindImageAsFramebuffer(EGLImageKHR image, uint32_t* texName, uint32_t* fbName, uint32_t* status) = 0;
+ virtual void bindImageAsFramebuffer(EGLImageKHR image, uint32_t* texName, uint32_t* fbName,
+ uint32_t* status) = 0;
virtual void unbindFramebuffer(uint32_t texName, uint32_t fbName) = 0;
protected:
@@ -86,8 +86,8 @@
// flush returns -1 or a valid native fence fd owned by the caller
int flush(bool wait);
void clearWithColor(float red, float green, float blue, float alpha);
- void fillRegionWithColor(const Region& region, uint32_t height,
- float red, float green, float blue, float alpha);
+ void fillRegionWithColor(const Region& region, uint32_t height, float red, float green,
+ float blue, float alpha);
// common to all GL versions
void setScissor(uint32_t left, uint32_t bottom, uint32_t right, uint32_t top);
@@ -101,6 +101,7 @@
EGLImageKHR mImage;
uint32_t mTexName, mFbName;
uint32_t mStatus;
+
public:
BindNativeBufferAsFramebuffer(RenderEngine& engine, ANativeWindowBuffer* buffer);
~BindNativeBufferAsFramebuffer();
@@ -112,10 +113,10 @@
// set-up
virtual void checkErrors() const;
- virtual void setViewportAndProjection(size_t vpw, size_t vph,
- Rect sourceCrop, size_t hwh, bool yswap, Transform::orientation_flags rotation) = 0;
- virtual void setupLayerBlending(bool premultipliedAlpha, bool opaque,
- bool disableTexture, const half4& color) = 0;
+ virtual void setViewportAndProjection(size_t vpw, size_t vph, Rect sourceCrop, size_t hwh,
+ bool yswap, Transform::orientation_flags rotation) = 0;
+ virtual void setupLayerBlending(bool premultipliedAlpha, bool opaque, bool disableTexture,
+ const half4& color) = 0;
virtual void setColorMode(android_color_mode mode) = 0;
virtual void setSourceDataSpace(android_dataspace source) = 0;
virtual void setWideColor(bool hasWideColor) = 0;
@@ -124,9 +125,7 @@
virtual void setupLayerBlackedOut() = 0;
virtual void setupFillWithColor(float r, float g, float b, float a) = 0;
- virtual mat4 setupColorTransform(const mat4& /* colorTransform */) {
- return mat4();
- }
+ virtual mat4 setupColorTransform(const mat4& /* colorTransform */) { return mat4(); }
virtual void disableTexturing() = 0;
virtual void disableBlending() = 0;
diff --git a/services/surfaceflinger/RenderEngine/Texture.cpp b/services/surfaceflinger/RenderEngine/Texture.cpp
index 8875b6d..351430f 100644
--- a/services/surfaceflinger/RenderEngine/Texture.cpp
+++ b/services/surfaceflinger/RenderEngine/Texture.cpp
@@ -20,24 +20,22 @@
namespace android {
-Texture::Texture() :
- mTextureName(0), mTextureTarget(TEXTURE_2D),
- mWidth(0), mHeight(0), mFiltering(false) {
-}
+Texture::Texture()
+ : mTextureName(0), mTextureTarget(TEXTURE_2D), mWidth(0), mHeight(0), mFiltering(false) {}
-Texture::Texture(Target textureTarget, uint32_t textureName) :
- mTextureName(textureName), mTextureTarget(textureTarget),
- mWidth(0), mHeight(0), mFiltering(false) {
-}
+Texture::Texture(Target textureTarget, uint32_t textureName)
+ : mTextureName(textureName),
+ mTextureTarget(textureTarget),
+ mWidth(0),
+ mHeight(0),
+ mFiltering(false) {}
void Texture::init(Target textureTarget, uint32_t textureName) {
mTextureName = textureName;
mTextureTarget = textureTarget;
}
-Texture::~Texture() {
-}
-
+Texture::~Texture() {}
void Texture::setMatrix(float const* matrix) {
mTextureMatrix = mat4(matrix);
diff --git a/services/surfaceflinger/RenderEngine/Texture.h b/services/surfaceflinger/RenderEngine/Texture.h
index a07e0c3..56b6b31 100644
--- a/services/surfaceflinger/RenderEngine/Texture.h
+++ b/services/surfaceflinger/RenderEngine/Texture.h
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#include <stdint.h>
#include <math/mat4.h>
+#include <stdint.h>
#ifndef SF_RENDER_ENGINE_TEXTURE_H
#define SF_RENDER_ENGINE_TEXTURE_H