Skip to content

Commit

Permalink
Merge branch 'mr1-staging' of https://github.com/ColdFusionX/android_…
Browse files Browse the repository at this point in the history
…frameworks_native into cm-10.1

Conflicts:
	services/surfaceflinger/DisplayHardware/HWComposer.cpp
  • Loading branch information
Rashed97 committed Dec 16, 2012
2 parents d262585 + 2869c4d commit 1399ec2
Show file tree
Hide file tree
Showing 10 changed files with 135 additions and 27 deletions.
2 changes: 2 additions & 0 deletions include/binder/IMemory.h
Expand Up @@ -44,7 +44,9 @@ class IMemoryHeap : public IInterface
virtual void* getBase() const = 0; virtual void* getBase() const = 0;
virtual size_t getSize() const = 0; virtual size_t getSize() const = 0;
virtual uint32_t getFlags() const = 0; virtual uint32_t getFlags() const = 0;
#ifndef BINDER_COMPAT
virtual uint32_t getOffset() const = 0; virtual uint32_t getOffset() const = 0;
#endif


// these are there just for backward source compatibility // these are there just for backward source compatibility
int32_t heapID() const { return getHeapID(); } int32_t heapID() const { return getHeapID(); }
Expand Down
8 changes: 5 additions & 3 deletions include/binder/MemoryHeapBase.h
Expand Up @@ -64,10 +64,10 @@ class MemoryHeapBase : public virtual BnMemoryHeap


virtual size_t getSize() const; virtual size_t getSize() const;
virtual uint32_t getFlags() const; virtual uint32_t getFlags() const;
virtual uint32_t getOffset() const; #ifndef BINDER_COMPAT

virtual uint32_t getOffset() const;
#endif
const char* getDevice() const; const char* getDevice() const;

/* this closes this heap -- use carefully */ /* this closes this heap -- use carefully */
void dispose(); void dispose();


Expand All @@ -94,7 +94,9 @@ class MemoryHeapBase : public virtual BnMemoryHeap
uint32_t mFlags; uint32_t mFlags;
const char* mDevice; const char* mDevice;
bool mNeedUnmap; bool mNeedUnmap;
#ifndef BINDER_COMPAT
uint32_t mOffset; uint32_t mOffset;
#endif
}; };


// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
Expand Down
8 changes: 8 additions & 0 deletions include/gui/SurfaceTexture.h
Expand Up @@ -246,7 +246,11 @@ class SurfaceTexture : public ConsumerBase {
virtual ~BufferRejecter() { } virtual ~BufferRejecter() { }
}; };
friend class Layer; friend class Layer;
#ifdef DECIDE_TEXTURE_TARGET
status_t updateTexImage(BufferRejecter* rejecter, bool skipSync, bool isComposition=false);
#else
status_t updateTexImage(BufferRejecter* rejecter, bool skipSync); status_t updateTexImage(BufferRejecter* rejecter, bool skipSync);
#endif


