Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1fed11c8 authored by Mathias Agopian's avatar Mathias Agopian
Browse files

checkpoint. bring back video/camera

parent 9f8b0c90
Loading
Loading
Loading
Loading
+5 −7
Original line number Original line Diff line number Diff line
@@ -188,6 +188,8 @@ void Layer::reloadTexture(const Region& dirty)
                } else {
                } else {
                    // Everything went okay!
                    // 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)) {
            if (UNLIKELY(mTextures[0].name == -1U)) {
                mTextures[0].name = createTexture();
                mTextures[0].name = createTexture();
            }
            }
            loadTexture(dirty, mTextures[0].name, t, 
            loadTexture(&mTextures[0], mTextures[0].name, dirty, t);
                    mTextures[0].width, mTextures[0].height);
            buffer->unlock();
            buffer->unlock();
        }
        }
    }
    }
@@ -222,10 +223,7 @@ void Layer::onDraw(const Region& clip) const
        clearWithOpenGL(clip);
        clearWithOpenGL(clip);
        return;
        return;
    }
    }

    drawWithOpenGL(clip, mTextures[index]);
    GGLSurface t;
    sp<const Buffer> buffer(frontBuffer().getBuffer());
    drawWithOpenGL(clip, textureName, buffer);
}
}


sp<SurfaceBuffer> Layer::peekBuffer()
sp<SurfaceBuffer> Layer::peekBuffer()
+0 −10
Original line number Original line Diff line number Diff line
@@ -123,16 +123,6 @@ private:
    };
    };
    friend class SurfaceLayer;
    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;
    sp<Surface>             mSurface;


            bool            mSecure;
            bool            mSecure;
+14 −9
Original line number Original line Diff line number Diff line
@@ -380,17 +380,17 @@ void LayerBase::clearWithOpenGL(const Region& clip) const
    }
    }
}
}


void LayerBase::drawWithOpenGL(const Region& clip,
void LayerBase::drawWithOpenGL(const Region& clip, const Texture& texture) const
        GLint textureName, const sp<const Buffer>& buffer, int transform) const
{
{
    const DisplayHardware& hw(graphicPlane(0).displayHardware());
    const DisplayHardware& hw(graphicPlane(0).displayHardware());
    const uint32_t fbHeight = hw.getHeight();
    const uint32_t fbHeight = hw.getHeight();
    const State& s(drawingState());
    const State& s(drawingState());
    const uint32_t width = buffer->width;
    const uint32_t height = buffer->height;
    
    
    // bind our texture
    // bind our texture
    validateTexture(textureName);
    validateTexture(texture.name);
    uint32_t width  = texture.width; 
    uint32_t height = texture.height;
    
    glEnable(GL_TEXTURE_2D);
    glEnable(GL_TEXTURE_2D);


    // Dithering...
    // Dithering...
@@ -457,7 +457,9 @@ void LayerBase::drawWithOpenGL(const Region& clip,
            glMatrixMode(GL_TEXTURE);
            glMatrixMode(GL_TEXTURE);
            glLoadIdentity();
            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);
                glTranslatef(0, 1, 0);
                glRotatef(-90, 0, 0, 1);
                glRotatef(-90, 0, 0, 1);
            }
            }
@@ -518,13 +520,16 @@ void LayerBase::validateTexture(GLint textureName) const
    // this is currently done in loadTexture() below
    // this is currently done in loadTexture() below
}
}


