OSDN Git Service

Merge changes I8283a989,I64add89a into klp-dev
authorMathias Agopian <mathias@google.com>
Sat, 31 Aug 2013 01:30:10 +0000 (01:30 +0000)
committerAndroid (Google) Code Review <android-gerrit@google.com>
Sat, 31 Aug 2013 01:30:10 +0000 (01:30 +0000)
* changes:
  switch to use mat4
  vector and matrix classes for graphics use

16 files changed:
libs/gui/BufferQueue.cpp
opengl/libs/Android.mk
opengl/libs/EGL/Loader.cpp
opengl/libs/EGL/eglApi.cpp
opengl/libs/EGL/egl_display.cpp
services/surfaceflinger/DisplayDevice.cpp
services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp
services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h
services/surfaceflinger/Layer.cpp
services/surfaceflinger/RenderEngine/GLES11RenderEngine.cpp
services/surfaceflinger/RenderEngine/GLES11RenderEngine.h
services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp
services/surfaceflinger/RenderEngine/GLES20RenderEngine.h
services/surfaceflinger/RenderEngine/RenderEngine.cpp
services/surfaceflinger/RenderEngine/RenderEngine.h
services/surfaceflinger/SurfaceFlinger.cpp

index 65007fa..57a41f2 100644 (file)
@@ -637,7 +637,8 @@ void BufferQueue::cancelBuffer(int buf, const sp<Fence>& fence) {
 
 status_t BufferQueue::connect(int api, bool producerControlledByApp, QueueBufferOutput* output) {
     ATRACE_CALL();
-    ST_LOGV("connect: api=%d", api);
+    ST_LOGV("connect: api=%d producerControlledByApp=%s", api,
+            producerControlledByApp ? "true" : "false");
     Mutex::Autolock lock(mMutex);
 
     if (mAbandoned) {
@@ -1001,7 +1002,8 @@ status_t BufferQueue::releaseBuffer(
 
 status_t BufferQueue::consumerConnect(const sp<IConsumerListener>& consumerListener,
         bool controlledByApp) {
-    ST_LOGV("consumerConnect");
+    ST_LOGV("consumerConnect controlledByApp=%s",
+            controlledByApp ? "true" : "false");
     Mutex::Autolock lock(mMutex);
 
     if (mAbandoned) {
index b4756dd..528b983 100644 (file)
@@ -48,16 +48,9 @@ LOCAL_CFLAGS += -DEGL_TRACE=1
 ifeq ($(BOARD_ALLOW_EGL_HIBERNATION),true)
   LOCAL_CFLAGS += -DBOARD_ALLOW_EGL_HIBERNATION
 endif
-
-ifeq ($(TARGET_BOARD_PLATFORM),msm7k)
-  LOCAL_CFLAGS += -DADRENO130=1
-endif
-
-ifeq ($(TARGET_BOARD_PLATFORM), s5pc110)
-  # see Loader.cpp for details
-  LOCAL_CFLAGS += -DSYSTEMUI_PBSIZE_HACK=1
+ifeq ($(TARGET_BOARD_PLATFORM), omap4)
+  LOCAL_CFLAGS += -DWORKAROUND_BUG_10194508=1
 endif
-
 ifneq ($(MAX_EGL_CACHE_ENTRY_SIZE),)
   LOCAL_CFLAGS += -DMAX_EGL_CACHE_ENTRY_SIZE=$(MAX_EGL_CACHE_ENTRY_SIZE)
 endif
index beaa560..02914a0 100644 (file)
@@ -374,35 +374,6 @@ void *Loader::load_driver(const char* kind,
         ALOGE_IF(!getProcAddress,
                 "can't find eglGetProcAddress() in %s", driver_absolute_path);
 
-#ifdef SYSTEMUI_PBSIZE_HACK
-#warning "SYSTEMUI_PBSIZE_HACK enabled"
-        /*
-         * TODO: replace SYSTEMUI_PBSIZE_HACK by something less hackish
-         *
-         * Here we adjust the PB size from its default value to 512KB which
-         * is the minimum acceptable for the systemui process.
-         * We do this on low-end devices only because it allows us to enable
-         * h/w acceleration in the systemui process while keeping the
-         * memory usage down.
-         *
-         * Obviously, this is the wrong place and wrong way to make this
-         * adjustment, but at the time of this writing this was the safest
-         * solution.
-         */
-        const char *cmdline = getProcessCmdline();
-        if (strstr(cmdline, "systemui")) {
-            void *imgegl = dlopen("/vendor/lib/libIMGegl.so", RTLD_LAZY);
-            if (imgegl) {
-                unsigned int *PVRDefaultPBS =
-                        (unsigned int *)dlsym(imgegl, "PVRDefaultPBS");
-                if (PVRDefaultPBS) {
-                    ALOGD("setting default PBS to 512KB, was %d KB", *PVRDefaultPBS / 1024);
-                    *PVRDefaultPBS = 512*1024;
-                }
-            }
-        }
-#endif
-
         egl_t* egl = &cnx->egl;
         __eglMustCastToProperFunctionPointerType* curr =
             (__eglMustCastToProperFunctionPointerType*)egl;
index 7410c12..9d792fb 100644 (file)
@@ -413,7 +413,25 @@ EGLSurface eglCreateWindowSurface(  EGLDisplay dpy, EGLConfig config,
         // of our native format. So if sRGB gamma is requested, we have to
         // modify the EGLconfig's format before setting the native window's
         // format.
-
+#if WORKAROUND_BUG_10194508
+#warning "WORKAROUND_10194508 enabled"
+        EGLint format;
+        if (!cnx->egl.eglGetConfigAttrib(iDpy, config, EGL_NATIVE_VISUAL_ID,
+                &format)) {
+            ALOGE("eglGetConfigAttrib(EGL_NATIVE_VISUAL_ID) failed: %#x",
+                    eglGetError());
+            format = 0;
+        }
+        if (attrib_list) {
+            for (const EGLint* attr = attrib_list; *attr != EGL_NONE;
+                    attr += 2) {
+                if (*attr == EGL_GL_COLORSPACE_KHR &&
+                        dp->haveExtension("EGL_KHR_gl_colorspace")) {
+                    format = modifyFormatColorspace(format, *(attr+1));
+                }
+            }
+        }
+#else
         // by default, just pick RGBA_8888
         EGLint format = HAL_PIXEL_FORMAT_RGBA_8888;
 
@@ -444,6 +462,7 @@ EGLSurface eglCreateWindowSurface(  EGLDisplay dpy, EGLConfig config,
                 }
             }
         }
+#endif
         if (format != 0) {
             int err = native_window_set_buffers_format(window, format);
             if (err != 0) {
index 0380521..26240f1 100644 (file)
@@ -150,21 +150,6 @@ EGLBoolean egl_display_t::initialize(EGLint *major, EGLint *minor) {
     cnx->major = -1;
     cnx->minor = -1;
     if (cnx->dso) {
-
-#if defined(ADRENO130)
-#warning "Adreno-130 eglInitialize() workaround"
-        /*
-         * The ADRENO 130 driver returns a different EGLDisplay each time
-         * eglGetDisplay() is called, but also makes the EGLDisplay invalid
-         * after eglTerminate() has been called, so that eglInitialize()
-         * cannot be called again. Therefore, we need to make sure to call
-         * eglGetDisplay() before calling eglInitialize();
-         */
-        if (i == IMPL_HARDWARE) {
-            disp[i].dpy = cnx->egl.eglGetDisplay(EGL_DEFAULT_DISPLAY);
-        }
-#endif
-
         EGLDisplay idpy = disp.dpy;
         if (cnx->egl.eglInitialize(idpy, &cnx->major, &cnx->minor)) {
             //ALOGD("initialized dpy=%p, ver=%d.%d, cnx=%p",
index 9708ee3..61a9361 100644 (file)
@@ -271,9 +271,9 @@ EGLBoolean DisplayDevice::makeCurrent(EGLDisplay dpy, EGLContext ctx) const {
         if (result == EGL_TRUE) {
             if (mType >= DisplayDevice::DISPLAY_VIRTUAL)
                 eglSwapInterval(dpy, 0);
-            setViewportAndProjection();
         }
     }
+    setViewportAndProjection();
     return result;
 }
 
index 01ca38a..43d27bb 100644 (file)
@@ -175,9 +175,12 @@ void VirtualDisplaySurface::onFrameCommitted() {
         sp<Fence> outFence = mHwc.getLastRetireFence(mDisplayId);
         VDS_LOGV("onFrameCommitted: queue sink sslot=%d", sslot);
         status_t result = mSource[SOURCE_SINK]->queueBuffer(sslot,
-                QueueBufferInput(systemTime(), false,
+                QueueBufferInput(
+                    systemTime(), false /* isAutoTimestamp */,
                     Rect(mSinkBufferWidth, mSinkBufferHeight),
-                    NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false, outFence),
+                    NATIVE_WINDOW_SCALING_MODE_FREEZE, 0 /* transform */,
+                    true /* async*/,
+                    outFence),
                 &qbo);
         if (result == NO_ERROR) {
             updateQueueBufferOutput(qbo);
@@ -205,7 +208,10 @@ status_t VirtualDisplaySurface::setBufferCount(int bufferCount) {
 }
 
 status_t VirtualDisplaySurface::dequeueBuffer(Source source,
-        uint32_t format, int* sslot, sp<Fence>* fence, bool async) {
+        uint32_t format, int* sslot, sp<Fence>* fence) {
+    // Don't let a slow consumer block us
+    bool async = (source == SOURCE_SINK);
+
     status_t result = mSource[source]->dequeueBuffer(sslot, fence, async,
             mSinkBufferWidth, mSinkBufferHeight, format, mProducerUsage);
     if (result < 0)
@@ -244,6 +250,7 @@ status_t VirtualDisplaySurface::dequeueBuffer(int* pslot, sp<Fence>* fence, bool
             "Unexpected dequeueBuffer() in %s state", dbgStateStr());
     mDbgState = DBG_STATE_GLES;
 
+    VDS_LOGW_IF(!async, "EGL called dequeueBuffer with !async despite eglSwapInterval(0)");
     VDS_LOGV("dequeueBuffer %dx%d fmt=%d usage=%#x", w, h, format, usage);
 
     status_t result = NO_ERROR;
@@ -275,7 +282,7 @@ status_t VirtualDisplaySurface::dequeueBuffer(int* pslot, sp<Fence>* fence, bool
         *fence = mOutputFence;
     } else {
         int sslot;
-        result = dequeueBuffer(source, format, &sslot, fence, async);
+        result = dequeueBuffer(source, format, &sslot, fence);
         if (result >= 0) {
             *pslot = mapSource2ProducerSlot(source, sslot);
         }
@@ -391,7 +398,7 @@ status_t VirtualDisplaySurface::refreshOutputBuffer() {
     }
 
     int sslot;
-    status_t result = dequeueBuffer(SOURCE_SINK, 0, &sslot, &mOutputFence, false);
+    status_t result = dequeueBuffer(SOURCE_SINK, 0, &sslot, &mOutputFence);
     if (result < 0)
         return result;
     mOutputProducerSlot = mapSource2ProducerSlot(SOURCE_SINK, sslot);
index 4ab80e4..536007e 100644 (file)
@@ -110,7 +110,7 @@ private:
     //
     static Source fbSourceForCompositionType(CompositionType type);
     status_t dequeueBuffer(Source source, uint32_t format,
-            int* sslot, sp<Fence>* fence, bool async);
+            int* sslot, sp<Fence>* fence);
     void updateQueueBufferOutput(const QueueBufferOutput& qbo);
     void resetPerFrameState();
     status_t refreshOutputBuffer();
index f867e86..56bddd6 100644 (file)
@@ -506,8 +506,10 @@ void Layer::onDraw(const sp<const DisplayDevice>& hw, const Region& clip) const
 void Layer::clearWithOpenGL(const sp<const DisplayDevice>& hw, const Region& clip,
         float red, float green, float blue, float alpha) const
 {
+    RenderEngine& engine(mFlinger->getRenderEngine());
     computeGeometry(hw, mMesh);
-    mFlinger->getRenderEngine().fillWithColor(mMesh, red, green, blue, alpha);
+    engine.setupFillWithColor(red, green, blue, alpha);
+    engine.drawMesh(mMesh);
 }
 
 void Layer::clearWithOpenGL(
index baa57e6..d0ae253 100644 (file)
@@ -209,18 +209,11 @@ void GLES11RenderEngine::unbindFramebuffer(uint32_t texName, uint32_t fbName) {
     glDeleteTextures(1, &texName);
 }
 
-void GLES11RenderEngine::fillWithColor(const Mesh& mesh, float r, float g, float b, float a) {
+void GLES11RenderEngine::setupFillWithColor(float r, float g, float b, float a) {
     glColor4f(r, g, b, a);
     glDisable(GL_TEXTURE_EXTERNAL_OES);
     glDisable(GL_TEXTURE_2D);
     glDisable(GL_BLEND);
-
-    glVertexPointer(mesh.getVertexSize(),
-            GL_FLOAT,
-            mesh.getByteStride(),
-            mesh.getPositions());
-
-    glDrawArrays(mesh.getPrimitive(), 0, mesh.getVertexCount());
 }
 
 void GLES11RenderEngine::drawMesh(const Mesh& mesh) {
index 90fc82f..1de0443 100644 (file)
@@ -54,10 +54,10 @@ protected:
     virtual void setupDimLayerBlending(int alpha);
     virtual void setupLayerTexturing(const Texture& texture);
     virtual void setupLayerBlackedOut();
+    virtual void setupFillWithColor(float r, float g, float b, float a) ;
     virtual void disableTexturing();
     virtual void disableBlending();
 
-    virtual void fillWithColor(const Mesh& mesh, float r, float g, float b, float a) ;
     virtual void drawMesh(const Mesh& mesh);
 
     virtual size_t getMaxTextureSize() const;
index 0979647..9754758 100644 (file)
@@ -170,20 +170,13 @@ void GLES20RenderEngine::unbindFramebuffer(uint32_t texName, uint32_t fbName) {
     glDeleteTextures(1, &texName);
 }
 
-void GLES20RenderEngine::fillWithColor(const Mesh& mesh, float r, float g, float b, float a) {
+void GLES20RenderEngine::setupFillWithColor(float r, float g, float b, float a) {
+    mState.setPlaneAlpha(1.0f);
+    mState.setPremultipliedAlpha(true);
+    mState.setOpaque(false);
     mState.setColor(r, g, b, a);
-    disableTexturing();
+    mState.disableTexture();
     glDisable(GL_BLEND);
-
-    ProgramCache::getInstance().useProgram(mState);
-
-    glVertexAttribPointer(Program::position,
-            mesh.getVertexSize(),
-            GL_FLOAT, GL_FALSE,
-            mesh.getByteStride(),
-            mesh.getPositions());
-
-    glDrawArrays(mesh.getPrimitive(), 0, mesh.getVertexCount());
 }
 
 void GLES20RenderEngine::drawMesh(const Mesh& mesh) {
index 3ff6d9f..eb8f31a 100644 (file)
@@ -58,10 +58,10 @@ protected:
     virtual void setupDimLayerBlending(int alpha);
     virtual void setupLayerTexturing(const Texture& texture);
     virtual void setupLayerBlackedOut();
+    virtual void setupFillWithColor(float r, float g, float b, float a);
     virtual void disableTexturing();
     virtual void disableBlending();
 
-    virtual void fillWithColor(const Mesh& mesh, float r, float g, float b, float a);
     virtual void drawMesh(const Mesh& mesh);
 
     virtual size_t getMaxTextureSize() const;
index 063be2e..2abda82 100644 (file)
@@ -164,7 +164,8 @@ void RenderEngine::fillRegionWithColor(const Region& region, uint32_t height,
         position[i*6 + 5].x = r->right;
         position[i*6 + 5].y = height - r->top;
     }
-    fillWithColor(mesh, red, green, blue, alpha);
+    setupFillWithColor(red, green, blue, alpha);
+    drawMesh(mesh);
 }
 
 void RenderEngine::clearWithColor(float red, float green, float blue, float alpha) {
index 82765c7..bc88b69 100644 (file)
@@ -87,12 +87,12 @@ public:
     virtual void setupDimLayerBlending(int alpha) = 0;
     virtual void setupLayerTexturing(const Texture& texture) = 0;
     virtual void setupLayerBlackedOut() = 0;
+    virtual void setupFillWithColor(float r, float g, float b, float a) = 0;
 
     virtual void disableTexturing() = 0;
     virtual void disableBlending() = 0;
 
     // drawing
-    virtual void fillWithColor(const Mesh& mesh, float r, float g, float b, float a) = 0;
     virtual void drawMesh(const Mesh& mesh) = 0;
 
     // queries
index 9fd3f25..0323cb7 100644 (file)
@@ -2726,6 +2726,7 @@ void SurfaceFlinger::renderScreenImplLocked(
 
     // compositionComplete is needed for older driver
     hw->compositionComplete();
+    hw->setViewportAndProjection();
 }
 
 
@@ -2805,8 +2806,6 @@ status_t SurfaceFlinger::captureScreenImplLocked(
         native_window_api_disconnect(window, NATIVE_WINDOW_API_EGL);
     }
 
-    hw->setViewportAndProjection();
-
     return result;
 }