// createImage creates a new EGLImage from a GraphicBuffer. // createImage creates a new EGLImage from a GraphicBuffer.
EGLImageKHR createImage(EGLDisplay dpy, EGLImageKHR createImage(EGLDisplay dpy,
Expand Down Expand Up @@ -338,7 +342,11 @@ class SurfaceTexture : public ConsumerBase {
// glCopyTexSubImage to read from the texture. This is a hack to work // glCopyTexSubImage to read from the texture. This is a hack to work
// around a GL driver limitation on the number of FBO attachments, which the // around a GL driver limitation on the number of FBO attachments, which the
// browser's tile cache exceeds. // browser's tile cache exceeds.
#ifdef DECIDE_TEXTURE_TARGET
GLenum mTexTarget;
#else
const GLenum mTexTarget; const GLenum mTexTarget;
#endif


// EGLSlot contains the information and object references that // EGLSlot contains the information and object references that
// SurfaceTexture maintains about a BufferQueue buffer slot. // SurfaceTexture maintains about a BufferQueue buffer slot.
Expand Down
25 changes: 22 additions & 3 deletions libs/binder/IMemory.cpp
Expand Up @@ -85,8 +85,9 @@ class BpMemoryHeap : public BpInterface<IMemoryHeap>
virtual void* getBase() const; virtual void* getBase() const;
virtual size_t getSize() const; virtual size_t getSize() const;
virtual uint32_t getFlags() const; virtual uint32_t getFlags() const;
#ifndef BINDER_COMPAT
virtual uint32_t getOffset() const; virtual uint32_t getOffset() const;

#endif
private: private:
friend class IMemory; friend class IMemory;
friend class HeapCache; friend class HeapCache;
Expand All @@ -112,7 +113,9 @@ class BpMemoryHeap : public BpInterface<IMemoryHeap>
mutable void* mBase; mutable void* mBase;
mutable size_t mSize; mutable size_t mSize;
mutable uint32_t mFlags; mutable uint32_t mFlags;
#ifndef BINDER_COMPAT
mutable uint32_t mOffset; mutable uint32_t mOffset;
#endif
mutable bool mRealHeap; mutable bool mRealHeap;
mutable Mutex mLock; mutable Mutex mLock;
}; };
Expand Down Expand Up @@ -235,8 +238,13 @@ status_t BnMemory::onTransact(


BpMemoryHeap::BpMemoryHeap(const sp<IBinder>& impl) BpMemoryHeap::BpMemoryHeap(const sp<IBinder>& impl)
: BpInterface<IMemoryHeap>(impl), : BpInterface<IMemoryHeap>(impl),
mHeapId(-1), mBase(MAP_FAILED), mSize(0), mFlags(0), mOffset(0), mRealHeap(false) mHeapId(-1), mBase(MAP_FAILED), mSize(0), mFlags(0),
#ifndef BINDER_COMPAT
mOffset(0),
#endif
mRealHeap(false)
{ {
//HERE!
} }


BpMemoryHeap::~BpMemoryHeap() { BpMemoryHeap::~BpMemoryHeap() {
Expand Down Expand Up @@ -276,7 +284,9 @@ void BpMemoryHeap::assertMapped() const
if (mHeapId == -1) { if (mHeapId == -1) {
mBase = heap->mBase; mBase = heap->mBase;
mSize = heap->mSize; mSize = heap->mSize;
#ifndef BINDER_COMPAT
mOffset = heap->mOffset; mOffset = heap->mOffset;
#endif
android_atomic_write( dup( heap->mHeapId ), &mHeapId ); android_atomic_write( dup( heap->mHeapId ), &mHeapId );
} }
} else { } else {
Expand All @@ -300,7 +310,11 @@ void BpMemoryHeap::assertReallyMapped() const
int parcel_fd = reply.readFileDescriptor(); int parcel_fd = reply.readFileDescriptor();
ssize_t size = reply.readInt32(); ssize_t size = reply.readInt32();
uint32_t flags = reply.readInt32(); uint32_t flags = reply.readInt32();
#ifndef BINDER_COMPAT
uint32_t offset = reply.readInt32(); uint32_t offset = reply.readInt32();
#else
uint32_t offset = 0;
#endif


ALOGE_IF(err, "binder=%p transaction failed fd=%d, size=%ld, err=%d (%s)", ALOGE_IF(err, "binder=%p transaction failed fd=%d, size=%ld, err=%d (%s)",
asBinder().get(), parcel_fd, size, err, strerror(-err)); asBinder().get(), parcel_fd, size, err, strerror(-err));
Expand Down Expand Up @@ -342,7 +356,9 @@ void BpMemoryHeap::assertReallyMapped() const
} else { } else {
mSize = size; mSize = size;
mFlags = flags; mFlags = flags;
#ifndef BINDER_COMPAT
mOffset = offset; mOffset = offset;
#endif
android_atomic_write(fd, &mHeapId); android_atomic_write(fd, &mHeapId);
} }
} }
Expand Down Expand Up @@ -374,11 +390,12 @@ uint32_t BpMemoryHeap::getFlags() const {
assertMapped(); assertMapped();
return mFlags; return mFlags;
} }

