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

Commit 256fc043 authored by Mathias Agopian's avatar Mathias Agopian Committed by Android Git Automerger
Browse files

am 081bc5c4: fix [2793164] Spam 2x/second with TOT master in SurfaceFlinger

Merge commit '081bc5c4' into gingerbread-plus-aosp

* commit '081bc5c4':
  fix [2793164] Spam 2x/second with TOT master in SurfaceFlinger
parents b9353372 081bc5c4
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -6,6 +6,7 @@ LOCAL_SRC_FILES:= \
    DisplayHardware/DisplayHardware.cpp \
    DisplayHardware/DisplayHardware.cpp \
    DisplayHardware/DisplayHardwareBase.cpp \
    DisplayHardware/DisplayHardwareBase.cpp \
    BlurFilter.cpp.arm \
    BlurFilter.cpp.arm \
    GLExtensions.cpp \
    Layer.cpp \
    Layer.cpp \
    LayerBase.cpp \
    LayerBase.cpp \
    LayerBuffer.cpp \
    LayerBuffer.cpp \
+59 −74
Original line number Original line Diff line number Diff line
@@ -40,6 +40,8 @@
#include <hardware/overlay.h>
#include <hardware/overlay.h>
#include <hardware/gralloc.h>
#include <hardware/gralloc.h>


#include "GLExtensions.h"

using namespace android;
using namespace android;




@@ -73,7 +75,8 @@ void checkEGLErrors(const char* token)
DisplayHardware::DisplayHardware(
DisplayHardware::DisplayHardware(
        const sp<SurfaceFlinger>& flinger,
        const sp<SurfaceFlinger>& flinger,
        uint32_t dpy)
        uint32_t dpy)
    : DisplayHardwareBase(flinger, dpy), mFlags(0)
    : DisplayHardwareBase(flinger, dpy),
      mFlags(0)
{
{
    init(dpy);
    init(dpy);
}
}
@@ -97,6 +100,9 @@ void DisplayHardware::init(uint32_t dpy)
{
{
    mNativeWindow = new FramebufferNativeWindow();
    mNativeWindow = new FramebufferNativeWindow();
    framebuffer_device_t const * fbDev = mNativeWindow->getDevice();
    framebuffer_device_t const * fbDev = mNativeWindow->getDevice();
    mDpiX = mNativeWindow->xdpi;
    mDpiY = mNativeWindow->ydpi;
    mRefreshRate = fbDev->fps;


    mOverlayEngine = NULL;
    mOverlayEngine = NULL;
    hw_module_t const* module;
    hw_module_t const* module;
@@ -104,6 +110,11 @@ void DisplayHardware::init(uint32_t dpy)
        overlay_control_open(module, &mOverlayEngine);
        overlay_control_open(module, &mOverlayEngine);
    }
    }


    EGLint w, h, dummy;
    EGLint numConfigs=0;
    EGLSurface surface;
    EGLContext context;

    // initialize EGL
    // initialize EGL
    EGLint attribs[] = {
    EGLint attribs[] = {
            EGL_SURFACE_TYPE,   EGL_WINDOW_BIT,
            EGL_SURFACE_TYPE,   EGL_WINDOW_BIT,
@@ -121,11 +132,6 @@ void DisplayHardware::init(uint32_t dpy)
        }
        }
    }
    }


    EGLint w, h, dummy;
    EGLint numConfigs=0;
    EGLSurface surface;
    EGLContext context;

    // TODO: all the extensions below should be queried through
    // TODO: all the extensions below should be queried through
    // eglGetProcAddress().
    // eglGetProcAddress().


@@ -144,22 +150,6 @@ void DisplayHardware::init(uint32_t dpy)
    eglGetConfigAttrib(display, config, EGL_BLUE_SIZE,  &b);
    eglGetConfigAttrib(display, config, EGL_BLUE_SIZE,  &b);
    eglGetConfigAttrib(display, config, EGL_ALPHA_SIZE, &a);
    eglGetConfigAttrib(display, config, EGL_ALPHA_SIZE, &a);


    /*
     * Gather EGL extensions
     */

    const char* const egl_extensions = eglQueryString(
            display, EGL_EXTENSIONS);
    
    LOGI("EGL informations:");
    LOGI("# of configs : %d", numConfigs);
    LOGI("vendor    : %s", eglQueryString(display, EGL_VENDOR));
    LOGI("version   : %s", eglQueryString(display, EGL_VERSION));
    LOGI("extensions: %s", egl_extensions);
    LOGI("Client API: %s", eglQueryString(display, EGL_CLIENT_APIS)?:"Not Supported");
    LOGI("EGLSurface: %d-%d-%d-%d, config=%p", r, g, b, a, config);
    

    if (mNativeWindow->isUpdateOnDemand()) {
    if (mNativeWindow->isUpdateOnDemand()) {
        mFlags |= PARTIAL_UPDATES;
        mFlags |= PARTIAL_UPDATES;
    }
    }
