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

Commit 52212713 authored by Mathias Agopian's avatar Mathias Agopian
Browse files

second take, hopefully this time it doesn't break one of the builds:...

second take, hopefully this time it doesn't break one of the builds: "SurfaceFlinger will now allocate buffers based on the usage specified by the clients. This allows to allocate the right kind of buffer automatically, without having the user to specify anything."
parent 40ef81c7
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ private:
    static int lockBuffer(android_native_window_t* window, android_native_buffer_t* buffer);
    static int queueBuffer(android_native_window_t* window, android_native_buffer_t* buffer);
    static int query(android_native_window_t* window, int what, int* value);
    static int perform(android_native_window_t* window, int operation, ...);
    
    framebuffer_device_t* fbDev;
    alloc_device_t* grDev;
+1 −1
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ protected:
public: 
    DECLARE_META_INTERFACE(Surface);

    virtual sp<SurfaceBuffer> getBuffer() = 0; 
    virtual sp<SurfaceBuffer> getBuffer(int usage) = 0; 
    
    class BufferHeap {
    public:
+4 −1
Original line number Diff line number Diff line
@@ -184,7 +184,7 @@ private:
    friend class IOMX;
    const sp<ISurface>& getISurface() const { return mSurface; }

    status_t getBufferLocked(int index);
    status_t getBufferLocked(int index, int usage);
   
           status_t validate(per_client_cblk_t const* cblk) const;
    static void _send_dirty_region(layer_cblk_t* lcblk, const Region& dirty);
@@ -197,11 +197,13 @@ private:
    static int lockBuffer(android_native_window_t* window, android_native_buffer_t* buffer);
    static int queueBuffer(android_native_window_t* window, android_native_buffer_t* buffer);
    static int query(android_native_window_t* window, int what, int* value);
    static int perform(android_native_window_t* window, int operation, ...);

    int dequeueBuffer(android_native_buffer_t** buffer);
    int lockBuffer(android_native_buffer_t* buffer);
    int queueBuffer(android_native_buffer_t* buffer);
    int query(int what, int* value);
    int perform(int operation, va_list args);

    status_t dequeueBuffer(sp<SurfaceBuffer>* buffer);
    status_t lockBuffer(const sp<SurfaceBuffer>& buffer);
@@ -217,6 +219,7 @@ private:
    uint32_t                    mIdentity;
    uint32_t                    mWidth;
    uint32_t                    mHeight;
    uint32_t                    mUsage;
    PixelFormat                 mFormat;
    uint32_t                    mFlags;
    mutable Region              mDirtyRegion;
+41 −2
Original line number Diff line number Diff line
@@ -67,6 +67,11 @@ enum {
    NATIVE_WINDOW_FORMAT    = 2,
};

/* valid operations for the (*perform)() hook */
enum {
    NATIVE_WINDOW_SET_USAGE = 0
};

struct android_native_window_t 
{
#ifdef __cplusplus
@@ -144,9 +149,43 @@ struct android_native_window_t
    int     (*query)(struct android_native_window_t* window,
                int what, int* value);
    
    void* reserved_proc[4];
    /*
     * hook used to perform various operations on the surface.
     * (*perform)() is a generic mechanism to add functionality to
     * android_native_window_t while keeping backward binary compatibility.
     * 
     * This hook should not be called directly, instead use the helper functions
     * defined below.
     * 
     * The valid operations are:
     *     NATIVE_WINDOW_SET_USAGE
     *  
     */
    
    int     (*perform)(struct android_native_window_t* window,
                int operation, ... );
    
    void* reserved_proc[3];
};


/*
 *  native_window_set_usage() sets the intended usage flags for the next
 *  buffers acquired with (*lockBuffer)() and on.
 *  By default (if this function is never called), a usage of
 *      GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE
 *  is assumed.
 *  Calling this function will usually cause following buffers to be
 *  reallocated.
 */

inline int native_window_set_usage(
        struct android_native_window_t* window, int usage)
{
    return window->perform(window, NATIVE_WINDOW_SET_USAGE, usage);
}


// ---------------------------------------------------------------------------

/* FIXME: this is legacy for pixmaps */
+4 −4
Original line number Diff line number Diff line
@@ -217,7 +217,7 @@ void Layer::onDraw(const Region& clip) const
    drawWithOpenGL(clip, mTextures[index]);
}

sp<SurfaceBuffer> Layer::peekBuffer()
sp<SurfaceBuffer> Layer::peekBuffer(int usage)
{
    /*
     * This is called from the client's Surface::lock(), after it locked
@@ -250,7 +250,7 @@ sp<SurfaceBuffer> Layer::peekBuffer()
    }
    
    LayerBitmap& layerBitmap(mBuffers[backBufferIndex]);
    sp<SurfaceBuffer> buffer = layerBitmap.allocate();
    sp<SurfaceBuffer> buffer = layerBitmap.allocate(usage);
    
    LOGD_IF(DEBUG_RESIZE,
            "Layer::getBuffer(this=%p), index=%d, (%d,%d), (%d,%d)",
@@ -649,12 +649,12 @@ Layer::SurfaceLayer::~SurfaceLayer()
{
}

sp<SurfaceBuffer> Layer::SurfaceLayer::getBuffer()
sp<SurfaceBuffer> Layer::SurfaceLayer::getBuffer(int usage)
{
    sp<SurfaceBuffer> buffer = 0;
    sp<Layer> owner(getOwner());
    if (owner != 0) {
        buffer = owner->peekBuffer();
        buffer = owner->peekBuffer(usage);
    }
    return buffer;
}
Loading