#ifndef BINDER_COMPAT
uint32_t BpMemoryHeap::getOffset() const { uint32_t BpMemoryHeap::getOffset() const {
assertMapped(); assertMapped();
return mOffset; return mOffset;
} }
#endif


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


Expand All @@ -399,7 +416,9 @@ status_t BnMemoryHeap::onTransact(
reply->writeFileDescriptor(getHeapID()); reply->writeFileDescriptor(getHeapID());
reply->writeInt32(getSize()); reply->writeInt32(getSize());
reply->writeInt32(getFlags()); reply->writeInt32(getFlags());
#ifndef BINDER_COMPAT
reply->writeInt32(getOffset()); reply->writeInt32(getOffset());
#endif
return NO_ERROR; return NO_ERROR;
} break; } break;
default: default:
Expand Down
28 changes: 22 additions & 6 deletions libs/binder/MemoryHeapBase.cpp
Expand Up @@ -42,13 +42,19 @@ namespace android {


MemoryHeapBase::MemoryHeapBase() MemoryHeapBase::MemoryHeapBase()
: mFD(-1), mSize(0), mBase(MAP_FAILED), : mFD(-1), mSize(0), mBase(MAP_FAILED),
mDevice(NULL), mNeedUnmap(false), mOffset(0) mDevice(NULL), mNeedUnmap(false)
#ifndef BINDER_COMPAT
, mOffset(0)
#endif
{ {
} }


MemoryHeapBase::MemoryHeapBase(size_t size, uint32_t flags, char const * name) MemoryHeapBase::MemoryHeapBase(size_t size, uint32_t flags, char const * name)
: mFD(-1), mSize(0), mBase(MAP_FAILED), mFlags(flags), : mFD(-1), mSize(0), mBase(MAP_FAILED), mFlags(flags),
mDevice(0), mNeedUnmap(false), mOffset(0) mDevice(0), mNeedUnmap(false)
#ifndef BINDER_COMPAT
, mOffset(0)
#endif
{ {
const size_t pagesize = getpagesize(); const size_t pagesize = getpagesize();
size = ((size + pagesize-1) & ~(pagesize-1)); size = ((size + pagesize-1) & ~(pagesize-1));
Expand All @@ -65,7 +71,10 @@ MemoryHeapBase::MemoryHeapBase(size_t size, uint32_t flags, char const * name)


MemoryHeapBase::MemoryHeapBase(const char* device, size_t size, uint32_t flags) MemoryHeapBase::MemoryHeapBase(const char* device, size_t size, uint32_t flags)
: mFD(-1), mSize(0), mBase(MAP_FAILED), mFlags(flags), : mFD(-1), mSize(0), mBase(MAP_FAILED), mFlags(flags),
mDevice(0), mNeedUnmap(false), mOffset(0) mDevice(0), mNeedUnmap(false)
#ifndef BINDER_COMPAT
, mOffset(0)
#endif
{ {
int open_flags = O_RDWR; int open_flags = O_RDWR;
if (flags & NO_CACHING) if (flags & NO_CACHING)
Expand All @@ -84,7 +93,10 @@ MemoryHeapBase::MemoryHeapBase(const char* device, size_t size, uint32_t flags)


MemoryHeapBase::MemoryHeapBase(int fd, size_t size, uint32_t flags, uint32_t offset) MemoryHeapBase::MemoryHeapBase(int fd, size_t size, uint32_t flags, uint32_t offset)
: mFD(-1), mSize(0), mBase(MAP_FAILED), mFlags(flags), : mFD(-1), mSize(0), mBase(MAP_FAILED), mFlags(flags),
mDevice(0), mNeedUnmap(false), mOffset(0) mDevice(0), mNeedUnmap(false)
#ifndef BINDER_COMPAT
, mOffset(0)
#endif
{ {
const size_t pagesize = getpagesize(); const size_t pagesize = getpagesize();
size = ((size + pagesize-1) & ~(pagesize-1)); size = ((size + pagesize-1) & ~(pagesize-1));
Expand Down Expand Up @@ -132,7 +144,7 @@ status_t MemoryHeapBase::mapfd(int fd, size_t size, uint32_t offset)
close(fd); close(fd);
return -errno; return -errno;
} }
//ALOGD("mmap(fd=%d, base=%p, size=%lu)", fd, base, size); //LOGD("mmap(fd=%d, base=%p, size=%lu)", fd, base, size);
mBase = base; mBase = base;
mNeedUnmap = true; mNeedUnmap = true;
} else { } else {
Expand All @@ -141,7 +153,9 @@ status_t MemoryHeapBase::mapfd(int fd, size_t size, uint32_t offset)
} }
mFD = fd; mFD = fd;
mSize = size; mSize = size;
#ifndef BINDER_COMPAT
mOffset = offset; mOffset = offset;
#endif
return NO_ERROR; return NO_ERROR;
} }


Expand All @@ -155,7 +169,7 @@ void MemoryHeapBase::dispose()
int fd = android_atomic_or(-1, &mFD); int fd = android_atomic_or(-1, &mFD);
if (fd >= 0) { if (fd >= 0) {
if (mNeedUnmap) { if (mNeedUnmap) {
//ALOGD("munmap(fd=%d, base=%p, size=%lu)", fd, mBase, mSize); //LOGD("munmap(fd=%d, base=%p, size=%lu)", fd, mBase, mSize);
munmap(mBase, mSize); munmap(mBase, mSize);
} }
mBase = 0; mBase = 0;
Expand Down Expand Up @@ -184,9 +198,11 @@ const char* MemoryHeapBase::getDevice() const {
return mDevice; return mDevice;
} }


#ifndef BINDER_COMPAT
uint32_t MemoryHeapBase::getOffset() const { uint32_t MemoryHeapBase::getOffset() const {
return mOffset; return mOffset;
} }
#endif


// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
}; // namespace android }; // namespace android
6 changes: 5 additions & 1 deletion libs/gui/Android.mk
Expand Up @@ -55,7 +55,11 @@ ifneq ($(filter generic%,$(TARGET_DEVICE)),)
endif endif


ifeq ($(TARGET_BOARD_PLATFORM), msm8960) ifeq ($(TARGET_BOARD_PLATFORM), msm8960)
LOCAL_CFLAGS += -DUSE_NATIVE_FENCE_SYNC LOCAL_CFLAGS += -DUSE_NATIVE_FENCE_SYNC
endif

ifeq ($(BOARD_ADRENO_DECIDE_TEXTURE_TARGET),true)
LOCAL_CFLAGS += -DDECIDE_TEXTURE_TARGET
endif endif


include $(BUILD_SHARED_LIBRARY) include $(BUILD_SHARED_LIBRARY)
Expand Down
26 changes: 26 additions & 0 deletions libs/gui/SurfaceTexture.cpp
Expand Up @@ -195,7 +195,11 @@ status_t SurfaceTexture::releaseBufferLocked(int buf, EGLDisplay display,
return err; return err;
} }


#ifdef DECIDE_TEXTURE_TARGET
status_t SurfaceTexture::updateTexImage(BufferRejecter* rejecter, bool skipSync, bool isComposition) {
#else
status_t SurfaceTexture::updateTexImage(BufferRejecter* rejecter, bool skipSync) { status_t SurfaceTexture::updateTexImage(BufferRejecter* rejecter, bool skipSync) {
#endif
ATRACE_CALL(); ATRACE_CALL();
ST_LOGV("updateTexImage"); ST_LOGV("updateTexImage");
Mutex::Autolock lock(mMutex); Mutex::Autolock lock(mMutex);
Expand Down Expand Up @@ -254,6 +258,28 @@ status_t SurfaceTexture::updateTexImage(BufferRejecter* rejecter, bool skipSync)
} }


EGLImageKHR image = mEglSlots[buf].mEglImage; EGLImageKHR image = mEglSlots[buf].mEglImage;
#ifdef DECIDE_TEXTURE_TARGET
// GPU is not efficient in handling GL_TEXTURE_EXTERNAL_OES
// texture target. Depending on the image format, decide,
// the texture target to be used

if(isComposition){
switch (mSlots[buf].mGraphicBuffer->format) {
case HAL_PIXEL_FORMAT_RGBA_8888:
case HAL_PIXEL_FORMAT_RGBX_8888:
case HAL_PIXEL_FORMAT_RGB_888:
case HAL_PIXEL_FORMAT_RGB_565:
case HAL_PIXEL_FORMAT_BGRA_8888:
case HAL_PIXEL_FORMAT_RGBA_5551:
case HAL_PIXEL_FORMAT_RGBA_4444:
mTexTarget = GL_TEXTURE_2D;
break;
default:
mTexTarget = GL_TEXTURE_EXTERNAL_OES;
break;
}
}
#endif
glBindTexture(mTexTarget, mTexName); glBindTexture(mTexTarget, mTexName);
glEGLImageTargetTexture2DOES(mTexTarget, (GLeglImageOES)image); glEGLImageTargetTexture2DOES(mTexTarget, (GLeglImageOES)image);


Expand Down
4 changes: 4 additions & 0 deletions services/surfaceflinger/Android.mk
Expand Up @@ -46,6 +46,10 @@ ifneq ($(NUM_FRAMEBUFFER_SURFACE_BUFFERS),)
LOCAL_CFLAGS += -DNUM_FRAMEBUFFER_SURFACE_BUFFERS=$(NUM_FRAMEBUFFER_SURFACE_BUFFERS) LOCAL_CFLAGS += -DNUM_FRAMEBUFFER_SURFACE_BUFFERS=$(NUM_FRAMEBUFFER_SURFACE_BUFFERS)
endif endif


ifeq ($(BOARD_ADRENO_DECIDE_TEXTURE_TARGET),true)
LOCAL_CFLAGS += -DDECIDE_TEXTURE_TARGET
endif

LOCAL_SHARED_LIBRARIES := \ LOCAL_SHARED_LIBRARIES := \
libcutils \ libcutils \
libdl \ libdl \
Expand Down
21 changes: 10 additions & 11 deletions services/surfaceflinger/DisplayHardware/HWComposer.cpp
Expand Up @@ -233,17 +233,16 @@ HWComposer::HWComposer(
loadFbHalModule(); loadFbHalModule();
loadHwcModule(); loadHwcModule();


if (mFbDev && mHwc && hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) { if (mHwc && hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) {
// close FB HAL if we don't needed it. if (mFbDev) {
// FIXME: this is temporary until we're not forced to open FB HAL // close FB HAL if we don't needed it.
// before HWC. // FIXME: this is temporary until we're not forced to open FB HAL
framebuffer_close(mFbDev); // before HWC.
mFbDev = NULL; framebuffer_close(mFbDev);
} mFbDev = NULL;

}
// If we have no HWC, or a pre-1.1 HWC, an FB dev is mandatory. } else if (!mFbDev) {
if ((!mHwc || !hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) // If we have no HWC, or a pre-1.1 HWC, an FB dev is mandatory.
&& !mFbDev) {
ALOGE("ERROR: failed to open framebuffer, aborting"); ALOGE("ERROR: failed to open framebuffer, aborting");
abort(); abort();
} }
Expand Down

0 comments on commit 1399ec2

Please sign in to comment.