am 360865e2: Merge "clean-up surfaceflinger a bit" into kraken
This commit is contained in:
commit
aae4b44357
@ -266,9 +266,6 @@ void DisplayHardware::init(uint32_t dpy)
|
|||||||
if (strstr(gl_extensions, "GL_ARB_texture_non_power_of_two")) {
|
if (strstr(gl_extensions, "GL_ARB_texture_non_power_of_two")) {
|
||||||
mFlags |= NPOT_EXTENSION;
|
mFlags |= NPOT_EXTENSION;
|
||||||
}
|
}
|
||||||
if (strstr(gl_extensions, "GL_OES_draw_texture")) {
|
|
||||||
mFlags |= DRAW_TEXTURE_EXTENSION;
|
|
||||||
}
|
|
||||||
#ifdef EGL_ANDROID_image_native_buffer
|
#ifdef EGL_ANDROID_image_native_buffer
|
||||||
if (strstr( gl_extensions, "GL_OES_EGL_image") &&
|
if (strstr( gl_extensions, "GL_OES_EGL_image") &&
|
||||||
(strstr(egl_extensions, "EGL_KHR_image_base") ||
|
(strstr(egl_extensions, "EGL_KHR_image_base") ||
|
||||||
|
@ -46,7 +46,6 @@ public:
|
|||||||
DIRECT_TEXTURE = 0x00000002,
|
DIRECT_TEXTURE = 0x00000002,
|
||||||
COPY_BITS_EXTENSION = 0x00000008,
|
COPY_BITS_EXTENSION = 0x00000008,
|
||||||
NPOT_EXTENSION = 0x00000100,
|
NPOT_EXTENSION = 0x00000100,
|
||||||
DRAW_TEXTURE_EXTENSION = 0x00000200,
|
|
||||||
BUFFER_PRESERVED = 0x00010000,
|
BUFFER_PRESERVED = 0x00010000,
|
||||||
PARTIAL_UPDATES = 0x00020000, // video driver feature
|
PARTIAL_UPDATES = 0x00020000, // video driver feature
|
||||||
SLOW_CONFIG = 0x00040000, // software
|
SLOW_CONFIG = 0x00040000, // software
|
||||||
|
@ -374,7 +374,7 @@ void LayerBase::clearWithOpenGL(const Region& clip, GLclampx red,
|
|||||||
Region::const_iterator it = clip.begin();
|
Region::const_iterator it = clip.begin();
|
||||||
Region::const_iterator const end = clip.end();
|
Region::const_iterator const end = clip.end();
|
||||||
glEnable(GL_SCISSOR_TEST);
|
glEnable(GL_SCISSOR_TEST);
|
||||||
glVertexPointer(2, GL_FIXED, 0, mVertices);
|
glVertexPointer(2, GL_FLOAT, 0, mVertices);
|
||||||
while (it != end) {
|
while (it != end) {
|
||||||
const Rect& r = *it++;
|
const Rect& r = *it++;
|
||||||
const GLint sy = fbHeight - (r.top + r.height());
|
const GLint sy = fbHeight - (r.top + r.height());
|
||||||
@ -418,14 +418,14 @@ void LayerBase::drawWithOpenGL(const Region& clip, const Texture& texture) const
|
|||||||
env = GL_REPLACE;
|
env = GL_REPLACE;
|
||||||
src = GL_SRC_ALPHA;
|
src = GL_SRC_ALPHA;
|
||||||
}
|
}
|
||||||
const GGLfixed alpha = (s.alpha << 16)/255;
|
const GLfloat alpha = s.alpha * (1.0f/255.0f);
|
||||||
glColor4x(alpha, alpha, alpha, alpha);
|
glColor4f(alpha, alpha, alpha, alpha);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(src, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(src, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, env);
|
glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, env);
|
||||||
} else {
|
} else {
|
||||||
glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||||
glColor4x(0x10000, 0x10000, 0x10000, 0x10000);
|
glColor4f(1, 1, 1, 1);
|
||||||
if (needsBlending()) {
|
if (needsBlending()) {
|
||||||
GLenum src = mPremultipliedAlpha ? GL_ONE : GL_SRC_ALPHA;
|
GLenum src = mPremultipliedAlpha ? GL_ONE : GL_SRC_ALPHA;
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
@ -437,64 +437,47 @@ void LayerBase::drawWithOpenGL(const Region& clip, const Texture& texture) const
|
|||||||
|
|
||||||
Region::const_iterator it = clip.begin();
|
Region::const_iterator it = clip.begin();
|
||||||
Region::const_iterator const end = clip.end();
|
Region::const_iterator const end = clip.end();
|
||||||
if (UNLIKELY(transformed()
|
const GLfloat texCoords[4][2] = {
|
||||||
|| !(mFlags & DisplayHardware::DRAW_TEXTURE_EXTENSION) ))
|
{ 0, 0 },
|
||||||
{
|
{ 0, 1 },
|
||||||
//StopWatch watch("GL transformed");
|
{ 1, 1 },
|
||||||
const GLfixed texCoords[4][2] = {
|
{ 1, 0 }
|
||||||
{ 0, 0 },
|
};
|
||||||
{ 0, 0x10000 },
|
|
||||||
{ 0x10000, 0x10000 },
|
|
||||||
{ 0x10000, 0 }
|
|
||||||
};
|
|
||||||
|
|
||||||
glMatrixMode(GL_TEXTURE);
|
glMatrixMode(GL_TEXTURE);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
// the texture's source is rotated
|
// the texture's source is rotated
|
||||||
switch (texture.transform) {
|
switch (texture.transform) {
|
||||||
case HAL_TRANSFORM_ROT_90:
|
case HAL_TRANSFORM_ROT_90:
|
||||||
glTranslatef(0, 1, 0);
|
glTranslatef(0, 1, 0);
|
||||||
glRotatef(-90, 0, 0, 1);
|
glRotatef(-90, 0, 0, 1);
|
||||||
break;
|
break;
|
||||||
case HAL_TRANSFORM_ROT_180:
|
case HAL_TRANSFORM_ROT_180:
|
||||||
glTranslatef(1, 1, 0);
|
glTranslatef(1, 1, 0);
|
||||||
glRotatef(-180, 0, 0, 1);
|
glRotatef(-180, 0, 0, 1);
|
||||||
break;
|
break;
|
||||||
case HAL_TRANSFORM_ROT_270:
|
case HAL_TRANSFORM_ROT_270:
|
||||||
glTranslatef(1, 0, 0);
|
glTranslatef(1, 0, 0);
|
||||||
glRotatef(-270, 0, 0, 1);
|
glRotatef(-270, 0, 0, 1);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
if (texture.NPOTAdjust) {
|
|
||||||
glScalef(texture.wScale, texture.hScale, 1.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
||||||
glVertexPointer(2, GL_FIXED, 0, mVertices);
|
|
||||||
glTexCoordPointer(2, GL_FIXED, 0, texCoords);
|
|
||||||
|
|
||||||
while (it != end) {
|
|
||||||
const Rect& r = *it++;
|
|
||||||
const GLint sy = fbHeight - (r.top + r.height());
|
|
||||||
glScissor(r.left, sy, r.width(), r.height());
|
|
||||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
|
||||||
}
|
|
||||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
||||||
} else {
|
|
||||||
GLint crop[4] = { 0, height, width, -height };
|
|
||||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop);
|
|
||||||
int x = tx();
|
|
||||||
int y = ty();
|
|
||||||
y = fbHeight - (y + height);
|
|
||||||
while (it != end) {
|
|
||||||
const Rect& r = *it++;
|
|
||||||
const GLint sy = fbHeight - (r.top + r.height());
|
|
||||||
glScissor(r.left, sy, r.width(), r.height());
|
|
||||||
glDrawTexiOES(x, y, 0, width, height);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (texture.NPOTAdjust) {
|
||||||
|
glScalef(texture.wScale, texture.hScale, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
glVertexPointer(2, GL_FLOAT, 0, mVertices);
|
||||||
|
glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
|
||||||
|
|
||||||
|
while (it != end) {
|
||||||
|
const Rect& r = *it++;
|
||||||
|
const GLint sy = fbHeight - (r.top + r.height());
|
||||||
|
glScissor(r.left, sy, r.width(), r.height());
|
||||||
|
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||||
|
}
|
||||||
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerBase::validateTexture(GLint textureName) const
|
void LayerBase::validateTexture(GLint textureName) const
|
||||||
|
@ -278,7 +278,7 @@ protected:
|
|||||||
bool mTransformed;
|
bool mTransformed;
|
||||||
bool mUseLinearFiltering;
|
bool mUseLinearFiltering;
|
||||||
int32_t mOrientation;
|
int32_t mOrientation;
|
||||||
GLfixed mVertices[4][2];
|
GLfloat mVertices[4][2];
|
||||||
Rect mTransformedBounds;
|
Rect mTransformedBounds;
|
||||||
int mLeft;
|
int mLeft;
|
||||||
int mTop;
|
int mTop;
|
||||||
|
@ -206,8 +206,8 @@ void LayerBlur::onDraw(const Region& clip) const
|
|||||||
|
|
||||||
const State& s = drawingState();
|
const State& s = drawingState();
|
||||||
if (UNLIKELY(s.alpha < 0xFF)) {
|
if (UNLIKELY(s.alpha < 0xFF)) {
|
||||||
const GGLfixed alpha = (s.alpha << 16)/255;
|
const GLfloat alpha = s.alpha * (1.0f/255.0f);
|
||||||
glColor4x(0, 0, 0, alpha);
|
glColor4f(0, 0, 0, alpha);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||||
@ -225,38 +225,20 @@ void LayerBlur::onDraw(const Region& clip) const
|
|||||||
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
|
|
||||||
if (UNLIKELY(transformed()
|
glMatrixMode(GL_TEXTURE);
|
||||||
|| !(mFlags & DisplayHardware::DRAW_TEXTURE_EXTENSION) )) {
|
glLoadIdentity();
|
||||||
// This is a very rare scenario.
|
glScalef(mWidthScale, mHeightScale, 1);
|
||||||
glMatrixMode(GL_TEXTURE);
|
glTranslatef(-x, mYOffset - y, 0);
|
||||||
glLoadIdentity();
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
glScalef(mWidthScale, mHeightScale, 1);
|
glVertexPointer(2, GL_FLOAT, 0, mVertices);
|
||||||
glTranslatef(-x, mYOffset - y, 0);
|
glTexCoordPointer(2, GL_FLOAT, 0, mVertices);
|
||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
while (it != end) {
|
||||||
glVertexPointer(2, GL_FIXED, 0, mVertices);
|
const Rect& r = *it++;
|
||||||
glTexCoordPointer(2, GL_FIXED, 0, mVertices);
|
const GLint sy = fbHeight - (r.top + r.height());
|
||||||
while (it != end) {
|
glScissor(r.left, sy, r.width(), r.height());
|
||||||
const Rect& r = *it++;
|
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||||
const GLint sy = fbHeight - (r.top + r.height());
|
|
||||||
glScissor(r.left, sy, r.width(), r.height());
|
|
||||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
|
||||||
}
|
|
||||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
||||||
} else {
|
|
||||||
// NOTE: this is marginally faster with the software gl, because
|
|
||||||
// glReadPixels() reads the fb bottom-to-top, however we'll
|
|
||||||
// skip all the jaccobian computations.
|
|
||||||
Rect r;
|
|
||||||
GLint crop[4] = { 0, 0, w, h };
|
|
||||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop);
|
|
||||||
y = fbHeight - (y + h);
|
|
||||||
while (it != end) {
|
|
||||||
const Rect& r = *it++;
|
|
||||||
const GLint sy = fbHeight - (r.top + r.height());
|
|
||||||
glScissor(r.left, sy, r.width(), r.height());
|
|
||||||
glDrawTexiOES(x, y, 0, w, h);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,8 +206,8 @@ void SurfaceFlinger::init()
|
|||||||
property_get("debug.sf.showbackground", value, "0");
|
property_get("debug.sf.showbackground", value, "0");
|
||||||
mDebugBackground = atoi(value);
|
mDebugBackground = atoi(value);
|
||||||
|
|
||||||
LOGI_IF(mDebugRegion, "showupdates enabled");
|
LOGI_IF(mDebugRegion, "showupdates enabled");
|
||||||
LOGI_IF(mDebugBackground, "showbackground enabled");
|
LOGI_IF(mDebugBackground, "showbackground enabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
SurfaceFlinger::~SurfaceFlinger()
|
SurfaceFlinger::~SurfaceFlinger()
|
||||||
@ -357,7 +357,6 @@ status_t SurfaceFlinger::readyToRun()
|
|||||||
dcblk->ydpi = hw.getDpiY();
|
dcblk->ydpi = hw.getDpiY();
|
||||||
dcblk->fps = hw.getRefreshRate();
|
dcblk->fps = hw.getRefreshRate();
|
||||||
dcblk->density = hw.getDensity();
|
dcblk->density = hw.getDensity();
|
||||||
asm volatile ("":::"memory");
|
|
||||||
|
|
||||||
// Initialize OpenGL|ES
|
// Initialize OpenGL|ES
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
@ -229,14 +229,13 @@ Transform::vec3 Transform::transform(const vec3& v) const {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transform::transform(fixed1616* point, int x, int y) const
|
void Transform::transform(float* point, int x, int y) const
|
||||||
{
|
{
|
||||||
const float toFixed = 65536.0f;
|
|
||||||
const mat33& M(mMatrix);
|
const mat33& M(mMatrix);
|
||||||
vec2 v(x, y);
|
vec2 v(x, y);
|
||||||
v = transform(v);
|
v = transform(v);
|
||||||
point[0] = v[0] * toFixed;
|
point[0] = v[0];
|
||||||
point[1] = v[1] * toFixed;
|
point[1] = v[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect Transform::makeBounds(int w, int h) const
|
Rect Transform::makeBounds(int w, int h) const
|
||||||
|
@ -37,8 +37,6 @@ public:
|
|||||||
explicit Transform(uint32_t orientation);
|
explicit Transform(uint32_t orientation);
|
||||||
~Transform();
|
~Transform();
|
||||||
|
|
||||||
typedef int32_t fixed1616;
|
|
||||||
|
|
||||||
// FIXME: must match OVERLAY_TRANSFORM_*, pull from hardware.h
|
// FIXME: must match OVERLAY_TRANSFORM_*, pull from hardware.h
|
||||||
enum orientation_flags {
|
enum orientation_flags {
|
||||||
ROT_0 = 0x00000000,
|
ROT_0 = 0x00000000,
|
||||||
@ -76,7 +74,7 @@ public:
|
|||||||
|
|
||||||
// transform data
|
// transform data
|
||||||
Rect makeBounds(int w, int h) const;
|
Rect makeBounds(int w, int h) const;
|
||||||
void transform(fixed1616* point, int x, int y) const;
|
void transform(float* point, int x, int y) const;
|
||||||
Region transform(const Region& reg) const;
|
Region transform(const Region& reg) const;
|
||||||
Transform operator * (const Transform& rhs) const;
|
Transform operator * (const Transform& rhs) const;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user