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

Commit 0a3139a2 authored by Mathias Agopian's avatar Mathias Agopian
Browse files

fix a bug where copybit only renders in the first buffer when used with s/w GL

parent 7e2a937c
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@

#include <private/pixelflinger/ggl_context.h>
#include <hardware/copybit.h>
#include <hardware/gralloc.h>

#include <GLES/gl.h>
#include <GLES/glext.h>
@@ -600,9 +601,7 @@ struct copybits_context_t {
    copybit_device_t*       blitEngine;
    int32_t                 minScale;
    int32_t                 maxScale;
    // File descriptor of current drawing surface, if it's suitable for use as
    // a copybits destination, else -1.
    int                     drawSurfaceFd;
    buffer_handle_t         drawSurfaceBuffer;
};

struct ogles_context_t {
+1 −1
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ void EGLTextureObject::init()
    generate_mipmap = GL_FALSE;
    direct = GL_FALSE;
#ifdef LIBAGL_USE_GRALLOC_COPYBITS
    copybits_fd = -1;
    try_copybit = false;
#endif // LIBAGL_USE_GRALLOC_COPYBITS
    buffer = 0;
}
+1 −1
Original line number Diff line number Diff line
@@ -80,7 +80,7 @@ public:
    GLint               generate_mipmap;
    GLint               direct;
#ifdef LIBAGL_USE_GRALLOC_COPYBITS
    int                 copybits_fd;
    bool                try_copybit;
#endif // LIBAGL_USE_GRALLOC_COPYBITS
    android_native_buffer_t* buffer;
};
+17 −10
Original line number Diff line number Diff line
@@ -27,23 +27,28 @@
#include "primitives.h"
#include "texture.h"
#include "BufferObjectManager.h"

#include "TextureObjectManager.h"

#include <hardware/gralloc.h>
#include <hardware/copybit.h>
#include <private/ui/android_natives_priv.h>
#include "gralloc_priv.h"

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

namespace android {

static void textureToCopyBitImage(const GGLSurface* surface, int fd, copybit_image_t* img) {
static void textureToCopyBitImage(
        const GGLSurface* surface, buffer_handle_t buffer, copybit_image_t* img) 
{
    // we know private_handle_t is good here
    private_handle_t* hnd = (private_handle_t*)buffer;
    img->w      = surface->stride;
    img->h      = surface->height;
    img->format = surface->format;
    img->offset = 0;
    img->offset = hnd->offset;
    img->base   = surface->data;
    img->fd     = fd;
    img->fd     = hnd->fd;
}

struct clipRectRegion : public copybit_region_t {
@@ -109,7 +114,7 @@ static inline int fixedToByte(GGLfixed val) {

static bool checkContext(ogles_context_t* c) {

	// By convenction copybitQuickCheckContext() has already returned true.
	// By convention copybitQuickCheckContext() has already returned true.
	// avoid checking the same information again.
	
    if (c->copybits.blitEngine == NULL
@@ -118,7 +123,7 @@ static bool checkContext(ogles_context_t* c) {
        return false;
    }

    // Note: The drawSurfaceFd is only set for destination
    // Note: The drawSurfaceBuffer is only set for destination
    // surfaces types that are supported by the hardware and
    // do not have an alpha channel. So we don't have to re-check that here.

@@ -237,18 +242,20 @@ static bool copybit(GLint x, GLint y,
    // LOGW("calling copybits");

    copybit_device_t* copybit = c->copybits.blitEngine;

    copybit_image_t dst;
    textureToCopyBitImage(&cbSurface, c->copybits.drawSurfaceFd, &dst);
    buffer_handle_t target_hnd = c->copybits.drawSurfaceBuffer;
    textureToCopyBitImage(&cbSurface, target_hnd, &dst);
    copybit_rect_t drect = {x, y, x+w, y+h};

    // we know private_handle_t is good here
    copybit_image_t src;
    textureToCopyBitImage(&textureObject->surface, textureObject->copybits_fd,
            &src);
    buffer_handle_t source_hnd = textureObject->buffer->handle;
    textureToCopyBitImage(&textureObject->surface, source_hnd, &src);
    copybit_rect_t srect = { Ucr, Vcr + Hcr, Ucr + Wcr, Vcr };

    copybit->set_parameter(copybit, COPYBIT_TRANSFORM, transform);
    copybit->set_parameter(copybit, COPYBIT_PLANE_ALPHA, planeAlpha);

    copybit->set_parameter(copybit, COPYBIT_DITHER,
            (enables & GGL_ENABLE_DITHER) ? COPYBIT_ENABLE : COPYBIT_DISABLE);

+2 −2
Original line number Diff line number Diff line
@@ -32,9 +32,9 @@ bool drawTrangleFanWithCopybit_impl(ogles_context_t* c, GLint first,
        GLsizei count);

inline bool copybitQuickCheckContext(ogles_context_t* c) {
        return  c->copybits.drawSurfaceFd >= 0
        return  c->copybits.drawSurfaceBuffer != 0
            && c->rasterizer.state.enabled_tmu == 1
            && c->textures.tmu[0].texture->copybits_fd >= 0;
            && c->textures.tmu[0].texture->try_copybit;
}

/*
Loading