summaryrefslogtreecommitdiffstats
path: root/libs/surfaceflinger/LayerBase.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/surfaceflinger/LayerBase.cpp')
-rw-r--r--libs/surfaceflinger/LayerBase.cpp83
1 files changed, 54 insertions, 29 deletions
diff --git a/libs/surfaceflinger/LayerBase.cpp b/libs/surfaceflinger/LayerBase.cpp
index 8003d22..efbc77a 100644
--- a/libs/surfaceflinger/LayerBase.cpp
+++ b/libs/surfaceflinger/LayerBase.cpp
@@ -52,8 +52,9 @@ LayerBase::LayerBase(SurfaceFlinger* flinger, DisplayID display)
mTransformed(false),
mUseLinearFiltering(false),
mOrientation(0),
+ mLeft(0), mTop(0),
mTransactionFlags(0),
- mPremultipliedAlpha(true),
+ mPremultipliedAlpha(true), mDebug(false),
mInvalidate(0)
{
const DisplayHardware& hw(flinger->graphicPlane(0).displayHardware());
@@ -64,6 +65,14 @@ LayerBase::~LayerBase()
{
}
+void LayerBase::setName(const String8& name) {
+ mName = name;
+}
+
+String8 LayerBase::getName() const {
+ return mName;
+}
+
const GraphicPlane& LayerBase::graphicPlane(int dpy) const
{
return mFlinger->graphicPlane(dpy);
@@ -205,7 +214,6 @@ uint32_t LayerBase::doTransaction(uint32_t flags)
if ((front.w != temp.w) || (front.h != temp.h)) {
// invalidate and recompute the visible regions if needed
flags |= Layer::eVisibleRegion;
- this->contentDirty = true;
}
if (temp.sequence != front.sequence) {
@@ -444,12 +452,21 @@ void LayerBase::drawWithOpenGL(const Region& clip, const Texture& texture) const
glLoadIdentity();
// the texture's source is rotated
- if (texture.transform == HAL_TRANSFORM_ROT_90) {
- // TODO: handle the other orientations
- glTranslatef(0, 1, 0);
- glRotatef(-90, 0, 0, 1);
+ switch (texture.transform) {
+ case HAL_TRANSFORM_ROT_90:
+ glTranslatef(0, 1, 0);
+ glRotatef(-90, 0, 0, 1);
+ break;
+ case HAL_TRANSFORM_ROT_180:
+ glTranslatef(1, 1, 0);
+ glRotatef(-180, 0, 0, 1);
+ break;
+ case HAL_TRANSFORM_ROT_270:
+ glTranslatef(1, 0, 0);
+ glRotatef(-270, 0, 0, 1);
+ break;
}
-
+
if (texture.NPOTAdjust) {
glScalef(texture.wScale, texture.hScale, 1.0f);
}
@@ -500,6 +517,21 @@ void LayerBase::validateTexture(GLint textureName) const
}
}
+bool LayerBase::isSupportedYuvFormat(int format) const
+{
+ switch (format) {
+ case HAL_PIXEL_FORMAT_YCbCr_422_SP:
+ case HAL_PIXEL_FORMAT_YCbCr_420_SP:
+ case HAL_PIXEL_FORMAT_YCbCr_422_P:
+ case HAL_PIXEL_FORMAT_YCbCr_420_P:
+ case HAL_PIXEL_FORMAT_YCbCr_422_I:
+ case HAL_PIXEL_FORMAT_YCbCr_420_I:
+ case HAL_PIXEL_FORMAT_YCrCb_420_SP:
+ return true;
+ }
+ return false;
+}
+
void LayerBase::loadTexture(Texture* texture,
const Region& dirty, const GGLSurface& t) const
{
@@ -564,21 +596,20 @@ void LayerBase::loadTexture(Texture* texture,
data = t.data;
}
- if (t.format == GGL_PIXEL_FORMAT_RGB_565) {
+ if (t.format == HAL_PIXEL_FORMAT_RGB_565) {
glTexImage2D(GL_TEXTURE_2D, 0,
GL_RGB, texture->potWidth, texture->potHeight, 0,
GL_RGB, GL_UNSIGNED_SHORT_5_6_5, data);
- } else if (t.format == GGL_PIXEL_FORMAT_RGBA_4444) {
+ } else if (t.format == HAL_PIXEL_FORMAT_RGBA_4444) {
glTexImage2D(GL_TEXTURE_2D, 0,
GL_RGBA, texture->potWidth, texture->potHeight, 0,
GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, data);
- } else if (t.format == GGL_PIXEL_FORMAT_RGBA_8888 ||
- t.format == GGL_PIXEL_FORMAT_RGBX_8888) {
+ } else if (t.format == HAL_PIXEL_FORMAT_RGBA_8888 ||
+ t.format == HAL_PIXEL_FORMAT_RGBX_8888) {
glTexImage2D(GL_TEXTURE_2D, 0,
GL_RGBA, texture->potWidth, texture->potHeight, 0,
GL_RGBA, GL_UNSIGNED_BYTE, data);
- } else if ( t.format == GGL_PIXEL_FORMAT_YCbCr_422_SP ||
- t.format == GGL_PIXEL_FORMAT_YCbCr_420_SP) {
+ } else if (isSupportedYuvFormat(t.format)) {
// just show the Y plane of YUV buffers
glTexImage2D(GL_TEXTURE_2D, 0,
GL_LUMINANCE, texture->potWidth, texture->potHeight, 0,
@@ -590,24 +621,23 @@ void LayerBase::loadTexture(Texture* texture,
}
}
if (!data) {
- if (t.format == GGL_PIXEL_FORMAT_RGB_565) {
+ if (t.format == HAL_PIXEL_FORMAT_RGB_565) {
glTexSubImage2D(GL_TEXTURE_2D, 0,
0, bounds.top, t.width, bounds.height(),
GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
t.data + bounds.top*t.stride*2);
- } else if (t.format == GGL_PIXEL_FORMAT_RGBA_4444) {
+ } else if (t.format == HAL_PIXEL_FORMAT_RGBA_4444) {
glTexSubImage2D(GL_TEXTURE_2D, 0,
0, bounds.top, t.width, bounds.height(),
GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4,
t.data + bounds.top*t.stride*2);
- } else if (t.format == GGL_PIXEL_FORMAT_RGBA_8888 ||
- t.format == GGL_PIXEL_FORMAT_RGBX_8888) {
+ } else if (t.format == HAL_PIXEL_FORMAT_RGBA_8888 ||
+ t.format == HAL_PIXEL_FORMAT_RGBX_8888) {
glTexSubImage2D(GL_TEXTURE_2D, 0,
0, bounds.top, t.width, bounds.height(),
GL_RGBA, GL_UNSIGNED_BYTE,
t.data + bounds.top*t.stride*4);
- } else if ( t.format == GGL_PIXEL_FORMAT_YCbCr_422_SP ||
- t.format == GGL_PIXEL_FORMAT_YCbCr_420_SP) {
+ } else if (isSupportedYuvFormat(t.format)) {
// just show the Y plane of YUV buffers
glTexSubImage2D(GL_TEXTURE_2D, 0,
0, bounds.top, t.width, bounds.height(),
@@ -643,22 +673,15 @@ status_t LayerBase::initializeEglImage(
dpy, EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID,
(EGLClientBuffer)clientBuf, attrs);
- LOGE_IF(texture->image == EGL_NO_IMAGE_KHR,
- "eglCreateImageKHR() failed. err=0x%4x",
- eglGetError());
-
if (texture->image != EGL_NO_IMAGE_KHR) {
glBindTexture(GL_TEXTURE_2D, texture->name);
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D,
(GLeglImageOES)texture->image);
GLint error = glGetError();
if (UNLIKELY(error != GL_NO_ERROR)) {
- // this failed, for instance, because we don't support NPOT.
- // FIXME: do something!
LOGE("layer=%p, glEGLImageTargetTexture2DOES(%p) "
"failed err=0x%04x",
this, texture->image, error);
- mFlags &= ~DisplayHardware::DIRECT_TEXTURE;
err = INVALID_OPERATION;
} else {
// Everything went okay!
@@ -668,6 +691,8 @@ status_t LayerBase::initializeEglImage(
texture->height = clientBuf->height;
}
} else {
+ LOGE("layer=%p, eglCreateImageKHR() failed. err=0x%4x",
+ this, eglGetError());
err = INVALID_OPERATION;
}
return err;
@@ -680,8 +705,8 @@ int32_t LayerBaseClient::sIdentity = 0;
LayerBaseClient::LayerBaseClient(SurfaceFlinger* flinger, DisplayID display,
const sp<Client>& client, int32_t i)
- : LayerBase(flinger, display), lcblk(NULL), client(client),
- mIndex(i), mIdentity(uint32_t(android_atomic_inc(&sIdentity)))
+ : LayerBase(flinger, display), lcblk(NULL), client(client), mIndex(i),
+ mIdentity(uint32_t(android_atomic_inc(&sIdentity)))
{
lcblk = new SharedBufferServer(
client->ctrlblk, i, NUM_BUFFERS,
@@ -809,7 +834,7 @@ void LayerBaseClient::Surface::unregisterBuffers()
}
sp<OverlayRef> LayerBaseClient::Surface::createOverlay(
- uint32_t w, uint32_t h, int32_t format)
+ uint32_t w, uint32_t h, int32_t format, int32_t orientation)
{
return NULL;
};