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

Commit 0926f506 authored by Mathias Agopian's avatar Mathias Agopian
Browse files

update surfaceflinger, libui and libagl to the new gralloc api

- Currently the lock/unlock path is naive and is done for each drawing operation (glDrawElements and glDrawArrays). this should be improved eventually.
- factor all the lock/unlock code in SurfaceBuffer.
- fixed "showupdate" so it works even when we don't have preserving eglSwapBuffers().
- improved the situation with the dirty-region and fixed a problem that caused GL apps to not update.
- make use of LightRefBase() where needed, instead of duplicating its implementation
- add LightRefBase::getStrongCount()
- renamed EGLNativeWindowSurface.cpp to FramebufferNativeWindow.cpp

- disabled copybits test, since it clashes with the new gralloc api

- Camera/Video will be fixed later when we rework the overlay apis
parent 7be3e5d2
Loading
Loading
Loading
Loading
+8 −15
Original line number Diff line number Diff line
@@ -20,10 +20,7 @@
#include <stdint.h>
#include <sys/types.h>

#include <utils/CallStack.h>
#include <utils/threads.h>
#include <utils/Singleton.h>
#include <utils/KeyedVector.h>

#include <hardware/gralloc.h>

@@ -40,9 +37,14 @@ class BufferMapper : public Singleton<BufferMapper>
{
public:
    static inline BufferMapper& get() { return getInstance(); }
    status_t map(buffer_handle_t handle, void** addr, const void* id);
    status_t unmap(buffer_handle_t handle, const void* id);
    status_t lock(buffer_handle_t handle, int usage, const Rect& bounds);

    status_t registerBuffer(buffer_handle_t handle);

    status_t unregisterBuffer(buffer_handle_t handle);
    
    status_t lock(buffer_handle_t handle,
            int usage, const Rect& bounds, void** vaddr);

    status_t unlock(buffer_handle_t handle);
    
    // dumps information about the mapping of this handle
@@ -51,16 +53,7 @@ public:
private:
    friend class Singleton<BufferMapper>;
    BufferMapper();
    mutable Mutex mLock;
    gralloc_module_t const *mAllocMod;
    
    void logMapLocked(buffer_handle_t handle, const void* id);
    void logUnmapLocked(buffer_handle_t handle, const void* id);
    struct map_info_t {
        const void* id;
        CallStack stack;
    };
    KeyedVector<buffer_handle_t, Vector<map_info_t> > mMapInfo;
};

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

include/ui/EGLDisplaySurface.h

deleted100644 → 0
+0 −86
Original line number Diff line number Diff line
/*
 * Copyright (C) 2007 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef ANDROID_EGL_DISPLAY_SURFACE_H
#define ANDROID_EGL_DISPLAY_SURFACE_H

#include <stdint.h>
#include <sys/types.h>

#include <utils/Timers.h>

#include <ui/EGLNativeSurface.h>

#include <pixelflinger/pixelflinger.h>
#include <linux/fb.h>

#include <EGL/egl.h>

struct copybit_device_t;
struct copybit_image_t;

// ---------------------------------------------------------------------------
namespace android {
// ---------------------------------------------------------------------------

class Region;
class Rect;

class EGLDisplaySurface : public EGLNativeSurface<EGLDisplaySurface>
{
public:
    EGLDisplaySurface();
    ~EGLDisplaySurface();
    
    int32_t getPageFlipCount() const;
    void    copyFrontToBack(const Region& copyback);
    void    copyFrontToImage(const copybit_image_t& dst);
    void    copyBackToImage(const copybit_image_t& dst);
    
    void        setSwapRectangle(int l, int t, int w, int h);

private:
    static void         hook_incRef(NativeWindowType window);
    static void         hook_decRef(NativeWindowType window);
    static uint32_t     hook_swapBuffers(NativeWindowType window);
     
            uint32_t    swapBuffers();

            status_t    mapFrameBuffer();

            enum {
                PAGE_FLIP = 0x00000001
            };
    GGLSurface          mFb[2];
    int                 mIndex;
    uint32_t            mFlags;
    size_t              mSize;
    fb_var_screeninfo   mInfo;
    fb_fix_screeninfo   mFinfo;
    int32_t             mPageFlipCount;
    nsecs_t             mTime;
    int32_t             mSwapCount;
    nsecs_t             mSleep;
    uint32_t            mFeatureFlags;
    copybit_device_t*   mBlitEngine;
};

// ---------------------------------------------------------------------------
}; // namespace android
// ---------------------------------------------------------------------------

#endif // ANDROID_EGL_DISPLAY_SURFACE_H
+5 −19
Original line number Diff line number Diff line
@@ -14,8 +14,8 @@
 * limitations under the License.
 */

#ifndef ANDROID_EGL_NATIVE_WINDOW_SURFACE_H
#define ANDROID_EGL_NATIVE_WINDOW_SURFACE_H
#ifndef ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H
#define ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H

#include <stdint.h>
#include <sys/types.h>
@@ -76,32 +76,18 @@ public:

    framebuffer_device_t const * getDevice() const { return fbDev; } 

    void setSwapRectangle(const Rect& dirty);

