summaryrefslogtreecommitdiffstats
path: root/libs/surfaceflinger
diff options
context:
space:
mode:
authorAndroid (Google) Code Review <android-gerrit@google.com>2009-10-30 17:54:10 -0400
committerAndroid (Google) Code Review <android-gerrit@google.com>2009-10-30 17:54:10 -0400
commitd01767f8b7038108f9125cd2122b117db9919824 (patch)
treeec6353d79a856b6227eeeb474fd9c653cc142d95 /libs/surfaceflinger
parentf989c1140bbc84480498df38abec0fafff04e6ee (diff)
parent0b0722f980f40e1ac0929a7f1a6e2df7af983478 (diff)
downloadframeworks_base-d01767f8b7038108f9125cd2122b117db9919824.zip
frameworks_base-d01767f8b7038108f9125cd2122b117db9919824.tar.gz
frameworks_base-d01767f8b7038108f9125cd2122b117db9919824.tar.bz2
Merge change I56779290 into eclair
* changes: fix[2222341] Soft reset while going back from camcorder settings
Diffstat (limited to 'libs/surfaceflinger')
-rw-r--r--libs/surfaceflinger/LayerBuffer.cpp57
-rw-r--r--libs/surfaceflinger/LayerBuffer.h5
2 files changed, 41 insertions, 21 deletions
diff --git a/libs/surfaceflinger/LayerBuffer.cpp b/libs/surfaceflinger/LayerBuffer.cpp
index f70bcf4..82a8e51 100644
--- a/libs/surfaceflinger/LayerBuffer.cpp
+++ b/libs/surfaceflinger/LayerBuffer.cpp
@@ -33,14 +33,13 @@
#include "SurfaceFlinger.h"
#include "DisplayHardware/DisplayHardware.h"
-#include "gralloc_priv.h" // needed for msm / copybit
-
namespace android {
// ---------------------------------------------------------------------------
const uint32_t LayerBuffer::typeInfo = LayerBaseClient::typeInfo | 0x20;
const char* const LayerBuffer::typeID = "LayerBuffer";
+gralloc_module_t const* LayerBuffer::sGrallocModule = 0;
// ---------------------------------------------------------------------------
@@ -60,6 +59,16 @@ void LayerBuffer::onFirstRef()
LayerBaseClient::onFirstRef();
mSurface = new SurfaceLayerBuffer(mFlinger, clientIndex(),
const_cast<LayerBuffer *>(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;
+ }
+ }
}
sp<LayerBaseClient::Surface> LayerBuffer::createSurface() const
@@ -243,30 +252,36 @@ LayerBuffer::Buffer::Buffer(const ISurface::BufferHeap& buffers, ssize_t offset)
: mBufferHeap(buffers)
{
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);
-
- // FIXME: gross hack, we should never access private_handle_t from here,
- // but this is needed by msm drivers
- private_handle_t* hnd = new private_handle_t(
- buffers.heap->heapID(), buffers.heap->getSize(), 0);
- hnd->offset = offset;
- src.img.handle = hnd;
+ 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(), buffers.heap->getSize(),
+ offset, buffers.heap->base(),
+ &src.img.handle);
+
+ if (err == NO_ERROR) {
+ 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);
+ }
+ }
}
LayerBuffer::Buffer::~Buffer()
{
NativeBuffer& src(mNativeBuffer);
- if (src.img.handle)
- delete (private_handle_t*)src.img.handle;
+ if (src.img.handle) {
+ native_handle_delete(src.img.handle);
+ }
}
// ============================================================================
diff --git a/libs/surfaceflinger/LayerBuffer.h b/libs/surfaceflinger/LayerBuffer.h
index 438b711..47482f4 100644
--- a/libs/surfaceflinger/LayerBuffer.h
+++ b/libs/surfaceflinger/LayerBuffer.h
@@ -91,6 +91,11 @@ private:
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);