[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
This commit is contained in:
parent
733189d408
commit
30eb1b1803
@ -26,6 +26,8 @@
|
||||
#include <utils/Flattenable.h>
|
||||
#include <pixelflinger/pixelflinger.h>
|
||||
|
||||
#include <hardware/hardware.h>
|
||||
|
||||
struct android_native_buffer_t;
|
||||
|
||||
namespace android {
|
||||
@ -63,6 +65,13 @@ public:
|
||||
USAGE_HW_MASK = GRALLOC_USAGE_HW_MASK
|
||||
};
|
||||
|
||||
enum {
|
||||
TRANSFORM_IDENTITY = 0,
|
||||
TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90,
|
||||
TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180,
|
||||
TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270
|
||||
};
|
||||
|
||||
GraphicBuffer();
|
||||
|
||||
// creates w * h buffer
|
||||
@ -79,6 +88,7 @@ public:
|
||||
uint32_t getHeight() const { return height; }
|
||||
uint32_t getStride() const { return stride; }
|
||||
uint32_t getUsage() const { return usage; }
|
||||
uint32_t getTransform() const { return transform; }
|
||||
PixelFormat getPixelFormat() const { return format; }
|
||||
Rect getBounds() const { return Rect(width, height); }
|
||||
|
||||
|
@ -51,8 +51,12 @@ typedef struct android_native_buffer_t
|
||||
int stride;
|
||||
int format;
|
||||
int usage;
|
||||
|
||||
void* reserved[2];
|
||||
|
||||
/* transformation as defined in hardware.h */
|
||||
uint8_t transform;
|
||||
|
||||
uint8_t reserved_bytes[3];
|
||||
void* reserved[1];
|
||||
|
||||
buffer_handle_t handle;
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user