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

Commit ca64ed6a authored by Mathias Agopian's avatar Mathias Agopian Committed by Android (Google) Code Review
Browse files

Merge "remove the "memcpy" hack" into kraken

parents 8b518577 aca2ee8a
Loading
Loading
Loading
Loading
+0 −10
Original line number Original line Diff line number Diff line
@@ -125,7 +125,6 @@ void DisplayHardware::init(uint32_t dpy)
    EGLint numConfigs=0;
    EGLint numConfigs=0;
    EGLSurface surface;
    EGLSurface surface;
    EGLContext context;
    EGLContext context;
    mFlags = CACHED_BUFFERS;


    // TODO: all the extensions below should be queried through
    // TODO: all the extensions below should be queried through
    // eglGetProcAddress().
    // eglGetProcAddress().
@@ -253,15 +252,6 @@ void DisplayHardware::init(uint32_t dpy)
    LOGI("GL_MAX_TEXTURE_SIZE = %d", mMaxTextureSize);
    LOGI("GL_MAX_TEXTURE_SIZE = %d", mMaxTextureSize);
    LOGI("GL_MAX_VIEWPORT_DIMS = %d", mMaxViewportDims);
    LOGI("GL_MAX_VIEWPORT_DIMS = %d", mMaxViewportDims);


#if 0
    // for drivers that don't have proper support for flushing cached buffers
    // on gralloc unlock, uncomment this block and test for the specific
    // renderer substring
    if (strstr(gl_renderer, "<some vendor string>")) {
        LOGD("Assuming uncached graphics buffers.");
        mFlags &= ~CACHED_BUFFERS;
    }
