Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/api/current.xml b/api/current.xml
- index d6f2e87..6d9dded 100644
- --- a/api/current.xml
- +++ b/api/current.xml
- @@ -749,6 +749,17 @@
- visibility="public"
- >
- </field>
- +<field name="RAW_AUDIO"
- + type="java.lang.String"
- + transient="false"
- + volatile="false"
- + value=""android.permission.RAW_AUDIO""
- + static="true"
- + final="true"
- + deprecated="not deprecated"
- + visibility="public"
- +>
- +</field>
- <field name="READ_CALENDAR"
- type="java.lang.String"
- transient="false"
- @@ -24759,7 +24770,7 @@
- extends="java.lang.Object"
- abstract="false"
- static="false"
- - final="false"
- + final="true"
- deprecated="not deprecated"
- visibility="public"
- >
- @@ -24808,7 +24819,7 @@
- deprecated="not deprecated"
- visibility="public"
- >
- -<parameter name="name" type="java.lang.String">
- +<parameter name="uuid" type="java.util.UUID">
- </parameter>
- </method>
- <method name="getProfileGroups"
- @@ -24822,6 +24833,41 @@
- visibility="public"
- >
- </method>
- +<method name="getStatusBarIndicator"
- + return="boolean"
- + abstract="false"
- + native="false"
- + synchronized="false"
- + static="false"
- + final="false"
- + deprecated="not deprecated"
- + visibility="public"
- +>
- +</method>
- +<method name="getUuid"
- + return="java.util.UUID"
- + abstract="false"
- + native="false"
- + synchronized="false"
- + static="false"
- + final="false"
- + deprecated="not deprecated"
- + visibility="public"
- +>
- +</method>
- +<method name="setStatusBarIndicator"
- + return="void"
- + abstract="false"
- + native="false"
- + synchronized="false"
- + static="false"
- + final="false"
- + deprecated="not deprecated"
- + visibility="public"
- +>
- +<parameter name="newStatusBarIndicator" type="boolean">
- +</parameter>
- +</method>
- <method name="writeToParcel"
- return="void"
- abstract="false"
- @@ -24842,7 +24888,7 @@
- extends="java.lang.Object"
- abstract="false"
- static="false"
- - final="false"
- + final="true"
- deprecated="not deprecated"
- visibility="public"
- >
- @@ -24870,8 +24916,8 @@
- visibility="public"
- >
- </method>
- -<method name="getName"
- - return="java.lang.String"
- +<method name="getRingerMode"
- + return="android.app.ProfileGroup.Mode"
- abstract="false"
- native="false"
- synchronized="false"
- @@ -24881,8 +24927,8 @@
- visibility="public"
- >
- </method>
- -<method name="getRingerMode"
- - return="android.app.ProfileGroup.Mode"
- +<method name="getRingerOverride"
- + return="android.net.Uri"
- abstract="false"
- native="false"
- synchronized="false"
- @@ -24892,8 +24938,8 @@
- visibility="public"
- >
- </method>
- -<method name="getRingerOverride"
- - return="android.net.Uri"
- +<method name="getSoundMode"
- + return="android.app.ProfileGroup.Mode"
- abstract="false"
- native="false"
- synchronized="false"
- @@ -24903,8 +24949,8 @@
- visibility="public"
- >
- </method>
- -<method name="getSoundMode"
- - return="android.app.ProfileGroup.Mode"
- +<method name="getSoundOverride"
- + return="android.net.Uri"
- abstract="false"
- native="false"
- synchronized="false"
- @@ -24914,8 +24960,8 @@
- visibility="public"
- >
- </method>
- -<method name="getSoundOverride"
- - return="android.net.Uri"
- +<method name="getUuid"
- + return="java.util.UUID"
- abstract="false"
- native="false"
- synchronized="false"
- @@ -25022,12 +25068,25 @@
- synchronized="false"
- static="false"
- final="false"
- - deprecated="not deprecated"
- + deprecated="deprecated"
- visibility="public"
- >
- <parameter name="profileName" type="java.lang.String">
- </parameter>
- </method>
- +<method name="getProfile"
- + return="android.app.Profile"
- + abstract="false"
- + native="false"
- + synchronized="false"
- + static="false"
- + final="false"
- + deprecated="not deprecated"
- + visibility="public"
- +>
- +<parameter name="profileUuid" type="java.util.UUID">
- +</parameter>
- +</method>
- <method name="getProfileNames"
- return="java.lang.String[]"
- abstract="false"
- @@ -25050,6 +25109,32 @@
- visibility="public"
- >
- </method>
- +<method name="profileExists"
- + return="boolean"
- + abstract="false"
- + native="false"
- + synchronized="false"
- + static="false"
- + final="false"
- + deprecated="not deprecated"
- + visibility="public"
- +>
- +<parameter name="profileName" type="java.lang.String">
- +</parameter>
- +</method>
- +<method name="profileExists"
- + return="boolean"
- + abstract="false"
- + native="false"
- + synchronized="false"
- + static="false"
- + final="false"
- + deprecated="not deprecated"
- + visibility="public"
- +>
- +<parameter name="profileUuid" type="java.util.UUID">
- +</parameter>
- +</method>
- <method name="setActiveProfile"
- return="void"
- abstract="false"
- @@ -25057,12 +25142,25 @@
- synchronized="false"
- static="false"
- final="false"
- - deprecated="not deprecated"
- + deprecated="deprecated"
- visibility="public"
- >
- <parameter name="profileName" type="java.lang.String">
- </parameter>
- </method>
- +<method name="setActiveProfile"
- + return="void"
- + abstract="false"
- + native="false"
- + synchronized="false"
- + static="false"
- + final="false"
- + deprecated="not deprecated"
- + visibility="public"
- +>
- +<parameter name="profileUuid" type="java.util.UUID">
- +</parameter>
- +</method>
- </class>
- <class name="ProgressDialog"
- extends="android.app.AlertDialog"
- @@ -77381,7 +77479,7 @@
- type="float"
- transient="false"
- volatile="false"
- - value="0.001f"
- + value="0.0010f"
- static="true"
- final="true"
- deprecated="not deprecated"
- @@ -133143,6 +133241,50 @@
- </parameter>
- </method>
- </class>
- +<class name="MultiSelectListPreference"
- + extends="android.preference.ListPreference"
- + abstract="false"
- + static="false"
- + final="false"
- + deprecated="not deprecated"
- + visibility="public"
- +>
- +<constructor name="MultiSelectListPreference"
- + type="android.preference.MultiSelectListPreference"
- + static="false"
- + final="false"
- + deprecated="not deprecated"
- + visibility="public"
- +>
- +<parameter name="context" type="android.content.Context">
- +</parameter>
- +</constructor>
- +<constructor name="MultiSelectListPreference"
- + type="android.preference.MultiSelectListPreference"
- + static="false"
- + final="false"
- + deprecated="not deprecated"
- + visibility="public"
- +>
- +<parameter name="context" type="android.content.Context">
- +</parameter>
- +<parameter name="attrs" type="android.util.AttributeSet">
- +</parameter>
- +</constructor>
- +<method name="parseStoredValue"
- + return="java.lang.String[]"
- + abstract="false"
- + native="false"
- + synchronized="false"
- + static="true"
- + final="false"
- + deprecated="not deprecated"
- + visibility="public"
- +>
- +<parameter name="val" type="java.lang.CharSequence">
- +</parameter>
- +</method>
- +</class>
- <class name="Preference"
- extends="java.lang.Object"
- abstract="false"
- @@ -154288,6 +154430,17 @@
- visibility="public"
- >
- </method>
- +<method name="isDormancyRejected"
- + return="boolean"
- + abstract="false"
- + native="false"
- + synchronized="false"
- + static="true"
- + final="false"
- + deprecated="not deprecated"
- + visibility="public"
- +>
- +</method>
- <method name="isNetworkRoaming"
- return="boolean"
- abstract="false"
- @@ -154314,6 +154467,19 @@
- <parameter name="events" type="int">
- </parameter>
- </method>
- +<method name="setDormancyRejected"
- + return="boolean"
- + abstract="false"
- + native="false"
- + synchronized="false"
- + static="true"
- + final="false"
- + deprecated="not deprecated"
- + visibility="public"
- +>
- +<parameter name="rejected" type="boolean">
- +</parameter>
- +</method>
- <field name="ACTION_PHONE_STATE_CHANGED"
- type="java.lang.String"
- transient="false"
- diff --git a/include/ui/GraphicBuffer.h b/include/ui/GraphicBuffer.h
- index 0be26a7..0574fac 100644
- --- a/include/ui/GraphicBuffer.h
- +++ b/include/ui/GraphicBuffer.h
- @@ -150,6 +150,8 @@ private:
- GraphicBufferMapper& mBufferMapper;
- ssize_t mInitCheck;
- int mIndex;
- +public:
- + unsigned int mTexId;
- };
- }; // namespace android
- diff --git a/include/ui/GraphicBufferAllocator.h b/include/ui/GraphicBufferAllocator.h
- index dffa788..ae38d90 100644
- --- a/include/ui/GraphicBufferAllocator.h
- +++ b/include/ui/GraphicBufferAllocator.h
- @@ -63,13 +63,16 @@ public:
- status_t alloc(uint32_t w, uint32_t h, PixelFormat format, int usage,
- - buffer_handle_t* handle, int32_t* stride);
- + buffer_handle_t* handle, int32_t* stride, unsigned int* text);
- status_t free(buffer_handle_t handle);
- void dump(String8& res) const;
- static void dumpToSystemLog();
- + static ogl_alloc_t ogl_alloc;
- + static ogl_free_t ogl_free;
- +
- private:
- struct alloc_rec_t {
- uint32_t w;
- diff --git a/libs/surfaceflinger_client/ISurface.cpp b/libs/surfaceflinger_client/ISurface.cpp
- index bdf3277..7f75d9d 100644
- --- a/libs/surfaceflinger_client/ISurface.cpp
- +++ b/libs/surfaceflinger_client/ISurface.cpp
- @@ -81,6 +81,7 @@ public:
- data.writeInt32(h);
- data.writeInt32(format);
- data.writeInt32(usage);
- + LOGW("Calling remote request buffer");
- remote()->transact(REQUEST_BUFFER, data, &reply);
- sp<GraphicBuffer> buffer = new GraphicBuffer();
- reply.read(*buffer);
- diff --git a/libs/surfaceflinger_client/Surface.cpp b/libs/surfaceflinger_client/Surface.cpp
- index 017e94c..e3e5951 100644
- --- a/libs/surfaceflinger_client/Surface.cpp
- +++ b/libs/surfaceflinger_client/Surface.cpp
- @@ -1061,6 +1061,7 @@ status_t Surface::getBufferLocked(int index,
- }
- } else {
- err = err<0 ? err : status_t(NO_MEMORY);
- + LOGE("Err: %d, handle %p", err, buffer->handle);
- }
- }
- return err;
- diff --git a/libs/ui/FramebufferNativeWindow.cpp b/libs/ui/FramebufferNativeWindow.cpp
- index 6360e39..985221f 100644
- --- a/libs/ui/FramebufferNativeWindow.cpp
- +++ b/libs/ui/FramebufferNativeWindow.cpp
- @@ -136,14 +136,14 @@ FramebufferNativeWindow::FramebufferNativeWindow()
- err = grDev->alloc(grDev,
- fbDev->width, fbDev->height, fbDev->format,
- - GRALLOC_USAGE_HW_FB, &buffers[0]->handle, &buffers[0]->stride);
- + GRALLOC_USAGE_HW_FB, &buffers[0]->handle, &buffers[0]->stride, NULL, NULL, NULL);
- LOGE_IF(err, "fb buffer 0 allocation failed w=%d, h=%d, err=%s",
- fbDev->width, fbDev->height, strerror(-err));
- err = grDev->alloc(grDev,
- fbDev->width, fbDev->height, fbDev->format,
- - GRALLOC_USAGE_HW_FB, &buffers[1]->handle, &buffers[1]->stride);
- + GRALLOC_USAGE_HW_FB, &buffers[1]->handle, &buffers[1]->stride, NULL, NULL, NULL);
- LOGE_IF(err, "fb buffer 1 allocation failed w=%d, h=%d, err=%s",
- fbDev->width, fbDev->height, strerror(-err));
- @@ -363,6 +363,8 @@ int FramebufferNativeWindow::queueBuffer(ANativeWindow* window,
- GraphicLog& logger(GraphicLog::getInstance());
- logger.log(GraphicLog::SF_FB_POST_BEFORE, index);
- + LOGE("post");
- +
- int res = fb->post(fb, handle);
- logger.log(GraphicLog::SF_FB_POST_AFTER, index);
- diff --git a/libs/ui/GraphicBuffer.cpp b/libs/ui/GraphicBuffer.cpp
- index 3671954..b4074c0 100644
- --- a/libs/ui/GraphicBuffer.cpp
- +++ b/libs/ui/GraphicBuffer.cpp
- @@ -134,7 +134,8 @@ status_t GraphicBuffer::initSize(uint32_t w, uint32_t h, PixelFormat format,
- uint32_t reqUsage)
- {
- GraphicBufferAllocator& allocator = GraphicBufferAllocator::get();
- - status_t err = allocator.alloc(w, h, format, reqUsage, &handle, &stride);
- + status_t err = allocator.alloc(w, h, format, reqUsage, &handle, &stride, &mTexId);
- + LOGW("Called allocator: handle: 0x%08X", handle);
- if (err == NO_ERROR) {
- this->width = w;
- this->height = h;
- diff --git a/libs/ui/GraphicBufferAllocator.cpp b/libs/ui/GraphicBufferAllocator.cpp
- index cd802d6..8d1765c 100644
- --- a/libs/ui/GraphicBufferAllocator.cpp
- +++ b/libs/ui/GraphicBufferAllocator.cpp
- @@ -24,9 +24,21 @@
- #include <ui/GraphicBufferAllocator.h>
- +#include <GLES/gl.h>
- +
- #include <private/ui/sw_gralloc_handle.h>
- namespace android {
- +
- +void* ogl_alloc_tmp(int w, int h, int format)
- +{
- + LOGE("ogl_alloc used before surfaceflinger setup callback");
- + return NULL;
- +}
- +
- +ogl_alloc_t GraphicBufferAllocator::ogl_alloc;
- +ogl_free_t GraphicBufferAllocator::ogl_free;
- +
- // ---------------------------------------------------------------------------
- ANDROID_SINGLETON_STATIC_INSTANCE( GraphicBufferAllocator )
- @@ -44,6 +56,7 @@ GraphicBufferAllocator::GraphicBufferAllocator()
- if (err == 0) {
- gralloc_open(module, &mAllocDev);
- }
- +// ogl_alloc = ogl_alloc_tmp;
- }
- GraphicBufferAllocator::~GraphicBufferAllocator()
- @@ -81,7 +94,7 @@ void GraphicBufferAllocator::dumpToSystemLog()
- }
- status_t GraphicBufferAllocator::alloc(uint32_t w, uint32_t h, PixelFormat format,
- - int usage, buffer_handle_t* handle, int32_t* stride)
- + int usage, buffer_handle_t* handle, int32_t* stride, unsigned int *text)
- {
- // make sure to not allocate a N x 0 or 0 x N buffer, since this is
- // allowed from an API stand-point allocate a 1x1 buffer instead.
- @@ -90,8 +103,16 @@ status_t GraphicBufferAllocator::alloc(uint32_t w, uint32_t h, PixelFormat forma
- // we have a h/w allocator and h/w buffer is requested
- status_t err;
- -
- - err = mAllocDev->alloc(mAllocDev, w, h, format, usage, handle, stride);
- +
- + LOGW("alloc(%u, %u, %d, %08x, ...)",
- + w, h, format, usage);
- +
- + if (usage & GRALLOC_USAGE_HW_MASK) {
- + err = mAllocDev->alloc(mAllocDev, w, h, format, usage, handle, stride, text, ogl_alloc, ogl_free);
- + } else {
- + err = sw_gralloc_handle_t::alloc(w, h, format, usage, handle, stride);
- + }
- +
- LOGW_IF(err, "alloc(%u, %u, %d, %08x, ...) failed %d (%s)",
- w, h, format, usage, err, strerror(-err));
- diff --git a/services/audioflinger/Android.mk b/services/audioflinger/Android.mk
- index b33c2a8..41177f8 100644
- --- a/services/audioflinger/Android.mk
- +++ b/services/audioflinger/Android.mk
- @@ -35,6 +35,7 @@ endif
- LOCAL_MODULE:= libaudiointerface
- ifeq ($(BOARD_HAVE_BLUETOOTH),true)
- +khjakjsh
- LOCAL_SRC_FILES += A2dpAudioInterface.cpp
- LOCAL_SHARED_LIBRARIES += liba2dp
- LOCAL_CFLAGS += -DWITH_BLUETOOTH -DWITH_A2DP
- @@ -107,6 +108,7 @@ endif
- LOCAL_MODULE:= libaudioflinger
- ifeq ($(BOARD_HAVE_BLUETOOTH),true)
- +lkjlkj
- LOCAL_CFLAGS += -DWITH_BLUETOOTH -DWITH_A2DP
- LOCAL_SHARED_LIBRARIES += liba2dp
- ifeq ($(BOARD_FORCE_STATIC_A2DP),true)
- diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk
- index 853180d..1e6c7e6 100644
- --- a/services/surfaceflinger/Android.mk
- +++ b/services/surfaceflinger/Android.mk
- @@ -13,6 +13,7 @@ LOCAL_SRC_FILES:= \
- LayerBlur.cpp \
- LayerDim.cpp \
- MessageQueue.cpp \
- + OGLAlloc.cpp \
- SurfaceFlinger.cpp \
- TextureManager.cpp \
- Transform.cpp
- diff --git a/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp b/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp
- index 844cf18..8c70d2b 100644
- --- a/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp
- +++ b/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp
- @@ -94,7 +94,11 @@ int DisplayHardware::getWidth() const { return mWidth; }
- int DisplayHardware::getHeight() const { return mHeight; }
- PixelFormat DisplayHardware::getFormat() const { return mFormat; }
- uint32_t DisplayHardware::getMaxTextureSize() const { return mMaxTextureSize; }
- -uint32_t DisplayHardware::getMaxViewportDims() const { return mMaxViewportDims; }
- +uint32_t DisplayHardware::getMaxViewportDims() const {
- + if(mMaxViewportDims[0] > mMaxViewportDims[1])
- + return mMaxViewportDims[0];
- + return mMaxViewportDims[1];
- +}
- void DisplayHardware::init(uint32_t dpy)
- {
- @@ -235,7 +239,7 @@ void DisplayHardware::init(uint32_t dpy)
- eglQueryString(display, EGL_EXTENSIONS));
- glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize);
- - glGetIntegerv(GL_MAX_VIEWPORT_DIMS, &mMaxViewportDims);
- + glGetIntegerv(GL_MAX_VIEWPORT_DIMS, mMaxViewportDims);
- #ifdef EGL_ANDROID_swap_rectangle
- @@ -267,7 +271,7 @@ void DisplayHardware::init(uint32_t dpy)
- 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("GL_MAX_VIEWPORT_DIMS = %d x %d", mMaxViewportDims[0], mMaxViewportDims[1]);
- LOGI("flags = %08x", mFlags);
- // Unbind the context from this thread
- @@ -318,12 +322,12 @@ void DisplayHardware::flip(const Region& dirty) const
- EGLSurface surface = mSurface;
- #ifdef EGL_ANDROID_swap_rectangle
- - if (mFlags & SWAP_RECTANGLE) {
- + /* if (mFlags & SWAP_RECTANGLE) {
- const Region newDirty(dirty.intersect(bounds()));
- const Rect b(newDirty.getBounds());
- eglSetSwapRectangleANDROID(dpy, surface,
- b.left, b.top, b.width(), b.height());
- - }
- + } */
- #endif
- if (mFlags & PARTIAL_UPDATES) {
- @@ -332,20 +336,22 @@ void DisplayHardware::flip(const Region& dirty) const
- mPageFlipCount++;
- eglSwapBuffers(dpy, surface);
- +// framebuffer_device_t *fbDev = (framebuffer_device_t *)mNativeWindow->getDevice();
- +// fbDev->post(fbDev, handle);
- // glFinish here prevents the impedence mismatch between software-rendered
- // surfaceflinger surfaces in another thread. Shows no perf loss with vsync on.
- glFinish();
- checkEGLErrors("eglSwapBuffers");
- // for debugging
- - //glClearColor(1,0,0,0);
- - //glClear(GL_COLOR_BUFFER_BIT);
- +// glClearColor(1,0,0,0);
- +// glClear(GL_COLOR_BUFFER_BIT);
- }
- status_t DisplayHardware::postBypassBuffer(const native_handle_t* handle) const
- {
- framebuffer_device_t *fbDev = (framebuffer_device_t *)mNativeWindow->getDevice();
- - return fbDev->post(fbDev, handle);
- + return 0;//fbDev->post(fbDev, handle);
- }
- uint32_t DisplayHardware::getFlags() const
- diff --git a/services/surfaceflinger/DisplayHardware/DisplayHardware.h b/services/surfaceflinger/DisplayHardware/DisplayHardware.h
- index 79ef2a7..f6d2a28 100644
- --- a/services/surfaceflinger/DisplayHardware/DisplayHardware.h
- +++ b/services/surfaceflinger/DisplayHardware/DisplayHardware.h
- @@ -108,7 +108,7 @@ private:
- PixelFormat mFormat;
- uint32_t mFlags;
- mutable uint32_t mPageFlipCount;
- - GLint mMaxViewportDims;
- + GLint mMaxViewportDims[2];
- GLint mMaxTextureSize;
- sp<FramebufferNativeWindow> mNativeWindow;
- diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
- index e311ee5..bf33e44 100644
- --- a/services/surfaceflinger/Layer.cpp
- +++ b/services/surfaceflinger/Layer.cpp
- @@ -26,6 +26,7 @@
- #include <utils/StopWatch.h>
- #include <ui/GraphicBuffer.h>
- +#include <ui/GraphicBufferAllocator.h>
- #include <ui/PixelFormat.h>
- #include <surfaceflinger/Surface.h>
- @@ -196,26 +197,21 @@ void Layer::reloadTexture(const Region& dirty)
- return;
- }
- - if (mGLExtensions.haveDirectTexture()) {
- - EGLDisplay dpy(mFlinger->graphicPlane(0).getEGLDisplay());
- - if (mBufferManager.initEglImage(dpy, buffer) != NO_ERROR) {
- - // not sure what we can do here...
- - goto slowpath;
- - }
- - } else {
- -slowpath:
- - GGLSurface t;
- - if (buffer->usage & GRALLOC_USAGE_SW_READ_MASK) {
- + EGLDisplay dpy(mFlinger->graphicPlane(0).getEGLDisplay());
- + mBufferManager.initEglImage(dpy, buffer);
- + GGLSurface t;
- + if (buffer->usage & GRALLOC_USAGE_SW_READ_MASK) {
- 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) {
- - mBufferManager.loadTexture(dirty, t);
- + // mBufferManager.loadTexture(dirty, t);
- + // glBindTexture(GL_TEXTURE_2D, buffer->mTexId);
- +
- buffer->unlock();
- }
- - } else {
- - // we can't do anything
- - }
- + }else{
- + LOGE("Unable to load texture");
- }
- }
- @@ -229,6 +225,7 @@ void Layer::drawForSreenShot() const
- void Layer::onDraw(const Region& clip) const
- {
- + LOGW("Layer Draw");
- Texture tex(mBufferManager.getActiveTexture());
- if (tex.name == -1LU) {
- // the texture has not been created yet, this Layer has
- @@ -874,6 +871,8 @@ status_t Layer::BufferManager::destroy(EGLDisplay dpy)
- status_t Layer::BufferManager::initEglImage(EGLDisplay dpy,
- const sp<GraphicBuffer>& buffer)
- {
- +
- + LOGE("BufferManager: initEglImage");
- status_t err = NO_INIT;
- ssize_t index = mActiveBuffer;
- if (index >= 0) {
- @@ -885,21 +884,18 @@ status_t Layer::BufferManager::initEglImage(EGLDisplay dpy,
- // that is being used in initEglImage.
- // (e.g. dirty flag in texture)
- Mutex::Autolock _l(mLock);
- - Image& texture(mBufferData[index].texture);
- - err = mTextureManager.initEglImage(&texture, dpy, buffer);
- + err = mTextureManager.initEglImage(&mBufferData[index].texture, dpy, buffer);
- }
- - // if EGLImage fails, we switch to regular texture mode, and we
- - // free all resources associated with using EGLImages.
- if (err == NO_ERROR) {
- mFailover = false;
- 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{
- + mFailover = true;
- + const size_t num = mNumBuffers;
- + for (size_t i=0 ; i<num ; i++) {
- + destroyTexture(&mBufferData[i].texture, dpy);
- + }
- + }
- } else {
- // we failed once, don't try again
- err = BAD_VALUE;
- @@ -921,7 +917,7 @@ status_t Layer::BufferManager::destroyTexture(Image* tex, EGLDisplay dpy)
- tex->name = -1U;
- }
- if (tex->image != EGL_NO_IMAGE_KHR) {
- - eglDestroyImageKHR(dpy, tex->image);
- +// eglDestroyImageKHR(dpy, tex->image);
- tex->image = EGL_NO_IMAGE_KHR;
- }
- return NO_ERROR;
- diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
- index 2c4f756..5f7e088 100644
- --- a/services/surfaceflinger/Layer.h
- +++ b/services/surfaceflinger/Layer.h
- @@ -157,7 +157,7 @@ private:
- static const size_t NUM_BUFFERS = 2;
- struct BufferData {
- sp<GraphicBuffer> buffer;
- - Image texture;
- + Texture texture;
- };
- // this lock protect mBufferData[].buffer but since there
- // is very little contention, we have only one like for
- diff --git a/services/surfaceflinger/LayerBase.cpp b/services/surfaceflinger/LayerBase.cpp
- index 550030a..ab8ee63 100644
- --- a/services/surfaceflinger/LayerBase.cpp
- +++ b/services/surfaceflinger/LayerBase.cpp
- @@ -341,8 +341,13 @@ void LayerBase::clearWithOpenGL(const Region& clip, GLclampf red,
- TextureManager::deactivateTextures();
- + LOGW("clearWithOpengl");
- +
- glDisable(GL_BLEND);
- glDisable(GL_DITHER);
- +
- + // glClearColor(.2f,.4f,.3f,.5f);
- + // glClear(GL_COLOR_BUFFER_BIT);
- Region::const_iterator it = clip.begin();
- Region::const_iterator const end = clip.end();
- @@ -374,6 +379,8 @@ void LayerBase::drawWithOpenGL(const Region& clip, const Texture& texture) const
- const DisplayHardware& hw(graphicPlane(0).displayHardware());
- const uint32_t fbHeight = hw.getHeight();
- const State& s(drawingState());
- +
- + LOGW("DrawWithOpenGL");
- // bind our texture
- TextureManager::activateTexture(texture, needsFiltering());
- @@ -451,6 +458,17 @@ void LayerBase::drawWithOpenGL(const Region& clip, const Texture& texture) const
- glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, env);
- }
- + //TODO: this should be done a single time during texture setup. but it seems to get clobbered.
- + // find the smallest power-of-two that will accommodate our surface
- + int potWidth = 1 << (31 - clz(width));
- + int potHeight = 1 << (31 - clz(height));
- + if (potWidth < width) potWidth <<= 1;
- + if (potHeight < height) potHeight <<= 1;
- + float wScale = float(width) / potWidth;
- + float hScale = float(height) / potHeight;
- +
- + int NPOTAdjust = true;
- +
- /*
- * compute texture coordinates
- * here, we handle NPOT, cropping and buffer transformations
- @@ -459,8 +477,8 @@ void LayerBase::drawWithOpenGL(const Region& clip, const Texture& texture) const
- GLfloat cl, ct, cr, cb;
- if (!mBufferCrop.isEmpty()) {
- // source is cropped
- - const GLfloat us = (texture.NPOTAdjust ? texture.wScale : 1.0f) / width;
- - const GLfloat vs = (texture.NPOTAdjust ? texture.hScale : 1.0f) / height;
- + const GLfloat us = (NPOTAdjust ? wScale : 1.0f) / width;
- + const GLfloat vs = (NPOTAdjust ? hScale : 1.0f) / height;
- cl = mBufferCrop.left * us;
- ct = mBufferCrop.top * vs;
- cr = mBufferCrop.right * us;
- @@ -468,10 +486,12 @@ void LayerBase::drawWithOpenGL(const Region& clip, const Texture& texture) const
- } else {
- cl = 0;
- ct = 0;
- - cr = (texture.NPOTAdjust ? texture.wScale : 1.0f);
- - cb = (texture.NPOTAdjust ? texture.hScale : 1.0f);
- + cr = (NPOTAdjust ? wScale : 1.0f);
- + cb = (NPOTAdjust ? hScale : 1.0f);
- }
- + LOGE("Drawing %d %f %f", NPOTAdjust, wScale, hScale);
- +
- /*
- * For the buffer transformation, we apply the rotation last.
- * Since we're transforming the texture-coordinates, we need
- @@ -532,14 +552,20 @@ void LayerBase::drawWithOpenGL(const Region& clip, const Texture& texture) const
- texCoords[vRT].u = cr;
- texCoords[vRT].v = ct;
- + GLfloat colors[] = {1,0,0,.5f, 1,1,0,.5f, 1,0,1,0.5f, 1,1,1,0.5f};
- +
- if (needsDithering()) {
- glEnable(GL_DITHER);
- } else {
- glDisable(GL_DITHER);
- }
- +// glDisable(GL_TEXTURE_2D);
- +// glShadeModel(GL_SMOOTH);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- +// glEnableClientState(GL_COLOR_ARRAY);
- glVertexPointer(2, GL_FLOAT, 0, mVertices);
- +// glColorPointer(4, GL_FLOAT, 0, colors);
- glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
- Region::const_iterator it = clip.begin();
- @@ -550,6 +576,7 @@ void LayerBase::drawWithOpenGL(const Region& clip, const Texture& texture) const
- glScissor(r.left, sy, r.width(), r.height());
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
- }
- +// glDisableClientState(GL_COLOR_ARRAY);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- }
- diff --git a/services/surfaceflinger/LayerBlur.cpp b/services/surfaceflinger/LayerBlur.cpp
- index 9204aad..62ab983 100644
- --- a/services/surfaceflinger/LayerBlur.cpp
- +++ b/services/surfaceflinger/LayerBlur.cpp
- @@ -147,9 +147,9 @@ void LayerBlur::onDraw(const Region& clip) const
- Region::const_iterator const end = clip.end();
- if (it != end) {
- #if defined(GL_OES_EGL_image_external)
- - if (GLExtensions::getInstance().haveTextureExternal()) {
- +/* if (GLExtensions::getInstance().haveTextureExternal()) {
- glDisable(GL_TEXTURE_EXTERNAL_OES);
- - }
- + }*/
- #endif
- glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, mTextureName);
- diff --git a/services/surfaceflinger/LayerBuffer.cpp b/services/surfaceflinger/LayerBuffer.cpp
- index 7a1404d..f771e02 100644
- --- a/services/surfaceflinger/LayerBuffer.cpp
- +++ b/services/surfaceflinger/LayerBuffer.cpp
- @@ -639,7 +639,7 @@ void LayerBuffer::BufferSource::clearTempBufferImage() const
- {
- // delete the image
- EGLDisplay dpy(getFlinger()->graphicPlane(0).getEGLDisplay());
- - eglDestroyImageKHR(dpy, mTexture.image);
- + // eglDestroyImageKHR(dpy, mTexture.image);
- // and the associated texture (recreate a name)
- glDeleteTextures(1, &mTexture.name);
- diff --git a/services/surfaceflinger/LayerDim.cpp b/services/surfaceflinger/LayerDim.cpp
- index de1c7e1..fcd7a69 100644
- --- a/services/surfaceflinger/LayerDim.cpp
- +++ b/services/surfaceflinger/LayerDim.cpp
- @@ -107,9 +107,9 @@ void LayerDim::onDraw(const Region& clip) const
- glColor4f(0, 0, 0, alpha);
- #if defined(GL_OES_EGL_image_external)
- - if (GLExtensions::getInstance().haveTextureExternal()) {
- +/* if (GLExtensions::getInstance().haveTextureExternal()) {
- glDisable(GL_TEXTURE_EXTERNAL_OES);
- - }
- + } */
- #endif
- #ifdef AVOID_DRAW_TEXTURE
- if (!sUseTexture) {
- diff --git a/services/surfaceflinger/OGLAlloc.cpp b/services/surfaceflinger/OGLAlloc.cpp
- new file mode 100644
- index 0000000..7cfd808
- --- /dev/null
- +++ b/services/surfaceflinger/OGLAlloc.cpp
- @@ -0,0 +1,204 @@
- +/*
- + * Copyright (C) 2011 The HTC-Linux 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 <limits.h>
- +#include <unistd.h>
- +#include <fcntl.h>
- +#include <errno.h>
- +#include <pthread.h>
- +#include <stdlib.h>
- +#include <string.h>
- +
- +#include <sys/mman.h>
- +#include <sys/stat.h>
- +#include <sys/types.h>
- +#include <sys/ioctl.h>
- +
- +#include <utils/Errors.h>
- +#include <utils/Log.h>
- +#include <utils/StopWatch.h>
- +
- +#include <hardware/hardware.h>
- +
- +#include <linux/android_pmem.h>
- +
- +#include <GLES/gl.h>
- +
- +#include "OGLAlloc.h"
- +#include "clz.h"
- +
- +namespace android {
- +
- +// ---------------------------------------------------------------------------
- +
- +static void checkGLErrors()
- +{
- + do {
- + // there could be more than one error flag
- + GLenum error = glGetError();
- + if (error == GL_NO_ERROR)
- + break;
- + LOGE("GL error 0x%04x", int(error));
- + } while(true);
- +}
- +
- +static unsigned int* gpu1_base=0;
- +static int textures_allocated=0;
- +static int createGLTexture(int w, int h, int format, GLuint *text, int *stride, int *size)
- +{
- + int i, j, base;
- +
- + int bpp = 0;
- + GLuint components = GL_RGBA;
- + GLuint data_format = GL_UNSIGNED_BYTE;
- +
- + //init_texture_access();
- + /* if(!gpu1_base)
- + {
- + LOGE("GPU not properly initialized during memory allocation");
- + return -1;
- + }*/
- +
- + LOGE("createGLTexture: 1");
- +
- + textures_allocated++;
- +
- + switch (format) {
- + case HAL_PIXEL_FORMAT_RGBA_8888:
- + case HAL_PIXEL_FORMAT_RGBX_8888:
- + bpp = 4;
- + break;
- + case HAL_PIXEL_FORMAT_RGB_565:
- + components = GL_RGB;
- + data_format = GL_UNSIGNED_SHORT_5_6_5;
- + bpp = 2;
- + break;
- + case HAL_PIXEL_FORMAT_RGBA_4444:
- + data_format = GL_UNSIGNED_SHORT_4_4_4_4;
- + bpp = 2;
- + break;
- + default:
- + return -EINVAL;
- + }
- +
- + LOGE("createGLTexture: 2");
- +
- + *stride = w;
- + *size = w * h * bpp;
- +
- + LOGE("createGLTexture: 3");
- +
- + glEnable (GL_TEXTURE_2D);
- + checkGLErrors();
- + glGenTextures(1,text);
- + checkGLErrors();
- + glBindTexture(GL_TEXTURE_2D, *text);
- + checkGLErrors();
- +
- + unsigned int* data = (unsigned int*)malloc(w*h*bpp);
- + for(i=0; i < w*h*bpp/4; i++)
- + {
- + data[i] = rand();
- + }
- +
- + glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- + glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- + glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- + glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- + checkGLErrors();
- +
- + glTexImage2D(GL_TEXTURE_2D, 0,
- + components, w, h, 0,
- + components, data_format, data);
- + checkGLErrors();
- +
- + //We have to use the texture of the blob will not actually upload it to
- + //Gpu memory
- + //TODO: make sure this drawing takes place in some small corner of the display
- + //or potentially out of the viewport all together.
- + GLfloat vertices[] = {50,50, 75,50, 50,75, 75,75};
- + GLfloat texcoords[] = {0,0, 0,1, 1,1, 1,0};
- +
- + glEnableClientState(GL_VERTEX_ARRAY);
- + glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- +
- + glTexCoordPointer(2, GL_FLOAT, 0, texcoords);
- + glVertexPointer(2, GL_FLOAT, 0, vertices);
- + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
- +
- + //TODO: make sure this was really disabled when we started
- + //also check that VERTEX_ARRAY was already on
- + glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- +
- + glFinish();
- + checkGLErrors();
- +
- + //TODO: get gpu1 size from somewhere
- + //Lets find it
- + base=0;
- + for(i=0x2F0000/4; i < (13*1024*1024-w*h*bpp)/4; i++)
- + {
- + base=i;
- + for(j=0; j < w*h*bpp/4; j++)
- + {
- + if(gpu1_base[i+j] != data[j])
- + {
- + if(textures_allocated==1)
- + LOGE("Got 0x%8.8X Expected 0x%8.8X at 0x%8.8X", gpu1_base[i+j], data[j], i);
- + base=0;
- + break;
- + }
- + }
- + if(base||textures_allocated==1)
- + break;
- + }
- +
- + if(base)
- + LOGW("Located texture at 0x%8.8X", base*4);
- + else
- + LOGE("Failed to locate texture");
- +
- + free(data);
- + return base*4;
- +}
- +
- +
- +void* OGLAlloc::Alloc(int w, int h, int format, GLuint *text, int* stride, int* size, void* base)
- +{
- + gpu1_base = (unsigned int*)base;
- + //TODO: check if we can reuse part of an already allocated texture
- +
- + // find the smallest power-of-two that will accommodate our surface
- + int potWidth = 1 << (31 - clz(w));
- + int potHeight = 1 << (31 - clz(h));
- + if (potWidth < w) potWidth <<= 1;
- + if (potHeight < h) potHeight <<= 1;
- +
- + int loc = createGLTexture(potWidth,potHeight,format,text,stride,size);
- + // glDeleteTextures(1,text);
- +
- + return (void*)loc;
- +}
- +
- +void OGLAlloc::Free(GLuint text)
- +{
- + glDeleteTextures(1,&text);
- +}
- +
- +// ---------------------------------------------------------------------------
- +
- +}; // namespace android
- +
- diff --git a/services/surfaceflinger/OGLAlloc.h b/services/surfaceflinger/OGLAlloc.h
- new file mode 100644
- index 0000000..e987a59
- --- /dev/null
- +++ b/services/surfaceflinger/OGLAlloc.h
- @@ -0,0 +1,34 @@
- +/*
- + * Copyright (C) 2011 The HTC-Linux 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_OGLALLOC_H
- +#define ANDROID_OGLALLOC_H
- +
- +namespace android {
- +
- +// ---------------------------------------------------------------------------
- +
- +class OGLAlloc {
- +public:
- + static void* Alloc(int w, int h, int format, GLuint *text, int* stride, int* size, void* base);
- + static void Free(GLuint text);
- +};
- +
- +// ---------------------------------------------------------------------------
- +
- +}; // namespace android
- +
- +#endif //ANDROID_OGLALLOC_H
- diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
- index b8a59c1..3a4ca40 100644
- --- a/services/surfaceflinger/SurfaceFlinger.cpp
- +++ b/services/surfaceflinger/SurfaceFlinger.cpp
- @@ -51,6 +51,7 @@
- #include "LayerBuffer.h"
- #include "LayerDim.h"
- #include "SurfaceFlinger.h"
- +#include "OGLAlloc.h"
- #include "DisplayHardware/DisplayHardware.h"
- @@ -74,6 +75,87 @@ extern "C" void NvDispMgrAutoOrientation(int rotation);
- namespace android {
- // ---------------------------------------------------------------------------
- + SurfaceFlinger *theFlinger;
- + pid_t drawing_thread;
- +
- + class MessageOglAlloc : public MessageBase {
- + public:
- + status_t result;
- + int w, h, format, stride, size;
- + GLuint text;
- + void* base;
- + MessageOglAlloc(int w, int h, int format, void* base)
- + : w(w), h(h), format(format), base(base) {
- + }
- + status_t getResult() const {
- + return result;
- + }
- + virtual bool handler() {
- + LOGE("Running ogl_alloc from surfaceflinger main thread");
- + base = OGLAlloc::Alloc(w,h,format,&text,&stride,&size,base);
- +// Mutex::Autolock _l(flinger->mStateLock);
- +// result = flinger->turnElectronBeamOffImplLocked(mode);
- + return true;
- + }
- + };
- +
- + class MessageOglFree : public MessageBase {
- + public:
- + status_t result;
- + GLuint text;
- + MessageOglFree(unsigned int text_i)
- + {
- + text = text_i;
- + }
- + status_t getResult() const {
- + return result;
- + }
- + virtual bool handler() {
- + LOGE("Running ogl_free from surfaceflinger main thread");
- + OGLAlloc::Free(text);
- +// Mutex::Autolock _l(flinger->mStateLock);
- +// result = flinger->turnElectronBeamOffImplLocked(mode);
- + return true;
- + }
- + };
- +
- +void *ogl_alloc(int w, int h, int format, GLuint *text, int *stride, int *size, void* base)
- +{
- + int res;
- +
- + LOGE("Running ogl_alloc from libsurfaceflinger");
- + sp<MessageOglAlloc> msg = new MessageOglAlloc(w,h,format,base);
- +
- + if(drawing_thread == gettid())
- + {
- + LOGE("ogl_alloc called from drawing thread");
- + res = msg->handler();
- + } else
- + res = theFlinger->postMessageSync(msg, 0,0);
- + LOGE("ogl_alloc: 1");
- + *text = msg->text;
- + *stride = msg->stride;
- + *size = msg->size;
- + LOGE("ogl_alloc: 2");
- + return msg->base;
- +}
- +
- +void ogl_free(unsigned int text)
- +{
- + LOGE("Running ogl_free from libsurfaceflinger");
- +
- + sp<MessageOglFree> msg = new MessageOglFree(text);
- + int res;
- + if(drawing_thread == gettid())
- + {
- + LOGE("ogl_free called from drawing thread");
- + res = msg->handler();
- + } else
- + res = theFlinger->postMessageSync(msg, 0,0);
- +
- + LOGE("ogl_free complete");
- +}
- +
- SurfaceFlinger::SurfaceFlinger()
- : BnSurfaceComposer(), Thread(false),
- mTransactionFlags(0),
- @@ -108,6 +190,7 @@ SurfaceFlinger::SurfaceFlinger()
- mUse16bppAlpha(false)
- {
- init();
- + theFlinger = this;
- }
- void SurfaceFlinger::init()
- @@ -137,6 +220,9 @@ void SurfaceFlinger::init()
- property_get("debug.sf.render_color_blue", value, "824");
- mRenderColorB = atoi(value);
- + GraphicBufferAllocator::ogl_alloc = ogl_alloc;
- + GraphicBufferAllocator::ogl_free = ogl_free;
- +
- // perf setting for the dynamic 16bpp alpha mode
- property_get("persist.sys.use_16bpp_alpha", value, "0");
- mUse16bppAlpha = atoi(value) == 1;
- @@ -390,6 +476,8 @@ status_t SurfaceFlinger::postMessageSync(const sp<MessageBase>& msg,
- bool SurfaceFlinger::threadLoop()
- {
- + drawing_thread = gettid();
- +
- waitForEvent();
- // call Layer's destructor
- @@ -884,7 +972,7 @@ void SurfaceFlinger::handleRepaint()
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- - uint32_t flags = hw.getFlags();
- + /* uint32_t flags = hw.getFlags();
- if ((flags & DisplayHardware::SWAP_RECTANGLE) ||
- (flags & DisplayHardware::BUFFER_PRESERVED))
- {
- @@ -906,14 +994,14 @@ void SurfaceFlinger::handleRepaint()
- // We need to redraw the rectangle that will be updated
- // (pushed to the framebuffer).
- // This is needed because PARTIAL_UPDATES only takes one
- - // rectangle instead of a region (see DisplayHardware::flip())
- + // rectangle instead of a region (see DisplayHardware::flip()) */
- mDirtyRegion.set(mInvalidRegion.bounds());
- - } else {
- +/* } else {
- // we need to redraw everything (the whole screen)
- mDirtyRegion.set(hw.bounds());
- mInvalidRegion = mDirtyRegion;
- }
- - }
- + }*/
- // compose all surfaces
- composeSurfaces(mDirtyRegion);
- @@ -1024,9 +1112,9 @@ void SurfaceFlinger::drawWormhole() const
- glTexCoordPointer(2, GL_SHORT, 0, tcoords);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- #if defined(GL_OES_EGL_image_external)
- - if (GLExtensions::getInstance().haveTextureExternal()) {
- + /* if (GLExtensions::getInstance().haveTextureExternal()) {
- glDisable(GL_TEXTURE_EXTERNAL_OES);
- - }
- + }*/
- #endif
- glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, mWormholeTexName);
- @@ -1309,20 +1397,11 @@ sp<Layer> SurfaceFlinger::createNormalSurface(
- switch (format) { // TODO: take h/w into account
- case PIXEL_FORMAT_TRANSPARENT:
- case PIXEL_FORMAT_TRANSLUCENT:
- - format = PIXEL_FORMAT_RGBA_8888;
- + format = PIXEL_FORMAT_RGBA_4444;
- break;
- case PIXEL_FORMAT_OPAQUE:
- - if (mUse16bppAlpha) {
- - format = PIXEL_FORMAT_RGB_565;
- - //LOGD("Using 16bpp alpha PIXEL_FORMAT_RGB_565 (window %d x %d)", w, h);
- - } else {
- -#ifndef NO_RGBX_8888
- - format = PIXEL_FORMAT_RGBX_8888;
- -#else
- - format = PIXEL_FORMAT_RGBA_8888;
- -#endif
- - }
- + format = PIXEL_FORMAT_RGB_565;
- break;
- }
- @@ -1675,9 +1754,9 @@ status_t SurfaceFlinger::onTransact(
- status_t SurfaceFlinger::renderScreenToTextureLocked(DisplayID dpy,
- GLuint* textureName, GLfloat* uOut, GLfloat* vOut)
- {
- - if (!GLExtensions::getInstance().haveFramebufferObject())
- + // if (!GLExtensions::getInstance().haveFramebufferObject())
- return INVALID_OPERATION;
- -
- +/*
- // get screen geometry
- const DisplayHardware& hw(graphicPlane(dpy).displayHardware());
- const uint32_t hw_w = hw.getWidth();
- @@ -1726,7 +1805,7 @@ status_t SurfaceFlinger::renderScreenToTextureLocked(DisplayID dpy,
- *textureName = tname;
- *uOut = u;
- *vOut = v;
- - return NO_ERROR;
- + return NO_ERROR; */
- }
- // ---------------------------------------------------------------------------
- @@ -1740,12 +1819,12 @@ status_t SurfaceFlinger::electronBeamOffAnimationImplLocked()
- status_t result = PERMISSION_DENIED;
- #ifndef HAS_LIMITED_EGL
- - if (!GLExtensions::getInstance().haveFramebufferObject())
- + // if (!GLExtensions::getInstance().haveFramebufferObject())
- return INVALID_OPERATION;
- #endif
- // get screen geometry
- - const DisplayHardware& hw(graphicPlane(0).displayHardware());
- + /* const DisplayHardware& hw(graphicPlane(0).displayHardware());
- const uint32_t hw_w = hw.getWidth();
- const uint32_t hw_h = hw.getHeight();
- const Region screenBounds(hw.bounds());
- @@ -1876,20 +1955,20 @@ status_t SurfaceFlinger::electronBeamOffAnimationImplLocked()
- glColorMask(1,1,1,1);
- glEnable(GL_SCISSOR_TEST);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- - glDeleteTextures(1, &tname);
- - return NO_ERROR;
- + glDeleteTextures(1, &tname);
- + return NO_ERROR; */
- }
- status_t SurfaceFlinger::electronBeamOnAnimationImplLocked()
- {
- status_t result = PERMISSION_DENIED;
- -#ifndef HAS_LIMITED_EGL
- - if (!GLExtensions::getInstance().haveFramebufferObject())
- +//#ifndef HAS_LIMITED_EGL
- +// if (!GLExtensions::getInstance().haveFramebufferObject())
- return INVALID_OPERATION;
- -#endif
- +//#endif
- - // get screen geometry
- +/* // get screen geometry
- const DisplayHardware& hw(graphicPlane(0).displayHardware());
- const uint32_t hw_w = hw.getWidth();
- const uint32_t hw_h = hw.getHeight();
- @@ -2021,9 +2100,9 @@ status_t SurfaceFlinger::electronBeamOnAnimationImplLocked()
- glColorMask(1,1,1,1);
- glEnable(GL_SCISSOR_TEST);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- - glDeleteTextures(1, &tname);
- + glDeleteTextures(1, &tname); */
- - return NO_ERROR;
- + return NO_ERROR;
- }
- // ---------------------------------------------------------------------------
- @@ -2145,10 +2224,10 @@ status_t SurfaceFlinger::captureScreenImplLocked(DisplayID dpy,
- if (UNLIKELY(uint32_t(dpy) >= DISPLAY_COUNT))
- return BAD_VALUE;
- - if (!GLExtensions::getInstance().haveFramebufferObject())
- +// if (!GLExtensions::getInstance().haveFramebufferObject())
- return INVALID_OPERATION;
- - // get screen geometry
- + /* // get screen geometry
- const DisplayHardware& hw(graphicPlane(dpy).displayHardware());
- const uint32_t hw_w = hw.getWidth();
- const uint32_t hw_h = hw.getHeight();
- @@ -2241,7 +2320,7 @@ status_t SurfaceFlinger::captureScreenImplLocked(DisplayID dpy,
- hw.compositionComplete();
- - return result;
- + return result;*/
- }
- diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
- index afa9a21..b51db1d 100644
- --- a/services/surfaceflinger/SurfaceFlinger.h
- +++ b/services/surfaceflinger/SurfaceFlinger.h
- @@ -307,6 +307,9 @@ private:
- void waitForEvent();
- public: // hack to work around gcc 4.0.3 bug
- void signalEvent();
- +
- + status_t postMessageSync(const sp<MessageBase>& msg,
- + nsecs_t reltime=0, uint32_t flags = 0);
- private:
- void handleConsoleEvents();
- void handleTransaction(uint32_t transactionFlags);
- @@ -369,16 +372,12 @@ private:
- void debugShowFPS() const;
- void drawWormhole() const;
- -
- mutable MessageQueue mEventQueue;
- status_t postMessageAsync(const sp<MessageBase>& msg,
- nsecs_t reltime=0, uint32_t flags = 0);
- - status_t postMessageSync(const sp<MessageBase>& msg,
- - nsecs_t reltime=0, uint32_t flags = 0);
- -
- - // access must be protected by mStateLock
- + // access must be protected by mStateLock
- mutable Mutex mStateLock;
- State mCurrentState;
- State mDrawingState;
- diff --git a/services/surfaceflinger/TextureManager.cpp b/services/surfaceflinger/TextureManager.cpp
- index 9e24f90..45e2f94 100644
- --- a/services/surfaceflinger/TextureManager.cpp
- +++ b/services/surfaceflinger/TextureManager.cpp
- @@ -33,6 +33,12 @@
- #include "GLExtensions.h"
- #include "TextureManager.h"
- +extern "C"
- +{
- +#include <fcntl.h>
- +#include <linux/android_pmem.h>
- +#include <sys/mman.h>
- +}
- namespace android {
- // ---------------------------------------------------------------------------
- @@ -44,10 +50,10 @@ TextureManager::TextureManager()
- GLenum TextureManager::getTextureTarget(const Image* image) {
- #if defined(GL_OES_EGL_image_external)
- - switch (image->target) {
- +/* switch (image->target) {
- case Texture::TEXTURE_EXTERNAL:
- return GL_TEXTURE_EXTERNAL_OES;
- - }
- + }*/
- #endif
- return GL_TEXTURE_2D;
- }
- @@ -57,6 +63,8 @@ status_t TextureManager::initTexture(Texture* texture)
- if (texture->name != -1UL)
- return INVALID_OPERATION;
- + LOGE("Unsupported initTexture");
- +
- GLuint textureName = -1;
- glGenTextures(1, &textureName);
- texture->name = textureName;
- @@ -75,6 +83,8 @@ status_t TextureManager::initTexture(Texture* texture)
- status_t TextureManager::initTexture(Image* pImage, int32_t format)
- {
- + LOGE("init texture");
- +
- if (pImage->name != -1UL)
- return INVALID_OPERATION;
- @@ -84,14 +94,16 @@ status_t TextureManager::initTexture(Image* pImage, int32_t format)
- pImage->width = 0;
- pImage->height = 0;
- + LOGE("TextureName after init %d", textureName);
- +
- GLenum target = GL_TEXTURE_2D;
- #if defined(GL_OES_EGL_image_external)
- - if (GLExtensions::getInstance().haveTextureExternal()) {
- +/* if (GLExtensions::getInstance().haveTextureExternal()) {
- if (format && isYuvFormat(format)) {
- target = GL_TEXTURE_EXTERNAL_OES;
- pImage->target = Texture::TEXTURE_EXTERNAL;
- }
- - }
- + }*/
- #endif
- glBindTexture(target, textureName);
- @@ -131,37 +143,36 @@ bool TextureManager::isYuvFormat(int format)
- return false;
- }
- -status_t TextureManager::initEglImage(Image* pImage,
- +status_t TextureManager::initEglImage(Texture* pImage,
- EGLDisplay dpy, const sp<GraphicBuffer>& buffer)
- {
- status_t err = NO_ERROR;
- +
- + LOGE("initEglImage");
- +
- if (!pImage->dirty) return err;
- + LOGE("initEglImage dirty");
- +
- // free the previous image
- - if (pImage->image != EGL_NO_IMAGE_KHR) {
- - eglDestroyImageKHR(dpy, pImage->image);
- - pImage->image = EGL_NO_IMAGE_KHR;
- + if (pImage->image != NULL) {
- + //TODO: destory the tex somhow. glDeleteTexture probably does it
- +// eglDestroyImageKHR(dpy, pImage->image);
- + pImage->image = NULL;
- }
- // construct an EGL_NATIVE_BUFFER_ANDROID
- android_native_buffer_t* clientBuf = buffer->getNativeBuffer();
- - // create the new EGLImageKHR
- - const EGLint attrs[] = {
- - EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
- - EGL_NONE, EGL_NONE
- - };
- - pImage->image = eglCreateImageKHR(
- - dpy, EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID,
- - (EGLClientBuffer)clientBuf, attrs);
- -
- - if (pImage->image != EGL_NO_IMAGE_KHR) {
- - if (pImage->name == -1UL) {
- - initTexture(pImage, buffer->format);
- - }
- + pImage->image = (void*)buffer->mTexId;
- + //TODO: do glTexImage2d
- +
- + if (pImage->image != NULL) {
- + //TODO: go glTexSubImage
- + pImage->name = buffer->mTexId;
- const GLenum target = getTextureTarget(pImage);
- glBindTexture(target, pImage->name);
- - glEGLImageTargetTexture2DOES(target, (GLeglImageOES)pImage->image);
- + // glEGLImageTargetTexture2DOES(target, (GLeglImageOES)pImage->image); */
- GLint error = glGetError();
- if (error != GL_NO_ERROR) {
- LOGE("glEGLImageTargetTexture2DOES(%p) failed err=0x%04x",
- @@ -172,6 +183,18 @@ status_t TextureManager::initEglImage(Image* pImage,
- pImage->dirty = false;
- pImage->width = clientBuf->width;
- pImage->height = clientBuf->height;
- +
- + // find the smallest power-of-two that will accommodate our surface
- + int potWidth = 1 << (31 - clz(pImage->width));
- + int potHeight = 1 << (31 - clz(pImage->height));
- + if (potWidth < pImage->width) potWidth <<= 1;
- + if (potHeight < pImage->height) potHeight <<= 1;
- + pImage->wScale = float(pImage->width) / potWidth;
- + pImage->hScale = float(pImage->height) / potHeight;
- +
- + pImage->NPOTAdjust = true;
- +
- + LOGW("Scale factors: %f, %f", pImage->wScale, pImage->hScale);
- }
- } else {
- LOGE("eglCreateImageKHR() failed. err=0x%4x", eglGetError());
- @@ -212,7 +235,7 @@ status_t TextureManager::loadTexture(Texture* texture,
- int unpack = __builtin_ctz(t.stride * bytesPerPixel(t.format));
- unpack = 1 << ((unpack > 3) ? 3 : unpack);
- - glPixelStorei(GL_UNPACK_ALIGNMENT, unpack);
- + glPixelStorei(GL_UNPACK_ALIGNMENT, unpack);
- /*
- * round to POT if needed
- @@ -234,7 +257,7 @@ status_t TextureManager::loadTexture(Texture* texture,
- texture->potHeight = t.height;
- }
- - Rect bounds(dirty.bounds());
- +/* Rect bounds(dirty.bounds());
- GLvoid* data = 0;
- if (texture->width != t.width || texture->height != t.height) {
- texture->width = t.width;
- @@ -273,18 +296,22 @@ status_t TextureManager::loadTexture(Texture* texture,
- }
- }
- if (!data) {
- + //To determine the effect of texture copy speed: bounds.bottom -= (bounds.bottom - bounds.top)/2;
- if (t.format == HAL_PIXEL_FORMAT_RGB_565) {
- + LOGW("565 texture update");
- glTexSubImage2D(GL_TEXTURE_2D, 0,
- 0, bounds.top, t.width, bounds.height(),
- GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
- t.data + bounds.top*t.stride*2);
- } else if (t.format == HAL_PIXEL_FORMAT_RGBA_4444) {
- + LOGW("4444 texture update");
- glTexSubImage2D(GL_TEXTURE_2D, 0,
- 0, bounds.top, t.width, bounds.height(),
- GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4,
- t.data + bounds.top*t.stride*2);
- } else if (t.format == HAL_PIXEL_FORMAT_RGBA_8888 ||
- t.format == HAL_PIXEL_FORMAT_RGBX_8888) {
- + LOGW("8888 texture update");
- glTexSubImage2D(GL_TEXTURE_2D, 0,
- 0, bounds.top, t.width, bounds.height(),
- GL_RGBA, GL_UNSIGNED_BYTE,
- @@ -296,7 +323,7 @@ status_t TextureManager::loadTexture(Texture* texture,
- GL_LUMINANCE, GL_UNSIGNED_BYTE,
- t.data + bounds.top*t.stride);
- }
- - }
- + } */
- return NO_ERROR;
- }
- @@ -307,13 +334,13 @@ void TextureManager::activateTexture(const Texture& texture, bool filter)
- glBindTexture(GL_TEXTURE_2D, texture.name);
- glEnable(GL_TEXTURE_2D);
- #if defined(GL_OES_EGL_image_external)
- - if (GLExtensions::getInstance().haveTextureExternal()) {
- +/* if (GLExtensions::getInstance().haveTextureExternal()) {
- glDisable(GL_TEXTURE_EXTERNAL_OES);
- }
- } else {
- glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture.name);
- glEnable(GL_TEXTURE_EXTERNAL_OES);
- - glDisable(GL_TEXTURE_2D);
- + glDisable(GL_TEXTURE_2D); */
- #endif
- }
- @@ -330,9 +357,9 @@ void TextureManager::deactivateTextures()
- {
- glDisable(GL_TEXTURE_2D);
- #if defined(GL_OES_EGL_image_external)
- - if (GLExtensions::getInstance().haveTextureExternal()) {
- +/* if (GLExtensions::getInstance().haveTextureExternal()) {
- glDisable(GL_TEXTURE_EXTERNAL_OES);
- - }
- + }*/
- #endif
- }
- diff --git a/services/surfaceflinger/TextureManager.h b/services/surfaceflinger/TextureManager.h
- index 18c4348..238be2f 100644
- --- a/services/surfaceflinger/TextureManager.h
- +++ b/services/surfaceflinger/TextureManager.h
- @@ -39,7 +39,7 @@ class GraphicBuffer;
- struct Image {
- enum { TEXTURE_2D=0, TEXTURE_EXTERNAL=1 };
- - Image() : name(-1U), image(EGL_NO_IMAGE_KHR), width(0), height(0),
- + Image() : name(-1U), image(NULL), width(0), height(0),
- dirty(1), target(TEXTURE_2D) { }
- GLuint name;
- EGLImageKHR image;
- @@ -76,7 +76,7 @@ public:
- const Region& dirty, const GGLSurface& t);
- // make active buffer an EGLImage if needed
- - status_t initEglImage(Image* texture,
- + status_t initEglImage(Texture* texture,
- EGLDisplay dpy, const sp<GraphicBuffer>& buffer);
- // activate a texture
- diff --git a/tests/LargeAssetTest/assets/million-ints b/tests/LargeAssetTest/assets/million-ints
- index 0607de1..ea7f904 100644
- Binary files a/tests/LargeAssetTest/assets/million-ints and b/tests/LargeAssetTest/assets/million-ints differ
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement