Merge "3205857 java.lang.ExceptionInInitializerError at java.lang.Class.newInstanceImpl(Native Method)"
diff --git a/include/private/ui/sw_gralloc_handle.h b/include/private/ui/sw_gralloc_handle.h
deleted file mode 100644
index b3d333e..0000000
--- a/include/private/ui/sw_gralloc_handle.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2008 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_UI_PRIVATE_SW_GRALLOC_HANDLE_H
-#define ANDROID_UI_PRIVATE_SW_GRALLOC_HANDLE_H
-
-#include <stdint.h>
-#include <limits.h>
-#include <sys/cdefs.h>
-#include <hardware/gralloc.h>
-#include <errno.h>
-
-#include <cutils/native_handle.h>
-
-namespace android {
-
-/*****************************************************************************/
-
-struct sw_gralloc_handle_t : public native_handle
-{
- // file-descriptors
- int fd;
- // ints
- int magic;
- int size;
- int base;
- int prot;
- int pid;
-
- static const int sNumInts = 5;
- static const int sNumFds = 1;
- static const int sMagic = '_sgh';
-
- sw_gralloc_handle_t() :
- fd(-1), magic(sMagic), size(0), base(0), prot(0), pid(getpid())
- {
- version = sizeof(native_handle);
- numInts = sNumInts;
- numFds = sNumFds;
- }
- ~sw_gralloc_handle_t() {
- magic = 0;
- }
-
- static int validate(const native_handle* h) {
- const sw_gralloc_handle_t* hnd = (const sw_gralloc_handle_t*)h;
- if (!h || h->version != sizeof(native_handle) ||
- h->numInts != sNumInts || h->numFds != sNumFds ||
- hnd->magic != sMagic)
- {
- return -EINVAL;
- }
- return 0;
- }
-
- static status_t alloc(uint32_t w, uint32_t h, int format,
- int usage, buffer_handle_t* handle, int32_t* stride);
- static status_t free(sw_gralloc_handle_t* hnd);
- static status_t registerBuffer(sw_gralloc_handle_t* hnd);
- static status_t unregisterBuffer(sw_gralloc_handle_t* hnd);
- static status_t lock(sw_gralloc_handle_t* hnd, int usage,
- int l, int t, int w, int h, void** vaddr);
- static status_t unlock(sw_gralloc_handle_t* hnd);
-};
-
-/*****************************************************************************/
-
-}; // namespace android
-
-#endif /* ANDROID_UI_PRIVATE_SW_GRALLOC_HANDLE_H */
diff --git a/include/surfaceflinger/ISurface.h b/include/surfaceflinger/ISurface.h
index ddbe03d..cd0ee40 100644
--- a/include/surfaceflinger/ISurface.h
+++ b/include/surfaceflinger/ISurface.h
@@ -34,18 +34,15 @@
typedef int32_t SurfaceID;
-class IMemoryHeap;
-class OverlayRef;
class GraphicBuffer;
class ISurface : public IInterface
{
protected:
enum {
- REGISTER_BUFFERS = IBinder::FIRST_CALL_TRANSACTION,
- UNREGISTER_BUFFERS,
- POST_BUFFER, // one-way transaction
- CREATE_OVERLAY,
+ RESERVED0 = IBinder::FIRST_CALL_TRANSACTION,
+ RESERVED1,
+ RESERVED2,
REQUEST_BUFFER,
SET_BUFFER_COUNT,
};
@@ -66,49 +63,6 @@
* sets the number of buffers dequeuable for this surface.
*/
virtual status_t setBufferCount(int bufferCount) = 0;
-
- // ------------------------------------------------------------------------
- // Deprecated...
- // ------------------------------------------------------------------------
-
- class BufferHeap {
- public:
- enum {
- /* rotate source image */
- ROT_0 = 0,
- ROT_90 = HAL_TRANSFORM_ROT_90,
- ROT_180 = HAL_TRANSFORM_ROT_180,
- ROT_270 = HAL_TRANSFORM_ROT_270,
- };
- BufferHeap();
-
- BufferHeap(uint32_t w, uint32_t h,
- int32_t hor_stride, int32_t ver_stride,
- PixelFormat format, const sp<IMemoryHeap>& heap);
-
- BufferHeap(uint32_t w, uint32_t h,
- int32_t hor_stride, int32_t ver_stride,
- PixelFormat format, uint32_t transform, uint32_t flags,
- const sp<IMemoryHeap>& heap);
-
- ~BufferHeap();
-
- uint32_t w;
- uint32_t h;
- int32_t hor_stride;
- int32_t ver_stride;
- PixelFormat format;
- uint32_t transform;
- uint32_t flags;
- sp<IMemoryHeap> heap;
- };
-
- virtual status_t registerBuffers(const BufferHeap& buffers) = 0;
- virtual void postBuffer(ssize_t offset) = 0; // one-way
- virtual void unregisterBuffers() = 0;
-
- virtual sp<OverlayRef> createOverlay(
- uint32_t w, uint32_t h, int32_t format, int32_t orientation) = 0;
};
// ----------------------------------------------------------------------------
diff --git a/include/surfaceflinger/ISurfaceComposer.h b/include/surfaceflinger/ISurfaceComposer.h
index db57859..382cbda 100644
--- a/include/surfaceflinger/ISurfaceComposer.h
+++ b/include/surfaceflinger/ISurfaceComposer.h
@@ -42,7 +42,6 @@
eDestroyBackbuffer = 0x00000020,
eSecure = 0x00000080,
eNonPremultiplied = 0x00000100,
- ePushBuffers = 0x00000200,
eOpaque = 0x00000400,
eFXSurfaceNormal = 0x00000000,
diff --git a/include/ui/FramebufferNativeWindow.h b/include/ui/FramebufferNativeWindow.h
index 2cd0911..16117ad 100644
--- a/include/ui/FramebufferNativeWindow.h
+++ b/include/ui/FramebufferNativeWindow.h
@@ -23,6 +23,7 @@
#include <EGL/egl.h>
#include <utils/threads.h>
+#include <utils/String8.h>
#include <ui/Rect.h>
#include <pixelflinger/pixelflinger.h>
@@ -56,7 +57,9 @@
bool isUpdateOnDemand() const { return mUpdateOnDemand; }
status_t setUpdateRectangle(const Rect& updateRect);
status_t compositionComplete();
-
+
+ void dump(String8& result);
+
// for debugging only
int getCurrentBufferIndex() const;
diff --git a/include/ui/IOverlay.h b/include/ui/IOverlay.h
deleted file mode 100644
index af3add1..0000000
--- a/include/ui/IOverlay.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2007 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_IOVERLAY_H
-#define ANDROID_IOVERLAY_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <utils/Errors.h>
-#include <binder/IInterface.h>
-#include <utils/RefBase.h>
-#include <ui/PixelFormat.h>
-
-namespace android {
-
-class IOverlay : public IInterface
-{
-public:
- DECLARE_META_INTERFACE(Overlay);
-
- virtual void destroy() = 0; // one-way
-};
-
-// ----------------------------------------------------------------------------
-
-class BnOverlay : public BnInterface<IOverlay>
-{
-public:
- virtual status_t onTransact( uint32_t code,
- const Parcel& data,
- Parcel* reply,
- uint32_t flags = 0);
-};
-
-// ----------------------------------------------------------------------------
-
-}; // namespace android
-
-#endif // ANDROID_IOVERLAY_H
diff --git a/include/ui/Overlay.h b/include/ui/Overlay.h
deleted file mode 100644
index a9ae1c4..0000000
--- a/include/ui/Overlay.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (C) 2007 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_OVERLAY_H
-#define ANDROID_OVERLAY_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <utils/Errors.h>
-#include <binder/IInterface.h>
-#include <utils/RefBase.h>
-#include <utils/threads.h>
-
-#include <ui/PixelFormat.h>
-#include <ui/IOverlay.h>
-
-#include <hardware/overlay.h>
-
-namespace android {
-
-class IMemory;
-class IMemoryHeap;
-
-// ----------------------------------------------------------------------------
-
-class OverlayRef : public LightRefBase<OverlayRef>
-{
-public:
- OverlayRef(overlay_handle_t, const sp<IOverlay>&,
- uint32_t w, uint32_t h, int32_t f, uint32_t ws, uint32_t hs);
-
- static sp<OverlayRef> readFromParcel(const Parcel& data);
- static status_t writeToParcel(Parcel* reply, const sp<OverlayRef>& o);
-
-private:
- friend class LightRefBase<OverlayRef>;
- friend class Overlay;
-
- OverlayRef();
- virtual ~OverlayRef();
-
- overlay_handle_t mOverlayHandle;
- sp<IOverlay> mOverlayChannel;
- uint32_t mWidth;
- uint32_t mHeight;
- int32_t mFormat;
- int32_t mWidthStride;
- int32_t mHeightStride;
- bool mOwnHandle;
-};
-
-// ----------------------------------------------------------------------------
-
-class Overlay : public virtual RefBase
-{
-public:
- Overlay(const sp<OverlayRef>& overlayRef);
-
- /* destroys this overlay */
- void destroy();
-
- /* get the HAL handle for this overlay */
- overlay_handle_t getHandleRef() const;
-
- /* blocks until an overlay buffer is available and return that buffer. */
- status_t dequeueBuffer(overlay_buffer_t* buffer);
-
- /* release the overlay buffer and post it */
- status_t queueBuffer(overlay_buffer_t buffer);
-
- /* change the width and height of the overlay */
- status_t resizeInput(uint32_t width, uint32_t height);
-
- status_t setCrop(uint32_t x, uint32_t y, uint32_t w, uint32_t h) ;
-
- status_t getCrop(uint32_t* x, uint32_t* y, uint32_t* w, uint32_t* h) ;
-
- /* set the buffer attributes */
- status_t setParameter(int param, int value);
-
- /* returns the address of a given buffer if supported, NULL otherwise. */
- void* getBufferAddress(overlay_buffer_t buffer);
-
- /* get physical informations about the overlay */
- uint32_t getWidth() const;
- uint32_t getHeight() const;
- int32_t getFormat() const;
- int32_t getWidthStride() const;
- int32_t getHeightStride() const;
- int32_t getBufferCount() const;
- status_t getStatus() const;
-
-private:
- virtual ~Overlay();
-
- sp<OverlayRef> mOverlayRef;
- overlay_data_device_t *mOverlayData;
- status_t mStatus;
-};
-
-// ----------------------------------------------------------------------------
-
-}; // namespace android
-
-#endif // ANDROID_OVERLAY_H
diff --git a/include/utils/Asset.h b/include/utils/Asset.h
index 2a09095..1fe0e06 100644
--- a/include/utils/Asset.h
+++ b/include/utils/Asset.h
@@ -23,9 +23,11 @@
#include <stdio.h>
#include <sys/types.h>
-#include "FileMap.h"
-#include "String8.h"
-#include "Errors.h"
+
+#include <utils/Compat.h>
+#include <utils/Errors.h>
+#include <utils/FileMap.h>
+#include <utils/String8.h>
namespace android {
@@ -69,10 +71,10 @@
/*
* Seek to the specified offset. "whence" uses the same values as
- * lseek/fseek. Returns the new position on success, or (off_t) -1
+ * lseek/fseek. Returns the new position on success, or (off64_t) -1
* on failure.
*/
- virtual off_t seek(off_t offset, int whence) = 0;
+ virtual off64_t seek(off64_t offset, int whence) = 0;
/*
* Close the asset, freeing all associated resources.
@@ -87,26 +89,26 @@
/*
* Get the total amount of data that can be read.
*/
- virtual off_t getLength(void) const = 0;
+ virtual off64_t getLength(void) const = 0;
/*
* Get the total amount of data that can be read from the current position.
*/
- virtual off_t getRemainingLength(void) const = 0;
+ virtual off64_t getRemainingLength(void) const = 0;
/*
* Open a new file descriptor that can be used to read this asset.
* Returns -1 if you can not use the file descriptor (for example if the
* asset is compressed).
*/
- virtual int openFileDescriptor(off_t* outStart, off_t* outLength) const = 0;
-
+ virtual int openFileDescriptor(off64_t* outStart, off64_t* outLength) const = 0;
+
/*
* Return whether this asset's buffer is allocated in RAM (not mmapped).
* Note: not virtual so it is safe to call even when being destroyed.
*/
virtual bool isAllocated(void) const { return false; }
-
+
/*
* Get a string identifying the asset's source. This might be a full
* path, it might be a colon-separated list of identifiers.
@@ -120,7 +122,7 @@
Asset(void); // constructor; only invoked indirectly
/* handle common seek() housekeeping */
- off_t handleSeek(off_t offset, int whence, off_t curPosn, off_t maxPosn);
+ off64_t handleSeek(off64_t offset, int whence, off64_t curPosn, off64_t maxPosn);
/* set the asset source string */
void setAssetSource(const String8& path) { mAssetSource = path; }
@@ -153,7 +155,7 @@
*
* The asset takes ownership of the file descriptor.
*/
- static Asset* createFromFileSegment(int fd, off_t offset, size_t length,
+ static Asset* createFromFileSegment(int fd, off64_t offset, size_t length,
AccessMode mode);
/*
@@ -166,7 +168,7 @@
* This may not verify the validity of the compressed data until first
* use.
*/
- static Asset* createFromCompressedData(int fd, off_t offset,
+ static Asset* createFromCompressedData(int fd, off64_t offset,
int compressionMethod, size_t compressedLength,
size_t uncompressedLength, AccessMode mode);
#endif
@@ -221,7 +223,7 @@
*
* On success, the object takes ownership of "fd".
*/
- status_t openChunk(const char* fileName, int fd, off_t offset, size_t length);
+ status_t openChunk(const char* fileName, int fd, off64_t offset, size_t length);
/*
* Use a memory-mapped region.
@@ -234,18 +236,18 @@
* Standard Asset interfaces.
*/
virtual ssize_t read(void* buf, size_t count);
- virtual off_t seek(off_t offset, int whence);
+ virtual off64_t seek(off64_t offset, int whence);
virtual void close(void);
virtual const void* getBuffer(bool wordAligned);
- virtual off_t getLength(void) const { return mLength; }
- virtual off_t getRemainingLength(void) const { return mLength-mOffset; }
- virtual int openFileDescriptor(off_t* outStart, off_t* outLength) const;
+ virtual off64_t getLength(void) const { return mLength; }
+ virtual off64_t getRemainingLength(void) const { return mLength-mOffset; }
+ virtual int openFileDescriptor(off64_t* outStart, off64_t* outLength) const;
virtual bool isAllocated(void) const { return mBuf != NULL; }
private:
- off_t mStart; // absolute file offset of start of chunk
- off_t mLength; // length of the chunk
- off_t mOffset; // current local offset, 0 == mStart
+ off64_t mStart; // absolute file offset of start of chunk
+ off64_t mLength; // length of the chunk
+ off64_t mOffset; // current local offset, 0 == mStart
FILE* mFp; // for read/seek
char* mFileName; // for opening
@@ -276,7 +278,7 @@
*
* On success, the object takes ownership of "fd".
*/
- status_t openChunk(int fd, off_t offset, int compressionMethod,
+ status_t openChunk(int fd, off64_t offset, int compressionMethod,
size_t uncompressedLen, size_t compressedLen);
/*
@@ -291,19 +293,19 @@
* Standard Asset interfaces.
*/
virtual ssize_t read(void* buf, size_t count);
- virtual off_t seek(off_t offset, int whence);
+ virtual off64_t seek(off64_t offset, int whence);
virtual void close(void);
virtual const void* getBuffer(bool wordAligned);
- virtual off_t getLength(void) const { return mUncompressedLen; }
- virtual off_t getRemainingLength(void) const { return mUncompressedLen-mOffset; }
- virtual int openFileDescriptor(off_t* outStart, off_t* outLength) const { return -1; }
+ virtual off64_t getLength(void) const { return mUncompressedLen; }
+ virtual off64_t getRemainingLength(void) const { return mUncompressedLen-mOffset; }
+ virtual int openFileDescriptor(off64_t* outStart, off64_t* outLength) const { return -1; }
virtual bool isAllocated(void) const { return mBuf != NULL; }
private:
- off_t mStart; // offset to start of compressed data
- off_t mCompressedLen; // length of the compressed data
- off_t mUncompressedLen; // length of the uncompressed data
- off_t mOffset; // current offset, 0 == start of uncomp data
+ off64_t mStart; // offset to start of compressed data
+ off64_t mCompressedLen; // length of the compressed data
+ off64_t mUncompressedLen; // length of the uncompressed data
+ off64_t mOffset; // current offset, 0 == start of uncomp data
FileMap* mMap; // for memory-mapped input
int mFd; // for file input
diff --git a/include/utils/Compat.h b/include/utils/Compat.h
new file mode 100644
index 0000000..1819266
--- /dev/null
+++ b/include/utils/Compat.h
@@ -0,0 +1,42 @@
+/*
+ * 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 __LIB_UTILS_COMPAT_H
+#define __LIB_UTILS_COMPAT_H
+
+#include <unistd.h>
+
+/* Compatibility definitions for non-Linux (i.e., BSD-based) hosts. */
+#ifndef HAVE_OFF64_T
+#if _FILE_OFFSET_BITS < 64
+#error "_FILE_OFFSET_BITS < 64; large files are not supported on this platform"
+#endif /* _FILE_OFFSET_BITS < 64 */
+
+typedef off_t off64_t;
+
+static inline off64_t lseek64(int fd, off64_t offset, int whence) {
+ return lseek(fd, offset, whence);
+}
+
+#ifdef HAVE_PREAD
+static inline ssize_t pread64(int fd, void* buf, size_t nbytes, off64_t offset) {
+ return pread(fd, buf, nbytes, offset);
+}
+#endif
+
+#endif /* !HAVE_OFF64_T */
+
+#endif /* __LIB_UTILS_COMPAT_H */
diff --git a/include/utils/FileMap.h b/include/utils/FileMap.h
index 8dfd3be..dfe6d51 100644
--- a/include/utils/FileMap.h
+++ b/include/utils/FileMap.h
@@ -22,6 +22,8 @@
#include <sys/types.h>
+#include <utils/Compat.h>
+
#ifdef HAVE_WIN32_FILEMAP
#include <windows.h>
#endif
@@ -55,7 +57,7 @@
* Returns "false" on failure.
*/
bool create(const char* origFileName, int fd,
- off_t offset, size_t length, bool readOnly);
+ off64_t offset, size_t length, bool readOnly);
/*
* Return the name of the file this map came from, if known.
@@ -75,7 +77,7 @@
/*
* Get the data offset used to create this map.
*/
- off_t getDataOffset(void) const { return mDataOffset; }
+ off64_t getDataOffset(void) const { return mDataOffset; }
/*
* Get a "copy" of the object.
@@ -118,7 +120,7 @@
char* mFileName; // original file name, if known
void* mBasePtr; // base of mmap area; page aligned
size_t mBaseLength; // length, measured from "mBasePtr"
- off_t mDataOffset; // offset used when map was created
+ off64_t mDataOffset; // offset used when map was created
void* mDataPtr; // start of requested data, offset from base
size_t mDataLength; // length, measured from "mDataPtr"
#ifdef HAVE_WIN32_FILEMAP
diff --git a/include/utils/StreamingZipInflater.h b/include/utils/StreamingZipInflater.h
index 16867d8..3ace5d5 100644
--- a/include/utils/StreamingZipInflater.h
+++ b/include/utils/StreamingZipInflater.h
@@ -21,6 +21,8 @@
#include <inttypes.h>
#include <zlib.h>
+#include <utils/Compat.h>
+
namespace android {
class StreamingZipInflater {
@@ -29,7 +31,7 @@
static const size_t OUTPUT_CHUNK_SIZE = 64 * 1024;
// Flavor that pages in the compressed data from a fd
- StreamingZipInflater(int fd, off_t compDataStart, size_t uncompSize, size_t compSize);
+ StreamingZipInflater(int fd, off64_t compDataStart, size_t uncompSize, size_t compSize);
// Flavor that gets the compressed data from an in-memory buffer
StreamingZipInflater(class FileMap* dataMap, size_t uncompSize);
@@ -43,7 +45,7 @@
// seeking backwards requires uncompressing fom the beginning, so is very
// expensive. seeking forwards only requires uncompressing from the current
// position to the destination.
- off_t seekAbsolute(off_t absoluteInputPosition);
+ off64_t seekAbsolute(off64_t absoluteInputPosition);
private:
void initInflateState();
@@ -51,7 +53,7 @@
// where to find the uncompressed data
int mFd;
- off_t mInFileStart; // where the compressed data lives in the file
+ off64_t mInFileStart; // where the compressed data lives in the file
class FileMap* mDataMap;
z_stream mInflateState;
@@ -63,7 +65,7 @@
size_t mOutTotalSize; // total uncompressed size of the blob
// current output state bookkeeping
- off_t mOutCurPosition; // current position in total offset
+ off64_t mOutCurPosition; // current position in total offset
size_t mOutLastDecoded; // last decoded byte + 1 in mOutbuf
size_t mOutDeliverable; // next undelivered byte of decoded output in mOutBuf
diff --git a/include/utils/ZipFileCRO.h b/include/utils/ZipFileCRO.h
index e38bf66..3e42a95 100644
--- a/include/utils/ZipFileCRO.h
+++ b/include/utils/ZipFileCRO.h
@@ -24,6 +24,8 @@
#include <stdlib.h>
#include <unistd.h>
+#include <utils/Compat.h>
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -48,7 +50,7 @@
extern bool ZipFileCRO_getEntryInfo(ZipFileCRO zip, ZipEntryCRO entry,
int* pMethod, size_t* pUncompLen,
- size_t* pCompLen, off_t* pOffset, long* pModWhen, long* pCrc32);
+ size_t* pCompLen, off64_t* pOffset, long* pModWhen, long* pCrc32);
extern bool ZipFileCRO_uncompressEntry(ZipFileCRO zip, ZipEntryCRO entry, int fd);
diff --git a/include/utils/ZipFileRO.h b/include/utils/ZipFileRO.h
index 3c1f3ca..3a99979 100644
--- a/include/utils/ZipFileRO.h
+++ b/include/utils/ZipFileRO.h
@@ -30,6 +30,7 @@
#ifndef __LIBS_ZIPFILERO_H
#define __LIBS_ZIPFILERO_H
+#include <utils/Compat.h>
#include <utils/Errors.h>
#include <utils/FileMap.h>
#include <utils/threads.h>
@@ -128,7 +129,7 @@
* appears to be bad.
*/
bool getEntryInfo(ZipEntryRO entry, int* pMethod, size_t* pUncompLen,
- size_t* pCompLen, off_t* pOffset, long* pModWhen, long* pCrc32) const;
+ size_t* pCompLen, off64_t* pOffset, long* pModWhen, long* pCrc32) const;
/*
* Create a new FileMap object that maps a subset of the archive. For
@@ -231,7 +232,7 @@
int mNumEntries;
/* CD directory offset in the Zip archive */
- off_t mDirectoryOffset;
+ off64_t mDirectoryOffset;
/*
* We know how many entries are in the Zip archive, so we have a
diff --git a/libs/surfaceflinger_client/ISurface.cpp b/libs/surfaceflinger_client/ISurface.cpp
index 7049d9e..23b90af 100644
--- a/libs/surfaceflinger_client/ISurface.cpp
+++ b/libs/surfaceflinger_client/ISurface.cpp
@@ -21,9 +21,7 @@
#include <sys/types.h>
#include <binder/Parcel.h>
-#include <binder/IMemory.h>
-#include <ui/Overlay.h>
#include <ui/GraphicBuffer.h>
#include <surfaceflinger/Surface.h>
@@ -33,36 +31,6 @@
// ----------------------------------------------------------------------
-ISurface::BufferHeap::BufferHeap()
- : w(0), h(0), hor_stride(0), ver_stride(0), format(0),
- transform(0), flags(0)
-{
-}
-
-ISurface::BufferHeap::BufferHeap(uint32_t w, uint32_t h,
- int32_t hor_stride, int32_t ver_stride,
- PixelFormat format, const sp<IMemoryHeap>& heap)
- : w(w), h(h), hor_stride(hor_stride), ver_stride(ver_stride),
- format(format), transform(0), flags(0), heap(heap)
-{
-}
-
-ISurface::BufferHeap::BufferHeap(uint32_t w, uint32_t h,
- int32_t hor_stride, int32_t ver_stride,
- PixelFormat format, uint32_t transform, uint32_t flags,
- const sp<IMemoryHeap>& heap)
- : w(w), h(h), hor_stride(hor_stride), ver_stride(ver_stride),
- format(format), transform(transform), flags(flags), heap(heap)
-{
-}
-
-
-ISurface::BufferHeap::~BufferHeap()
-{
-}
-
-// ----------------------------------------------------------------------
-
class BpSurface : public BpInterface<ISurface>
{
public:
@@ -96,51 +64,6 @@
status_t err = reply.readInt32();
return err;
}
-
- virtual status_t registerBuffers(const BufferHeap& buffers)
- {
- Parcel data, reply;
- data.writeInterfaceToken(ISurface::getInterfaceDescriptor());
- data.writeInt32(buffers.w);
- data.writeInt32(buffers.h);
- data.writeInt32(buffers.hor_stride);
- data.writeInt32(buffers.ver_stride);
- data.writeInt32(buffers.format);
- data.writeInt32(buffers.transform);
- data.writeInt32(buffers.flags);
- data.writeStrongBinder(buffers.heap->asBinder());
- remote()->transact(REGISTER_BUFFERS, data, &reply);
- status_t result = reply.readInt32();
- return result;
- }
-
- virtual void postBuffer(ssize_t offset)
- {
- Parcel data, reply;
- data.writeInterfaceToken(ISurface::getInterfaceDescriptor());
- data.writeInt32(offset);
- remote()->transact(POST_BUFFER, data, &reply, IBinder::FLAG_ONEWAY);
- }
-
- virtual void unregisterBuffers()
- {
- Parcel data, reply;
- data.writeInterfaceToken(ISurface::getInterfaceDescriptor());
- remote()->transact(UNREGISTER_BUFFERS, data, &reply);
- }
-
- virtual sp<OverlayRef> createOverlay(
- uint32_t w, uint32_t h, int32_t format, int32_t orientation)
- {
- Parcel data, reply;
- data.writeInterfaceToken(ISurface::getInterfaceDescriptor());
- data.writeInt32(w);
- data.writeInt32(h);
- data.writeInt32(format);
- data.writeInt32(orientation);
- remote()->transact(CREATE_OVERLAY, data, &reply);
- return OverlayRef::readFromParcel(reply);
- }
};
IMPLEMENT_META_INTERFACE(Surface, "android.ui.ISurface");
@@ -170,41 +93,6 @@
reply->writeInt32(err);
return NO_ERROR;
}
- case REGISTER_BUFFERS: {
- CHECK_INTERFACE(ISurface, data, reply);
- BufferHeap buffer;
- buffer.w = data.readInt32();
- buffer.h = data.readInt32();
- buffer.hor_stride = data.readInt32();
- buffer.ver_stride= data.readInt32();
- buffer.format = data.readInt32();
- buffer.transform = data.readInt32();
- buffer.flags = data.readInt32();
- buffer.heap = interface_cast<IMemoryHeap>(data.readStrongBinder());
- status_t err = registerBuffers(buffer);
- reply->writeInt32(err);
- return NO_ERROR;
- } break;
- case UNREGISTER_BUFFERS: {
- CHECK_INTERFACE(ISurface, data, reply);
- unregisterBuffers();
- return NO_ERROR;
- } break;
- case POST_BUFFER: {
- CHECK_INTERFACE(ISurface, data, reply);
- ssize_t offset = data.readInt32();
- postBuffer(offset);
- return NO_ERROR;
- } break;
- case CREATE_OVERLAY: {
- CHECK_INTERFACE(ISurface, data, reply);
- int w = data.readInt32();
- int h = data.readInt32();
- int f = data.readInt32();
- int orientation = data.readInt32();
- sp<OverlayRef> o = createOverlay(w, h, f, orientation);
- return OverlayRef::writeToParcel(reply, o);
- } break;
default:
return BBinder::onTransact(code, data, reply, flags);
}
diff --git a/libs/ui/Android.mk b/libs/ui/Android.mk
index d0e041a..4ba8b5b 100644
--- a/libs/ui/Android.mk
+++ b/libs/ui/Android.mk
@@ -54,8 +54,6 @@
InputManager.cpp \
InputReader.cpp \
InputTransport.cpp \
- IOverlay.cpp \
- Overlay.cpp \
PixelFormat.cpp \
Rect.cpp \
Region.cpp
@@ -64,7 +62,6 @@
libcutils \
libutils \
libEGL \
- libbinder \
libpixelflinger \
libhardware \
libhardware_legacy
diff --git a/libs/ui/FramebufferNativeWindow.cpp b/libs/ui/FramebufferNativeWindow.cpp
index 04a0195..0702d49 100644
--- a/libs/ui/FramebufferNativeWindow.cpp
+++ b/libs/ui/FramebufferNativeWindow.cpp
@@ -182,6 +182,16 @@
return fb->setSwapInterval(fb, interval);
}
+void FramebufferNativeWindow::dump(String8& result) {
+ if (fbDev->common.version >= 1 && fbDev->dump) {
+ const size_t SIZE = 4096;
+ char buffer[SIZE];
+
+ fbDev->dump(fbDev, buffer, SIZE);
+ result.append(buffer);
+ }
+}
+
// only for debugging / logging
int FramebufferNativeWindow::getCurrentBufferIndex() const
{
diff --git a/libs/ui/GraphicBufferAllocator.cpp b/libs/ui/GraphicBufferAllocator.cpp
index fa46ab7..ce84683 100644
--- a/libs/ui/GraphicBufferAllocator.cpp
+++ b/libs/ui/GraphicBufferAllocator.cpp
@@ -24,8 +24,6 @@
#include <ui/GraphicBufferAllocator.h>
-#include <private/ui/sw_gralloc_handle.h>
-
namespace android {
// ---------------------------------------------------------------------------
@@ -56,7 +54,7 @@
Mutex::Autolock _l(sLock);
KeyedVector<buffer_handle_t, alloc_rec_t>& list(sAllocList);
size_t total = 0;
- const size_t SIZE = 512;
+ const size_t SIZE = 4096;
char buffer[SIZE];
snprintf(buffer, SIZE, "Allocated buffers:\n");
result.append(buffer);
@@ -71,6 +69,10 @@
}
snprintf(buffer, SIZE, "Total allocated: %.2f KB\n", total/1024.0f);
result.append(buffer);
+ if (mAllocDev->common.version >= 1 && mAllocDev->dump) {
+ mAllocDev->dump(mAllocDev, buffer, SIZE);
+ result.append(buffer);
+ }
}
void GraphicBufferAllocator::dumpToSystemLog()
@@ -91,11 +93,7 @@
// we have a h/w allocator and h/w buffer is requested
status_t err;
- if (usage & GRALLOC_USAGE_HW_MASK) {
- err = mAllocDev->alloc(mAllocDev, w, h, format, usage, handle, stride);
- } else {
- err = sw_gralloc_handle_t::alloc(w, h, format, usage, handle, stride);
- }
+ err = mAllocDev->alloc(mAllocDev, w, h, format, usage, handle, stride);
LOGW_IF(err, "alloc(%u, %u, %d, %08x, ...) failed %d (%s)",
w, h, format, usage, err, strerror(-err));
@@ -119,11 +117,8 @@
status_t GraphicBufferAllocator::free(buffer_handle_t handle)
{
status_t err;
- if (sw_gralloc_handle_t::validate(handle) < 0) {
- err = mAllocDev->free(mAllocDev, handle);
- } else {
- err = sw_gralloc_handle_t::free((sw_gralloc_handle_t*)handle);
- }
+
+ err = mAllocDev->free(mAllocDev, handle);
LOGW_IF(err, "free(...) failed %d (%s)", err, strerror(-err));
if (err == NO_ERROR) {
diff --git a/libs/ui/GraphicBufferMapper.cpp b/libs/ui/GraphicBufferMapper.cpp
index ce2acd0..07c0674 100644
--- a/libs/ui/GraphicBufferMapper.cpp
+++ b/libs/ui/GraphicBufferMapper.cpp
@@ -17,15 +17,7 @@
#define LOG_TAG "GraphicBufferMapper"
#include <stdint.h>
-#ifdef HAVE_ANDROID_OS // just want PAGE_SIZE define
-# include <asm/page.h>
-#else
-# include <sys/user.h>
-#endif
#include <errno.h>
-#include <sys/mman.h>
-
-#include <cutils/ashmem.h>
#include <utils/Errors.h>
#include <utils/Log.h>
@@ -35,8 +27,6 @@
#include <hardware/gralloc.h>
-#include <private/ui/sw_gralloc_handle.h>
-
namespace android {
// ---------------------------------------------------------------------------
@@ -57,11 +47,9 @@
status_t GraphicBufferMapper::registerBuffer(buffer_handle_t handle)
{
status_t err;
- if (sw_gralloc_handle_t::validate(handle) < 0) {
- err = mAllocMod->registerBuffer(mAllocMod, handle);
- } else {
- err = sw_gralloc_handle_t::registerBuffer((sw_gralloc_handle_t*)handle);
- }
+
+ err = mAllocMod->registerBuffer(mAllocMod, handle);
+
LOGW_IF(err, "registerBuffer(%p) failed %d (%s)",
handle, err, strerror(-err));
return err;
@@ -70,11 +58,9 @@
status_t GraphicBufferMapper::unregisterBuffer(buffer_handle_t handle)
{
status_t err;
- if (sw_gralloc_handle_t::validate(handle) < 0) {
- err = mAllocMod->unregisterBuffer(mAllocMod, handle);
- } else {
- err = sw_gralloc_handle_t::unregisterBuffer((sw_gralloc_handle_t*)handle);
- }
+
+ err = mAllocMod->unregisterBuffer(mAllocMod, handle);
+
LOGW_IF(err, "unregisterBuffer(%p) failed %d (%s)",
handle, err, strerror(-err));
return err;
@@ -84,15 +70,11 @@
int usage, const Rect& bounds, void** vaddr)
{
status_t err;
- if (sw_gralloc_handle_t::validate(handle) < 0) {
- err = mAllocMod->lock(mAllocMod, handle, usage,
- bounds.left, bounds.top, bounds.width(), bounds.height(),
- vaddr);
- } else {
- err = sw_gralloc_handle_t::lock((sw_gralloc_handle_t*)handle, usage,
- bounds.left, bounds.top, bounds.width(), bounds.height(),
- vaddr);
- }
+
+ err = mAllocMod->lock(mAllocMod, handle, usage,
+ bounds.left, bounds.top, bounds.width(), bounds.height(),
+ vaddr);
+
LOGW_IF(err, "lock(...) failed %d (%s)", err, strerror(-err));
return err;
}
@@ -100,129 +82,12 @@
status_t GraphicBufferMapper::unlock(buffer_handle_t handle)
{
status_t err;
- if (sw_gralloc_handle_t::validate(handle) < 0) {
- err = mAllocMod->unlock(mAllocMod, handle);
- } else {
- err = sw_gralloc_handle_t::unlock((sw_gralloc_handle_t*)handle);
- }
+
+ err = mAllocMod->unlock(mAllocMod, handle);
+
LOGW_IF(err, "unlock(...) failed %d (%s)", err, strerror(-err));
return err;
}
// ---------------------------------------------------------------------------
-
-status_t sw_gralloc_handle_t::alloc(uint32_t w, uint32_t h, int format,
- int usage, buffer_handle_t* pHandle, int32_t* pStride)
-{
- int align = 4;
- int bpp = 0;
- switch (format) {
- case HAL_PIXEL_FORMAT_RGBA_8888:
- case HAL_PIXEL_FORMAT_RGBX_8888:
- case HAL_PIXEL_FORMAT_BGRA_8888:
- bpp = 4;
- break;
- case HAL_PIXEL_FORMAT_RGB_888:
- bpp = 3;
- break;
- case HAL_PIXEL_FORMAT_RGB_565:
- case HAL_PIXEL_FORMAT_RGBA_5551:
- case HAL_PIXEL_FORMAT_RGBA_4444:
- bpp = 2;
- break;
- default:
- return -EINVAL;
- }
- size_t bpr = (w*bpp + (align-1)) & ~(align-1);
- size_t size = bpr * h;
- size_t stride = bpr / bpp;
- size = (size + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1);
-
- int fd = ashmem_create_region("sw-gralloc-buffer", size);
- if (fd < 0) {
- LOGE("ashmem_create_region(size=%d) failed (%s)",
- size, strerror(-errno));
- return -errno;
- }
-
- int prot = PROT_READ;
- if (usage & GRALLOC_USAGE_SW_WRITE_MASK)
- prot |= PROT_WRITE;
-
- if (ashmem_set_prot_region(fd, prot) < 0) {
- LOGE("ashmem_set_prot_region(fd=%d, prot=%x) failed (%s)",
- fd, prot, strerror(-errno));
- close(fd);
- return -errno;
- }
-
- void* base = mmap(0, size, prot, MAP_SHARED, fd, 0);
- if (base == MAP_FAILED) {
- LOGE("alloc mmap(fd=%d, size=%d, prot=%x) failed (%s)",
- fd, size, prot, strerror(-errno));
- close(fd);
- return -errno;
- }
-
- sw_gralloc_handle_t* hnd = new sw_gralloc_handle_t();
- hnd->fd = fd;
- hnd->size = size;
- hnd->base = intptr_t(base);
- hnd->prot = prot;
- *pStride = stride;
- *pHandle = hnd;
-
- return NO_ERROR;
-}
-
-status_t sw_gralloc_handle_t::free(sw_gralloc_handle_t* hnd)
-{
- if (hnd->base) {
- munmap((void*)hnd->base, hnd->size);
- }
- if (hnd->fd >= 0) {
- close(hnd->fd);
- }
- delete hnd;
- return NO_ERROR;
-}
-
-status_t sw_gralloc_handle_t::registerBuffer(sw_gralloc_handle_t* hnd)
-{
- if (hnd->pid != getpid()) {
- void* base = mmap(0, hnd->size, hnd->prot, MAP_SHARED, hnd->fd, 0);
- if (base == MAP_FAILED) {
- LOGE("registerBuffer mmap(fd=%d, size=%d, prot=%x) failed (%s)",
- hnd->fd, hnd->size, hnd->prot, strerror(-errno));
- return -errno;
- }
- hnd->base = intptr_t(base);
- }
- return NO_ERROR;
-}
-
-status_t sw_gralloc_handle_t::unregisterBuffer(sw_gralloc_handle_t* hnd)
-{
- if (hnd->pid != getpid()) {
- if (hnd->base) {
- munmap((void*)hnd->base, hnd->size);
- }
- hnd->base = 0;
- }
- return NO_ERROR;
-}
-
-status_t sw_gralloc_handle_t::lock(sw_gralloc_handle_t* hnd, int usage,
- int l, int t, int w, int h, void** vaddr)
-{
- *vaddr = (void*)hnd->base;
- return NO_ERROR;
-}
-
-status_t sw_gralloc_handle_t::unlock(sw_gralloc_handle_t* hnd)
-{
- return NO_ERROR;
-}
-
-// ---------------------------------------------------------------------------
}; // namespace android
diff --git a/libs/ui/IOverlay.cpp b/libs/ui/IOverlay.cpp
deleted file mode 100644
index 65e6b4f..0000000
--- a/libs/ui/IOverlay.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2007 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 <stdio.h>
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <binder/Parcel.h>
-#include <binder/IInterface.h>
-
-#include <ui/IOverlay.h>
-
-namespace android {
-
-enum {
- DESTROY = IBinder::FIRST_CALL_TRANSACTION, // one-way transaction
-};
-
-class BpOverlay : public BpInterface<IOverlay>
-{
-public:
- BpOverlay(const sp<IBinder>& impl)
- : BpInterface<IOverlay>(impl)
- {
- }
-
- virtual void destroy()
- {
- Parcel data, reply;
- data.writeInterfaceToken(IOverlay::getInterfaceDescriptor());
- remote()->transact(DESTROY, data, &reply, IBinder::FLAG_ONEWAY);
- }
-};
-
-IMPLEMENT_META_INTERFACE(Overlay, "android.ui.IOverlay");
-
-// ----------------------------------------------------------------------
-
-status_t BnOverlay::onTransact(
- uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
-{
- switch(code) {
- case DESTROY: {
- CHECK_INTERFACE(IOverlay, data, reply);
- destroy();
- return NO_ERROR;
- } break;
- default:
- return BBinder::onTransact(code, data, reply, flags);
- }
-}
-
-}; // namespace android
diff --git a/libs/ui/Overlay.cpp b/libs/ui/Overlay.cpp
deleted file mode 100644
index b082c53..0000000
--- a/libs/ui/Overlay.cpp
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Copyright (C) 2007 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 <binder/IMemory.h>
-#include <binder/Parcel.h>
-#include <utils/Errors.h>
-#include <binder/MemoryHeapBase.h>
-
-#include <ui/IOverlay.h>
-#include <ui/Overlay.h>
-
-#include <hardware/overlay.h>
-
-namespace android {
-
-Overlay::Overlay(const sp<OverlayRef>& overlayRef)
- : mOverlayRef(overlayRef), mOverlayData(0), mStatus(NO_INIT)
-{
- mOverlayData = NULL;
- hw_module_t const* module;
- if (overlayRef != 0) {
- if (hw_get_module(OVERLAY_HARDWARE_MODULE_ID, &module) == 0) {
- if (overlay_data_open(module, &mOverlayData) == NO_ERROR) {
- mStatus = mOverlayData->initialize(mOverlayData,
- overlayRef->mOverlayHandle);
- }
- }
- }
-}
-
-Overlay::~Overlay() {
- if (mOverlayData) {
- overlay_data_close(mOverlayData);
- }
-}
-
-status_t Overlay::dequeueBuffer(overlay_buffer_t* buffer)
-{
- if (mStatus != NO_ERROR) return mStatus;
- return mOverlayData->dequeueBuffer(mOverlayData, buffer);
-}
-
-status_t Overlay::queueBuffer(overlay_buffer_t buffer)
-{
- if (mStatus != NO_ERROR) return mStatus;
- return mOverlayData->queueBuffer(mOverlayData, buffer);
-}
-
-status_t Overlay::resizeInput(uint32_t width, uint32_t height)
-{
- if (mStatus != NO_ERROR) return mStatus;
- return mOverlayData->resizeInput(mOverlayData, width, height);
-}
-
-status_t Overlay::setParameter(int param, int value)
-{
- if (mStatus != NO_ERROR) return mStatus;
- return mOverlayData->setParameter(mOverlayData, param, value);
-}
-
-status_t Overlay::setCrop(uint32_t x, uint32_t y, uint32_t w, uint32_t h)
-{
- if (mStatus != NO_ERROR) return mStatus;
- return mOverlayData->setCrop(mOverlayData, x, y, w, h);
-}
-
-status_t Overlay::getCrop(uint32_t* x, uint32_t* y, uint32_t* w, uint32_t* h)
-{
- if (mStatus != NO_ERROR) return mStatus;
- return mOverlayData->getCrop(mOverlayData, x, y, w, h);
-}
-
-int32_t Overlay::getBufferCount() const
-{
- if (mStatus != NO_ERROR) return mStatus;
- return mOverlayData->getBufferCount(mOverlayData);
-}
-
-void* Overlay::getBufferAddress(overlay_buffer_t buffer)
-{
- if (mStatus != NO_ERROR) return NULL;
- return mOverlayData->getBufferAddress(mOverlayData, buffer);
-}
-
-void Overlay::destroy() {
-
- // Must delete the objects in reverse creation order, thus the
- // data side must be closed first and then the destroy send to
- // the control side.
- if (mOverlayData) {
- overlay_data_close(mOverlayData);
- mOverlayData = NULL;
- } else {
- LOGD("Overlay::destroy mOverlayData is NULL");
- }
-
- if (mOverlayRef != 0) {
- mOverlayRef->mOverlayChannel->destroy();
- } else {
- LOGD("Overlay::destroy mOverlayRef is NULL");
- }
-}
-
-status_t Overlay::getStatus() const {
- return mStatus;
-}
-
-overlay_handle_t Overlay::getHandleRef() const {
- if (mStatus != NO_ERROR) return NULL;
- return mOverlayRef->mOverlayHandle;
-}
-
-uint32_t Overlay::getWidth() const {
- if (mStatus != NO_ERROR) return 0;
- return mOverlayRef->mWidth;
-}
-
-uint32_t Overlay::getHeight() const {
- if (mStatus != NO_ERROR) return 0;
- return mOverlayRef->mHeight;
-}
-
-int32_t Overlay::getFormat() const {
- if (mStatus != NO_ERROR) return -1;
- return mOverlayRef->mFormat;
-}
-
-int32_t Overlay::getWidthStride() const {
- if (mStatus != NO_ERROR) return 0;
- return mOverlayRef->mWidthStride;
-}
-
-int32_t Overlay::getHeightStride() const {
- if (mStatus != NO_ERROR) return 0;
- return mOverlayRef->mHeightStride;
-}
-// ----------------------------------------------------------------------------
-
-OverlayRef::OverlayRef()
- : mOverlayHandle(0),
- mWidth(0), mHeight(0), mFormat(0), mWidthStride(0), mHeightStride(0),
- mOwnHandle(true)
-{
-}
-
-OverlayRef::OverlayRef(overlay_handle_t handle, const sp<IOverlay>& channel,
- uint32_t w, uint32_t h, int32_t f, uint32_t ws, uint32_t hs)
- : mOverlayHandle(handle), mOverlayChannel(channel),
- mWidth(w), mHeight(h), mFormat(f), mWidthStride(ws), mHeightStride(hs),
- mOwnHandle(false)
-{
-}
-
-OverlayRef::~OverlayRef()
-{
- if (mOwnHandle) {
- native_handle_close(mOverlayHandle);
- native_handle_delete(const_cast<native_handle*>(mOverlayHandle));
- }
-}
-
-sp<OverlayRef> OverlayRef::readFromParcel(const Parcel& data) {
- sp<OverlayRef> result;
- sp<IOverlay> overlay = IOverlay::asInterface(data.readStrongBinder());
- if (overlay != NULL) {
- uint32_t w = data.readInt32();
- uint32_t h = data.readInt32();
- uint32_t f = data.readInt32();
- uint32_t ws = data.readInt32();
- uint32_t hs = data.readInt32();
- native_handle* handle = data.readNativeHandle();
-
- result = new OverlayRef();
- result->mOverlayHandle = handle;
- result->mOverlayChannel = overlay;
- result->mWidth = w;
- result->mHeight = h;
- result->mFormat = f;
- result->mWidthStride = ws;
- result->mHeightStride = hs;
- }
- return result;
-}
-
-status_t OverlayRef::writeToParcel(Parcel* reply, const sp<OverlayRef>& o) {
- if (o != NULL) {
- reply->writeStrongBinder(o->mOverlayChannel->asBinder());
- reply->writeInt32(o->mWidth);
- reply->writeInt32(o->mHeight);
- reply->writeInt32(o->mFormat);
- reply->writeInt32(o->mWidthStride);
- reply->writeInt32(o->mHeightStride);
- reply->writeNativeHandle(o->mOverlayHandle);
- } else {
- reply->writeStrongBinder(NULL);
- }
- return NO_ERROR;
-}
-
-// ----------------------------------------------------------------------------
-
-}; // namespace android
diff --git a/libs/utils/Android.mk b/libs/utils/Android.mk
index 8bd833b..e8d40ba 100644
--- a/libs/utils/Android.mk
+++ b/libs/utils/Android.mk
@@ -70,11 +70,6 @@
endif
endif
-ifeq ($(HOST_OS),darwin)
-# MacOS doesn't have lseek64. However, off_t is 64-bit anyway.
-LOCAL_CFLAGS += -DOFF_T_IS_64_BIT
-endif
-
include $(BUILD_HOST_STATIC_LIBRARY)
diff --git a/libs/utils/Asset.cpp b/libs/utils/Asset.cpp
index cef7db4..a18294b 100644
--- a/libs/utils/Asset.cpp
+++ b/libs/utils/Asset.cpp
@@ -35,6 +35,9 @@
#include <fcntl.h>
#include <errno.h>
#include <assert.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
using namespace android;
@@ -62,7 +65,7 @@
if (cur->isAllocated()) {
res.append(" ");
res.append(cur->getAssetSource());
- off_t size = (cur->getLength()+512)/1024;
+ off64_t size = (cur->getLength()+512)/1024;
char buf[64];
sprintf(buf, ": %dK\n", (int)size);
res.append(buf);
@@ -119,7 +122,7 @@
{
_FileAsset* pAsset;
status_t result;
- off_t length;
+ off64_t length;
int fd;
fd = open(fileName, O_RDONLY | O_BINARY);
@@ -132,12 +135,26 @@
* always open things read-only it doesn't really matter, so there's
* no value in incurring the extra overhead of an fstat() call.
*/
- length = lseek(fd, 0, SEEK_END);
+ // TODO(kroot): replace this with fstat despite the plea above.
+#if 1
+ length = lseek64(fd, 0, SEEK_END);
if (length < 0) {
::close(fd);
return NULL;
}
- (void) lseek(fd, 0, SEEK_SET);
+ (void) lseek64(fd, 0, SEEK_SET);
+#else
+ struct stat st;
+ if (fstat(fd, &st) < 0) {
+ ::close(fd);
+ return NULL;
+ }
+
+ if (!S_ISREG(st.st_mode)) {
+ ::close(fd);
+ return NULL;
+ }
+#endif
pAsset = new _FileAsset;
result = pAsset->openChunk(fileName, fd, 0, length);
@@ -162,7 +179,7 @@
{
_CompressedAsset* pAsset;
status_t result;
- off_t fileLen;
+ off64_t fileLen;
bool scanResult;
long offset;
int method;
@@ -215,7 +232,7 @@
/*
* Create a new Asset from part of an open file.
*/
-/*static*/ Asset* Asset::createFromFileSegment(int fd, off_t offset,
+/*static*/ Asset* Asset::createFromFileSegment(int fd, off64_t offset,
size_t length, AccessMode mode)
{
_FileAsset* pAsset;
@@ -233,7 +250,7 @@
/*
* Create a new Asset from compressed data in an open file.
*/
-/*static*/ Asset* Asset::createFromCompressedData(int fd, off_t offset,
+/*static*/ Asset* Asset::createFromCompressedData(int fd, off64_t offset,
int compressionMethod, size_t uncompressedLen, size_t compressedLen,
AccessMode mode)
{
@@ -295,9 +312,9 @@
*
* Returns the new chunk offset, or -1 if the seek is illegal.
*/
-off_t Asset::handleSeek(off_t offset, int whence, off_t curPosn, off_t maxPosn)
+off64_t Asset::handleSeek(off64_t offset, int whence, off64_t curPosn, off64_t maxPosn)
{
- off_t newOffset;
+ off64_t newOffset;
switch (whence) {
case SEEK_SET:
@@ -311,15 +328,15 @@
break;
default:
LOGW("unexpected whence %d\n", whence);
- // this was happening due to an off_t size mismatch
+ // this was happening due to an off64_t size mismatch
assert(false);
- return (off_t) -1;
+ return (off64_t) -1;
}
if (newOffset < 0 || newOffset > maxPosn) {
LOGW("seek out of range: want %ld, end=%ld\n",
(long) newOffset, (long) maxPosn);
- return (off_t) -1;
+ return (off64_t) -1;
}
return newOffset;
@@ -353,7 +370,7 @@
*
* Zero-length chunks are allowed.
*/
-status_t _FileAsset::openChunk(const char* fileName, int fd, off_t offset, size_t length)
+status_t _FileAsset::openChunk(const char* fileName, int fd, off64_t offset, size_t length)
{
assert(mFp == NULL); // no reopen
assert(mMap == NULL);
@@ -363,15 +380,15 @@
/*
* Seek to end to get file length.
*/
- off_t fileLength;
- fileLength = lseek(fd, 0, SEEK_END);
- if (fileLength == (off_t) -1) {
+ off64_t fileLength;
+ fileLength = lseek64(fd, 0, SEEK_END);
+ if (fileLength == (off64_t) -1) {
// probably a bad file descriptor
LOGD("failed lseek (errno=%d)\n", errno);
return UNKNOWN_ERROR;
}
- if ((off_t) (offset + length) > fileLength) {
+ if ((off64_t) (offset + length) > fileLength) {
LOGD("start (%ld) + len (%ld) > end (%ld)\n",
(long) offset, (long) length, (long) fileLength);
return BAD_INDEX;
@@ -482,21 +499,21 @@
/*
* Seek to a new position.
*/
-off_t _FileAsset::seek(off_t offset, int whence)
+off64_t _FileAsset::seek(off64_t offset, int whence)
{
- off_t newPosn;
- long actualOffset;
+ off64_t newPosn;
+ off64_t actualOffset;
// compute new position within chunk
newPosn = handleSeek(offset, whence, mOffset, mLength);
- if (newPosn == (off_t) -1)
+ if (newPosn == (off64_t) -1)
return newPosn;
- actualOffset = (long) (mStart + newPosn);
+ actualOffset = mStart + newPosn;
if (mFp != NULL) {
if (fseek(mFp, (long) actualOffset, SEEK_SET) != 0)
- return (off_t) -1;
+ return (off64_t) -1;
}
mOffset = actualOffset - mStart;
@@ -603,7 +620,7 @@
}
}
-int _FileAsset::openFileDescriptor(off_t* outStart, off_t* outLength) const
+int _FileAsset::openFileDescriptor(off64_t* outStart, off64_t* outLength) const
{
if (mMap != NULL) {
const char* fname = mMap->getFileName();
@@ -678,7 +695,7 @@
* This currently just sets up some values and returns. On the first
* read, we expand the entire file into a buffer and return data from it.
*/
-status_t _CompressedAsset::openChunk(int fd, off_t offset,
+status_t _CompressedAsset::openChunk(int fd, off64_t offset,
int compressionMethod, size_t uncompressedLen, size_t compressedLen)
{
assert(mFd < 0); // no re-open
@@ -782,13 +799,13 @@
* expensive, because it requires plowing through a bunch of compressed
* data.
*/
-off_t _CompressedAsset::seek(off_t offset, int whence)
+off64_t _CompressedAsset::seek(off64_t offset, int whence)
{
- off_t newPosn;
+ off64_t newPosn;
// compute new position within chunk
newPosn = handleSeek(offset, whence, mOffset, mUncompressedLen);
- if (newPosn == (off_t) -1)
+ if (newPosn == (off64_t) -1)
return newPosn;
if (mZipInflater) {
diff --git a/libs/utils/FileMap.cpp b/libs/utils/FileMap.cpp
index f1f8bda..c220a90 100644
--- a/libs/utils/FileMap.cpp
+++ b/libs/utils/FileMap.cpp
@@ -88,11 +88,12 @@
*
* Returns "false" on failure.
*/
-bool FileMap::create(const char* origFileName, int fd, off_t offset, size_t length, bool readOnly)
+bool FileMap::create(const char* origFileName, int fd, off64_t offset, size_t length,
+ bool readOnly)
{
#ifdef HAVE_WIN32_FILEMAP
int adjust;
- off_t adjOffset;
+ off64_t adjOffset;
size_t adjLength;
if (mPageSize == -1) {
@@ -131,7 +132,7 @@
#endif
#ifdef HAVE_POSIX_FILEMAP
int prot, flags, adjust;
- off_t adjOffset;
+ off64_t adjOffset;
size_t adjLength;
void* ptr;
diff --git a/libs/utils/ObbFile.cpp b/libs/utils/ObbFile.cpp
index 2c3724c..2907b56 100644
--- a/libs/utils/ObbFile.cpp
+++ b/libs/utils/ObbFile.cpp
@@ -22,6 +22,8 @@
#include <unistd.h>
#define LOG_TAG "ObbFile"
+
+#include <utils/Compat.h>
#include <utils/Log.h>
#include <utils/ObbFile.h>
@@ -67,17 +69,6 @@
_rc; })
#endif
-/*
- * Work around situations where off_t is 64-bit and use off64_t in
- * situations where it's 32-bit.
- */
-#ifdef OFF_T_IS_64_BIT
-#define my_lseek64 lseek
-typedef off_t my_off64_t;
-#else
-#define my_lseek64 lseek64
-typedef off64_t my_off64_t;
-#endif
namespace android {
@@ -125,7 +116,7 @@
bool ObbFile::parseObbFile(int fd)
{
- my_off64_t fileLength = my_lseek64(fd, 0, SEEK_END);
+ off64_t fileLength = lseek64(fd, 0, SEEK_END);
if (fileLength < kFooterMinSize) {
if (fileLength < 0) {
@@ -140,7 +131,7 @@
size_t footerSize;
{
- my_lseek64(fd, fileLength - kFooterTagSize, SEEK_SET);
+ lseek64(fd, fileLength - kFooterTagSize, SEEK_SET);
char *footer = new char[kFooterTagSize];
actual = TEMP_FAILURE_RETRY(read(fd, footer, kFooterTagSize));
@@ -171,8 +162,8 @@
}
}
- my_off64_t fileOffset = fileLength - footerSize - kFooterTagSize;
- if (my_lseek64(fd, fileOffset, SEEK_SET) != fileOffset) {
+ off64_t fileOffset = fileLength - footerSize - kFooterTagSize;
+ if (lseek64(fd, fileOffset, SEEK_SET) != fileOffset) {
LOGW("seek %lld failed: %s\n", fileOffset, strerror(errno));
return false;
}
@@ -211,10 +202,10 @@
memcpy(&mSalt, (unsigned char*)scanBuf + kSaltOffset, sizeof(mSalt));
- uint32_t packageNameLen = get4LE((unsigned char*)scanBuf + kPackageNameLenOffset);
- if (packageNameLen <= 0
+ size_t packageNameLen = get4LE((unsigned char*)scanBuf + kPackageNameLenOffset);
+ if (packageNameLen == 0
|| packageNameLen > (footerSize - kPackageNameOffset)) {
- LOGW("bad ObbFile package name length (0x%04x; 0x%04x possible)\n",
+ LOGW("bad ObbFile package name length (0x%04zx; 0x%04zx possible)\n",
packageNameLen, footerSize - kPackageNameOffset);
free(scanBuf);
return false;
@@ -257,7 +248,7 @@
return false;
}
- my_lseek64(fd, 0, SEEK_END);
+ lseek64(fd, 0, SEEK_END);
if (mPackageName.size() == 0 || mVersion == -1) {
LOGW("tried to write uninitialized ObbFile data\n");
diff --git a/libs/utils/StreamingZipInflater.cpp b/libs/utils/StreamingZipInflater.cpp
index 1f62ac5..5a162cc 100644
--- a/libs/utils/StreamingZipInflater.cpp
+++ b/libs/utils/StreamingZipInflater.cpp
@@ -31,7 +31,7 @@
/*
* Streaming access to compressed asset data in an open fd
*/
-StreamingZipInflater::StreamingZipInflater(int fd, off_t compDataStart,
+StreamingZipInflater::StreamingZipInflater(int fd, off64_t compDataStart,
size_t uncompSize, size_t compSize) {
mFd = fd;
mDataMap = NULL;
@@ -210,7 +210,7 @@
// seeking backwards requires uncompressing fom the beginning, so is very
// expensive. seeking forwards only requires uncompressing from the current
// position to the destination.
-off_t StreamingZipInflater::seekAbsolute(off_t absoluteInputPosition) {
+off64_t StreamingZipInflater::seekAbsolute(off64_t absoluteInputPosition) {
if (absoluteInputPosition < mOutCurPosition) {
// rewind and reprocess the data from the beginning
if (!mStreamNeedsInit) {
diff --git a/libs/utils/ZipFileCRO.cpp b/libs/utils/ZipFileCRO.cpp
index 16b219c..55dfd9f 100644
--- a/libs/utils/ZipFileCRO.cpp
+++ b/libs/utils/ZipFileCRO.cpp
@@ -40,7 +40,7 @@
bool ZipFileCRO_getEntryInfo(ZipFileCRO zipToken, ZipEntryRO entryToken,
int* pMethod, size_t* pUncompLen,
- size_t* pCompLen, off_t* pOffset, long* pModWhen, long* pCrc32) {
+ size_t* pCompLen, off64_t* pOffset, long* pModWhen, long* pCrc32) {
ZipFileRO* zip = (ZipFileRO*)zipToken;
ZipEntryRO entry = (ZipEntryRO)entryToken;
return zip->getEntryInfo(entry, pMethod, pUncompLen, pCompLen, pOffset,
diff --git a/libs/utils/ZipFileRO.cpp b/libs/utils/ZipFileRO.cpp
index 4261196..b18c383 100644
--- a/libs/utils/ZipFileRO.cpp
+++ b/libs/utils/ZipFileRO.cpp
@@ -146,7 +146,7 @@
return NAME_NOT_FOUND;
}
- mFileLength = lseek(fd, 0, SEEK_END);
+ mFileLength = lseek64(fd, 0, SEEK_END);
if (mFileLength < kEOCDLen) {
TEMP_FAILURE_RETRY(close(fd));
return UNKNOWN_ERROR;
@@ -202,7 +202,7 @@
/*
* Make sure this is a Zip archive.
*/
- if (lseek(mFd, 0, SEEK_SET) != 0) {
+ if (lseek64(mFd, 0, SEEK_SET) != 0) {
LOGW("seek to start failed: %s", strerror(errno));
free(scanBuf);
return false;
@@ -240,9 +240,9 @@
*
* We start by pulling in the last part of the file.
*/
- off_t searchStart = mFileLength - readAmount;
+ off64_t searchStart = mFileLength - readAmount;
- if (lseek(mFd, searchStart, SEEK_SET) != searchStart) {
+ if (lseek64(mFd, searchStart, SEEK_SET) != searchStart) {
LOGW("seek %ld failed: %s\n", (long) searchStart, strerror(errno));
free(scanBuf);
return false;
@@ -274,7 +274,7 @@
return false;
}
- off_t eocdOffset = searchStart + i;
+ off64_t eocdOffset = searchStart + i;
const unsigned char* eocdPtr = scanBuf + i;
assert(eocdOffset < mFileLength);
@@ -473,7 +473,7 @@
* appear to be bogus.
*/
bool ZipFileRO::getEntryInfo(ZipEntryRO entry, int* pMethod, size_t* pUncompLen,
- size_t* pCompLen, off_t* pOffset, long* pModWhen, long* pCrc32) const
+ size_t* pCompLen, off64_t* pOffset, long* pModWhen, long* pCrc32) const
{
bool ret = false;
@@ -489,7 +489,7 @@
* so we can just subtract back from that.
*/
const unsigned char* ptr = (const unsigned char*) hashEntry.name;
- off_t cdOffset = mDirectoryOffset;
+ off64_t cdOffset = mDirectoryOffset;
ptr -= kCDELen;
@@ -536,12 +536,12 @@
#ifdef HAVE_PREAD
/*
* This file descriptor might be from zygote's preloaded assets,
- * so we need to do an pread() instead of a lseek() + read() to
+ * so we need to do an pread64() instead of a lseek64() + read() to
* guarantee atomicity across the processes with the shared file
* descriptors.
*/
ssize_t actual =
- TEMP_FAILURE_RETRY(pread(mFd, lfhBuf, sizeof(lfhBuf), localHdrOffset));
+ TEMP_FAILURE_RETRY(pread64(mFd, lfhBuf, sizeof(lfhBuf), localHdrOffset));
if (actual != sizeof(lfhBuf)) {
LOGW("failed reading lfh from offset %ld\n", localHdrOffset);
@@ -556,17 +556,17 @@
}
#else /* HAVE_PREAD */
/*
- * For hosts don't have pread() we cannot guarantee atomic reads from
+ * For hosts don't have pread64() we cannot guarantee atomic reads from
* an offset in a file. Android should never run on those platforms.
* File descriptors inherited from a fork() share file offsets and
* there would be nothing to protect from two different processes
- * calling lseek() concurrently.
+ * calling lseek64() concurrently.
*/
{
AutoMutex _l(mFdLock);
- if (lseek(mFd, localHdrOffset, SEEK_SET) != localHdrOffset) {
+ if (lseek64(mFd, localHdrOffset, SEEK_SET) != localHdrOffset) {
LOGW("failed seeking to lfh at offset %ld\n", localHdrOffset);
return false;
}
@@ -579,7 +579,7 @@
}
if (get4LE(lfhBuf) != kLFHSignature) {
- off_t actualOffset = lseek(mFd, 0, SEEK_CUR);
+ off64_t actualOffset = lseek64(mFd, 0, SEEK_CUR);
LOGW("didn't find signature at start of lfh; wanted: offset=%ld data=0x%08x; "
"got: offset=" ZD " data=0x%08lx\n",
localHdrOffset, kLFHSignature, (ZD_TYPE) actualOffset, get4LE(lfhBuf));
@@ -588,7 +588,7 @@
}
#endif /* HAVE_PREAD */
- off_t dataOffset = localHdrOffset + kLFHLen
+ off64_t dataOffset = localHdrOffset + kLFHLen
+ get2LE(lfhBuf + kLFHNameLen) + get2LE(lfhBuf + kLFHExtraLen);
if (dataOffset >= cdOffset) {
LOGW("bad data offset %ld in zip\n", (long) dataOffset);
@@ -596,14 +596,14 @@
}
/* check lengths */
- if ((off_t)(dataOffset + compLen) > cdOffset) {
+ if ((off64_t)(dataOffset + compLen) > cdOffset) {
LOGW("bad compressed length in zip (%ld + " ZD " > %ld)\n",
(long) dataOffset, (ZD_TYPE) compLen, (long) cdOffset);
return false;
}
if (method == kCompressStored &&
- (off_t)(dataOffset + uncompLen) > cdOffset)
+ (off64_t)(dataOffset + uncompLen) > cdOffset)
{
LOGE("ERROR: bad uncompressed length in zip (%ld + " ZD " > %ld)\n",
(long) dataOffset, (ZD_TYPE) uncompLen, (long) cdOffset);
@@ -649,7 +649,7 @@
FileMap* newMap;
size_t compLen;
- off_t offset;
+ off64_t offset;
if (!getEntryInfo(entry, NULL, NULL, &compLen, &offset, NULL, NULL))
return NULL;
@@ -679,7 +679,7 @@
int method;
size_t uncompLen, compLen;
- off_t offset;
+ off64_t offset;
const unsigned char* ptr;
getEntryInfo(entry, &method, &uncompLen, &compLen, &offset, NULL, NULL);
@@ -739,7 +739,7 @@
int method;
size_t uncompLen, compLen;
- off_t offset;
+ off64_t offset;
const unsigned char* ptr;
getEntryInfo(entry, &method, &uncompLen, &compLen, &offset, NULL, NULL);
diff --git a/opengl/libagl/egl.cpp b/opengl/libagl/egl.cpp
index 7c496e7..7ac6f92 100644
--- a/opengl/libagl/egl.cpp
+++ b/opengl/libagl/egl.cpp
@@ -40,7 +40,6 @@
#include <pixelflinger/pixelflinger.h>
#include <private/ui/android_natives_priv.h>
-#include <private/ui/sw_gralloc_handle.h>
#include <hardware/copybit.h>
@@ -446,15 +445,10 @@
android_native_buffer_t* buf, int usage, void** vaddr)
{
int err;
- if (sw_gralloc_handle_t::validate(buf->handle) < 0) {
- err = module->lock(module, buf->handle,
- usage, 0, 0, buf->width, buf->height, vaddr);
- } else {
- sw_gralloc_handle_t const* hnd =
- reinterpret_cast<sw_gralloc_handle_t const*>(buf->handle);
- *vaddr = (void*)hnd->base;
- err = NO_ERROR;
- }
+
+ err = module->lock(module, buf->handle,
+ usage, 0, 0, buf->width, buf->height, vaddr);
+
return err;
}
@@ -462,9 +456,9 @@
{
if (!buf) return BAD_VALUE;
int err = NO_ERROR;
- if (sw_gralloc_handle_t::validate(buf->handle) < 0) {
- err = module->unlock(module, buf->handle);
- }
+
+ err = module->unlock(module, buf->handle);
+
return err;
}
diff --git a/opengl/libs/EGL/egl.cpp b/opengl/libs/EGL/egl.cpp
index d71ec1b..7acce02 100644
--- a/opengl/libs/EGL/egl.cpp
+++ b/opengl/libs/EGL/egl.cpp
@@ -220,8 +220,8 @@
egl_context_t(EGLDisplay dpy, EGLContext context, EGLConfig config,
int impl, egl_connection_t const* cnx, int version)
- : dpy(dpy), context(context), read(0), draw(0), impl(impl), cnx(cnx),
- version(version)
+ : dpy(dpy), context(context), config(config), read(0), draw(0), impl(impl),
+ cnx(cnx), version(version)
{
}
EGLDisplay dpy;
diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk
index 1c2a2c8..74d1ac9 100644
--- a/services/surfaceflinger/Android.mk
+++ b/services/surfaceflinger/Android.mk
@@ -6,12 +6,9 @@
DisplayHardware/DisplayHardware.cpp \
DisplayHardware/DisplayHardwareBase.cpp \
DisplayHardware/HWComposer.cpp \
- BlurFilter.cpp.arm \
GLExtensions.cpp \
Layer.cpp \
LayerBase.cpp \
- LayerBuffer.cpp \
- LayerBlur.cpp \
LayerDim.cpp \
MessageQueue.cpp \
SurfaceFlinger.cpp \
@@ -22,7 +19,7 @@
LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
ifeq ($(TARGET_BOARD_PLATFORM), omap3)
- LOCAL_CFLAGS += -DNO_RGBX_8888 -DHAS_PUSH_BUFFERS
+ LOCAL_CFLAGS += -DNO_RGBX_8888
endif
ifeq ($(TARGET_BOARD_PLATFORM), s5pc110)
LOCAL_CFLAGS += -DHAS_CONTEXT_PRIORITY
diff --git a/services/surfaceflinger/BlurFilter.cpp b/services/surfaceflinger/BlurFilter.cpp
deleted file mode 100644
index 1ffbd5b..0000000
--- a/services/surfaceflinger/BlurFilter.cpp
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
-**
-** Copyright 2006, 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 <string.h>
-#include <stdint.h>
-#include <utils/Errors.h>
-
-#include <pixelflinger/pixelflinger.h>
-
-#include "clz.h"
-
-#define LIKELY( exp ) (__builtin_expect( (exp) != 0, true ))
-#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false ))
-
-namespace android {
-
-#if BYTE_ORDER == LITTLE_ENDIAN
-inline uint32_t BLUR_RGBA_TO_HOST(uint32_t v) {
- return v;
-}
-inline uint32_t BLUR_HOST_TO_RGBA(uint32_t v) {
- return v;
-}
-#else
-inline uint32_t BLUR_RGBA_TO_HOST(uint32_t v) {
- return (v<<24) | (v>>24) | ((v<<8)&0xff0000) | ((v>>8)&0xff00);
-}
-inline uint32_t BLUR_HOST_TO_RGBA(uint32_t v) {
- return (v<<24) | (v>>24) | ((v<<8)&0xff0000) | ((v>>8)&0xff00);
-}
-#endif
-
-const int BLUR_DITHER_BITS = 6; // dither weights stored on 6 bits
-const int BLUR_DITHER_ORDER_SHIFT= 3;
-const int BLUR_DITHER_ORDER = (1<<BLUR_DITHER_ORDER_SHIFT);
-const int BLUR_DITHER_SIZE = BLUR_DITHER_ORDER * BLUR_DITHER_ORDER;
-const int BLUR_DITHER_MASK = BLUR_DITHER_ORDER-1;
-
-static const uint8_t gDitherMatrix[BLUR_DITHER_SIZE] = {
- 0, 32, 8, 40, 2, 34, 10, 42,
- 48, 16, 56, 24, 50, 18, 58, 26,
- 12, 44, 4, 36, 14, 46, 6, 38,
- 60, 28, 52, 20, 62, 30, 54, 22,
- 3, 35, 11, 43, 1, 33, 9, 41,
- 51, 19, 59, 27, 49, 17, 57, 25,
- 15, 47, 7, 39, 13, 45, 5, 37,
- 63, 31, 55, 23, 61, 29, 53, 21
-};
-
-
-template <int FACTOR = 0>
-struct BlurColor565
-{
- typedef uint16_t type;
- int r, g, b;
- inline BlurColor565() { }
- inline BlurColor565(uint16_t v) {
- r = v >> 11;
- g = (v >> 5) & 0x3E;
- b = v & 0x1F;
- }
- inline void clear() { r=g=b=0; }
- inline uint16_t to(int shift, int last, int dither) const {
- int R = r;
- int G = g;
- int B = b;
- if (UNLIKELY(last)) {
- if (FACTOR>0) {
- int L = (R+G+B)>>1;
- R += (((L>>1) - R) * FACTOR) >> 8;
- G += (((L ) - G) * FACTOR) >> 8;
- B += (((L>>1) - B) * FACTOR) >> 8;
- }
- R += (dither << shift) >> BLUR_DITHER_BITS;
- G += (dither << shift) >> BLUR_DITHER_BITS;
- B += (dither << shift) >> BLUR_DITHER_BITS;
- }
- R >>= shift;
- G >>= shift;
- B >>= shift;
- return (R<<11) | (G<<5) | B;
- }
- inline BlurColor565& operator += (const BlurColor565& rhs) {
- r += rhs.r;
- g += rhs.g;
- b += rhs.b;
- return *this;
- }
- inline BlurColor565& operator -= (const BlurColor565& rhs) {
- r -= rhs.r;
- g -= rhs.g;
- b -= rhs.b;
- return *this;
- }
-};
-
-template <int FACTOR = 0>
-struct BlurColor888X
-{
- typedef uint32_t type;
- int r, g, b;
- inline BlurColor888X() { }
- inline BlurColor888X(uint32_t v) {
- v = BLUR_RGBA_TO_HOST(v);
- r = v & 0xFF;
- g = (v >> 8) & 0xFF;
- b = (v >> 16) & 0xFF;
- }
- inline void clear() { r=g=b=0; }
- inline uint32_t to(int shift, int last, int dither) const {
- int R = r;
- int G = g;
- int B = b;
- if (UNLIKELY(last)) {
- if (FACTOR>0) {
- int L = (R+G+G+B)>>2;
- R += ((L - R) * FACTOR) >> 8;
- G += ((L - G) * FACTOR) >> 8;
- B += ((L - B) * FACTOR) >> 8;
- }
- }
- R >>= shift;
- G >>= shift;
- B >>= shift;
- return BLUR_HOST_TO_RGBA((0xFF<<24) | (B<<16) | (G<<8) | R);
- }
- inline BlurColor888X& operator += (const BlurColor888X& rhs) {
- r += rhs.r;
- g += rhs.g;
- b += rhs.b;
- return *this;
- }
- inline BlurColor888X& operator -= (const BlurColor888X& rhs) {
- r -= rhs.r;
- g -= rhs.g;
- b -= rhs.b;
- return *this;
- }
-};
-
-struct BlurGray565
-{
- typedef uint16_t type;
- int l;
- inline BlurGray565() { }
- inline BlurGray565(uint16_t v) {
- int r = v >> 11;
- int g = (v >> 5) & 0x3F;
- int b = v & 0x1F;
- l = (r + g + b + 1)>>1;
- }
- inline void clear() { l=0; }
- inline uint16_t to(int shift, int last, int dither) const {
- int L = l;
- if (UNLIKELY(last)) {
- L += (dither << shift) >> BLUR_DITHER_BITS;
- }
- L >>= shift;
- return ((L>>1)<<11) | (L<<5) | (L>>1);
- }
- inline BlurGray565& operator += (const BlurGray565& rhs) {
- l += rhs.l;
- return *this;
- }
- inline BlurGray565& operator -= (const BlurGray565& rhs) {
- l -= rhs.l;
- return *this;
- }
-};
-
-struct BlurGray8888
-{
- typedef uint32_t type;
- int l, a;
- inline BlurGray8888() { }
- inline BlurGray8888(uint32_t v) {
- v = BLUR_RGBA_TO_HOST(v);
- int r = v & 0xFF;
- int g = (v >> 8) & 0xFF;
- int b = (v >> 16) & 0xFF;
- a = v >> 24;
- l = r + g + g + b;
- }
- inline void clear() { l=a=0; }
- inline uint32_t to(int shift, int last, int dither) const {
- int L = l;
- int A = a;
- if (UNLIKELY(last)) {
- L += (dither << (shift+2)) >> BLUR_DITHER_BITS;
- A += (dither << shift) >> BLUR_DITHER_BITS;
- }
- L >>= (shift+2);
- A >>= shift;
- return BLUR_HOST_TO_RGBA((A<<24) | (L<<16) | (L<<8) | L);
- }
- inline BlurGray8888& operator += (const BlurGray8888& rhs) {
- l += rhs.l;
- a += rhs.a;
- return *this;
- }
- inline BlurGray8888& operator -= (const BlurGray8888& rhs) {
- l -= rhs.l;
- a -= rhs.a;
- return *this;
- }
-};
-
-
-template<typename PIXEL>
-static status_t blurFilter(
- GGLSurface const* dst,
- GGLSurface const* src,
- int kernelSizeUser,
- int repeat)
-{
- typedef typename PIXEL::type TYPE;
-
- const int shift = 31 - clz(kernelSizeUser);
- const int areaShift = shift*2;
- const int kernelSize = 1<<shift;
- const int kernelHalfSize = kernelSize/2;
- const int mask = kernelSize-1;
- const int w = src->width;
- const int h = src->height;
- const uint8_t* ditherMatrix = gDitherMatrix;
-
- // we need a temporary buffer to store one line of blurred columns
- // as well as kernelSize lines of source pixels organized as a ring buffer.
- void* const temporary_buffer = malloc(
- (w + kernelSize) * sizeof(PIXEL) +
- (src->stride * kernelSize) * sizeof(TYPE));
- if (!temporary_buffer)
- return NO_MEMORY;
-
- PIXEL* const sums = (PIXEL*)temporary_buffer;
- TYPE* const scratch = (TYPE*)(sums + w + kernelSize);
-
- // Apply the blur 'repeat' times, this is used to approximate
- // gaussian blurs. 3 times gives good results.
- for (int k=0 ; k<repeat ; k++) {
-
- // Clear the columns sums for this round
- memset(sums, 0, (w + kernelSize) * sizeof(PIXEL));
- TYPE* head;
- TYPE pixel;
- PIXEL current;
-
- // Since we're going to override the source data we need
- // to copy it in a temporary buffer. Only kernelSize lines are
- // required. But since we start in the center of the kernel,
- // we only copy half of the data, and fill the rest with zeros
- // (assuming black/transparent pixels).
- memcpy( scratch + src->stride*kernelHalfSize,
- src->data,
- src->stride*kernelHalfSize*sizeof(TYPE));
-
- // sum half of each column, because we assume the first half is
- // zeros (black/transparent).
- for (int y=0 ; y<kernelHalfSize ; y++) {
- head = (TYPE*)src->data + y*src->stride;
- for (int x=0 ; x<w ; x++)
- sums[x] += PIXEL( *head++ );
- }
-
- for (int y=0 ; y<h ; y++) {
- TYPE* fb = (TYPE*)dst->data + y*dst->stride;
-
- // compute the dither matrix line
- uint8_t const * ditherY = ditherMatrix
- + (y & BLUR_DITHER_MASK)*BLUR_DITHER_ORDER;
-
- // Horizontal blur pass on the columns sums
- int count, dither, x=0;
- PIXEL const * out= sums;
- PIXEL const * in = sums;
- current.clear();
-
- count = kernelHalfSize;
- do {
- current += *in;
- in++;
- } while (--count);
-
- count = kernelHalfSize;
- do {
- current += *in;
- dither = *(ditherY + ((x++)&BLUR_DITHER_MASK));
- *fb++ = current.to(areaShift, k==repeat-1, dither);
- in++;
- } while (--count);
-
- count = w-kernelSize;
- do {
- current += *in;
- current -= *out;
- dither = *(ditherY + ((x++)&BLUR_DITHER_MASK));
- *fb++ = current.to(areaShift, k==repeat-1, dither);
- in++, out++;
- } while (--count);
-
- count = kernelHalfSize;
- do {
- current -= *out;
- dither = *(ditherY + ((x++)&BLUR_DITHER_MASK));
- *fb++ = current.to(areaShift, k==repeat-1, dither);
- out++;
- } while (--count);
-
- // vertical blur pass, subtract the oldest line from each columns
- // and add a new line. Subtract or add zeros at the top
- // and bottom edges.
- TYPE* const tail = scratch + (y & mask) * src->stride;
- if (y >= kernelHalfSize) {
- for (int x=0 ; x<w ; x++)
- sums[x] -= PIXEL( tail[x] );
- }
- if (y < h-kernelSize) {
- memcpy( tail,
- (TYPE*)src->data + (y+kernelHalfSize)*src->stride,
- src->stride*sizeof(TYPE));
- for (int x=0 ; x<w ; x++)
- sums[x] += PIXEL( tail[x] );
- }
- }
-
- // The subsequent passes are always done in-place.
- src = dst;
- }
-
- free(temporary_buffer);
-
- return NO_ERROR;
-}
-
-template status_t blurFilter< BlurColor565<0x80> >(
- GGLSurface const* dst,
- GGLSurface const* src,
- int kernelSizeUser,
- int repeat);
-
-status_t blurFilter(
- GGLSurface const* image,
- int kernelSizeUser,
- int repeat)
-{
- status_t err = BAD_VALUE;
- if (image->format == GGL_PIXEL_FORMAT_RGB_565) {
- err = blurFilter< BlurColor565<0x80> >(image, image, kernelSizeUser, repeat);
- } else if (image->format == GGL_PIXEL_FORMAT_RGBX_8888) {
- err = blurFilter< BlurColor888X<0x80> >(image, image, kernelSizeUser, repeat);
- }
- return err;
-}
-
-} // namespace android
-
-//err = blur< BlurColor565<0x80> >(dst, src, kernelSizeUser, repeat);
-//err = blur<BlurGray565>(dst, src, kernelSizeUser, repeat);
-//err = blur<BlurGray8888>(dst, src, kernelSizeUser, repeat);
diff --git a/services/surfaceflinger/BlurFilter.h b/services/surfaceflinger/BlurFilter.h
deleted file mode 100644
index 294db43..0000000
--- a/services/surfaceflinger/BlurFilter.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
-**
-** Copyright 2006, 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_BLUR_FILTER_H
-#define ANDROID_BLUR_FILTER_H
-
-#include <stdint.h>
-#include <utils/Errors.h>
-
-#include <pixelflinger/pixelflinger.h>
-
-namespace android {
-
-status_t blurFilter(
- GGLSurface const* image,
- int kernelSizeUser,
- int repeat);
-
-} // namespace android
-
-#endif // ANDROID_BLUR_FILTER_H
diff --git a/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp b/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp
index 8926c03..64cff96 100644
--- a/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp
+++ b/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp
@@ -36,7 +36,6 @@
#include "DisplayHardware/DisplayHardware.h"
-#include <hardware/overlay.h>
#include <hardware/gralloc.h>
#include "GLExtensions.h"
@@ -104,12 +103,6 @@
mDpiY = mNativeWindow->ydpi;
mRefreshRate = fbDev->fps;
- mOverlayEngine = NULL;
- hw_module_t const* module;
- if (hw_get_module(OVERLAY_HARDWARE_MODULE_ID, &module) == 0) {
- overlay_control_open(module, &mOverlayEngine);
- }
-
EGLint w, h, dummy;
EGLint numConfigs=0;
EGLSurface surface;
@@ -296,7 +289,6 @@
{
eglMakeCurrent(mDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglTerminate(mDisplay);
- overlay_control_close(mOverlayEngine);
}
void DisplayHardware::releaseScreen() const
@@ -367,3 +359,8 @@
{
eglMakeCurrent(mDisplay, mSurface, mSurface, mContext);
}
+
+void DisplayHardware::dump(String8& res) const
+{
+ mNativeWindow->dump(res);
+}
diff --git a/services/surfaceflinger/DisplayHardware/DisplayHardware.h b/services/surfaceflinger/DisplayHardware/DisplayHardware.h
index 75b55df..ee7a2af 100644
--- a/services/surfaceflinger/DisplayHardware/DisplayHardware.h
+++ b/services/surfaceflinger/DisplayHardware/DisplayHardware.h
@@ -33,8 +33,6 @@
#include "DisplayHardware/DisplayHardwareBase.h"
-struct overlay_control_device_t;
-
namespace android {
class FramebufferNativeWindow;
@@ -78,7 +76,8 @@
uint32_t getPageFlipCount() const;
EGLDisplay getEGLDisplay() const { return mDisplay; }
- overlay_control_device_t* getOverlayEngine() const { return mOverlayEngine; }
+
+ void dump(String8& res) const;
// Hardware Composer
HWComposer& getHwComposer() const;
@@ -115,7 +114,6 @@
HWComposer* mHwc;
sp<FramebufferNativeWindow> mNativeWindow;
- overlay_control_device_t* mOverlayEngine;
};
}; // namespace android
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
index 4af274b..4a3b20d 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
@@ -120,6 +120,11 @@
l.displayFrame.left, l.displayFrame.top, l.displayFrame.right, l.displayFrame.bottom);
result.append(buffer);
}
+
+ }
+ if (mHwc && mHwc->common.version >= 1 && mHwc->dump) {
+ mHwc->dump(mHwc, buffer, SIZE);
+ result.append(buffer);
}
}
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 15df888..80aef5f 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -58,7 +58,7 @@
mSecure(false),
mTextureManager(),
mBufferManager(mTextureManager),
- mWidth(0), mHeight(0), mFixedSize(false)
+ mWidth(0), mHeight(0), mNeedsScaling(false), mFixedSize(false)
{
}
@@ -204,7 +204,8 @@
return;
}
- hwcl->transform = mOrientation;
+ Transform tr(Transform(mOrientation) * Transform(mBufferTransform));
+ hwcl->transform = tr.getOrientation();
if (needsBlending()) {
hwcl->blending = mPremultipliedAlpha ?
@@ -232,11 +233,18 @@
return;
}
hwcl->handle = buffer->handle;
- // TODO: set the crop value properly
- hwcl->sourceCrop.left = 0;
- hwcl->sourceCrop.top = 0;
- hwcl->sourceCrop.right = buffer->width;
- hwcl->sourceCrop.bottom = buffer->height;
+
+ if (!mBufferCrop.isEmpty()) {
+ hwcl->sourceCrop.left = mBufferCrop.left;
+ hwcl->sourceCrop.top = mBufferCrop.top;
+ hwcl->sourceCrop.right = mBufferCrop.right;
+ hwcl->sourceCrop.bottom = mBufferCrop.bottom;
+ } else {
+ hwcl->sourceCrop.left = 0;
+ hwcl->sourceCrop.top = 0;
+ hwcl->sourceCrop.right = buffer->width;
+ hwcl->sourceCrop.bottom = buffer->height;
+ }
}
void Layer::reloadTexture(const Region& dirty)
@@ -274,13 +282,10 @@
void Layer::drawForSreenShot() const
{
- bool currentFixedSize = mFixedSize;
- bool currentBlending = mNeedsBlending;
- const_cast<Layer*>(this)->mFixedSize = false;
- const_cast<Layer*>(this)->mFixedSize = true;
+ const bool currentFiltering = mNeedsFiltering;
+ const_cast<Layer*>(this)->mNeedsFiltering = true;
LayerBase::drawForSreenShot();
- const_cast<Layer*>(this)->mFixedSize = currentFixedSize;
- const_cast<Layer*>(this)->mNeedsBlending = currentBlending;
+ const_cast<Layer*>(this)->mNeedsFiltering = currentFiltering;
}
void Layer::onDraw(const Region& clip) const
@@ -318,11 +323,10 @@
bool Layer::needsFiltering() const
{
if (!(mFlags & DisplayHardware::SLOW_CONFIG)) {
- // NOTE: there is a race here, because mFixedSize is updated in a
- // binder transaction. however, it doesn't really matter since it is
- // evaluated each time we draw. To be perfectly correct, this flag
- // would have to be associated with a buffer.
- if (mFixedSize)
+ // if our buffer is not the same size than ourselves,
+ // we need filtering.
+ Mutex::Autolock _l(mLock);
+ if (mNeedsScaling)
return true;
}
return LayerBase::needsFiltering();
@@ -396,6 +400,7 @@
mReqHeight = reqHeight;
mReqFormat = reqFormat;
mFixedSize = fixedSize;
+ mNeedsScaling = mWidth != mReqWidth || mHeight != mReqHeight;
lcblk->reallocateAllExcept(index);
}
@@ -519,6 +524,7 @@
Mutex::Autolock _l(mLock);
mWidth = w;
mHeight = h;
+ mNeedsScaling = mWidth != mReqWidth || mHeight != mReqHeight;
}
bool Layer::isFixedSize() const {
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 07434cf..30021d3 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -233,6 +233,7 @@
uint32_t mReqWidth;
uint32_t mReqHeight;
uint32_t mReqFormat;
+ bool mNeedsScaling;
bool mFixedSize;
};
diff --git a/services/surfaceflinger/LayerBase.cpp b/services/surfaceflinger/LayerBase.cpp
index df6aa51..8a021cb 100644
--- a/services/surfaceflinger/LayerBase.cpp
+++ b/services/surfaceflinger/LayerBase.cpp
@@ -216,14 +216,10 @@
flags |= eVisibleRegion;
this->contentDirty = true;
- mNeedsFiltering = false;
- if (!(mFlags & DisplayHardware::SLOW_CONFIG)) {
- // we may use linear filtering, if the matrix scales us
- const uint8_t type = temp.transform.getType();
- if (!temp.transform.preserveRects() || (type >= Transform::SCALE)) {
- mNeedsFiltering = true;
- }
- }
+ // we may use linear filtering, if the matrix scales us
+ const uint8_t type = temp.transform.getType();
+ mNeedsFiltering = (!temp.transform.preserveRects() ||
+ (type >= Transform::SCALE));
}
// Commit the transaction
@@ -614,21 +610,6 @@
status_t LayerBaseClient::Surface::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
- switch (code) {
- case REGISTER_BUFFERS:
- case UNREGISTER_BUFFERS:
- case CREATE_OVERLAY:
- {
- if (!mFlinger->mAccessSurfaceFlinger.checkCalling()) {
- IPCThreadState* ipc = IPCThreadState::self();
- const int pid = ipc->getCallingPid();
- const int uid = ipc->getCallingUid();
- LOGE("Permission Denial: "
- "can't access SurfaceFlinger pid=%d, uid=%d", pid, uid);
- return PERMISSION_DENIED;
- }
- }
- }
return BnSurface::onTransact(code, data, reply, flags);
}
@@ -643,26 +624,6 @@
return INVALID_OPERATION;
}
-status_t LayerBaseClient::Surface::registerBuffers(
- const ISurface::BufferHeap& buffers)
-{
- return INVALID_OPERATION;
-}
-
-void LayerBaseClient::Surface::postBuffer(ssize_t offset)
-{
-}
-
-void LayerBaseClient::Surface::unregisterBuffers()
-{
-}
-
-sp<OverlayRef> LayerBaseClient::Surface::createOverlay(
- uint32_t w, uint32_t h, int32_t format, int32_t orientation)
-{
- return NULL;
-};
-
// ---------------------------------------------------------------------------
}; // namespace android
diff --git a/services/surfaceflinger/LayerBase.h b/services/surfaceflinger/LayerBase.h
index bdee05b..f6c49fc 100644
--- a/services/surfaceflinger/LayerBase.h
+++ b/services/surfaceflinger/LayerBase.h
@@ -27,7 +27,6 @@
#include <utils/RefBase.h>
#include <ui/Region.h>
-#include <ui/Overlay.h>
#include <surfaceflinger/ISurfaceComposerClient.h>
#include <private/surfaceflinger/SharedBufferStack.h>
@@ -37,6 +36,7 @@
#include <hardware/hwcomposer.h>
+#include "DisplayHardware/DisplayHardware.h"
#include "Transform.h"
namespace android {
@@ -191,7 +191,9 @@
/**
* needsLinearFiltering - true if this surface needs filtering
*/
- virtual bool needsFiltering() const { return mNeedsFiltering; }
+ virtual bool needsFiltering() const {
+ return (!(mFlags & DisplayHardware::SLOW_CONFIG)) && mNeedsFiltering;
+ }
/**
* isSecure - true if this surface is secure, that is if it prevents
@@ -311,12 +313,6 @@
uint32_t w, uint32_t h, uint32_t format, uint32_t usage);
virtual status_t setBufferCount(int bufferCount);
- virtual status_t registerBuffers(const ISurface::BufferHeap& buffers);
- virtual void postBuffer(ssize_t offset);
- virtual void unregisterBuffers();
- virtual sp<OverlayRef> createOverlay(uint32_t w, uint32_t h,
- int32_t format, int32_t orientation);
-
protected:
friend class LayerBaseClient;
sp<SurfaceFlinger> mFlinger;
diff --git a/services/surfaceflinger/LayerBlur.cpp b/services/surfaceflinger/LayerBlur.cpp
deleted file mode 100644
index 4cfcfe3..0000000
--- a/services/surfaceflinger/LayerBlur.cpp
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * Copyright (C) 2007 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 <stdint.h>
-#include <sys/types.h>
-
-#include <utils/Errors.h>
-#include <utils/Log.h>
-
-#include <GLES/gl.h>
-#include <GLES/glext.h>
-
-#include "clz.h"
-#include "BlurFilter.h"
-#include "LayerBlur.h"
-#include "SurfaceFlinger.h"
-#include "DisplayHardware/DisplayHardware.h"
-
-namespace android {
-// ---------------------------------------------------------------------------
-
-LayerBlur::LayerBlur(SurfaceFlinger* flinger, DisplayID display,
- const sp<Client>& client)
- : LayerBaseClient(flinger, display, client), mCacheDirty(true),
- mRefreshCache(true), mCacheAge(0), mTextureName(-1U),
- mWidthScale(1.0f), mHeightScale(1.0f),
- mBlurFormat(GGL_PIXEL_FORMAT_RGB_565)
-{
-}
-
-LayerBlur::~LayerBlur()
-{
- if (mTextureName != -1U) {
- glDeleteTextures(1, &mTextureName);
- }
-}
-
-void LayerBlur::setVisibleRegion(const Region& visibleRegion)
-{
- LayerBaseClient::setVisibleRegion(visibleRegion);
- if (visibleRegionScreen.isEmpty()) {
- if (mTextureName != -1U) {
- // We're not visible, free the texture up.
- glBindTexture(GL_TEXTURE_2D, 0);
- glDeleteTextures(1, &mTextureName);
- mTextureName = -1U;
- }
- }
-}
-
-uint32_t LayerBlur::doTransaction(uint32_t flags)
-{
- // we're doing a transaction, refresh the cache!
- if (!mFlinger->isFrozen()) {
- mRefreshCache = true;
- mCacheDirty = true;
- flags |= eVisibleRegion;
- this->contentDirty = true;
- }
- return LayerBase::doTransaction(flags);
-}
-
-void LayerBlur::unlockPageFlip(const Transform& planeTransform, Region& outDirtyRegion)
-{
- // this code-path must be as tight as possible, it's called each time
- // the screen is composited.
- if (UNLIKELY(!visibleRegionScreen.isEmpty())) {
- // if anything visible below us is invalidated, the cache becomes dirty
- if (!mCacheDirty &&
- !visibleRegionScreen.intersect(outDirtyRegion).isEmpty()) {
- mCacheDirty = true;
- }
- if (mCacheDirty) {
- if (!mFlinger->isFrozen()) {
- // update everything below us that is visible
- outDirtyRegion.orSelf(visibleRegionScreen);
- nsecs_t now = systemTime();
- if ((now - mCacheAge) >= ms2ns(500)) {
- mCacheAge = now;
- mRefreshCache = true;
- mCacheDirty = false;
- } else {
- if (!mAutoRefreshPending) {
- mFlinger->postMessageAsync(
- new MessageBase(MessageQueue::INVALIDATE),
- ms2ns(500));
- mAutoRefreshPending = true;
- }
- }
- }
- }
- }
- LayerBase::unlockPageFlip(planeTransform, outDirtyRegion);
-}
-
-void LayerBlur::onDraw(const Region& clip) const
-{
- const DisplayHardware& hw(graphicPlane(0).displayHardware());
- const uint32_t fbHeight = hw.getHeight();
- int x = mTransformedBounds.left;
- int y = mTransformedBounds.top;
- int w = mTransformedBounds.width();
- int h = mTransformedBounds.height();
- GLint X = x;
- GLint Y = fbHeight - (y + h);
- if (X < 0) {
- w += X;
- X = 0;
- }
- if (Y < 0) {
- h += Y;
- Y = 0;
- }
- if (w<0 || h<0) {
- // we're outside of the framebuffer
- return;
- }
-
- if (mTextureName == -1U) {
- // create the texture name the first time
- // can't do that in the ctor, because it runs in another thread.
- glGenTextures(1, &mTextureName);
- glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES, &mReadFormat);
- glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE_OES, &mReadType);
- if (mReadFormat != GL_RGB || mReadType != GL_UNSIGNED_SHORT_5_6_5) {
- mReadFormat = GL_RGBA;
- mReadType = GL_UNSIGNED_BYTE;
- mBlurFormat = GGL_PIXEL_FORMAT_RGBX_8888;
- }
- }
-
- Region::const_iterator it = clip.begin();
- Region::const_iterator const end = clip.end();
- if (it != end) {
-#if defined(GL_OES_EGL_image_external)
- if (GLExtensions::getInstance().haveTextureExternal()) {
- glDisable(GL_TEXTURE_EXTERNAL_OES);
- }
-#endif
- glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, mTextureName);
-
- if (mRefreshCache) {
- mRefreshCache = false;
- mAutoRefreshPending = false;
-
- int32_t pixelSize = 4;
- int32_t s = w;
- if (mReadType == GL_UNSIGNED_SHORT_5_6_5) {
- // allocate enough memory for 4-bytes (2 pixels) aligned data
- s = (w + 1) & ~1;
- pixelSize = 2;
- }
-
- uint16_t* const pixels = (uint16_t*)malloc(s*h*pixelSize);
-
- // This reads the frame-buffer, so a h/w GL would have to
- // finish() its rendering first. we don't want to do that
- // too often. Read data is 4-bytes aligned.
- glReadPixels(X, Y, w, h, mReadFormat, mReadType, pixels);
-
- // blur that texture.
- GGLSurface bl;
- bl.version = sizeof(GGLSurface);
- bl.width = w;
- bl.height = h;
- bl.stride = s;
- bl.format = mBlurFormat;
- bl.data = (GGLubyte*)pixels;
- blurFilter(&bl, 8, 2);
-
- if (GLExtensions::getInstance().haveNpot()) {
- glTexImage2D(GL_TEXTURE_2D, 0, mReadFormat, w, h, 0,
- mReadFormat, mReadType, pixels);
- mWidthScale = 1.0f / w;
- mHeightScale =-1.0f / h;
- mYOffset = 0;
- } else {
- GLuint tw = 1 << (31 - clz(w));
- GLuint th = 1 << (31 - clz(h));
- if (tw < GLuint(w)) tw <<= 1;
- if (th < GLuint(h)) th <<= 1;
- glTexImage2D(GL_TEXTURE_2D, 0, mReadFormat, tw, th, 0,
- mReadFormat, mReadType, NULL);
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h,
- mReadFormat, mReadType, pixels);
- mWidthScale = 1.0f / tw;
- mHeightScale =-1.0f / th;
- mYOffset = th-h;
- }
-
- free((void*)pixels);
- }
-
- const State& s = drawingState();
- if (UNLIKELY(s.alpha < 0xFF)) {
- const GLfloat alpha = s.alpha * (1.0f/255.0f);
- glColor4f(0, 0, 0, alpha);
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
- } else {
- glDisable(GL_BLEND);
- }
-
- if (mFlags & DisplayHardware::SLOW_CONFIG) {
- glDisable(GL_DITHER);
- } else {
- glEnable(GL_DITHER);
- }
-
- glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
- glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-
- glMatrixMode(GL_TEXTURE);
- glLoadIdentity();
- glScalef(mWidthScale, mHeightScale, 1);
- glTranslatef(-x, mYOffset - y, 0);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glVertexPointer(2, GL_FLOAT, 0, mVertices);
- glTexCoordPointer(2, GL_FLOAT, 0, mVertices);
- while (it != end) {
- const Rect& r = *it++;
- const GLint sy = fbHeight - (r.top + r.height());
- glScissor(r.left, sy, r.width(), r.height());
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
- }
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glLoadIdentity();
- glMatrixMode(GL_MODELVIEW);
- }
-}
-
-// ---------------------------------------------------------------------------
-
-}; // namespace android
diff --git a/services/surfaceflinger/LayerBlur.h b/services/surfaceflinger/LayerBlur.h
deleted file mode 100644
index 4c9ec64..0000000
--- a/services/surfaceflinger/LayerBlur.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2007 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_LAYER_BLUR_H
-#define ANDROID_LAYER_BLUR_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <ui/Region.h>
-
-#include "LayerBase.h"
-
-namespace android {
-
-// ---------------------------------------------------------------------------
-
-class LayerBlur : public LayerBaseClient
-{
-public:
- LayerBlur(SurfaceFlinger* flinger, DisplayID display,
- const sp<Client>& client);
- virtual ~LayerBlur();
-
- virtual void onDraw(const Region& clip) const;
- virtual bool needsBlending() const { return true; }
- virtual bool isSecure() const { return false; }
- virtual const char* getTypeId() const { return "LayerBlur"; }
-
- virtual uint32_t doTransaction(uint32_t flags);
- virtual void setVisibleRegion(const Region& visibleRegion);
- virtual void unlockPageFlip(const Transform& planeTransform, Region& outDirtyRegion);
-
-private:
- bool mCacheDirty;
- mutable bool mRefreshCache;
- mutable bool mAutoRefreshPending;
- nsecs_t mCacheAge;
- mutable GLuint mTextureName;
- mutable GLfloat mWidthScale;
- mutable GLfloat mHeightScale;
- mutable GLfloat mYOffset;
- mutable GLint mReadFormat;
- mutable GLint mReadType;
- mutable uint32_t mBlurFormat;
-};
-
-// ---------------------------------------------------------------------------
-
-}; // namespace android
-
-#endif // ANDROID_LAYER_BLUR_H
diff --git a/services/surfaceflinger/LayerBuffer.cpp b/services/surfaceflinger/LayerBuffer.cpp
deleted file mode 100644
index 23506cf..0000000
--- a/services/surfaceflinger/LayerBuffer.cpp
+++ /dev/null
@@ -1,701 +0,0 @@
-/*
- * Copyright (C) 2007 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 <stdint.h>
-#include <math.h>
-#include <sys/types.h>
-
-#include <utils/Errors.h>
-#include <utils/Log.h>
-#include <utils/StopWatch.h>
-
-#include <ui/GraphicBuffer.h>
-#include <ui/PixelFormat.h>
-#include <ui/FramebufferNativeWindow.h>
-#include <ui/Rect.h>
-#include <ui/Region.h>
-
-#include <hardware/copybit.h>
-
-#include "LayerBuffer.h"
-#include "SurfaceFlinger.h"
-#include "DisplayHardware/DisplayHardware.h"
-
-namespace android {
-
-// ---------------------------------------------------------------------------
-
-gralloc_module_t const* LayerBuffer::sGrallocModule = 0;
-
-// ---------------------------------------------------------------------------
-
-LayerBuffer::LayerBuffer(SurfaceFlinger* flinger, DisplayID display,
- const sp<Client>& client)
- : LayerBaseClient(flinger, display, client),
- mNeedsBlending(false), mBlitEngine(0)
-{
-}
-
-LayerBuffer::~LayerBuffer()
-{
- if (mBlitEngine) {
- copybit_close(mBlitEngine);
- }
-}
-
-void LayerBuffer::onFirstRef()
-{
- LayerBaseClient::onFirstRef();
- mSurface = new SurfaceLayerBuffer(mFlinger, this);
-
- hw_module_t const* module = (hw_module_t const*)sGrallocModule;
- if (!module) {
- // NOTE: technically there is a race here, but it shouldn't
- // cause any problem since hw_get_module() always returns
- // the same value.
- if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module) == 0) {
- sGrallocModule = (gralloc_module_t const *)module;
- }
- }
-
- if (hw_get_module(COPYBIT_HARDWARE_MODULE_ID, &module) == 0) {
- copybit_open(module, &mBlitEngine);
- }
-}
-
-sp<LayerBaseClient::Surface> LayerBuffer::createSurface() const
-{
- return mSurface;
-}
-
-status_t LayerBuffer::ditch()
-{
- mSurface.clear();
- return NO_ERROR;
-}
-
-bool LayerBuffer::needsBlending() const {
- return mNeedsBlending;
-}
-
-void LayerBuffer::setNeedsBlending(bool blending) {
- mNeedsBlending = blending;
-}
-
-void LayerBuffer::postBuffer(ssize_t offset)
-{
- sp<Source> source(getSource());
- if (source != 0)
- source->postBuffer(offset);
-}
-
-void LayerBuffer::unregisterBuffers()
-{
- sp<Source> source(clearSource());
- if (source != 0)
- source->unregisterBuffers();
-}
-
-uint32_t LayerBuffer::doTransaction(uint32_t flags)
-{
- sp<Source> source(getSource());
- if (source != 0)
- source->onTransaction(flags);
- uint32_t res = LayerBase::doTransaction(flags);
- // we always want filtering for these surfaces
- mNeedsFiltering = !(mFlags & DisplayHardware::SLOW_CONFIG);
- return res;
-}
-
-void LayerBuffer::unlockPageFlip(const Transform& planeTransform,
- Region& outDirtyRegion)
-{
- // this code-path must be as tight as possible, it's called each time
- // the screen is composited.
- sp<Source> source(getSource());
- if (source != 0)
- source->onVisibilityResolved(planeTransform);
- LayerBase::unlockPageFlip(planeTransform, outDirtyRegion);
-}
-
-void LayerBuffer::validateVisibility(const Transform& globalTransform)
-{
- sp<Source> source(getSource());
- if (source != 0)
- source->onvalidateVisibility(globalTransform);
- LayerBase::validateVisibility(globalTransform);
-}
-
-void LayerBuffer::drawForSreenShot() const
-{
- const DisplayHardware& hw(graphicPlane(0).displayHardware());
- clearWithOpenGL( Region(hw.bounds()) );
-}
-
-void LayerBuffer::onDraw(const Region& clip) const
-{
- sp<Source> source(getSource());
- if (LIKELY(source != 0)) {
- source->onDraw(clip);
- } else {
- clearWithOpenGL(clip);
- }
-}
-
-void LayerBuffer::serverDestroy()
-{
- sp<Source> source(clearSource());
- if (source != 0) {
- source->destroy();
- }
-}
-
-/**
- * This creates a "buffer" source for this surface
- */
-status_t LayerBuffer::registerBuffers(const ISurface::BufferHeap& buffers)
-{
- Mutex::Autolock _l(mLock);
- if (mSource != 0)
- return INVALID_OPERATION;
-
- sp<BufferSource> source = new BufferSource(*this, buffers);
-
- status_t result = source->getStatus();
- if (result == NO_ERROR) {
- mSource = source;
- }
- return result;
-}
-
-/**
- * This creates an "overlay" source for this surface
- */
-sp<OverlayRef> LayerBuffer::createOverlay(uint32_t w, uint32_t h, int32_t f,
- int32_t orientation)
-{
- sp<OverlayRef> result;
- Mutex::Autolock _l(mLock);
- if (mSource != 0)
- return result;
-
- sp<OverlaySource> source = new OverlaySource(*this, &result, w, h, f, orientation);
- if (result != 0) {
- mSource = source;
- }
- return result;
-}
-
-sp<LayerBuffer::Source> LayerBuffer::getSource() const {
- Mutex::Autolock _l(mLock);
- return mSource;
-}
-
-sp<LayerBuffer::Source> LayerBuffer::clearSource() {
- sp<Source> source;
- Mutex::Autolock _l(mLock);
- source = mSource;
- mSource.clear();
- return source;
-}
-
-// ============================================================================
-// LayerBuffer::SurfaceLayerBuffer
-// ============================================================================
-
-LayerBuffer::SurfaceLayerBuffer::SurfaceLayerBuffer(
- const sp<SurfaceFlinger>& flinger, const sp<LayerBuffer>& owner)
- : LayerBaseClient::Surface(flinger, owner->getIdentity(), owner)
-{
-}
-
-LayerBuffer::SurfaceLayerBuffer::~SurfaceLayerBuffer()
-{
- unregisterBuffers();
-}
-
-status_t LayerBuffer::SurfaceLayerBuffer::registerBuffers(
- const ISurface::BufferHeap& buffers)
-{
- sp<LayerBuffer> owner(getOwner());
- if (owner != 0)
- return owner->registerBuffers(buffers);
- return NO_INIT;
-}
-
-void LayerBuffer::SurfaceLayerBuffer::postBuffer(ssize_t offset)
-{
- sp<LayerBuffer> owner(getOwner());
- if (owner != 0)
- owner->postBuffer(offset);
-}
-
-void LayerBuffer::SurfaceLayerBuffer::unregisterBuffers()
-{
- sp<LayerBuffer> owner(getOwner());
- if (owner != 0)
- owner->unregisterBuffers();
-}
-
-sp<OverlayRef> LayerBuffer::SurfaceLayerBuffer::createOverlay(
- uint32_t w, uint32_t h, int32_t format, int32_t orientation) {
- sp<OverlayRef> result;
- sp<LayerBuffer> owner(getOwner());
- if (owner != 0)
- result = owner->createOverlay(w, h, format, orientation);
- return result;
-}
-
-// ============================================================================
-// LayerBuffer::Buffer
-// ============================================================================
-
-LayerBuffer::Buffer::Buffer(const ISurface::BufferHeap& buffers,
- ssize_t offset, size_t bufferSize)
- : mBufferHeap(buffers), mSupportsCopybit(false)
-{
- NativeBuffer& src(mNativeBuffer);
- src.crop.l = 0;
- src.crop.t = 0;
- src.crop.r = buffers.w;
- src.crop.b = buffers.h;
-
- src.img.w = buffers.hor_stride ?: buffers.w;
- src.img.h = buffers.ver_stride ?: buffers.h;
- src.img.format = buffers.format;
- src.img.base = (void*)(intptr_t(buffers.heap->base()) + offset);
- src.img.handle = 0;
-
- gralloc_module_t const * module = LayerBuffer::getGrallocModule();
- if (module && module->perform) {
- int err = module->perform(module,
- GRALLOC_MODULE_PERFORM_CREATE_HANDLE_FROM_BUFFER,
- buffers.heap->heapID(), bufferSize,
- offset, buffers.heap->base(),
- &src.img.handle);
-
- // we can fail here is the passed buffer is purely software
- mSupportsCopybit = (err == NO_ERROR);
- }
- }
-
-LayerBuffer::Buffer::~Buffer()
-{
- NativeBuffer& src(mNativeBuffer);
- if (src.img.handle) {
- native_handle_delete(src.img.handle);
- }
-}
-
-// ============================================================================
-// LayerBuffer::Source
-// LayerBuffer::BufferSource
-// LayerBuffer::OverlaySource
-// ============================================================================
-
-LayerBuffer::Source::Source(LayerBuffer& layer)
- : mLayer(layer)
-{
-}
-LayerBuffer::Source::~Source() {
-}
-void LayerBuffer::Source::onDraw(const Region& clip) const {
-}
-void LayerBuffer::Source::onTransaction(uint32_t flags) {
-}
-void LayerBuffer::Source::onVisibilityResolved(
- const Transform& planeTransform) {
-}
-void LayerBuffer::Source::postBuffer(ssize_t offset) {
-}
-void LayerBuffer::Source::unregisterBuffers() {
-}
-
-// ---------------------------------------------------------------------------
-
-LayerBuffer::BufferSource::BufferSource(LayerBuffer& layer,
- const ISurface::BufferHeap& buffers)
- : Source(layer), mStatus(NO_ERROR), mBufferSize(0)
-{
- if (buffers.heap == NULL) {
- // this is allowed, but in this case, it is illegal to receive
- // postBuffer(). The surface just erases the framebuffer with
- // fully transparent pixels.
- mBufferHeap = buffers;
- mLayer.setNeedsBlending(false);
- return;
- }
-
- status_t err = (buffers.heap->heapID() >= 0) ? NO_ERROR : NO_INIT;
- if (err != NO_ERROR) {
- LOGE("LayerBuffer::BufferSource: invalid heap (%s)", strerror(err));
- mStatus = err;
- return;
- }
-
- PixelFormatInfo info;
- err = getPixelFormatInfo(buffers.format, &info);
- if (err != NO_ERROR) {
- LOGE("LayerBuffer::BufferSource: invalid format %d (%s)",
- buffers.format, strerror(err));
- mStatus = err;
- return;
- }
-
- if (buffers.hor_stride<0 || buffers.ver_stride<0) {
- LOGE("LayerBuffer::BufferSource: invalid parameters "
- "(w=%d, h=%d, xs=%d, ys=%d)",
- buffers.w, buffers.h, buffers.hor_stride, buffers.ver_stride);
- mStatus = BAD_VALUE;
- return;
- }
-
- mBufferHeap = buffers;
- mLayer.setNeedsBlending((info.h_alpha - info.l_alpha) > 0);
- mBufferSize = info.getScanlineSize(buffers.hor_stride)*buffers.ver_stride;
- mLayer.forceVisibilityTransaction();
-}
-
-LayerBuffer::BufferSource::~BufferSource()
-{
- class MessageDestroyTexture : public MessageBase {
- SurfaceFlinger* flinger;
- GLuint name;
- public:
- MessageDestroyTexture(
- SurfaceFlinger* flinger, GLuint name)
- : flinger(flinger), name(name) { }
- virtual bool handler() {
- glDeleteTextures(1, &name);
- return true;
- }
- };
-
- if (mTexture.name != -1U) {
- // GL textures can only be destroyed from the GL thread
- getFlinger()->mEventQueue.postMessage(
- new MessageDestroyTexture(getFlinger(), mTexture.name) );
- }
- if (mTexture.image != EGL_NO_IMAGE_KHR) {
- EGLDisplay dpy(getFlinger()->graphicPlane(0).getEGLDisplay());
- eglDestroyImageKHR(dpy, mTexture.image);
- }
-}
-
-void LayerBuffer::BufferSource::postBuffer(ssize_t offset)
-{
- ISurface::BufferHeap buffers;
- { // scope for the lock
- Mutex::Autolock _l(mBufferSourceLock);
- buffers = mBufferHeap;
- if (buffers.heap != 0) {
- const size_t memorySize = buffers.heap->getSize();
- if ((size_t(offset) + mBufferSize) > memorySize) {
- LOGE("LayerBuffer::BufferSource::postBuffer() "
- "invalid buffer (offset=%d, size=%d, heap-size=%d",
- int(offset), int(mBufferSize), int(memorySize));
- return;
- }
- }
- }
-
- sp<Buffer> buffer;
- if (buffers.heap != 0) {
- buffer = new LayerBuffer::Buffer(buffers, offset, mBufferSize);
- if (buffer->getStatus() != NO_ERROR)
- buffer.clear();
- setBuffer(buffer);
- mLayer.invalidate();
- }
-}
-
-void LayerBuffer::BufferSource::unregisterBuffers()
-{
- Mutex::Autolock _l(mBufferSourceLock);
- mBufferHeap.heap.clear();
- mBuffer.clear();
- mLayer.invalidate();
-}
-
-sp<LayerBuffer::Buffer> LayerBuffer::BufferSource::getBuffer() const
-{
- Mutex::Autolock _l(mBufferSourceLock);
- return mBuffer;
-}
-
-void LayerBuffer::BufferSource::setBuffer(const sp<LayerBuffer::Buffer>& buffer)
-{
- Mutex::Autolock _l(mBufferSourceLock);
- mBuffer = buffer;
-}
-
-void LayerBuffer::BufferSource::onDraw(const Region& clip) const
-{
- sp<Buffer> ourBuffer(getBuffer());
- if (UNLIKELY(ourBuffer == 0)) {
- // nothing to do, we don't have a buffer
- mLayer.clearWithOpenGL(clip);
- return;
- }
-
- status_t err = NO_ERROR;
- NativeBuffer src(ourBuffer->getBuffer());
- const Rect transformedBounds(mLayer.getTransformedBounds());
-
-#if defined(EGL_ANDROID_image_native_buffer)
- if (GLExtensions::getInstance().haveDirectTexture()) {
- err = INVALID_OPERATION;
- if (ourBuffer->supportsCopybit()) {
- copybit_device_t* copybit = mLayer.mBlitEngine;
- if (copybit && err != NO_ERROR) {
- // create our EGLImageKHR the first time
- err = initTempBuffer();
- if (err == NO_ERROR) {
- // NOTE: Assume the buffer is allocated with the proper USAGE flags
- const NativeBuffer& dst(mTempBuffer);
- region_iterator clip(Region(Rect(dst.crop.r, dst.crop.b)));
- copybit->set_parameter(copybit, COPYBIT_TRANSFORM, 0);
- copybit->set_parameter(copybit, COPYBIT_PLANE_ALPHA, 0xFF);
- copybit->set_parameter(copybit, COPYBIT_DITHER, COPYBIT_ENABLE);
- err = copybit->stretch(copybit, &dst.img, &src.img,
- &dst.crop, &src.crop, &clip);
- if (err != NO_ERROR) {
- clearTempBufferImage();
- }
- }
- }
- }
- }
-#endif
- else {
- err = INVALID_OPERATION;
- }
-
- if (err != NO_ERROR) {
- // slower fallback
- GGLSurface t;
- t.version = sizeof(GGLSurface);
- t.width = src.crop.r;
- t.height = src.crop.b;
- t.stride = src.img.w;
- t.vstride= src.img.h;
- t.format = src.img.format;
- t.data = (GGLubyte*)src.img.base;
- const Region dirty(Rect(t.width, t.height));
- mTextureManager.loadTexture(&mTexture, dirty, t);
- }
-
- mLayer.setBufferTransform(mBufferHeap.transform);
- mLayer.drawWithOpenGL(clip, mTexture);
-}
-
-status_t LayerBuffer::BufferSource::initTempBuffer() const
-{
- // figure out the size we need now
- const ISurface::BufferHeap& buffers(mBufferHeap);
- uint32_t w = mLayer.mTransformedBounds.width();
- uint32_t h = mLayer.mTransformedBounds.height();
- if (mLayer.getOrientation() & (Transform::ROT_90 | Transform::ROT_270)) {
- int t = w; w = h; h = t;
- }
-
- // we're in the copybit case, so make sure we can handle this blit
- // we don't have to keep the aspect ratio here
- copybit_device_t* copybit = mLayer.mBlitEngine;
- const int down = copybit->get(copybit, COPYBIT_MINIFICATION_LIMIT);
- const int up = copybit->get(copybit, COPYBIT_MAGNIFICATION_LIMIT);
- if (buffers.w > w*down) w = buffers.w / down;
- else if (w > buffers.w*up) w = buffers.w*up;
- if (buffers.h > h*down) h = buffers.h / down;
- else if (h > buffers.h*up) h = buffers.h*up;
-
- if (mTexture.image != EGL_NO_IMAGE_KHR) {
- // we have an EGLImage, make sure the needed size didn't change
- if (w!=mTexture.width || h!= mTexture.height) {
- // delete the EGLImage and texture
- clearTempBufferImage();
- } else {
- // we're good, we have an EGLImageKHR and it's (still) the
- // right size
- return NO_ERROR;
- }
- }
-
- // figure out if we need linear filtering
- if (buffers.w * h == buffers.h * w) {
- // same pixel area, don't use filtering
- mLayer.mNeedsFiltering = false;
- }
-
- // Allocate a temporary buffer and create the corresponding EGLImageKHR
- // once the EGLImage has been created we don't need the
- // graphic buffer reference anymore.
- sp<GraphicBuffer> buffer = new GraphicBuffer(
- w, h, HAL_PIXEL_FORMAT_RGB_565,
- GraphicBuffer::USAGE_HW_TEXTURE |
- GraphicBuffer::USAGE_HW_2D);
-
- status_t err = buffer->initCheck();
- if (err == NO_ERROR) {
- NativeBuffer& dst(mTempBuffer);
- dst.img.w = buffer->getStride();
- dst.img.h = h;
- dst.img.format = buffer->getPixelFormat();
- dst.img.handle = (native_handle_t *)buffer->handle;
- dst.img.base = 0;
- dst.crop.l = 0;
- dst.crop.t = 0;
- dst.crop.r = w;
- dst.crop.b = h;
-
- EGLDisplay dpy(getFlinger()->graphicPlane(0).getEGLDisplay());
- err = mTextureManager.initEglImage(&mTexture, dpy, buffer);
- }
-
- return err;
-}
-
-void LayerBuffer::BufferSource::clearTempBufferImage() const
-{
- // delete the image
- EGLDisplay dpy(getFlinger()->graphicPlane(0).getEGLDisplay());
- eglDestroyImageKHR(dpy, mTexture.image);
-
- // and the associated texture (recreate a name)
- glDeleteTextures(1, &mTexture.name);
- Texture defaultTexture;
- mTexture = defaultTexture;
-}
-
-// ---------------------------------------------------------------------------
-
-LayerBuffer::OverlaySource::OverlaySource(LayerBuffer& layer,
- sp<OverlayRef>* overlayRef,
- uint32_t w, uint32_t h, int32_t format, int32_t orientation)
- : Source(layer), mVisibilityChanged(false),
- mOverlay(0), mOverlayHandle(0), mOverlayDevice(0), mOrientation(orientation)
-{
- overlay_control_device_t* overlay_dev = getFlinger()->getOverlayEngine();
- if (overlay_dev == NULL) {
- // overlays not supported
- return;
- }
-
- mOverlayDevice = overlay_dev;
- overlay_t* overlay = overlay_dev->createOverlay(overlay_dev, w, h, format);
- if (overlay == NULL) {
- // couldn't create the overlay (no memory? no more overlays?)
- return;
- }
-
- // enable dithering...
- overlay_dev->setParameter(overlay_dev, overlay,
- OVERLAY_DITHER, OVERLAY_ENABLE);
-
- mOverlay = overlay;
- mWidth = overlay->w;
- mHeight = overlay->h;
- mFormat = overlay->format;
- mWidthStride = overlay->w_stride;
- mHeightStride = overlay->h_stride;
- mInitialized = false;
-
- mOverlayHandle = overlay->getHandleRef(overlay);
-
- sp<OverlayChannel> channel = new OverlayChannel( &layer );
-
- *overlayRef = new OverlayRef(mOverlayHandle, channel,
- mWidth, mHeight, mFormat, mWidthStride, mHeightStride);
- getFlinger()->signalEvent();
-}
-
-LayerBuffer::OverlaySource::~OverlaySource()
-{
- if (mOverlay && mOverlayDevice) {
- overlay_control_device_t* overlay_dev = mOverlayDevice;
- overlay_dev->destroyOverlay(overlay_dev, mOverlay);
- }
-}
-
-void LayerBuffer::OverlaySource::onDraw(const Region& clip) const
-{
- // this would be where the color-key would be set, should we need it.
- GLclampf red = 0;
- GLclampf green = 0;
- GLclampf blue = 0;
- mLayer.clearWithOpenGL(clip, red, green, blue, 0);
-}
-
-void LayerBuffer::OverlaySource::onTransaction(uint32_t flags)
-{
- const Layer::State& front(mLayer.drawingState());
- const Layer::State& temp(mLayer.currentState());
- if (temp.sequence != front.sequence) {
- mVisibilityChanged = true;
- }
-}
-
-void LayerBuffer::OverlaySource::onvalidateVisibility(const Transform&)
-{
- mVisibilityChanged = true;
-}
-
-void LayerBuffer::OverlaySource::onVisibilityResolved(
- const Transform& planeTransform)
-{
- // this code-path must be as tight as possible, it's called each time
- // the screen is composited.
- if (UNLIKELY(mOverlay != 0)) {
- if (mVisibilityChanged || !mInitialized) {
- mVisibilityChanged = false;
- mInitialized = true;
- const Rect bounds(mLayer.getTransformedBounds());
- int x = bounds.left;
- int y = bounds.top;
- int w = bounds.width();
- int h = bounds.height();
-
- // we need a lock here to protect "destroy"
- Mutex::Autolock _l(mOverlaySourceLock);
- if (mOverlay) {
- overlay_control_device_t* overlay_dev = mOverlayDevice;
- overlay_dev->setPosition(overlay_dev, mOverlay, x,y,w,h);
- // we need to combine the layer orientation and the
- // user-requested orientation.
- Transform finalTransform(Transform(mLayer.getOrientation()) *
- Transform(mOrientation));
- overlay_dev->setParameter(overlay_dev, mOverlay,
- OVERLAY_TRANSFORM, finalTransform.getOrientation());
- overlay_dev->commit(overlay_dev, mOverlay);
- }
- }
- }
-}
-
-void LayerBuffer::OverlaySource::destroy()
-{
- // we need a lock here to protect "onVisibilityResolved"
- Mutex::Autolock _l(mOverlaySourceLock);
- if (mOverlay && mOverlayDevice) {
- overlay_control_device_t* overlay_dev = mOverlayDevice;
- overlay_dev->destroyOverlay(overlay_dev, mOverlay);
- mOverlay = 0;
- }
-}
-
-// ---------------------------------------------------------------------------
-}; // namespace android
diff --git a/services/surfaceflinger/LayerBuffer.h b/services/surfaceflinger/LayerBuffer.h
deleted file mode 100644
index a89d8fe..0000000
--- a/services/surfaceflinger/LayerBuffer.h
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * Copyright (C) 2007 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_LAYER_BUFFER_H
-#define ANDROID_LAYER_BUFFER_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include "LayerBase.h"
-#include "TextureManager.h"
-
-struct copybit_device_t;
-
-namespace android {
-
-// ---------------------------------------------------------------------------
-
-class Buffer;
-class Region;
-class OverlayRef;
-
-// ---------------------------------------------------------------------------
-
-class LayerBuffer : public LayerBaseClient
-{
- class Source : public LightRefBase<Source> {
- public:
- Source(LayerBuffer& layer);
- virtual ~Source();
- virtual void onDraw(const Region& clip) const;
- virtual void onTransaction(uint32_t flags);
- virtual void onVisibilityResolved(const Transform& planeTransform);
- virtual void onvalidateVisibility(const Transform& globalTransform) { }
- virtual void postBuffer(ssize_t offset);
- virtual void unregisterBuffers();
- virtual void destroy() { }
- SurfaceFlinger* getFlinger() const { return mLayer.mFlinger.get(); }
- protected:
- LayerBuffer& mLayer;
- };
-
-public:
- LayerBuffer(SurfaceFlinger* flinger, DisplayID display,
- const sp<Client>& client);
- virtual ~LayerBuffer();
-
- virtual void onFirstRef();
- virtual bool needsBlending() const;
- virtual const char* getTypeId() const { return "LayerBuffer"; }
-
- virtual sp<LayerBaseClient::Surface> createSurface() const;
- virtual status_t ditch();
- virtual void onDraw(const Region& clip) const;
- virtual void drawForSreenShot() const;
- virtual uint32_t doTransaction(uint32_t flags);
- virtual void unlockPageFlip(const Transform& planeTransform, Region& outDirtyRegion);
- virtual void validateVisibility(const Transform& globalTransform);
-
- status_t registerBuffers(const ISurface::BufferHeap& buffers);
- void postBuffer(ssize_t offset);
- void unregisterBuffers();
- sp<OverlayRef> createOverlay(uint32_t w, uint32_t h, int32_t format,
- int32_t orientation);
-
- sp<Source> getSource() const;
- sp<Source> clearSource();
- void setNeedsBlending(bool blending);
- Rect getTransformedBounds() const {
- return mTransformedBounds;
- }
-
- void serverDestroy();
-
-private:
- struct NativeBuffer {
- copybit_image_t img;
- copybit_rect_t crop;
- };
-
- static gralloc_module_t const* sGrallocModule;
- static gralloc_module_t const* getGrallocModule() {
- return sGrallocModule;
- }
-
- class Buffer : public LightRefBase<Buffer> {
- public:
- Buffer(const ISurface::BufferHeap& buffers,
- ssize_t offset, size_t bufferSize);
- inline bool supportsCopybit() const {
- return mSupportsCopybit;
- }
- inline status_t getStatus() const {
- return mBufferHeap.heap!=0 ? NO_ERROR : NO_INIT;
- }
- inline const NativeBuffer& getBuffer() const {
- return mNativeBuffer;
- }
- protected:
- friend class LightRefBase<Buffer>;
- Buffer& operator = (const Buffer& rhs);
- Buffer(const Buffer& rhs);
- ~Buffer();
- private:
- ISurface::BufferHeap mBufferHeap;
- NativeBuffer mNativeBuffer;
- bool mSupportsCopybit;
- };
-
- class BufferSource : public Source {
- public:
- BufferSource(LayerBuffer& layer, const ISurface::BufferHeap& buffers);
- virtual ~BufferSource();
-
- status_t getStatus() const { return mStatus; }
- sp<Buffer> getBuffer() const;
- void setBuffer(const sp<Buffer>& buffer);
-
- virtual void onDraw(const Region& clip) const;
- virtual void postBuffer(ssize_t offset);
- virtual void unregisterBuffers();
- virtual void destroy() { }
- private:
- status_t initTempBuffer() const;
- void clearTempBufferImage() const;
- mutable Mutex mBufferSourceLock;
- sp<Buffer> mBuffer;
- status_t mStatus;
- ISurface::BufferHeap mBufferHeap;
- size_t mBufferSize;
- mutable Texture mTexture;
- mutable NativeBuffer mTempBuffer;
- mutable TextureManager mTextureManager;
- };
-
- class OverlaySource : public Source {
- public:
- OverlaySource(LayerBuffer& layer,
- sp<OverlayRef>* overlayRef,
- uint32_t w, uint32_t h, int32_t format, int32_t orientation);
- virtual ~OverlaySource();
- virtual void onDraw(const Region& clip) const;
- virtual void onTransaction(uint32_t flags);
- virtual void onVisibilityResolved(const Transform& planeTransform);
- virtual void onvalidateVisibility(const Transform& globalTransform);
- virtual void destroy();
- private:
-
- class OverlayChannel : public BnOverlay {
- wp<LayerBuffer> mLayer;
- virtual void destroy() {
- sp<LayerBuffer> layer(mLayer.promote());
- if (layer != 0) {
- layer->serverDestroy();
- }
- }
- public:
- OverlayChannel(const sp<LayerBuffer>& layer)
- : mLayer(layer) {
- }
- };
-
- friend class OverlayChannel;
- bool mVisibilityChanged;
-
- overlay_t* mOverlay;
- overlay_handle_t mOverlayHandle;
- overlay_control_device_t* mOverlayDevice;
- uint32_t mWidth;
- uint32_t mHeight;
- int32_t mFormat;
- int32_t mWidthStride;
- int32_t mHeightStride;
- int32_t mOrientation;
- mutable Mutex mOverlaySourceLock;
- bool mInitialized;
- };
-
-
- class SurfaceLayerBuffer : public LayerBaseClient::Surface
- {
- public:
- SurfaceLayerBuffer(const sp<SurfaceFlinger>& flinger,
- const sp<LayerBuffer>& owner);
- virtual ~SurfaceLayerBuffer();
-
- virtual status_t registerBuffers(const ISurface::BufferHeap& buffers);
- virtual void postBuffer(ssize_t offset);
- virtual void unregisterBuffers();
-
- virtual sp<OverlayRef> createOverlay(
- uint32_t w, uint32_t h, int32_t format, int32_t orientation);
- private:
- sp<LayerBuffer> getOwner() const {
- return static_cast<LayerBuffer*>(Surface::getOwner().get());
- }
- };
-
- mutable Mutex mLock;
- sp<Source> mSource;
- sp<Surface> mSurface;
- bool mInvalidate;
- bool mNeedsBlending;
- copybit_device_t* mBlitEngine;
-};
-
-// ---------------------------------------------------------------------------
-
-}; // namespace android
-
-#endif // ANDROID_LAYER_BUFFER_H
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 2e785aa..7980dfa 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -47,8 +47,6 @@
#include "clz.h"
#include "GLExtensions.h"
#include "Layer.h"
-#include "LayerBlur.h"
-#include "LayerBuffer.h"
#include "LayerDim.h"
#include "SurfaceFlinger.h"
@@ -119,11 +117,6 @@
glDeleteTextures(1, &mWormholeTexName);
}
-overlay_control_device_t* SurfaceFlinger::getOverlayEngine() const
-{
- return graphicPlane(0).displayHardware().getOverlayEngine();
-}
-
sp<IMemoryHeap> SurfaceFlinger::getCblk() const
{
return mServerHeap;
@@ -1228,19 +1221,12 @@
sp<Layer> normalLayer;
switch (flags & eFXSurfaceMask) {
case eFXSurfaceNormal:
-#if HAS_PUSH_BUFFERS
- if (UNLIKELY(flags & ePushBuffers)) {
- layer = createPushBuffersSurface(client, d, w, h, flags);
- } else
-#endif
- {
- normalLayer = createNormalSurface(client, d, w, h, flags, format);
- layer = normalLayer;
- }
+ normalLayer = createNormalSurface(client, d, w, h, flags, format);
+ layer = normalLayer;
break;
case eFXSurfaceBlur:
- layer = createBlurSurface(client, d, w, h, flags);
- break;
+ // for now we treat Blur as Dim, until we can implement it
+ // efficiently.
case eFXSurfaceDim:
layer = createDimSurface(client, d, w, h, flags);
break;
@@ -1304,15 +1290,6 @@
return layer;
}
-sp<LayerBlur> SurfaceFlinger::createBlurSurface(
- const sp<Client>& client, DisplayID display,
- uint32_t w, uint32_t h, uint32_t flags)
-{
- sp<LayerBlur> layer = new LayerBlur(this, display, client);
- layer->initStates(w, h, flags);
- return layer;
-}
-
sp<LayerDim> SurfaceFlinger::createDimSurface(
const sp<Client>& client, DisplayID display,
uint32_t w, uint32_t h, uint32_t flags)
@@ -1322,15 +1299,6 @@
return layer;
}
-sp<LayerBuffer> SurfaceFlinger::createPushBuffersSurface(
- const sp<Client>& client, DisplayID display,
- uint32_t w, uint32_t h, uint32_t flags)
-{
- sp<LayerBuffer> layer = new LayerBuffer(this, display, client);
- layer->initStates(w, h, flags);
- return layer;
-}
-
status_t SurfaceFlinger::removeSurface(const sp<Client>& client, SurfaceID sid)
{
/*
@@ -1460,7 +1428,7 @@
status_t SurfaceFlinger::dump(int fd, const Vector<String16>& args)
{
- const size_t SIZE = 1024;
+ const size_t SIZE = 4096;
char buffer[SIZE];
String8 result;
if (!mDump.checkCalling()) {
@@ -1538,6 +1506,7 @@
const GraphicBufferAllocator& alloc(GraphicBufferAllocator::get());
alloc.dump(result);
+ hw.dump(result);
if (locked) {
mStateLock.unlock();
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index dda25e8..c0e5acd 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -48,9 +48,7 @@
class DisplayHardware;
class FreezeLock;
class Layer;
-class LayerBlur;
class LayerDim;
-class LayerBuffer;
#define LIKELY( exp ) (__builtin_expect( (exp) != 0, true ))
#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false ))
@@ -207,8 +205,6 @@
void screenReleased(DisplayID dpy);
void screenAcquired(DisplayID dpy);
- overlay_control_device_t* getOverlayEngine() const;
-
status_t removeLayer(const sp<LayerBase>& layer);
status_t addLayer(const sp<LayerBase>& layer);
status_t invalidateLayerVisibility(const sp<LayerBase>& layer);
@@ -218,11 +214,9 @@
private:
friend class Client;
friend class LayerBase;
- friend class LayerBuffer;
friend class LayerBaseClient;
friend class LayerBaseClient::Surface;
friend class Layer;
- friend class LayerBlur;
friend class LayerDim;
sp<ISurface> createSurface(const sp<Client>& client,
@@ -236,18 +230,10 @@
uint32_t w, uint32_t h, uint32_t flags,
PixelFormat& format);
- sp<LayerBlur> createBlurSurface(
- const sp<Client>& client, DisplayID display,
- uint32_t w, uint32_t h, uint32_t flags);
-
sp<LayerDim> createDimSurface(
const sp<Client>& client, DisplayID display,
uint32_t w, uint32_t h, uint32_t flags);
- sp<LayerBuffer> createPushBuffersSurface(
- const sp<Client>& client, DisplayID display,
- uint32_t w, uint32_t h, uint32_t flags);
-
status_t removeSurface(const sp<Client>& client, SurfaceID sid);
status_t destroySurface(const sp<LayerBaseClient>& layer);
status_t setClientState(const sp<Client>& client,
diff --git a/services/surfaceflinger/tests/overlays/Android.mk b/services/surfaceflinger/tests/overlays/Android.mk
deleted file mode 100644
index 592b601..0000000
--- a/services/surfaceflinger/tests/overlays/Android.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- overlays.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libcutils \
- libutils \
- libui \
- libsurfaceflinger_client
-
-LOCAL_MODULE:= test-overlays
-
-LOCAL_MODULE_TAGS := tests
-
-include $(BUILD_EXECUTABLE)
diff --git a/services/surfaceflinger/tests/overlays/overlays.cpp b/services/surfaceflinger/tests/overlays/overlays.cpp
deleted file mode 100644
index c248a615..0000000
--- a/services/surfaceflinger/tests/overlays/overlays.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-#include <binder/IPCThreadState.h>
-#include <binder/ProcessState.h>
-#include <binder/IServiceManager.h>
-#include <utils/Log.h>
-
-#include <ui/Overlay.h>
-
-#include <surfaceflinger/Surface.h>
-#include <surfaceflinger/ISurface.h>
-#include <surfaceflinger/SurfaceComposerClient.h>
-
-using namespace android;
-
-namespace android {
-class Test {
-public:
- static const sp<ISurface>& getISurface(const sp<Surface>& s) {
- return s->getISurface();
- }
-};
-};
-
-int main(int argc, char** argv)
-{
- // set up the thread-pool
- sp<ProcessState> proc(ProcessState::self());
- ProcessState::self()->startThreadPool();
-
- // create a client to surfaceflinger
- sp<SurfaceComposerClient> client = new SurfaceComposerClient();
-
- // create pushbuffer surface
- sp<Surface> surface = client->createSurface(getpid(), 0, 320, 240,
- PIXEL_FORMAT_UNKNOWN, ISurfaceComposer::ePushBuffers);
-
- // get to the isurface
- sp<ISurface> isurface = Test::getISurface(surface);
- printf("isurface = %p\n", isurface.get());
-
- // now request an overlay
- sp<OverlayRef> ref = isurface->createOverlay(320, 240, PIXEL_FORMAT_RGB_565);
- sp<Overlay> overlay = new Overlay(ref);
-
-
- /*
- * here we can use the overlay API
- */
-
- overlay_buffer_t buffer;
- overlay->dequeueBuffer(&buffer);
- printf("buffer = %p\n", buffer);
-
- void* address = overlay->getBufferAddress(buffer);
- printf("address = %p\n", address);
-
- overlay->queueBuffer(buffer);
-
- return 0;
-}
diff --git a/services/surfaceflinger/tests/resize/resize.cpp b/services/surfaceflinger/tests/resize/resize.cpp
index 127cca3..99f4b4f 100644
--- a/services/surfaceflinger/tests/resize/resize.cpp
+++ b/services/surfaceflinger/tests/resize/resize.cpp
@@ -10,8 +10,6 @@
#include <surfaceflinger/ISurface.h>
#include <surfaceflinger/SurfaceComposerClient.h>
-#include <ui/Overlay.h>
-
using namespace android;
namespace android {
@@ -32,7 +30,6 @@
// create a client to surfaceflinger
sp<SurfaceComposerClient> client = new SurfaceComposerClient();
- // create pushbuffer surface
sp<Surface> surface = client->createSurface(getpid(), 0, 160, 240,
PIXEL_FORMAT_RGB_565);
diff --git a/services/surfaceflinger/tests/surface/surface.cpp b/services/surfaceflinger/tests/surface/surface.cpp
index b4de4b4..194fbb6 100644
--- a/services/surfaceflinger/tests/surface/surface.cpp
+++ b/services/surfaceflinger/tests/surface/surface.cpp
@@ -10,8 +10,6 @@
#include <surfaceflinger/ISurface.h>
#include <surfaceflinger/SurfaceComposerClient.h>
-#include <ui/Overlay.h>
-
using namespace android;
int main(int argc, char** argv)
@@ -23,7 +21,6 @@
// create a client to surfaceflinger
sp<SurfaceComposerClient> client = new SurfaceComposerClient();
- // create pushbuffer surface
sp<SurfaceControl> surfaceControl = client->createSurface(
getpid(), 0, 160, 240, PIXEL_FORMAT_RGB_565);
client->openTransaction();