@@ -174,6 +164,8 @@ void DisplayHardware::init(uint32_t dpy)
     */
     */


    surface = eglCreateWindowSurface(display, config, mNativeWindow.get(), NULL);
    surface = eglCreateWindowSurface(display, config, mNativeWindow.get(), NULL);
    eglQuerySurface(display, surface, EGL_WIDTH,  &mWidth);
    eglQuerySurface(display, surface, EGL_HEIGHT, &mHeight);


    if (mFlags & PARTIAL_UPDATES) {
    if (mFlags & PARTIAL_UPDATES) {
        // if we have partial updates, we definitely don't need to
        // if we have partial updates, we definitely don't need to
@@ -188,31 +180,6 @@ void DisplayHardware::init(uint32_t dpy)
        }
        }
    }
    }
    
    
    eglQuerySurface(display, surface, EGL_WIDTH,  &mWidth);
    eglQuerySurface(display, surface, EGL_HEIGHT, &mHeight);

#ifdef EGL_ANDROID_swap_rectangle    
    if (strstr(egl_extensions, "EGL_ANDROID_swap_rectangle")) {
        if (eglSetSwapRectangleANDROID(display, surface,
                0, 0, mWidth, mHeight) == EGL_TRUE) {
            // This could fail if this extension is not supported by this
            // specific surface (of config)
            mFlags |= SWAP_RECTANGLE;
        }
    }
    // when we have the choice between PARTIAL_UPDATES and SWAP_RECTANGLE
    // choose PARTIAL_UPDATES, which should be more efficient
    if (mFlags & PARTIAL_UPDATES)
        mFlags &= ~SWAP_RECTANGLE;
#endif
    

    LOGI("flags     : %08x", mFlags);
    
    mDpiX = mNativeWindow->xdpi;
    mDpiY = mNativeWindow->ydpi;
    mRefreshRate = fbDev->fps; 
    
    /* Read density from build-specific ro.sf.lcd_density property
    /* Read density from build-specific ro.sf.lcd_density property
     * except if it is overridden by qemu.sf.lcd_density.
     * except if it is overridden by qemu.sf.lcd_density.
     */
     */
@@ -234,49 +201,67 @@ void DisplayHardware::init(uint32_t dpy)
    
    
    context = eglCreateContext(display, config, NULL, NULL);
    context = eglCreateContext(display, config, NULL, NULL);
    
    
    mDisplay = display;
    mConfig  = config;
    mSurface = surface;
    mContext = context;
    mFormat  = fbDev->format;
    mPageFlipCount = 0;

    /*
    /*
     * Gather OpenGL ES extensions
     * Gather OpenGL ES extensions
     */
     */


    eglMakeCurrent(display, surface, surface, context);
    eglMakeCurrent(display, surface, surface, context);
    const char* const  gl_extensions = (const char*)glGetString(GL_EXTENSIONS);

    const char* const  gl_renderer = (const char*)glGetString(GL_RENDERER);
    GLExtensions& extensions(GLExtensions::getInstance());
    LOGI("OpenGL informations:");
    extensions.initWithGLStrings(
    LOGI("vendor    : %s", glGetString(GL_VENDOR));
            glGetString(GL_VENDOR),
    LOGI("renderer  : %s", gl_renderer);
            glGetString(GL_RENDERER),
    LOGI("version   : %s", glGetString(GL_VERSION));
            glGetString(GL_VERSION),
    LOGI("extensions: %s", gl_extensions);
            glGetString(GL_EXTENSIONS),
            eglQueryString(display, EGL_VENDOR),
            eglQueryString(display, EGL_VERSION),
            eglQueryString(display, EGL_EXTENSIONS));


    glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize);
    glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize);
    glGetIntegerv(GL_MAX_VIEWPORT_DIMS, &mMaxViewportDims);
    glGetIntegerv(GL_MAX_VIEWPORT_DIMS, &mMaxViewportDims);
    LOGI("GL_MAX_TEXTURE_SIZE = %d", mMaxTextureSize);
    LOGI("GL_MAX_VIEWPORT_DIMS = %d", mMaxViewportDims);




    if (strstr(gl_extensions, "GL_ARB_texture_non_power_of_two")) {
#ifdef EGL_ANDROID_swap_rectangle
        mFlags |= NPOT_EXTENSION;
    if (extensions.hasExtension("EGL_ANDROID_swap_rectangle")) {
        if (eglSetSwapRectangleANDROID(display, surface,
                0, 0, mWidth, mHeight) == EGL_TRUE) {
            // This could fail if this extension is not supported by this
            // specific surface (of config)
            mFlags |= SWAP_RECTANGLE;
        }
        }
#ifdef EGL_ANDROID_image_native_buffer
    if (strstr( gl_extensions, "GL_OES_EGL_image") &&
        (strstr(egl_extensions, "EGL_KHR_image_base") || 
                strstr(egl_extensions, "EGL_KHR_image")) &&
        strstr(egl_extensions, "EGL_ANDROID_image_native_buffer")) {
        mFlags |= DIRECT_TEXTURE;
    }
    }
