Add support for width != stride
BUG=6111812
Change-Id: Ie7e01613051160aa7071ea40431fe2eff1c8ab88
diff --git a/lib/ScriptCRT/rs_allocation.c b/lib/ScriptCRT/rs_allocation.c
index 2cc9108..dbfb76e 100644
--- a/lib/ScriptCRT/rs_allocation.c
+++ b/lib/ScriptCRT/rs_allocation.c
@@ -46,8 +46,8 @@
Allocation_t *alloc = (Allocation_t *)a.p;
const uint8_t *p = (const uint8_t *)alloc->mHal.drvState.mallocPtr;
const uint32_t eSize = alloc->mHal.state.elementSizeBytes;
- const uint32_t dimX = alloc->mHal.state.dimensionX;
- return &p[eSize * (x + y * dimX)];
+ const uint32_t stride = alloc->mHal.drvState.stride;
+ return &p[(eSize * x) + (y * stride)];
}
extern const void * __attribute__((overloadable))
@@ -55,9 +55,9 @@
Allocation_t *alloc = (Allocation_t *)a.p;
const uint8_t *p = (const uint8_t *)alloc->mHal.drvState.mallocPtr;
const uint32_t eSize = alloc->mHal.state.elementSizeBytes;
- const uint32_t dimX = alloc->mHal.state.dimensionX;
+ const uint32_t stride = alloc->mHal.drvState.stride;
const uint32_t dimY = alloc->mHal.state.dimensionY;
- return &p[eSize * (x + y * dimX + z * dimX * dimY)];
+ return &p[(eSize * x) + (y * stride) + (z * stride * dimY)];
}
extern rs_element __attribute__((overloadable))
diff --git a/lib/ScriptCRT/rs_structs.h b/lib/ScriptCRT/rs_structs.h
index 9d8c2d7..bef849c 100644
--- a/lib/ScriptCRT/rs_structs.h
+++ b/lib/ScriptCRT/rs_structs.h
@@ -47,6 +47,7 @@
struct DrvState {
void * mallocPtr;
+ uint32_t stride;
} drvState;
} mHal;
} Allocation_t;