summaryrefslogtreecommitdiffstats
path: root/libs/ui/GraphicBuffer.cpp
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2010-11-02 20:57:14 -0700
committerMathias Agopian <mathias@google.com>2010-12-03 17:35:07 -0800
commit48e723a0ee9b625825d23642f843b91fa276ab7c (patch)
tree51c657d5f49e1efee636f2e1aed19b90e22707bd /libs/ui/GraphicBuffer.cpp
parente33811512eb061338792dbb0dbd37a1b8e4e1079 (diff)
downloadframeworks_base-48e723a0ee9b625825d23642f843b91fa276ab7c.zip
frameworks_base-48e723a0ee9b625825d23642f843b91fa276ab7c.tar.gz
frameworks_base-48e723a0ee9b625825d23642f843b91fa276ab7c.tar.bz2
[3171580] Add transform field to native buffers. (DO NOT MERGE)
This field indicate how the content of the buffer needs to be transformed. Change-Id: Ide3e980a90599e931406135693231276626adbbb
Diffstat (limited to 'libs/ui/GraphicBuffer.cpp')
-rw-r--r--libs/ui/GraphicBuffer.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/libs/ui/GraphicBuffer.cpp b/libs/ui/GraphicBuffer.cpp
index 828a988..3671954 100644
--- a/libs/ui/GraphicBuffer.cpp
+++ b/libs/ui/GraphicBuffer.cpp
@@ -45,6 +45,7 @@ GraphicBuffer::GraphicBuffer()
stride =
format =
usage = 0;
+ transform = 0;
handle = NULL;
}
@@ -57,7 +58,8 @@ GraphicBuffer::GraphicBuffer(uint32_t w, uint32_t h,
height =
stride =
format =
- usage = 0;
+ usage =
+ transform = 0;
handle = NULL;
mInitCheck = initSize(w, h, reqFormat, reqUsage);
}
@@ -74,6 +76,7 @@ GraphicBuffer::GraphicBuffer(uint32_t w, uint32_t h,
stride = inStride;
format = inFormat;
usage = inUsage;
+ transform = 0;
handle = inHandle;
}
@@ -182,8 +185,10 @@ status_t GraphicBuffer::lock(GGLSurface* sur, uint32_t usage)
return res;
}
+const int kFlattenFdsOffset = 9;
+
size_t GraphicBuffer::getFlattenedSize() const {
- return (8 + (handle ? handle->numInts : 0))*sizeof(int);
+ return (kFlattenFdsOffset + (handle ? handle->numInts : 0))*sizeof(int);
}
size_t GraphicBuffer::getFdCount() const {
@@ -208,13 +213,14 @@ status_t GraphicBuffer::flatten(void* buffer, size_t size,
buf[5] = usage;
buf[6] = 0;
buf[7] = 0;
+ buf[8] = transform;
if (handle) {
buf[6] = handle->numFds;
buf[7] = handle->numInts;
native_handle_t const* const h = handle;
memcpy(fds, h->data, h->numFds*sizeof(int));
- memcpy(&buf[8], h->data + h->numFds, h->numInts*sizeof(int));
+ memcpy(&buf[kFlattenFdsOffset], h->data + h->numFds, h->numInts*sizeof(int));
}
return NO_ERROR;
@@ -223,7 +229,7 @@ status_t GraphicBuffer::flatten(void* buffer, size_t size,
status_t GraphicBuffer::unflatten(void const* buffer, size_t size,
int fds[], size_t count)
{
- if (size < 8*sizeof(int)) return NO_MEMORY;
+ if (size < kFlattenFdsOffset*sizeof(int)) return NO_MEMORY;
int const* buf = static_cast<int const*>(buffer);
if (buf[0] != 'GBFR') return BAD_TYPE;
@@ -231,7 +237,7 @@ status_t GraphicBuffer::unflatten(void const* buffer, size_t size,
const size_t numFds = buf[6];
const size_t numInts = buf[7];
- const size_t sizeNeeded = (8 + numInts) * sizeof(int);
+ const size_t sizeNeeded = (kFlattenFdsOffset + numInts) * sizeof(int);
if (size < sizeNeeded) return NO_MEMORY;
size_t fdCountNeeded = 0;
@@ -248,9 +254,10 @@ status_t GraphicBuffer::unflatten(void const* buffer, size_t size,
stride = buf[3];
format = buf[4];
usage = buf[5];
+ transform = buf[8];
native_handle* h = native_handle_create(numFds, numInts);
memcpy(h->data, fds, numFds*sizeof(int));
- memcpy(h->data + numFds, &buf[8], numInts*sizeof(int));
+ memcpy(h->data + numFds, &buf[kFlattenFdsOffset], numInts*sizeof(int));
handle = h;
} else {
width = height = stride = format = usage = 0;