#else
    // when we have the choice between PARTIAL_UPDATES and SWAP_RECTANGLE
#warning "EGL_ANDROID_image_native_buffer not supported"
    // choose PARTIAL_UPDATES, which should be more efficient
    if (mFlags & PARTIAL_UPDATES)
        mFlags &= ~SWAP_RECTANGLE;
#endif
#endif


    LOGI("EGL informations:");
    LOGI("# of configs : %d", numConfigs);
    LOGI("vendor    : %s", extensions.getEglVendor());
    LOGI("version   : %s", extensions.getEglVersion());
    LOGI("extensions: %s", extensions.getEglExtension());
    LOGI("Client API: %s", eglQueryString(display, EGL_CLIENT_APIS)?:"Not Supported");
    LOGI("EGLSurface: %d-%d-%d-%d, config=%p", r, g, b, a, config);

    LOGI("OpenGL informations:");
    LOGI("vendor    : %s", extensions.getVendor());
    LOGI("renderer  : %s", extensions.getRenderer());
    LOGI("version   : %s", extensions.getVersion());
    LOGI("extensions: %s", extensions.getExtension());
    LOGI("GL_MAX_TEXTURE_SIZE = %d", mMaxTextureSize);
    LOGI("GL_MAX_VIEWPORT_DIMS = %d", mMaxViewportDims);
    LOGI("flags = %08x", mFlags);


    // Unbind the context from this thread
    // Unbind the context from this thread
    eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
    eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);

    mDisplay = display;
    mConfig  = config;
    mSurface = surface;
    mContext = context;
    mFormat  = fbDev->format;
    mPageFlipCount = 0;
}
}


/*
/*
+7 −7
Original line number Original line Diff line number Diff line
@@ -29,6 +29,8 @@


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


#include "GLExtensions.h"

#include "DisplayHardware/DisplayHardwareBase.h"
#include "DisplayHardware/DisplayHardwareBase.h"


struct overlay_control_device_t;
struct overlay_control_device_t;
@@ -43,9 +45,7 @@ class DisplayHardware : public DisplayHardwareBase
{
{
public:
public:
    enum {
    enum {
        DIRECT_TEXTURE          = 0x00000002,
        COPY_BITS_EXTENSION         = 0x00000008,
        COPY_BITS_EXTENSION         = 0x00000008,
        NPOT_EXTENSION          = 0x00000100,
        BUFFER_PRESERVED            = 0x00010000,
        BUFFER_PRESERVED            = 0x00010000,
        PARTIAL_UPDATES             = 0x00020000,   // video driver feature
        PARTIAL_UPDATES             = 0x00020000,   // video driver feature
        SLOW_CONFIG                 = 0x00040000,   // software
        SLOW_CONFIG                 = 0x00040000,   // software
+133 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2010 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.
 */

#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>

#include "GLExtensions.h"

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

ANDROID_SINGLETON_STATIC_INSTANCE( GLExtensions )

GLExtensions::GLExtensions()
    : mHaveTextureExternal(false),
      mHaveNpot(false),
      mHaveDirectTexture(false)
{
}