void LayerBase::loadTexture(const Region& dirty,
void LayerBase::loadTexture(Texture* texture, GLint textureName, 
        GLint textureName, const GGLSurface& t,
        const Region& dirty, const GGLSurface& t) const
        GLuint& textureWidth, GLuint& textureHeight) const
{
{
    // TODO: defer the actual texture reload until LayerBase::validateTexture
    // TODO: defer the actual texture reload until LayerBase::validateTexture
    // is called.
    // is called.


    texture->name = textureName;
    GLuint& textureWidth(texture->width);
    GLuint& textureHeight(texture->height);
    
    uint32_t flags = mFlags;
    uint32_t flags = mFlags;
    glBindTexture(GL_TEXTURE_2D, textureName);
    glBindTexture(GL_TEXTURE_2D, textureName);


+18 −9
Original line number Original line Diff line number Diff line
@@ -20,6 +20,9 @@
#include <stdint.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/types.h>


#include <EGL/egl.h>
#include <EGL/eglext.h>

#include <private/ui/LayerState.h>
#include <private/ui/LayerState.h>


#include <utils/RefBase.h>
#include <utils/RefBase.h>
@@ -238,16 +241,22 @@ protected:


          GLuint createTexture() const;
          GLuint createTexture() const;
    
    
          void drawWithOpenGL(const Region& clip,
          struct Texture {
                  GLint textureName,
              Texture() : name(-1U), width(0), height(0),
                  const sp<const Buffer>& buffer,
                  image(EGL_NO_IMAGE_KHR), transform(0), dirty(true) { }
                  int transform = 0) const;
              GLuint        name;
              GLuint        width;
              GLuint        height;
              EGLImageKHR   image;
              uint32_t      transform;
              bool          dirty;
          };
          
          
          void clearWithOpenGL(const Region& clip) const;
          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;
                sp<SurfaceFlinger> mFlinger;
                uint32_t        mFlags;
                uint32_t        mFlags;
+24 −26
Original line number Original line Diff line number Diff line
@@ -276,8 +276,7 @@ bool LayerBuffer::Source::transformed() const {


LayerBuffer::BufferSource::BufferSource(LayerBuffer& layer,
LayerBuffer::BufferSource::BufferSource(LayerBuffer& layer,
        const ISurface::BufferHeap& buffers)
        const ISurface::BufferHeap& buffers)
    : Source(layer), mStatus(NO_ERROR), 
    : Source(layer), mStatus(NO_ERROR), mBufferSize(0)
      mBufferSize(0), mTextureName(-1U)
{
{
    if (buffers.heap == NULL) {
    if (buffers.heap == NULL) {
        // this is allowed, but in this case, it is illegal to receive
        // this is allowed, but in this case, it is illegal to receive
@@ -321,8 +320,8 @@ LayerBuffer::BufferSource::BufferSource(LayerBuffer& layer,


LayerBuffer::BufferSource::~BufferSource()
LayerBuffer::BufferSource::~BufferSource()
{    
{    
    if (mTextureName != -1U) {
    if (mTexture.name != -1U) {
        glDeleteTextures(1, &mTextureName);
        glDeleteTextures(1, &mTexture.name);
    }
    }
}
}


@@ -380,37 +379,36 @@ bool LayerBuffer::BufferSource::transformed() const


void LayerBuffer::BufferSource::onDraw(const Region& clip) const 
void LayerBuffer::BufferSource::onDraw(const Region& clip) const 
{
{
    // FIXME: we should get a native buffer here 
    sp<Buffer> ourBuffer(getBuffer());
    /*
    if (UNLIKELY(ourBuffer == 0))  {
    sp<Buffer> ourBbuffer(getBuffer());
    if (UNLIKELY(buffer == 0))  {
        // nothing to do, we don't have a buffer
        // nothing to do, we don't have a buffer
        mLayer.clearWithOpenGL(clip);
        mLayer.clearWithOpenGL(clip);
        return;
        return;
    }
    }


    // FIXME: We should model this after the overlay stuff
    const NativeBuffer& src( ourBuffer->getBuffer() );
    if (UNLIKELY(mTextureName == -1LU)) {
        mTextureName = mLayer.createTexture();
    }

    // FIXME: Use EGLImage extension for this


    
    //if (!can_use_copybit || err) 
    
    {
    GGLSurface t;
        // OpenGL fall-back
    status_t res = buffer->lock(&t, GRALLOC_USAGE_SW_READ_RARELY);
        if (UNLIKELY(mTexture.name == -1LU)) {
    if (res == NO_ERROR) {
            mTexture.name = mLayer.createTexture();
        }
        GLuint w = 0;
        GLuint w = 0;
        GLuint h = 0;
        GLuint h = 0;
        const Region dirty(Rect(buffer->width, buffer->height));
        GGLSurface t;
        mLayer.loadTexture(dirty, mTextureName, t, w, h);
        t.version = sizeof(GGLSurface);
        buffer->unlock();
        t.width  = src.crop.r;
    }
        t.height = src.crop.b;
    if (res == NO_ERROR) {
        t.stride = src.img.w;
        mLayer.drawWithOpenGL(clip, mTextureName, buffer, mBufferHeap.transform);
        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);
    }
    }
    */
}
}




Loading