Revert "fix [2793164] Spam 2x/second with TOT master in SurfaceFlinger"

This reverts commit 081bc5c47d.
This commit is contained in:
Andreas Huber
2010-06-25 09:25:19 -07:00
parent 357f8209f3
commit 330dd304a4
14 changed files with 144 additions and 380 deletions

View File

@@ -6,7 +6,6 @@ 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 \

View File

@@ -40,8 +40,6 @@
#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;
@@ -75,8 +73,7 @@ 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), : DisplayHardwareBase(flinger, dpy), mFlags(0)
mFlags(0)
{ {
init(dpy); init(dpy);
} }
@@ -100,9 +97,6 @@ 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;
@@ -110,11 +104,6 @@ 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,
@@ -132,6 +121,11 @@ 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().
@@ -150,6 +144,22 @@ 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;
} }
@@ -164,8 +174,6 @@ 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
@@ -179,6 +187,31 @@ void DisplayHardware::init(uint32_t dpy)
mFlags |= BUFFER_PRESERVED; mFlags |= BUFFER_PRESERVED;
} }
} }
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.
@@ -201,67 +234,49 @@ void DisplayHardware::init(uint32_t dpy)
context = eglCreateContext(display, config, NULL, NULL); context = eglCreateContext(display, config, NULL, NULL);
/*
* Gather OpenGL ES extensions
*/
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);
LOGI("OpenGL informations:");
LOGI("vendor : %s", glGetString(GL_VENDOR));
LOGI("renderer : %s", gl_renderer);
LOGI("version : %s", glGetString(GL_VERSION));
LOGI("extensions: %s", gl_extensions);
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize);
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")) {
mFlags |= NPOT_EXTENSION;
}
#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
#warning "EGL_ANDROID_image_native_buffer not supported"
#endif
// Unbind the context from this thread
eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
mDisplay = display; mDisplay = display;
mConfig = config; mConfig = config;
mSurface = surface; mSurface = surface;
mContext = context; mContext = context;
mFormat = fbDev->format; mFormat = fbDev->format;
mPageFlipCount = 0; mPageFlipCount = 0;
/*
* Gather OpenGL ES extensions
*/
eglMakeCurrent(display, surface, surface, context);
GLExtensions& extensions(GLExtensions::getInstance());
extensions.initWithGLStrings(
glGetString(GL_VENDOR),
glGetString(GL_RENDERER),
glGetString(GL_VERSION),
glGetString(GL_EXTENSIONS),
eglQueryString(display, EGL_VENDOR),
eglQueryString(display, EGL_VERSION),
eglQueryString(display, EGL_EXTENSIONS));
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize);
glGetIntegerv(GL_MAX_VIEWPORT_DIMS, &mMaxViewportDims);
#ifdef EGL_ANDROID_swap_rectangle
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;
}
}
// 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("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
eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
} }
/* /*

View File

@@ -29,8 +29,6 @@
#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;
@@ -45,11 +43,13 @@ class DisplayHardware : public DisplayHardwareBase
{ {
public: public:
enum { enum {
COPY_BITS_EXTENSION = 0x00000008, DIRECT_TEXTURE = 0x00000002,
BUFFER_PRESERVED = 0x00010000, COPY_BITS_EXTENSION = 0x00000008,
PARTIAL_UPDATES = 0x00020000, // video driver feature NPOT_EXTENSION = 0x00000100,
SLOW_CONFIG = 0x00040000, // software BUFFER_PRESERVED = 0x00010000,
SWAP_RECTANGLE = 0x00080000, PARTIAL_UPDATES = 0x00020000, // video driver feature
SLOW_CONFIG = 0x00040000, // software
SWAP_RECTANGLE = 0x00080000,
}; };
DisplayHardware( DisplayHardware(

View File

@@ -1,133 +0,0 @@
/*
* 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

View File

@@ -1,94 +0,0 @@
/*
* 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

View File

@@ -31,7 +31,6 @@
#include <surfaceflinger/Surface.h> #include <surfaceflinger/Surface.h>
#include "clz.h" #include "clz.h"
#include "GLExtensions.h"
#include "Layer.h" #include "Layer.h"
#include "SurfaceFlinger.h" #include "SurfaceFlinger.h"
#include "DisplayHardware/DisplayHardware.h" #include "DisplayHardware/DisplayHardware.h"
@@ -51,11 +50,10 @@ template <typename T> inline T min(T a, T b) {
Layer::Layer(SurfaceFlinger* flinger, Layer::Layer(SurfaceFlinger* flinger,
DisplayID display, const sp<Client>& client) DisplayID display, const sp<Client>& client)
: LayerBaseClient(flinger, display, client), : LayerBaseClient(flinger, display, client),
mGLExtensions(GLExtensions::getInstance()),
mNeedsBlending(true), mNeedsBlending(true),
mNeedsDithering(false), mNeedsDithering(false),
mSecure(false), mSecure(false),
mTextureManager(), mTextureManager(mFlags),
mBufferManager(mTextureManager), mBufferManager(mTextureManager),
mWidth(0), mHeight(0), mFixedSize(false) mWidth(0), mHeight(0), mFixedSize(false)
{ {
@@ -187,13 +185,17 @@ void Layer::reloadTexture(const Region& dirty)
return; return;
} }
if (mGLExtensions.haveDirectTexture()) { #ifdef EGL_ANDROID_image_native_buffer
if (mFlags & DisplayHardware::DIRECT_TEXTURE) {
EGLDisplay dpy(mFlinger->graphicPlane(0).getEGLDisplay()); EGLDisplay dpy(mFlinger->graphicPlane(0).getEGLDisplay());
if (mBufferManager.initEglImage(dpy, buffer) != NO_ERROR) { if (mBufferManager.initEglImage(dpy, buffer) != NO_ERROR) {
// not sure what we can do here... // not sure what we can do here...
mFlags &= ~DisplayHardware::DIRECT_TEXTURE;
goto slowpath; goto slowpath;
} }
} else { } else
#endif
{
slowpath: slowpath:
GGLSurface t; GGLSurface t;
status_t res = buffer->lock(&t, GRALLOC_USAGE_SW_READ_OFTEN); status_t res = buffer->lock(&t, GRALLOC_USAGE_SW_READ_OFTEN);
@@ -784,24 +786,19 @@ status_t Layer::BufferManager::initEglImage(EGLDisplay dpy,
status_t err = NO_INIT; status_t err = NO_INIT;
ssize_t index = mActiveBuffer; ssize_t index = mActiveBuffer;
if (index >= 0) { if (index >= 0) {
if (!mFailover) { Image& texture(mBufferData[index].texture);
Image& texture(mBufferData[index].texture); err = mTextureManager.initEglImage(&texture, dpy, buffer);
err = mTextureManager.initEglImage(&texture, dpy, buffer); // if EGLImage fails, we switch to regular texture mode, and we
// if EGLImage fails, we switch to regular texture mode, and we // free all resources associated with using EGLImages.
// free all resources associated with using EGLImages. if (err == NO_ERROR) {
if (err == NO_ERROR) { mFailover = false;
mFailover = false; destroyTexture(&mFailoverTexture, dpy);
destroyTexture(&mFailoverTexture, dpy);
} else {
mFailover = true;
const size_t num = mNumBuffers;
for (size_t i=0 ; i<num ; i++) {
destroyTexture(&mBufferData[i].texture, dpy);
}
}
} else { } else {
// we failed once, don't try again mFailover = true;
err = BAD_VALUE; const size_t num = mNumBuffers;
for (size_t i=0 ; i<num ; i++) {
destroyTexture(&mBufferData[i].texture, dpy);
}
} }
} }
return err; return err;

View File

@@ -37,10 +37,9 @@ namespace android {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
class FreezeLock;
class Client; class Client;
class GLExtensions;
class UserClient; class UserClient;
class FreezeLock;
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -207,7 +206,6 @@ private:
// constants // constants
sp<Surface> mSurface; sp<Surface> mSurface;
PixelFormat mFormat; PixelFormat mFormat;
const GLExtensions& mGLExtensions;
bool mNeedsBlending; bool mNeedsBlending;
bool mNeedsDithering; bool mNeedsDithering;

View File

@@ -147,9 +147,7 @@ void LayerBlur::onDraw(const Region& clip) const
Region::const_iterator const end = clip.end(); Region::const_iterator const end = clip.end();
if (it != end) { if (it != end) {
#if defined(GL_OES_texture_external) #if defined(GL_OES_texture_external)
if (GLExtensions::getInstance().haveTextureExternal()) { glDisable(GL_TEXTURE_EXTERNAL_OES);
glDisable(GL_TEXTURE_EXTERNAL_OES);
}
#endif #endif
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, mTextureName); glBindTexture(GL_TEXTURE_2D, mTextureName);
@@ -183,7 +181,7 @@ void LayerBlur::onDraw(const Region& clip) const
bl.data = (GGLubyte*)pixels; bl.data = (GGLubyte*)pixels;
blurFilter(&bl, 8, 2); blurFilter(&bl, 8, 2);
if (GLExtensions::getInstance().haveNpot()) { if (mFlags & (DisplayHardware::NPOT_EXTENSION)) {
glTexImage2D(GL_TEXTURE_2D, 0, mReadFormat, w, h, 0, glTexImage2D(GL_TEXTURE_2D, 0, mReadFormat, w, h, 0,
mReadFormat, mReadType, pixels); mReadFormat, mReadType, pixels);
mWidthScale = 1.0f / w; mWidthScale = 1.0f / w;

View File

@@ -315,7 +315,8 @@ void LayerBuffer::Source::unregisterBuffers() {
LayerBuffer::BufferSource::BufferSource(LayerBuffer& layer, LayerBuffer::BufferSource::BufferSource(LayerBuffer& layer,
const ISurface::BufferHeap& buffers) const ISurface::BufferHeap& buffers)
: Source(layer), mStatus(NO_ERROR), mBufferSize(0) : Source(layer), mStatus(NO_ERROR), mBufferSize(0),
mTextureManager(layer.mFlags)
{ {
if (buffers.heap == NULL) { if (buffers.heap == NULL) {
// this is allowed, but in this case, it is illegal to receive // this is allowed, but in this case, it is illegal to receive
@@ -373,11 +374,11 @@ LayerBuffer::BufferSource::~BufferSource()
if (mTexture.name != -1U) { if (mTexture.name != -1U) {
// GL textures can only be destroyed from the GL thread // GL textures can only be destroyed from the GL thread
getFlinger()->mEventQueue.postMessage( mLayer.mFlinger->mEventQueue.postMessage(
new MessageDestroyTexture(getFlinger(), mTexture.name) ); new MessageDestroyTexture(mLayer.mFlinger.get(), mTexture.name) );
} }
if (mTexture.image != EGL_NO_IMAGE_KHR) { if (mTexture.image != EGL_NO_IMAGE_KHR) {
EGLDisplay dpy(getFlinger()->graphicPlane(0).getEGLDisplay()); EGLDisplay dpy(mLayer.mFlinger->graphicPlane(0).getEGLDisplay());
eglDestroyImageKHR(dpy, mTexture.image); eglDestroyImageKHR(dpy, mTexture.image);
} }
} }
@@ -443,7 +444,7 @@ void LayerBuffer::BufferSource::onDraw(const Region& clip) const
const Rect transformedBounds(mLayer.getTransformedBounds()); const Rect transformedBounds(mLayer.getTransformedBounds());
#if defined(EGL_ANDROID_image_native_buffer) #if defined(EGL_ANDROID_image_native_buffer)
if (GLExtensions::getInstance().haveDirectTexture()) { if (mLayer.mFlags & DisplayHardware::DIRECT_TEXTURE) {
err = INVALID_OPERATION; err = INVALID_OPERATION;
if (ourBuffer->supportsCopybit()) { if (ourBuffer->supportsCopybit()) {
copybit_device_t* copybit = mLayer.mBlitEngine; copybit_device_t* copybit = mLayer.mBlitEngine;
@@ -548,7 +549,7 @@ status_t LayerBuffer::BufferSource::initTempBuffer() const
dst.crop.r = w; dst.crop.r = w;
dst.crop.b = h; dst.crop.b = h;
EGLDisplay dpy(getFlinger()->graphicPlane(0).getEGLDisplay()); EGLDisplay dpy(mLayer.mFlinger->graphicPlane(0).getEGLDisplay());
err = mTextureManager.initEglImage(&mTexture, dpy, buffer); err = mTextureManager.initEglImage(&mTexture, dpy, buffer);
} }
@@ -558,7 +559,7 @@ status_t LayerBuffer::BufferSource::initTempBuffer() const
void LayerBuffer::BufferSource::clearTempBufferImage() const void LayerBuffer::BufferSource::clearTempBufferImage() const
{ {
// delete the image // delete the image
EGLDisplay dpy(getFlinger()->graphicPlane(0).getEGLDisplay()); EGLDisplay dpy(mLayer.mFlinger->graphicPlane(0).getEGLDisplay());
eglDestroyImageKHR(dpy, mTexture.image); eglDestroyImageKHR(dpy, mTexture.image);
// and the associated texture (recreate a name) // and the associated texture (recreate a name)
@@ -575,7 +576,7 @@ LayerBuffer::OverlaySource::OverlaySource(LayerBuffer& layer,
: Source(layer), mVisibilityChanged(false), : Source(layer), mVisibilityChanged(false),
mOverlay(0), mOverlayHandle(0), mOverlayDevice(0), mOrientation(orientation) mOverlay(0), mOverlayHandle(0), mOverlayDevice(0), mOrientation(orientation)
{ {
overlay_control_device_t* overlay_dev = getFlinger()->getOverlayEngine(); overlay_control_device_t* overlay_dev = mLayer.mFlinger->getOverlayEngine();
if (overlay_dev == NULL) { if (overlay_dev == NULL) {
// overlays not supported // overlays not supported
return; return;
@@ -606,7 +607,7 @@ LayerBuffer::OverlaySource::OverlaySource(LayerBuffer& layer,
*overlayRef = new OverlayRef(mOverlayHandle, channel, *overlayRef = new OverlayRef(mOverlayHandle, channel,
mWidth, mHeight, mFormat, mWidthStride, mHeightStride); mWidth, mHeight, mFormat, mWidthStride, mHeightStride);
getFlinger()->signalEvent(); mLayer.mFlinger->signalEvent();
} }
LayerBuffer::OverlaySource::~OverlaySource() LayerBuffer::OverlaySource::~OverlaySource()

View File

@@ -47,7 +47,6 @@ class LayerBuffer : public LayerBaseClient
virtual void postBuffer(ssize_t offset); virtual void postBuffer(ssize_t offset);
virtual void unregisterBuffers(); virtual void unregisterBuffers();
virtual void destroy() { } virtual void destroy() { }
SurfaceFlinger* getFlinger() const { return mLayer.mFlinger.get(); }
protected: protected:
LayerBuffer& mLayer; LayerBuffer& mLayer;
}; };

View File

@@ -112,17 +112,15 @@ void LayerDim::onDraw(const Region& clip) const
Region::const_iterator const end = clip.end(); Region::const_iterator const end = clip.end();
if (s.alpha>0 && (it != end)) { if (s.alpha>0 && (it != end)) {
const DisplayHardware& hw(graphicPlane(0).displayHardware()); const DisplayHardware& hw(graphicPlane(0).displayHardware());
const GLfloat alpha = s.alpha/255.0f; const GGLfixed alpha = (s.alpha << 16)/255;
const uint32_t fbHeight = hw.getHeight(); const uint32_t fbHeight = hw.getHeight();
glDisable(GL_DITHER); glDisable(GL_DITHER);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(0, 0, 0, alpha); glColor4x(0, 0, 0, alpha);
#if defined(GL_OES_texture_external) #if defined(GL_OES_texture_external)
if (GLExtensions::getInstance().haveTextureExternal()) { glDisable(GL_TEXTURE_EXTERNAL_OES);
glDisable(GL_TEXTURE_EXTERNAL_OES);
}
#endif #endif
#if defined(DIM_WITH_TEXTURE) && defined(EGL_ANDROID_image_native_buffer) #if defined(DIM_WITH_TEXTURE) && defined(EGL_ANDROID_image_native_buffer)
if (sUseTexture) { if (sUseTexture) {

View File

@@ -44,7 +44,6 @@
#include <GLES/gl.h> #include <GLES/gl.h>
#include "clz.h" #include "clz.h"
#include "GLExtensions.h"
#include "Layer.h" #include "Layer.h"
#include "LayerBlur.h" #include "LayerBlur.h"
#include "LayerBuffer.h" #include "LayerBuffer.h"
@@ -994,9 +993,7 @@ void SurfaceFlinger::drawWormhole() const
glTexCoordPointer(2, GL_SHORT, 0, tcoords); glTexCoordPointer(2, GL_SHORT, 0, tcoords);
glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY);
#if defined(GL_OES_texture_external) #if defined(GL_OES_texture_external)
if (GLExtensions::getInstance().haveTextureExternal()) { glDisable(GL_TEXTURE_EXTERNAL_OES);
glDisable(GL_TEXTURE_EXTERNAL_OES);
}
#endif #endif
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, mWormholeTexName); glBindTexture(GL_TEXTURE_2D, mWormholeTexName);

View File

@@ -30,15 +30,14 @@
#include "clz.h" #include "clz.h"
#include "DisplayHardware/DisplayHardware.h" #include "DisplayHardware/DisplayHardware.h"
#include "GLExtensions.h"
#include "TextureManager.h" #include "TextureManager.h"
namespace android { namespace android {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
TextureManager::TextureManager() TextureManager::TextureManager(uint32_t flags)
: mGLExtensions(GLExtensions::getInstance()) : mFlags(flags)
{ {
} }
@@ -86,11 +85,9 @@ status_t TextureManager::initTexture(Image* pImage, int32_t format)
GLenum target = GL_TEXTURE_2D; GLenum target = GL_TEXTURE_2D;
#if defined(GL_OES_texture_external) #if defined(GL_OES_texture_external)
if (GLExtensions::getInstance().haveTextureExternal()) { if (format && isSupportedYuvFormat(format)) {
if (format && isSupportedYuvFormat(format)) { target = GL_TEXTURE_EXTERNAL_OES;
target = GL_TEXTURE_EXTERNAL_OES; pImage->target = Texture::TEXTURE_EXTERNAL;
pImage->target = Texture::TEXTURE_EXTERNAL;
}
} }
#endif #endif
@@ -211,7 +208,7 @@ status_t TextureManager::loadTexture(Texture* texture,
/* /*
* round to POT if needed * round to POT if needed
*/ */
if (!mGLExtensions.haveNpot()) { if (!(mFlags & DisplayHardware::NPOT_EXTENSION)) {
texture->NPOTAdjust = true; texture->NPOTAdjust = true;
} }
@@ -297,19 +294,14 @@ status_t TextureManager::loadTexture(Texture* texture,
void TextureManager::activateTexture(const Texture& texture, bool filter) void TextureManager::activateTexture(const Texture& texture, bool filter)
{ {
const GLenum target = getTextureTarget(&texture); const GLenum target = getTextureTarget(&texture);
if (target == Texture::TEXTURE_2D) {
glBindTexture(GL_TEXTURE_2D, texture.name); glBindTexture(target, texture.name);
glEnable(GL_TEXTURE_2D); glEnable(target);
#if defined(GL_OES_texture_external) #if defined(GL_OES_texture_external)
if (GLExtensions::getInstance().haveTextureExternal()) { if (texture.target == Texture::TEXTURE_2D) {
glDisable(GL_TEXTURE_EXTERNAL_OES); glDisable(GL_TEXTURE_EXTERNAL_OES);
} } else {
#endif
}
#if defined(GL_OES_texture_external)
else {
glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture.name);
glEnable(GL_TEXTURE_EXTERNAL_OES);
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
} }
#endif #endif
@@ -327,9 +319,7 @@ void TextureManager::deactivateTextures()
{ {
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
#if defined(GL_OES_texture_external) #if defined(GL_OES_texture_external)
if (GLExtensions::getInstance().haveTextureExternal()) { glDisable(GL_TEXTURE_EXTERNAL_OES);
glDisable(GL_TEXTURE_EXTERNAL_OES);
}
#endif #endif
} }

View File

@@ -32,7 +32,6 @@ namespace android {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
class GLExtensions;
class GraphicBuffer; class GraphicBuffer;
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -62,7 +61,7 @@ struct Texture : public Image {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
class TextureManager { class TextureManager {
const GLExtensions& mGLExtensions; uint32_t mFlags;
static status_t initTexture(Image* texture, int32_t format); static status_t initTexture(Image* texture, int32_t format);
static status_t initTexture(Texture* texture); static status_t initTexture(Texture* texture);
static bool isSupportedYuvFormat(int format); static bool isSupportedYuvFormat(int format);
@@ -70,7 +69,7 @@ class TextureManager {
static GLenum getTextureTarget(const Image* pImage); static GLenum getTextureTarget(const Image* pImage);
public: public:
TextureManager(); TextureManager(uint32_t flags);
// load bitmap data into the active buffer // load bitmap data into the active buffer
status_t loadTexture(Texture* texture, status_t loadTexture(Texture* texture,