summaryrefslogtreecommitdiffstats
path: root/libs/ui
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2009-05-04 14:17:04 -0700
committerMathias Agopian <mathias@google.com>2009-05-04 14:17:04 -0700
commit0926f50664c739eaee60341f8e8c694dc9a4f3eb (patch)
tree642597de2cc52f7636ae74f1a88f3706e3e54a4a /libs/ui
parent7be3e5d2d8101a8f5e12bbdf650431a734f88eba (diff)
downloadframeworks_native-0926f50664c739eaee60341f8e8c694dc9a4f3eb.tar.gz
frameworks_native-0926f50664c739eaee60341f8e8c694dc9a4f3eb.tar.bz2
frameworks_native-0926f50664c739eaee60341f8e8c694dc9a4f3eb.zip
update surfaceflinger, libui and libagl to the new gralloc api
- Currently the lock/unlock path is naive and is done for each drawing operation (glDrawElements and glDrawArrays). this should be improved eventually. - factor all the lock/unlock code in SurfaceBuffer. - fixed "showupdate" so it works even when we don't have preserving eglSwapBuffers(). - improved the situation with the dirty-region and fixed a problem that caused GL apps to not update. - make use of LightRefBase() where needed, instead of duplicating its implementation - add LightRefBase::getStrongCount() - renamed EGLNativeWindowSurface.cpp to FramebufferNativeWindow.cpp - disabled copybits test, since it clashes with the new gralloc api - Camera/Video will be fixed later when we rework the overlay apis
Diffstat (limited to 'libs/ui')
-rw-r--r--libs/ui/Android.mk2
-rw-r--r--libs/ui/BufferMapper.cpp100
-rw-r--r--libs/ui/FramebufferNativeWindow.cpp (renamed from libs/ui/EGLNativeWindowSurface.cpp)42
-rw-r--r--libs/ui/Region.cpp7
-rw-r--r--libs/ui/Surface.cpp225
5 files changed, 139 insertions, 237 deletions
diff --git a/libs/ui/Android.mk b/libs/ui/Android.mk
index 577dd4bf7..d44d2f965 100644
--- a/libs/ui/Android.mk
+++ b/libs/ui/Android.mk
@@ -5,9 +5,9 @@ LOCAL_SRC_FILES:= \
BufferMapper.cpp \
Camera.cpp \
CameraParameters.cpp \
- EGLNativeWindowSurface.cpp \
EventHub.cpp \
EventRecurrence.cpp \
+ FramebufferNativeWindow.cpp \
KeyLayoutMap.cpp \
KeyCharacterMap.cpp \
ICamera.cpp \
diff --git a/libs/ui/BufferMapper.cpp b/libs/ui/BufferMapper.cpp
index 85a029bcc..1a75c5d9a 100644
--- a/libs/ui/BufferMapper.cpp
+++ b/libs/ui/BufferMapper.cpp
@@ -17,14 +17,9 @@
#define LOG_TAG "BufferMapper"
#include <stdint.h>
-#include <unistd.h>
-#include <fcntl.h>
#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <utils/Errors.h>
-#include <utils/threads.h>
#include <utils/Log.h>
#include <ui/BufferMapper.h>
@@ -34,12 +29,6 @@
#include <hardware/gralloc.h>
-// ---------------------------------------------------------------------------
-// enable mapping debugging
-#define DEBUG_MAPPINGS 0
-// never remove mappings from the list
-#define DEBUG_MAPPINGS_KEEP_ALL 0
-// ---------------------------------------------------------------------------
namespace android {
// ---------------------------------------------------------------------------
@@ -57,34 +46,27 @@ BufferMapper::BufferMapper()
}
}
-status_t BufferMapper::map(buffer_handle_t handle, void** addr, const void* id)
+status_t BufferMapper::registerBuffer(buffer_handle_t handle)
{
- Mutex::Autolock _l(mLock);
- status_t err = mAllocMod->map(mAllocMod, handle, addr);
- LOGW_IF(err, "map(...) failed %d (%s)", err, strerror(-err));
-#if DEBUG_MAPPINGS
- if (err == NO_ERROR)
- logMapLocked(handle, id);
-#endif
+ status_t err = mAllocMod->registerBuffer(mAllocMod, handle);
+ LOGW_IF(err, "registerBuffer(%p) failed %d (%s)",
+ handle, err, strerror(-err));
return err;
}
-status_t BufferMapper::unmap(buffer_handle_t handle, const void* id)
+status_t BufferMapper::unregisterBuffer(buffer_handle_t handle)
{
- Mutex::Autolock _l(mLock);
- status_t err = mAllocMod->unmap(mAllocMod, handle);
- LOGW_IF(err, "unmap(...) failed %d (%s)", err, strerror(-err));
-#if DEBUG_MAPPINGS
- if (err == NO_ERROR)
- logUnmapLocked(handle, id);
-#endif
+ status_t err = mAllocMod->unregisterBuffer(mAllocMod, handle);
+ LOGW_IF(err, "unregisterBuffer(%p) failed %d (%s)",
+ handle, err, strerror(-err));
return err;
}
-status_t BufferMapper::lock(buffer_handle_t handle, int usage, const Rect& bounds)
+status_t BufferMapper::lock(buffer_handle_t handle,
+ int usage, const Rect& bounds, void** vaddr)
{
status_t err = mAllocMod->lock(mAllocMod, handle, usage,
- bounds.left, bounds.top, bounds.width(), bounds.height());
+ bounds.left, bounds.top, bounds.width(), bounds.height(), vaddr);
LOGW_IF(err, "unlock(...) failed %d (%s)", err, strerror(-err));
return err;
}
@@ -96,65 +78,5 @@ status_t BufferMapper::unlock(buffer_handle_t handle)
return err;
}
-void BufferMapper::logMapLocked(buffer_handle_t handle, const void* id)
-{
- CallStack stack;
- stack.update(2);
-
- map_info_t info;
- info.id = id;
- info.stack = stack;
-
- ssize_t index = mMapInfo.indexOfKey(handle);
- if (index >= 0) {
- Vector<map_info_t>& infos = mMapInfo.editValueAt(index);
- infos.add(info);
- } else {
- Vector<map_info_t> infos;
- infos.add(info);
- mMapInfo.add(handle, infos);
- }
-}
-
-void BufferMapper::logUnmapLocked(buffer_handle_t handle, const void* id)
-{
- ssize_t index = mMapInfo.indexOfKey(handle);
- if (index < 0) {
- LOGE("unmapping %p which doesn't exist in our map!", handle);
- return;
- }
-
- Vector<map_info_t>& infos = mMapInfo.editValueAt(index);
- ssize_t count = infos.size();
- for (int i=0 ; i<count ; ) {
- if (infos[i].id == id) {
- infos.removeAt(i);
- --count;
- } else {
- ++i;
- }
- }
- if (count == 0) {
- mMapInfo.removeItemsAt(index, 1);
- }
-}
-
-void BufferMapper::dump(buffer_handle_t handle)
-{
- Mutex::Autolock _l(mLock);
- ssize_t index = mMapInfo.indexOfKey(handle);
- if (index < 0) {
- LOGD("handle %p is not mapped through BufferMapper", handle);
- return;
- }
-
- const Vector<map_info_t>& infos = mMapInfo.valueAt(index);
- ssize_t count = infos.size();
- for (int i=0 ; i<count ; i++) {
- LOGD("#%d", i);
- infos[i].stack.dump();
- }
-}
-
// ---------------------------------------------------------------------------
}; // namespace android
diff --git a/libs/ui/EGLNativeWindowSurface.cpp b/libs/ui/FramebufferNativeWindow.cpp
index 5d9d6a432..407d6f4f2 100644
--- a/libs/ui/EGLNativeWindowSurface.cpp
+++ b/libs/ui/FramebufferNativeWindow.cpp
@@ -15,7 +15,7 @@
** limitations under the License.
*/
-#define LOG_TAG "EGLNativeWindowSurface"
+#define LOG_TAG "FramebufferNativeWindow"
#include <stdlib.h>
#include <stdio.h>
@@ -28,7 +28,7 @@
#include <ui/SurfaceComposerClient.h>
#include <ui/Rect.h>
-#include <ui/EGLNativeWindowSurface.h>
+#include <ui/FramebufferNativeWindow.h>
#include <EGL/egl.h>
@@ -87,13 +87,6 @@ FramebufferNativeWindow::FramebufferNativeWindow()
LOGE_IF(err, "fb buffer 1 allocation failed w=%d, h=%d, err=%s",
fbDev->width, fbDev->height, strerror(-err));
-
- gralloc_module_t* m =
- reinterpret_cast<gralloc_module_t*>(grDev->common.module);
-
- // FIXME: do we actually need to map the framebuffer?
- m->map(m, buffers[0]->handle, &buffers[0]->bits);
- m->map(m, buffers[1]->handle, &buffers[1]->bits);
}
uint32_t flags = fbDev->flags & SURFACE_FLAG_MAPPED;
@@ -125,10 +118,7 @@ FramebufferNativeWindow::FramebufferNativeWindow()
const_cast<int&>(android_native_window_t::maxSwapInterval) =
fbDev->maxSwapInterval;
- android_native_window_t::connect = connect;
- android_native_window_t::disconnect = disconnect;
android_native_window_t::setSwapInterval = setSwapInterval;
- android_native_window_t::setSwapRectangle = setSwapRectangle;
android_native_window_t::dequeueBuffer = dequeueBuffer;
android_native_window_t::lockBuffer = lockBuffer;
android_native_window_t::queueBuffer = queueBuffer;
@@ -137,10 +127,6 @@ FramebufferNativeWindow::FramebufferNativeWindow()
FramebufferNativeWindow::~FramebufferNativeWindow() {
grDev->free(grDev, buffers[0]->handle);
grDev->free(grDev, buffers[1]->handle);
- gralloc_module_t* m =
- reinterpret_cast<gralloc_module_t*>(grDev->common.module);
- m->unmap(m, buffers[0]->handle);
- m->unmap(m, buffers[1]->handle);
gralloc_close(grDev);
framebuffer_close(fbDev);
}
@@ -160,13 +146,10 @@ int FramebufferNativeWindow::setSwapInterval(
return fb->setSwapInterval(fb, interval);
}
-int FramebufferNativeWindow::setSwapRectangle(android_native_window_t* window,
- int l, int t, int w, int h)
+void FramebufferNativeWindow::setSwapRectangle(const Rect& dirty)
{
- FramebufferNativeWindow* self = getSelf(window);
- Mutex::Autolock _l(self->mutex);
- self->mDirty = Rect(l, t, l+w, t+h);
- return 0;
+ Mutex::Autolock _l(mutex);
+ mDirty = dirty;
}
int FramebufferNativeWindow::dequeueBuffer(android_native_window_t* window,
@@ -201,16 +184,8 @@ int FramebufferNativeWindow::lockBuffer(android_native_window_t* window,
while (self->front == buffer) {
self->mCondition.wait(self->mutex);
}
-
- gralloc_module_t* m =
- reinterpret_cast<gralloc_module_t*>(self->grDev->common.module);
- const Rect& dirty(self->mDirty);
- buffer_handle_t handle = static_cast<NativeBuffer*>(buffer)->handle;
- int res = m->lock(m, handle, GRALLOC_USAGE_HW_FB,
- dirty.left, dirty.right, dirty.width(), dirty.height());
-
- return res;
+ return NO_ERROR;
}
int FramebufferNativeWindow::queueBuffer(android_native_window_t* window,
@@ -219,13 +194,8 @@ int FramebufferNativeWindow::queueBuffer(android_native_window_t* window,
FramebufferNativeWindow* self = getSelf(window);
Mutex::Autolock _l(self->mutex);
framebuffer_device_t* fb = self->fbDev;
- gralloc_module_t* m =
- reinterpret_cast<gralloc_module_t*>(self->grDev->common.module);
-
buffer_handle_t handle = static_cast<NativeBuffer*>(buffer)->handle;
- m->unlock(m, handle);
int res = fb->post(fb, handle);
-
self->front = static_cast<NativeBuffer*>(buffer);
self->mNumFreeBuffers++;
self->mCondition.broadcast();
diff --git a/libs/ui/Region.cpp b/libs/ui/Region.cpp
index 26e694a70..30da911fc 100644
--- a/libs/ui/Region.cpp
+++ b/libs/ui/Region.cpp
@@ -88,6 +88,13 @@ void Region::set(const Rect& r)
mRegion.setRect(ir);
}
+void Region::set(uint32_t w, uint32_t h)
+{
+ SkIRect ir;
+ ir.set(0, 0, w, h);
+ mRegion.setRect(ir);
+}
+
// ----------------------------------------------------------------------------
Region& Region::orSelf(const Rect& r)
diff --git a/libs/ui/Surface.cpp b/libs/ui/Surface.cpp
index fb105b346..68fd9632c 100644
--- a/libs/ui/Surface.cpp
+++ b/libs/ui/Surface.cpp
@@ -31,7 +31,6 @@
#include <ui/DisplayInfo.h>
#include <ui/BufferMapper.h>
-#include <ui/EGLNativeWindowSurface.h>
#include <ui/ISurface.h>
#include <ui/Surface.h>
#include <ui/SurfaceComposerClient.h>
@@ -53,7 +52,7 @@ namespace android {
ANDROID_SINGLETON_STATIC_INSTANCE( SurfaceBuffer )
SurfaceBuffer::SurfaceBuffer()
- : BASE(), handle(0), mOwner(false)
+ : BASE(), handle(0), mOwner(false), mBufferMapper(BufferMapper::get())
{
width =
height =
@@ -64,7 +63,7 @@ SurfaceBuffer::SurfaceBuffer()
}
SurfaceBuffer::SurfaceBuffer(const Parcel& data)
- : BASE(), handle(0), mOwner(true)
+ : BASE(), handle(0), mOwner(true), mBufferMapper(BufferMapper::get())
{
// we own the handle in this case
width = data.readInt32();
@@ -91,6 +90,26 @@ int SurfaceBuffer::getHandle(android_native_buffer_t const * base,
return 0;
}
+status_t SurfaceBuffer::lock(uint32_t usage)
+{
+ const Rect lockBounds(width, height);
+ status_t res = lock(usage, lockBounds);
+ return res;
+}
+
+status_t SurfaceBuffer::lock(uint32_t usage, const Rect& rect)
+{
+ status_t res = getBufferMapper().lock(handle, usage, rect, &bits);
+ return res;
+}
+
+status_t SurfaceBuffer::unlock()
+{
+ status_t res = getBufferMapper().unlock(handle);
+ bits = NULL;
+ return res;
+}
+
status_t SurfaceBuffer::writeToParcel(Parcel* reply,
android_native_buffer_t const* buffer)
{
@@ -110,9 +129,17 @@ status_t SurfaceBuffer::writeToParcel(Parcel* reply,
// ----------------------------------------------------------------------
-static void copyBlt(const android_native_buffer_t* dst,
- const android_native_buffer_t* src, const Region& reg)
+static void copyBlt(
+ const sp<SurfaceBuffer>& dst,
+ const sp<SurfaceBuffer>& src,
+ const Region& reg)
{
+ src->lock(GRALLOC_USAGE_SW_READ_OFTEN, reg.bounds());
+ uint8_t const * const src_bits = (uint8_t const *)src->bits;
+
+ dst->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, reg.bounds());
+ uint8_t* const dst_bits = (uint8_t*)dst->bits;
+
Region::iterator iterator(reg);
if (iterator) {
// NOTE: dst and src must be the same format
@@ -120,29 +147,29 @@ static void copyBlt(const android_native_buffer_t* dst,
const size_t bpp = bytesPerPixel(src->format);
const size_t dbpr = dst->stride * bpp;
const size_t sbpr = src->stride * bpp;
+
while (iterator.iterate(&r)) {
- ssize_t h = r.bottom - r.top;
- if (h) {
- size_t size = (r.right - r.left) * bpp;
- uint8_t* s = (GGLubyte*)src->bits +
- (r.left + src->stride * r.top) * bpp;
- uint8_t* d = (GGLubyte*)dst->bits +
- (r.left + dst->stride * r.top) * bpp;
- if (dbpr==sbpr && size==sbpr) {
- size *= h;
- h = 1;
- }
- do {
- memcpy(d, s, size);
- d += dbpr;
- s += sbpr;
- } while (--h > 0);
+ ssize_t h = r.height();
+ if (h <= 0) continue;
+ size_t size = r.width() * bpp;
+ uint8_t const * s = src_bits + (r.left + src->stride * r.top) * bpp;
+ uint8_t * d = dst_bits + (r.left + dst->stride * r.top) * bpp;
+ if (dbpr==sbpr && size==sbpr) {
+ size *= h;
+ h = 1;
}
+ do {
+ memcpy(d, s, size);
+ d += dbpr;
+ s += sbpr;
+ } while (--h > 0);
}
}
+
+ src->unlock();
+ dst->unlock();
}
-
// ============================================================================
// SurfaceControl
// ============================================================================
@@ -347,12 +374,14 @@ sp<Surface> SurfaceControl::getSurface() const
Surface::Surface(const sp<SurfaceControl>& surface)
: mClient(surface->mClient), mSurface(surface->mSurface),
mToken(surface->mToken), mIdentity(surface->mIdentity),
- mFormat(surface->mFormat), mFlags(surface->mFlags)
+ mFormat(surface->mFormat), mFlags(surface->mFlags),
+ mBufferMapper(BufferMapper::get())
{
init();
}
Surface::Surface(const Parcel& parcel)
+ : mBufferMapper(BufferMapper::get())
{
sp<IBinder> clientBinder = parcel.readStrongBinder();
mSurface = interface_cast<ISurface>(parcel.readStrongBinder());
@@ -369,16 +398,11 @@ Surface::Surface(const Parcel& parcel)
void Surface::init()
{
- android_native_window_t::connect = connect;
- android_native_window_t::disconnect = disconnect;
android_native_window_t::setSwapInterval = setSwapInterval;
- android_native_window_t::setSwapRectangle = setSwapRectangle;
android_native_window_t::dequeueBuffer = dequeueBuffer;
android_native_window_t::lockBuffer = lockBuffer;
android_native_window_t::queueBuffer = queueBuffer;
-
mSwapRectangle.makeInvalid();
-
DisplayInfo dinfo;
SurfaceComposerClient::getDisplayInfo(0, &dinfo);
const_cast<float&>(android_native_window_t::xdpi) = dinfo.xdpi;
@@ -396,7 +420,7 @@ Surface::~Surface()
// its buffers in this process.
for (int i=0 ; i<2 ; i++) {
if (mBuffers[i] != 0) {
- BufferMapper::get().unmap(mBuffers[i]->getHandle(), this);
+ getBufferMapper().unregisterBuffer(mBuffers[i]->getHandle());
}
}
@@ -443,22 +467,6 @@ bool Surface::isSameSurface(
// ----------------------------------------------------------------------------
-int Surface::setSwapRectangle(android_native_window_t* window,
- int l, int t, int w, int h)
-{
- Surface* self = getSelf(window);
- self->setSwapRectangle(Rect(l, t, l+w, t+h));
- return 0;
-}
-
-void Surface::connect(android_native_window_t* window)
-{
-}
-
-void Surface::disconnect(android_native_window_t* window)
-{
-}
-
int Surface::setSwapInterval(android_native_window_t* window, int interval)
{
return 0;
@@ -487,6 +495,26 @@ int Surface::queueBuffer(android_native_window_t* window,
// ----------------------------------------------------------------------------
+status_t Surface::dequeueBuffer(sp<SurfaceBuffer>* buffer)
+{
+ android_native_buffer_t* out;
+ status_t err = dequeueBuffer(&out);
+ *buffer = SurfaceBuffer::getSelf(out);
+ return err;
+}
+
+status_t Surface::lockBuffer(const sp<SurfaceBuffer>& buffer)
+{
+ return lockBuffer(buffer.get());
+}
+
+status_t Surface::queueBuffer(const sp<SurfaceBuffer>& buffer)
+{
+ return queueBuffer(buffer.get());
+}
+
+// ----------------------------------------------------------------------------
+
int Surface::dequeueBuffer(android_native_buffer_t** buffer)
{
// FIXME: dequeueBuffer() needs proper implementation
@@ -515,8 +543,9 @@ int Surface::dequeueBuffer(android_native_buffer_t** buffer)
}
const sp<SurfaceBuffer>& backBuffer(mBuffers[backIdx]);
+ mDirtyRegion.set(backBuffer->width, backBuffer->height);
*buffer = backBuffer.get();
-
+
return NO_ERROR;
}
@@ -542,11 +571,14 @@ int Surface::queueBuffer(android_native_buffer_t* buffer)
if (err != NO_ERROR)
return err;
+ if (mSwapRectangle.isValid()) {
+ mDirtyRegion.set(mSwapRectangle);
+ }
+
// transmit the dirty region
- const Region dirty(swapRectangle());
SurfaceID index(mToken);
layer_cblk_t* const lcblk = &(cblk->layers[index]);
- _send_dirty_region(lcblk, dirty);
+ _send_dirty_region(lcblk, mDirtyRegion);
uint32_t newstate = cblk->unlock_layer_and_post(size_t(index));
if (!(newstate & eNextFlipPending))
@@ -561,27 +593,20 @@ status_t Surface::lock(SurfaceInfo* info, bool blocking) {
return Surface::lock(info, NULL, blocking);
}
-status_t Surface::lock(SurfaceInfo* other, Region* dirty, bool blocking)
+status_t Surface::lock(SurfaceInfo* other, Region* dirtyIn, bool blocking)
{
// FIXME: needs some locking here
- android_native_buffer_t* backBuffer;
+
+ sp<SurfaceBuffer> backBuffer;
status_t err = dequeueBuffer(&backBuffer);
if (err == NO_ERROR) {
err = lockBuffer(backBuffer);
if (err == NO_ERROR) {
- backBuffer->common.incRef(&backBuffer->common);
- mLockedBuffer = backBuffer;
- other->w = backBuffer->width;
- other->h = backBuffer->height;
- other->s = backBuffer->stride;
- other->usage = backBuffer->usage;
- other->format = backBuffer->format;
- other->bits = backBuffer->bits;
-
// we handle copy-back here...
const Rect bounds(backBuffer->width, backBuffer->height);
- Region newDirtyRegion;
+ Region scratch(bounds);
+ Region& newDirtyRegion(dirtyIn ? *dirtyIn : scratch);
per_client_cblk_t* const cblk = mClient->mControl;
layer_cblk_t* const lcblk = &(cblk->layers[SurfaceID(mToken)]);
@@ -590,43 +615,34 @@ status_t Surface::lock(SurfaceInfo* other, Region* dirty, bool blocking)
// content is meaningless in this case and the whole surface
// needs to be redrawn.
newDirtyRegion.set(bounds);
- if (dirty) {
- *dirty = newDirtyRegion;
- }
- } else
- {
- if (dirty) {
- dirty->andSelf(Region(bounds));
- newDirtyRegion = *dirty;
- } else {
- newDirtyRegion.set(bounds);
- }
- Region copyback;
+ } else {
+ newDirtyRegion.andSelf(bounds);
if (!(lcblk->flags & eNoCopyBack)) {
- const Region previousDirtyRegion(dirtyRegion());
- copyback = previousDirtyRegion.subtract(newDirtyRegion);
- }
- const sp<SurfaceBuffer>& frontBuffer(mBuffers[1-mBackbufferIndex]);
- if (!copyback.isEmpty() && frontBuffer!=0) {
- // copy front to back
- copyBlt(backBuffer, frontBuffer.get(), copyback);
+ const sp<SurfaceBuffer>& frontBuffer(mBuffers[1-mBackbufferIndex]);
+ const Region copyback(mOldDirtyRegion.subtract(newDirtyRegion));
+ if (!copyback.isEmpty() && frontBuffer!=0) {
+ // copy front to back
+ copyBlt(backBuffer, frontBuffer, copyback);
+ }
}
}
- setDirtyRegion(newDirtyRegion);
-
+ mDirtyRegion = newDirtyRegion;
+ mOldDirtyRegion = newDirtyRegion;
- Rect lockBounds(backBuffer->width, backBuffer->height);
- if (dirty) {
- lockBounds = dirty->bounds();
- }
- buffer_handle_t handle;
- backBuffer->getHandle(backBuffer, &handle);
- status_t res = BufferMapper::get().lock(handle,
- GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN,
- lockBounds);
+ status_t res = backBuffer->lock(
+ GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN,
+ newDirtyRegion.bounds());
+
LOGW_IF(res, "failed locking buffer %d (%p)",
- mBackbufferIndex, handle);
- setSwapRectangle(lockBounds);
+ mBackbufferIndex, backBuffer->handle);
+
+ mLockedBuffer = backBuffer;
+ other->w = backBuffer->width;
+ other->h = backBuffer->height;
+ other->s = backBuffer->stride;
+ other->usage = backBuffer->usage;
+ other->format = backBuffer->format;
+ other->bits = backBuffer->bits;
}
}
return err;
@@ -639,16 +655,12 @@ status_t Surface::unlockAndPost()
if (mLockedBuffer == 0)
return BAD_VALUE;
- buffer_handle_t handle;
- mLockedBuffer->getHandle(mLockedBuffer, &handle);
- status_t res = BufferMapper::get().unlock(handle);
+ status_t res = mLockedBuffer->unlock();
LOGW_IF(res, "failed unlocking buffer %d (%p)",
- mBackbufferIndex, handle);
-
- const Rect dirty(dirtyRegion().bounds());
- setSwapRectangle(dirty);
+ mBackbufferIndex, mLockedBuffer->handle);
+
status_t err = queueBuffer(mLockedBuffer);
- mLockedBuffer->common.decRef(&mLockedBuffer->common);
+ mLockedBuffer->bits = NULL;
mLockedBuffer = 0;
return err;
}
@@ -666,15 +678,6 @@ void Surface::_send_dirty_region(
}
}
-Region Surface::dirtyRegion() const {
- return mDirtyRegion;
-}
-void Surface::setDirtyRegion(const Region& region) const {
- mDirtyRegion = region;
-}
-const Rect& Surface::swapRectangle() const {
- return mSwapRectangle;
-}
void Surface::setSwapRectangle(const Rect& r) {
mSwapRectangle = r;
}
@@ -687,10 +690,10 @@ status_t Surface::getBufferLocked(int index)
if (buffer != 0) {
sp<SurfaceBuffer>& currentBuffer(mBuffers[index]);
if (currentBuffer != 0) {
- BufferMapper::get().unmap(currentBuffer->getHandle(), this);
+ getBufferMapper().unregisterBuffer(currentBuffer->getHandle());
currentBuffer.clear();
}
- err = BufferMapper::get().map(buffer->getHandle(), &buffer->bits, this);
+ err = getBufferMapper().registerBuffer(buffer->getHandle());
LOGW_IF(err, "map(...) failed %d (%s)", err, strerror(-err));
if (err == NO_ERROR) {
currentBuffer = buffer;