private:
    friend class LightRefBase<FramebufferNativeWindow>;    
    ~FramebufferNativeWindow(); // this class cannot be overloaded
    static void connect(android_native_window_t* window);
    static void disconnect(android_native_window_t* window);
    static int setSwapInterval(android_native_window_t* window, int interval);
    static int setSwapRectangle(android_native_window_t* window,
            int l, int t, int w, int h);
    static int dequeueBuffer(android_native_window_t* window, android_native_buffer_t** buffer);
    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 inline FramebufferNativeWindow* getSelf(
            android_native_window_t* window) {
        FramebufferNativeWindow* self = 
            static_cast<FramebufferNativeWindow*>(window);
            return self;
    }

    static inline FramebufferNativeWindow* getSelf(
            android_native_base_t* window) {
        return getSelf(reinterpret_cast<android_native_window_t*>(window));
    }

    
    framebuffer_device_t* fbDev;
    alloc_device_t* grDev;

@@ -121,5 +107,5 @@ private:
}; // namespace android
// ---------------------------------------------------------------------------

#endif // ANDROID_EGL_NATIVE_WINDOW_SURFACE_H
#endif // ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H
+1 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ public:

            void        clear();
            void        set(const Rect& r);
            void        set(uint32_t w, uint32_t h);
        
            Region&     orSelf(const Rect& rhs);
            Region&     andSelf(const Rect& rhs);
+24 −15
Original line number Diff line number Diff line
@@ -34,7 +34,9 @@ namespace android {

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

class BufferMapper;
class Rect;
class Surface;
class SurfaceComposerClient;
struct per_client_cblk_t;
struct layer_cblk_t;
@@ -52,6 +54,10 @@ public:
        return handle;
    }
    
    status_t lock(uint32_t usage);
    status_t lock(uint32_t usage, const Rect& rect);
    status_t unlock();

protected:
            SurfaceBuffer();
            SurfaceBuffer(const Parcel& reply);
@@ -59,7 +65,11 @@ protected:
    buffer_handle_t handle;
    bool mOwner;

    inline const BufferMapper& getBufferMapper() const { return mBufferMapper; }
    inline BufferMapper& getBufferMapper() { return mBufferMapper; }
    
private:
    friend class Surface;
    friend class BpSurface;
    friend class BnSurface;
    friend class LightRefBase<SurfaceBuffer>;    
@@ -72,6 +82,8 @@ private:
    
    static int getHandle(android_native_buffer_t const * base, 
            buffer_handle_t* handle);
    
    BufferMapper& mBufferMapper;
};

// ---------------------------------------------------------------------------
@@ -191,9 +203,8 @@ public:
    status_t    lock(SurfaceInfo* info, Region* dirty, bool blocking = true);
    status_t    unlockAndPost();

    // setSwapRectangle() is mainly used by EGL
    // setSwapRectangle() is intended to be used by GL ES clients
    void        setSwapRectangle(const Rect& r);
    const Rect& swapRectangle() const;

private:
    // can't be copied
@@ -217,21 +228,13 @@ private:

    status_t getBufferLocked(int index);
   
    
    
    Region dirtyRegion() const;
    void setDirtyRegion(const Region& region) const;

   
           status_t validate(per_client_cblk_t const* cblk) const;
    static void _send_dirty_region(layer_cblk_t* lcblk, const Region& dirty);

    inline const BufferMapper& getBufferMapper() const { return mBufferMapper; }
    inline BufferMapper& getBufferMapper() { return mBufferMapper; }
    
    static void connect(android_native_window_t* window);
    static void disconnect(android_native_window_t* window);
    static int setSwapInterval(android_native_window_t* window, int interval);
    static int setSwapRectangle(android_native_window_t* window,
            int l, int t, int w, int h);
    static int dequeueBuffer(android_native_window_t* window, android_native_buffer_t** buffer);
    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);
@@ -240,20 +243,26 @@ private:
    int lockBuffer(android_native_buffer_t* buffer);
    int queueBuffer(android_native_buffer_t* buffer);

    status_t dequeueBuffer(sp<SurfaceBuffer>* buffer);
    status_t lockBuffer(const sp<SurfaceBuffer>& buffer);
    status_t queueBuffer(const sp<SurfaceBuffer>& buffer);

    
    alloc_device_t*             mAllocDevice;
    sp<SurfaceComposerClient>   mClient;
    sp<ISurface>                mSurface;
    sp<SurfaceBuffer>           mBuffers[2];
    android_native_buffer_t*    mLockedBuffer;
    sp<SurfaceBuffer>           mLockedBuffer;
    SurfaceID                   mToken;
    uint32_t                    mIdentity;
    PixelFormat                 mFormat;
    uint32_t                    mFlags;
    mutable Region              mDirtyRegion;
    mutable Rect                mSwapRectangle;
    mutable Region              mOldDirtyRegion;
    mutable uint8_t             mBackbufferIndex;
    mutable Mutex               mSurfaceLock;
    Rect                        mSwapRectangle;
    BufferMapper&               mBufferMapper;
};

}; // namespace android
Loading