diff options
author | Mathias Agopian <mathias@google.com> | 2009-06-23 18:08:22 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2009-06-23 18:08:22 -0700 |
commit | 1fed11c86a9d59d0f5282ae8ae25ceba2f802fdd (patch) | |
tree | 940032f8fb572ae8096b79027382ddb0538404fd /libs/surfaceflinger | |
parent | 9f8b0c909760aa5b866255fe08042a3200b736cc (diff) | |
download | frameworks_native-1fed11c86a9d59d0f5282ae8ae25ceba2f802fdd.zip frameworks_native-1fed11c86a9d59d0f5282ae8ae25ceba2f802fdd.tar.gz frameworks_native-1fed11c86a9d59d0f5282ae8ae25ceba2f802fdd.tar.bz2 |
checkpoint. bring back video/camera
Diffstat (limited to 'libs/surfaceflinger')
-rw-r--r-- | libs/surfaceflinger/Layer.cpp | 12 | ||||
-rw-r--r-- | libs/surfaceflinger/Layer.h | 10 | ||||
-rw-r--r-- | libs/surfaceflinger/LayerBase.cpp | 23 | ||||
-rw-r--r-- | libs/surfaceflinger/LayerBase.h | 27 | ||||
-rw-r--r-- | libs/surfaceflinger/LayerBuffer.cpp | 50 | ||||
-rw-r--r-- | libs/surfaceflinger/LayerBuffer.h | 14 |
6 files changed, 68 insertions, 68 deletions
diff --git a/libs/surfaceflinger/Layer.cpp b/libs/surfaceflinger/Layer.cpp index 218cb39..c40fec1 100644 --- a/libs/surfaceflinger/Layer.cpp +++ b/libs/surfaceflinger/Layer.cpp @@ -187,7 +187,9 @@ void Layer::reloadTexture(const Region& dirty) mFlags &= ~DisplayHardware::DIRECT_TEXTURE; } else { // Everything went okay! - mTextures[index].dirty = false; + mTextures[index].dirty = false; + mTextures[index].width = clientBuf->width; + mTextures[index].height = clientBuf->height; } } } @@ -200,8 +202,7 @@ void Layer::reloadTexture(const Region& dirty) if (UNLIKELY(mTextures[0].name == -1U)) { mTextures[0].name = createTexture(); } - loadTexture(dirty, mTextures[0].name, t, - mTextures[0].width, mTextures[0].height); + loadTexture(&mTextures[0], mTextures[0].name, dirty, t); buffer->unlock(); } } @@ -222,10 +223,7 @@ void Layer::onDraw(const Region& clip) const clearWithOpenGL(clip); return; } - - GGLSurface t; - sp<const Buffer> buffer(frontBuffer().getBuffer()); - drawWithOpenGL(clip, textureName, buffer); + drawWithOpenGL(clip, mTextures[index]); } sp<SurfaceBuffer> Layer::peekBuffer() diff --git a/libs/surfaceflinger/Layer.h b/libs/surfaceflinger/Layer.h index a19c171..54d994f 100644 --- a/libs/surfaceflinger/Layer.h +++ b/libs/surfaceflinger/Layer.h @@ -123,16 +123,6 @@ private: }; friend class SurfaceLayer; - struct Texture { - Texture() : name(-1U), width(0), height(0), image(EGL_NO_IMAGE_KHR), - dirty(true) { } - GLuint name; - GLuint width; - GLuint height; - EGLImageKHR image; - bool dirty; - }; - sp<Surface> mSurface; bool mSecure; diff --git a/libs/surfaceflinger/LayerBase.cpp b/libs/surfaceflinger/LayerBase.cpp index 3b86350..5fa14b2 100644 --- a/libs/surfaceflinger/LayerBase.cpp +++ b/libs/surfaceflinger/LayerBase.cpp @@ -380,17 +380,17 @@ void LayerBase::clearWithOpenGL(const Region& clip) const } } -void LayerBase::drawWithOpenGL(const Region& clip, - GLint textureName, const sp<const Buffer>& buffer, int transform) const +void LayerBase::drawWithOpenGL(const Region& clip, const Texture& texture) const { const DisplayHardware& hw(graphicPlane(0).displayHardware()); const uint32_t fbHeight = hw.getHeight(); const State& s(drawingState()); - const uint32_t width = buffer->width; - const uint32_t height = buffer->height; // bind our texture - validateTexture(textureName); + validateTexture(texture.name); + uint32_t width = texture.width; + uint32_t height = texture.height; + glEnable(GL_TEXTURE_2D); // Dithering... @@ -457,7 +457,9 @@ void LayerBase::drawWithOpenGL(const Region& clip, glMatrixMode(GL_TEXTURE); glLoadIdentity(); - if (transform == HAL_TRANSFORM_ROT_90) { + // 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); } @@ -518,13 +520,16 @@ void LayerBase::validateTexture(GLint textureName) const // this is currently done in loadTexture() below } -void LayerBase::loadTexture(const Region& dirty, - GLint textureName, const GGLSurface& t, - GLuint& textureWidth, GLuint& textureHeight) const +void LayerBase::loadTexture(Texture* texture, GLint textureName, + const Region& dirty, const GGLSurface& t) const { // TODO: defer the actual texture reload until LayerBase::validateTexture // is called. + texture->name = textureName; + GLuint& textureWidth(texture->width); + GLuint& textureHeight(texture->height); + uint32_t flags = mFlags; glBindTexture(GL_TEXTURE_2D, textureName); diff --git a/libs/surfaceflinger/LayerBase.h b/libs/surfaceflinger/LayerBase.h index b5265d2..dad3d3d 100644 --- a/libs/surfaceflinger/LayerBase.h +++ b/libs/surfaceflinger/LayerBase.h @@ -20,6 +20,9 @@ #include <stdint.h> #include <sys/types.h> +#include <EGL/egl.h> +#include <EGL/eglext.h> + #include <private/ui/LayerState.h> #include <utils/RefBase.h> @@ -238,17 +241,23 @@ protected: GLuint createTexture() const; - void drawWithOpenGL(const Region& clip, - GLint textureName, - const sp<const Buffer>& buffer, - int transform = 0) const; - + struct Texture { + Texture() : name(-1U), width(0), height(0), + image(EGL_NO_IMAGE_KHR), transform(0), dirty(true) { } + GLuint name; + GLuint width; + GLuint height; + EGLImageKHR image; + uint32_t transform; + bool dirty; + }; + void clearWithOpenGL(const Region& clip) const; + void drawWithOpenGL(const Region& clip, const Texture& texture) const; + void loadTexture(Texture* texture, GLint textureName, + const Region& dirty, const GGLSurface& t) const; - void loadTexture(const Region& dirty, - GLint textureName, const GGLSurface& t, - GLuint& textureWidth, GLuint& textureHeight) const; - + sp<SurfaceFlinger> mFlinger; uint32_t mFlags; diff --git a/libs/surfaceflinger/LayerBuffer.cpp b/libs/surfaceflinger/LayerBuffer.cpp index 02b3651..3db5434 100644 --- a/libs/surfaceflinger/LayerBuffer.cpp +++ b/libs/surfaceflinger/LayerBuffer.cpp @@ -276,8 +276,7 @@ bool LayerBuffer::Source::transformed() const { LayerBuffer::BufferSource::BufferSource(LayerBuffer& layer, const ISurface::BufferHeap& buffers) - : Source(layer), mStatus(NO_ERROR), - mBufferSize(0), mTextureName(-1U) + : Source(layer), mStatus(NO_ERROR), mBufferSize(0) { if (buffers.heap == NULL) { // this is allowed, but in this case, it is illegal to receive @@ -321,8 +320,8 @@ LayerBuffer::BufferSource::BufferSource(LayerBuffer& layer, LayerBuffer::BufferSource::~BufferSource() { - if (mTextureName != -1U) { - glDeleteTextures(1, &mTextureName); + if (mTexture.name != -1U) { + glDeleteTextures(1, &mTexture.name); } } @@ -380,37 +379,36 @@ bool LayerBuffer::BufferSource::transformed() const void LayerBuffer::BufferSource::onDraw(const Region& clip) const { - // FIXME: we should get a native buffer here - /* - sp<Buffer> ourBbuffer(getBuffer()); - if (UNLIKELY(buffer == 0)) { + sp<Buffer> ourBuffer(getBuffer()); + if (UNLIKELY(ourBuffer == 0)) { // nothing to do, we don't have a buffer mLayer.clearWithOpenGL(clip); return; } - // FIXME: We should model this after the overlay stuff - if (UNLIKELY(mTextureName == -1LU)) { - mTextureName = mLayer.createTexture(); - } + const NativeBuffer& src( ourBuffer->getBuffer() ); - // FIXME: Use EGLImage extension for this - - - - GGLSurface t; - status_t res = buffer->lock(&t, GRALLOC_USAGE_SW_READ_RARELY); - if (res == NO_ERROR) { + //if (!can_use_copybit || err) + { + // OpenGL fall-back + if (UNLIKELY(mTexture.name == -1LU)) { + mTexture.name = mLayer.createTexture(); + } GLuint w = 0; GLuint h = 0; - const Region dirty(Rect(buffer->width, buffer->height)); - mLayer.loadTexture(dirty, mTextureName, t, w, h); - buffer->unlock(); - } - if (res == NO_ERROR) { - mLayer.drawWithOpenGL(clip, mTextureName, buffer, mBufferHeap.transform); + GGLSurface t; + t.version = sizeof(GGLSurface); + t.width = src.crop.r; + t.height = src.crop.b; + t.stride = src.img.w; + t.vstride= src.img.h; + t.format = src.img.format; + t.data = (GGLubyte*)(intptr_t(src.img.base) + src.img.offset); + const Region dirty(Rect(t.width, t.height)); + mLayer.loadTexture(&mTexture, mTexture.name, dirty, t); + mTexture.transform = mBufferHeap.transform; + mLayer.drawWithOpenGL(clip, mTexture); } - */ } diff --git a/libs/surfaceflinger/LayerBuffer.h b/libs/surfaceflinger/LayerBuffer.h index 587d31b..e1b3cf8 100644 --- a/libs/surfaceflinger/LayerBuffer.h +++ b/libs/surfaceflinger/LayerBuffer.h @@ -121,13 +121,13 @@ private: virtual void unregisterBuffers(); virtual bool transformed() const; private: - mutable Mutex mLock; - sp<Buffer> mBuffer; - status_t mStatus; - ISurface::BufferHeap mBufferHeap; - size_t mBufferSize; - mutable sp<android::Buffer> mTempBitmap; - mutable GLuint mTextureName; + mutable Mutex mLock; + sp<Buffer> mBuffer; + status_t mStatus; + ISurface::BufferHeap mBufferHeap; + size_t mBufferSize; + mutable sp<android::Buffer> mTempBitmap; + mutable LayerBase::Texture mTexture; }; class OverlaySource : public Source { |