void GLExtensions::initWithGLStrings(
        GLubyte const* vendor,
        GLubyte const* renderer,
        GLubyte const* version,
        GLubyte const* extensions,
        char const* egl_vendor,
        char const* egl_version,
        char const* egl_extensions)
{
    mVendor     = (char const*)vendor;
    mRenderer   = (char const*)renderer;
    mVersion    = (char const*)version;
    mExtensions = (char const*)extensions;
    mEglVendor     = egl_vendor;
    mEglVersion    = egl_version;
    mEglExtensions = egl_extensions;

    char const* curr = (char const*)extensions;
    char const* head = curr;
    do {
        head = strchr(curr, ' ');
        String8 s(curr, head ? head-curr : strlen(curr));
        if (s.length()) {
            mExtensionList.add(s);
        }
        curr = head+1;
    } while (head);

    curr = egl_extensions;
    head = curr;
    do {
        head = strchr(curr, ' ');
        String8 s(curr, head ? head-curr : strlen(curr));
        if (s.length()) {
            mExtensionList.add(s);
        }
        curr = head+1;
    } while (head);

#ifdef EGL_ANDROID_image_native_buffer
    if (hasExtension("GL_OES_EGL_image") &&
        (hasExtension("EGL_KHR_image_base") || hasExtension("EGL_KHR_image")) &&
        hasExtension("EGL_ANDROID_image_native_buffer"))
    {
        mHaveDirectTexture = true;
    }
#else
#warning "EGL_ANDROID_image_native_buffer not supported"
#endif

    if (hasExtension("GL_ARB_texture_non_power_of_two")) {
        mHaveNpot = true;
    }

    if (hasExtension("GL_OES_texture_external")) {
        mHaveTextureExternal = true;
    } else if (strstr(mRenderer.string(), "Adreno")) {
        // hack for Adreno 200
        mHaveTextureExternal = true;
    }
}

bool GLExtensions::hasExtension(char const* extension) const
{
    const String8 s(extension);
    return mExtensionList.indexOf(s) >= 0;
}

char const* GLExtensions::getVendor() const {
    return mVendor.string();
}

char const* GLExtensions::getRenderer() const {
    return mRenderer.string();
}

char const* GLExtensions::getVersion() const {
    return mVersion.string();
}

char const* GLExtensions::getExtension() const {
    return mExtensions.string();
}

char const* GLExtensions::getEglVendor() const {
    return mEglVendor.string();
}

char const* GLExtensions::getEglVersion() const {
    return mEglVersion.string();
}

char const* GLExtensions::getEglExtension() const {
    return mEglExtensions.string();
}


// ---------------------------------------------------------------------------
}; // namespace android
+94 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2010 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_SF_GLEXTENSION_H
#define ANDROID_SF_GLEXTENSION_H

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

#include <utils/String8.h>
#include <utils/SortedVector.h>
#include <utils/Singleton.h>

#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <GLES/gl.h>
#include <GLES/glext.h>

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

class GLExtensions : public Singleton<GLExtensions>
{
    friend class Singleton<GLExtensions>;

    bool mHaveTextureExternal   : 1;
    bool mHaveNpot              : 1;
    bool mHaveDirectTexture     : 1;

    String8 mVendor;
    String8 mRenderer;
    String8 mVersion;
    String8 mExtensions;
    String8 mEglVendor;
    String8 mEglVersion;
    String8 mEglExtensions;
    SortedVector<String8> mExtensionList;

    GLExtensions(const GLExtensions&);
    GLExtensions& operator = (const GLExtensions&);

protected:
    GLExtensions();

public:
    inline bool haveTextureExternal() const {
        return mHaveTextureExternal;
    }
    inline bool haveNpot() const {
        return mHaveNpot;
    }
    inline bool haveDirectTexture() const {
        return mHaveDirectTexture;
    }

    void initWithGLStrings(
            GLubyte const* vendor,
            GLubyte const* renderer,
            GLubyte const* version,
            GLubyte const* extensions,
            char const* egl_vendor,
            char const* egl_version,
            char const* egl_extensions);

    char const* getVendor() const;
    char const* getRenderer() const;
    char const* getVersion() const;
    char const* getExtension() const;

    char const* getEglVendor() const;
    char const* getEglVersion() const;
    char const* getEglExtension() const;

    bool hasExtension(char const* extension) const;
};


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

#endif // ANDROID_SF_GLEXTENSION_H
Loading