summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2009-05-05 00:59:23 -0700
committerMathias Agopian <mathias@google.com>2009-05-05 00:59:23 -0700
commit21c59d0070fe24a8e04e52ce04d511a924a9932f (patch)
treefb3f5f8519fce57c714dce607b12dc44aba67702
parente71212ba5397387100a578d23b15862518a7a859 (diff)
downloadframeworks_native-21c59d0070fe24a8e04e52ce04d511a924a9932f.zip
frameworks_native-21c59d0070fe24a8e04e52ce04d511a924a9932f.tar.gz
frameworks_native-21c59d0070fe24a8e04e52ce04d511a924a9932f.tar.bz2
get rid of android_native_buffer_t::getHandle() and replace it with an handle field
this abstraction was not necessary. things are easier now.
-rw-r--r--include/ui/FramebufferNativeWindow.h7
-rw-r--r--include/ui/Surface.h8
-rw-r--r--libs/ui/Surface.cpp27
-rw-r--r--opengl/include/EGL/android_natives.h9
-rw-r--r--opengl/libagl/egl.cpp19
-rw-r--r--opengl/libagl/texture.cpp21
6 files changed, 22 insertions, 69 deletions
diff --git a/include/ui/FramebufferNativeWindow.h b/include/ui/FramebufferNativeWindow.h
index 4b281db..0db245a 100644
--- a/include/ui/FramebufferNativeWindow.h
+++ b/include/ui/FramebufferNativeWindow.h
@@ -50,17 +50,10 @@ public:
android_native_buffer_t::height = h;
android_native_buffer_t::format = f;
android_native_buffer_t::usage = u;
- android_native_buffer_t::getHandle = getHandle;
}
-public:
- buffer_handle_t handle;
private:
friend class LightRefBase<NativeBuffer>;
~NativeBuffer() { }; // this class cannot be overloaded
- static int getHandle(android_native_buffer_t const * base, buffer_handle_t* handle) {
- *handle = getSelf(base)->handle;
- return 0;
- }
};
// ---------------------------------------------------------------------------
diff --git a/include/ui/Surface.h b/include/ui/Surface.h
index ce50719..e9bb1b3 100644
--- a/include/ui/Surface.h
+++ b/include/ui/Surface.h
@@ -50,10 +50,6 @@ class SurfaceBuffer
LightRefBase<SurfaceBuffer> >
{
public:
- buffer_handle_t getHandle() const {
- return handle;
- }
-
status_t lock(uint32_t usage, void** vaddr);
status_t lock(uint32_t usage, const Rect& rect, void** vaddr);
status_t unlock();
@@ -62,7 +58,6 @@ protected:
SurfaceBuffer();
SurfaceBuffer(const Parcel& reply);
virtual ~SurfaceBuffer();
- buffer_handle_t handle;
bool mOwner;
inline const BufferMapper& getBufferMapper() const { return mBufferMapper; }
@@ -80,9 +75,6 @@ private:
static status_t writeToParcel(Parcel* reply,
android_native_buffer_t const* buffer);
- static int getHandle(android_native_buffer_t const * base,
- buffer_handle_t* handle);
-
BufferMapper& mBufferMapper;
};
diff --git a/libs/ui/Surface.cpp b/libs/ui/Surface.cpp
index 5f2138e..782eac4 100644
--- a/libs/ui/Surface.cpp
+++ b/libs/ui/Surface.cpp
@@ -52,18 +52,18 @@ namespace android {
ANDROID_SINGLETON_STATIC_INSTANCE( SurfaceBuffer )
SurfaceBuffer::SurfaceBuffer()
- : BASE(), handle(0), mOwner(false), mBufferMapper(BufferMapper::get())
+ : BASE(), mOwner(false), mBufferMapper(BufferMapper::get())
{
width =
height =
stride =
format =
usage = 0;
- android_native_buffer_t::getHandle = getHandle;
+ handle = NULL;
}
SurfaceBuffer::SurfaceBuffer(const Parcel& data)
- : BASE(), handle(0), mOwner(true), mBufferMapper(BufferMapper::get())
+ : BASE(), mOwner(true), mBufferMapper(BufferMapper::get())
{
// we own the handle in this case
width = data.readInt32();
@@ -72,7 +72,6 @@ SurfaceBuffer::SurfaceBuffer(const Parcel& data)
format = data.readInt32();
usage = data.readInt32();
handle = data.readNativeHandle();
- android_native_buffer_t::getHandle = getHandle;
}
SurfaceBuffer::~SurfaceBuffer()
@@ -83,13 +82,6 @@ SurfaceBuffer::~SurfaceBuffer()
}
}
-int SurfaceBuffer::getHandle(android_native_buffer_t const * base,
- buffer_handle_t* handle)
-{
- *handle = getSelf(base)->handle;
- return 0;
-}
-
status_t SurfaceBuffer::lock(uint32_t usage, void** vaddr)
{
const Rect lockBounds(width, height);
@@ -112,17 +104,12 @@ status_t SurfaceBuffer::unlock()
status_t SurfaceBuffer::writeToParcel(Parcel* reply,
android_native_buffer_t const* buffer)
{
- buffer_handle_t handle;
- status_t err = buffer->getHandle(buffer, &handle);
- if (err < 0) {
- return err;
- }
reply->writeInt32(buffer->width);
reply->writeInt32(buffer->height);
reply->writeInt32(buffer->stride);
reply->writeInt32(buffer->format);
reply->writeInt32(buffer->usage);
- reply->writeNativeHandle(handle);
+ reply->writeNativeHandle(buffer->handle);
return NO_ERROR;
}
@@ -419,7 +406,7 @@ Surface::~Surface()
// its buffers in this process.
for (int i=0 ; i<2 ; i++) {
if (mBuffers[i] != 0) {
- getBufferMapper().unregisterBuffer(mBuffers[i]->getHandle());
+ getBufferMapper().unregisterBuffer(mBuffers[i]->handle);
}
}
@@ -689,10 +676,10 @@ status_t Surface::getBufferLocked(int index)
if (buffer != 0) {
sp<SurfaceBuffer>& currentBuffer(mBuffers[index]);
if (currentBuffer != 0) {
- getBufferMapper().unregisterBuffer(currentBuffer->getHandle());
+ getBufferMapper().unregisterBuffer(currentBuffer->handle);
currentBuffer.clear();
}
- err = getBufferMapper().registerBuffer(buffer->getHandle());
+ err = getBufferMapper().registerBuffer(buffer->handle);
LOGW_IF(err, "map(...) failed %d (%s)", err, strerror(-err));
if (err == NO_ERROR) {
currentBuffer = buffer;
diff --git a/opengl/include/EGL/android_natives.h b/opengl/include/EGL/android_natives.h
index 8db2bb3..b8465d5 100644
--- a/opengl/include/EGL/android_natives.h
+++ b/opengl/include/EGL/android_natives.h
@@ -157,13 +157,12 @@ struct android_native_buffer_t
int stride;
int format;
int usage;
+
+ void* reserved[2];
- void* reserved[3];
-
- int (*getHandle)(struct android_native_buffer_t const * base,
- buffer_handle_t* handle);
+ buffer_handle_t handle;
- void* reserved_proc[7];
+ void* reserved_proc[8];
};
diff --git a/opengl/libagl/egl.cpp b/opengl/libagl/egl.cpp
index 67dfd3e..720ba0b 100644
--- a/opengl/libagl/egl.cpp
+++ b/opengl/libagl/egl.cpp
@@ -274,26 +274,14 @@ void egl_window_surface_v2_t::disconnect()
status_t egl_window_surface_v2_t::lock(
android_native_buffer_t* buf, int usage, void** vaddr)
{
- int err;
- buffer_handle_t bufferHandle;
- err = buf->getHandle(buf, &bufferHandle);
- if (err < 0)
- return err;
-
- err = module->lock(module, bufferHandle,
+ int err = module->lock(module, buf->handle,
usage, 0, 0, buf->width, buf->height, vaddr);
return err;
}
status_t egl_window_surface_v2_t::unlock(android_native_buffer_t* buf)
{
- int err;
- buffer_handle_t bufferHandle;
- err = buf->getHandle(buf, &bufferHandle);
- if (err < 0)
- return err;
-
- err = module->unlock(module, bufferHandle);
+ int err = module->unlock(module, buf->handle);
return err;
}
@@ -379,8 +367,7 @@ EGLBoolean egl_window_surface_v2_t::bindDrawSurface(ogles_context_t* gl)
#ifdef LIBAGL_USE_GRALLOC_COPYBITS
gl->copybits.drawSurfaceFd = -1;
if (supportedCopybitsDestinationFormat(buffer.format)) {
- buffer_handle_t handle;
- this->buffer->getHandle(this->buffer, &handle);
+ buffer_handle_t handle = this->buffer->handle;
if (handle != NULL) {
private_handle_t* hand = private_handle_t::dynamicCast(handle);
if (hand != NULL) {
diff --git a/opengl/libagl/texture.cpp b/opengl/libagl/texture.cpp
index 9bcbfdd..1189643 100644
--- a/opengl/libagl/texture.cpp
+++ b/opengl/libagl/texture.cpp
@@ -139,10 +139,9 @@ void ogles_lock_textures(ogles_context_t* c)
gralloc_module_t const* module =
reinterpret_cast<gralloc_module_t const*>(pModule);
- buffer_handle_t bufferHandle;
- native_buffer->getHandle(native_buffer, &bufferHandle);
+
void* vaddr;
- int err = module->lock(module, bufferHandle,
+ int err = module->lock(module, native_buffer->handle,
GRALLOC_USAGE_SW_READ_OFTEN,
0, 0, native_buffer->width, native_buffer->height,
&vaddr);
@@ -168,9 +167,8 @@ void ogles_unlock_textures(ogles_context_t* c)
gralloc_module_t const* module =
reinterpret_cast<gralloc_module_t const*>(pModule);
- buffer_handle_t bufferHandle;
- native_buffer->getHandle(native_buffer, &bufferHandle);
- module->unlock(module, bufferHandle);
+
+ module->unlock(module, native_buffer->handle);
u.texture->setImageBits(NULL);
c->rasterizer.procs.bindTexture(c, &(u.texture->surface));
}
@@ -1547,13 +1545,10 @@ void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
*/
#ifdef LIBAGL_USE_GRALLOC_COPYBITS
tex->copybits_fd = -1;
- buffer_handle_t handle;
- if (native_buffer->getHandle(native_buffer, &handle) == 0) {
- private_handle_t* hand;
- if ((hand = private_handle_t::dynamicCast(handle)) != NULL) {
- if (hand->usesPhysicallyContiguousMemory()) {
- tex->copybits_fd = hand->fd;
- }
+ private_handle_t* hand;
+ if ((hand = private_handle_t::dynamicCast(native_buffer->handle)) != NULL) {
+ if (hand->usesPhysicallyContiguousMemory()) {
+ tex->copybits_fd = hand->fd;
}
}
#endif // LIBAGL_USE_GRALLOC_COPYBITS