#endif


    if (strstr(gl_extensions, "GL_ARB_texture_non_power_of_two")) {
    if (strstr(gl_extensions, "GL_ARB_texture_non_power_of_two")) {
        mFlags |= NPOT_EXTENSION;
        mFlags |= NPOT_EXTENSION;
+0 −1
Original line number Original line Diff line number Diff line
@@ -50,7 +50,6 @@ public:
        PARTIAL_UPDATES         = 0x00020000,   // video driver feature
        PARTIAL_UPDATES         = 0x00020000,   // video driver feature
        SLOW_CONFIG             = 0x00040000,   // software
        SLOW_CONFIG             = 0x00040000,   // software
        SWAP_RECTANGLE          = 0x00080000,
        SWAP_RECTANGLE          = 0x00080000,
        CACHED_BUFFERS          = 0x00100000
    };
    };


    DisplayHardware(
    DisplayHardware(
+7 −97
Original line number Original line Diff line number Diff line
@@ -51,7 +51,6 @@ Layer::Layer(SurfaceFlinger* flinger, DisplayID display,
        const sp<Client>& c, int32_t i)
        const sp<Client>& c, int32_t i)
    :   LayerBaseClient(flinger, display, c, i),
    :   LayerBaseClient(flinger, display, c, i),
        mSecure(false),
        mSecure(false),
        mNoEGLImageForSwBuffers(false),
        mNeedsBlending(true),
        mNeedsBlending(true),
        mNeedsDithering(false)
        mNeedsDithering(false)
{
{
@@ -126,7 +125,6 @@ status_t Layer::setBuffers( uint32_t w, uint32_t h,
    mHeight = h;
    mHeight = h;
    mSecure = (flags & ISurfaceComposer::eSecure) ? true : false;
    mSecure = (flags & ISurfaceComposer::eSecure) ? true : false;
    mNeedsBlending = (info.h_alpha - info.l_alpha) > 0;
    mNeedsBlending = (info.h_alpha - info.l_alpha) > 0;
    mNoEGLImageForSwBuffers = !(hwFlags & DisplayHardware::CACHED_BUFFERS);


    // we use the red index
    // we use the red index
    int displayRedSize = displayInfo.getSize(PixelFormatInfo::INDEX_RED);
    int displayRedSize = displayInfo.getSize(PixelFormatInfo::INDEX_RED);
@@ -162,7 +160,6 @@ void Layer::reloadTexture(const Region& dirty)


#ifdef EGL_ANDROID_image_native_buffer
#ifdef EGL_ANDROID_image_native_buffer
    if (mFlags & DisplayHardware::DIRECT_TEXTURE) {
    if (mFlags & DisplayHardware::DIRECT_TEXTURE) {
        if (buffer->usage & GraphicBuffer::USAGE_HW_TEXTURE) {
        if (mTextures[index].dirty) {
        if (mTextures[index].dirty) {
            if (initializeEglImage(buffer, &mTextures[index]) != NO_ERROR) {
            if (initializeEglImage(buffer, &mTextures[index]) != NO_ERROR) {
                // not sure what we can do here...
                // not sure what we can do here...
@@ -170,86 +167,6 @@ void Layer::reloadTexture(const Region& dirty)
                goto slowpath;
                goto slowpath;
            }
            }
        }
        }
        } else {
            if (mHybridBuffer==0 || (mHybridBuffer->width != buffer->width ||
                    mHybridBuffer->height != buffer->height)) {
                mHybridBuffer.clear();
                mHybridBuffer = new GraphicBuffer(
                        buffer->width, buffer->height, buffer->format,
                        GraphicBuffer::USAGE_SW_WRITE_OFTEN |
                        GraphicBuffer::USAGE_HW_TEXTURE);
                if (initializeEglImage(
                        mHybridBuffer, &mTextures[0]) != NO_ERROR) {
                    // not sure what we can do here...
                    mFlags &= ~DisplayHardware::DIRECT_TEXTURE;
                    mHybridBuffer.clear();
                    goto slowpath;
                }
            }

            GGLSurface t;
            status_t res = buffer->lock(&t, GRALLOC_USAGE_SW_READ_OFTEN);
            LOGE_IF(res, "error %d (%s) locking buffer %p",
                    res, strerror(res), buffer.get());
            if (res == NO_ERROR) {
                Texture* const texture(&mTextures[0]);

                glBindTexture(GL_TEXTURE_2D, texture->name);

                sp<GraphicBuffer> buf(mHybridBuffer);
                void* vaddr;
                res = buf->lock(GraphicBuffer::USAGE_SW_WRITE_OFTEN, &vaddr);
                if (res == NO_ERROR) {
                    int bpp = 0;
                    switch (t.format) {
                    case HAL_PIXEL_FORMAT_RGB_565:
                    case HAL_PIXEL_FORMAT_RGBA_4444:
                        bpp = 2;
                        break;
                    case HAL_PIXEL_FORMAT_RGBA_8888:
                    case HAL_PIXEL_FORMAT_RGBX_8888:
                        bpp = 4;
                        break;
                    default:
                        if (isSupportedYuvFormat(t.format)) {
                            // just show the Y plane of YUV buffers
                            bpp = 1;
                            break;
                        }
                        // oops, we don't handle this format!
                        LOGE("layer %p, texture=%d, using format %d, which is not "
                                "supported by the GL", this, texture->name, t.format);
                    }
                    if (bpp) {
                        const Rect bounds(dirty.getBounds());
                        size_t src_stride = t.stride;
                        size_t dst_stride = buf->stride;
                        if (src_stride == dst_stride &&
                            bounds.width() == t.width &&
                            bounds.height() == t.height)
                        {
                            memcpy(vaddr, t.data, t.height * t.stride * bpp);
                        } else {
                            GLubyte const * src = t.data +
                                (bounds.left + bounds.top * src_stride) * bpp;
                            GLubyte * dst = (GLubyte *)vaddr +
                                (bounds.left + bounds.top * dst_stride) * bpp;
                            const size_t length = bounds.width() * bpp;
                            size_t h = bounds.height();
                            src_stride *= bpp;
                            dst_stride *= bpp;
                            while (h--) {
                                memcpy(dst, src, length);
                                dst += dst_stride;
                                src += src_stride;
                            }
                        }
                    }
                    buf->unlock();
                }
                buffer->unlock();
            }
        }
    } else
    } else
#endif
#endif
    {
    {
@@ -406,16 +323,9 @@ uint32_t Layer::getEffectiveUsage(uint32_t usage) const
    } else {
    } else {
        // it's allowed to modify the usage flags here, but generally
        // it's allowed to modify the usage flags here, but generally
        // the requested flags should be honored.
        // the requested flags should be honored.
        if (mNoEGLImageForSwBuffers) {
            if (usage & GraphicBuffer::USAGE_HW_MASK) {
                // request EGLImage for h/w buffers only
                usage |= GraphicBuffer::USAGE_HW_TEXTURE;
            }
        } else {
        // request EGLImage for all buffers
        // request EGLImage for all buffers
        usage |= GraphicBuffer::USAGE_HW_TEXTURE;
        usage |= GraphicBuffer::USAGE_HW_TEXTURE;
    }
    }
    }
    return usage;
    return usage;
}
}


+0 −2
Original line number Original line Diff line number Diff line
@@ -109,7 +109,6 @@ private:
    sp<Surface>             mSurface;
    sp<Surface>             mSurface;


            bool            mSecure;
            bool            mSecure;
            bool            mNoEGLImageForSwBuffers;
            int32_t         mFrontBufferIndex;
            int32_t         mFrontBufferIndex;
            bool            mNeedsBlending;
            bool            mNeedsBlending;
            bool            mNeedsDithering;
            bool            mNeedsDithering;
@@ -120,7 +119,6 @@ private:
            // protected by mLock
            // protected by mLock
            sp<GraphicBuffer> mBuffers[NUM_BUFFERS];
            sp<GraphicBuffer> mBuffers[NUM_BUFFERS];
            Texture         mTextures[NUM_BUFFERS];
            Texture         mTextures[NUM_BUFFERS];
            sp<GraphicBuffer> mHybridBuffer;
            uint32_t        mWidth;
            uint32_t        mWidth;
            uint32_t        mHeight;
            uint32_t        mHeight;