summaryrefslogtreecommitdiff
path: root/libc2dcolorconvert
diff options
context:
space:
mode:
authorRajesh Sastrula <vrajesh@codeaurora.org>2015-10-12 15:32:22 -0700
committerRajesh Sastrula <vrajesh@codeaurora.org>2015-10-13 09:39:58 -0700
commit07a4eca7ae6371be3463a3e3a910f92307cd42aa (patch)
tree118cbc0a1b01a8234f17268651f1b003ff8884de /libc2dcolorconvert
parente49b105a1d6a036e064ce5a64d496da870eb52a0 (diff)
downloadmedia-07a4eca7ae6371be3463a3e3a910f92307cd42aa.tar.gz
libc2dcolorconvert: Fix height alignment issue with RGBA formats
Graphics width and height alignments change based on hardware version, hence get this information from adreno utils library. Change-Id: I5134601ac918de86028d02b88339eacf1039a543
Diffstat (limited to 'libc2dcolorconvert')
-rw-r--r--libc2dcolorconvert/C2DColorConverter.cpp33
-rw-r--r--libc2dcolorconvert/C2DColorConverter.h3
2 files changed, 33 insertions, 3 deletions
diff --git a/libc2dcolorconvert/C2DColorConverter.cpp b/libc2dcolorconvert/C2DColorConverter.cpp
index c9030f8e..d21ec48d 100644
--- a/libc2dcolorconvert/C2DColorConverter.cpp
+++ b/libc2dcolorconvert/C2DColorConverter.cpp
@@ -88,6 +88,9 @@ private:
LINK_c2dMapAddr mC2DMapAddr;
LINK_c2dUnMapAddr mC2DUnMapAddr;
+ void *mAdrenoUtilsHandle;
+ LINK_AdrenoComputeAlignedWidthAndHeight mAdrenoComputeAlignedWidthAndHeight;
+
uint32_t mSrcSurface, mDstSurface;
void * mSrcSurfaceDef;
void * mDstSurfaceDef;
@@ -142,6 +145,20 @@ C2DColorConverter::C2DColorConverter(size_t srcWidth, size_t srcHeight, size_t d
return;
}
+ mAdrenoUtilsHandle = dlopen("libadreno_utils.so", RTLD_NOW);
+ if (!mAdrenoUtilsHandle) {
+ ALOGE("FATAL ERROR: could not dlopen libadreno_utils.so: %s", dlerror());
+ mError = -1;
+ return;
+ }
+
+ mAdrenoComputeAlignedWidthAndHeight = (LINK_AdrenoComputeAlignedWidthAndHeight)dlsym(mAdrenoUtilsHandle, "compute_aligned_width_and_height");
+ if (!mAdrenoComputeAlignedWidthAndHeight) {
+ ALOGE("%s: dlsym ERROR", __FUNCTION__);
+ mError = -1;
+ return;
+ }
+
mSrcWidth = srcWidth;
mSrcHeight = srcHeight;
mSrcStride = srcStride;;
@@ -465,17 +482,27 @@ size_t C2DColorConverter::calcSize(ColorConvertFormat format, size_t width, size
int32_t alignedw = 0;
int32_t alignedh = 0;
int32_t size = 0;
+ int32_t tile_mode = 0;
+ int32_t raster_mode = 0;
+ int32_t padding_threshold = 512; /* hardcode for RGB formats */
+ int32_t bpp = 0;
switch (format) {
case RGB565:
- size = ALIGN(width, ALIGN32) * ALIGN(height, ALIGN32) * 2;
+ bpp = 2;
+ mAdrenoComputeAlignedWidthAndHeight(width, height, bpp, tile_mode, raster_mode, padding_threshold,
+ &alignedw, &alignedh);
+ size = alignedw * alignedh * bpp;
size = ALIGN(size, ALIGN4K);
break;
case RGBA8888:
+ bpp = 4;
+ mAdrenoComputeAlignedWidthAndHeight(width, height, bpp, tile_mode, raster_mode, padding_threshold,
+ &alignedw, &alignedh);
if (mSrcStride)
- size = mSrcStride * ALIGN(height, ALIGN32) * 4;
+ size = mSrcStride * alignedh * bpp;
else
- size = ALIGN(width, ALIGN32) * ALIGN(height, ALIGN32) * 4;
+ size = alignedw * alignedh * bpp;
size = ALIGN(size, ALIGN4K);
break;
case YCbCr420SP:
diff --git a/libc2dcolorconvert/C2DColorConverter.h b/libc2dcolorconvert/C2DColorConverter.h
index 89858854..1885f1ea 100644
--- a/libc2dcolorconvert/C2DColorConverter.h
+++ b/libc2dcolorconvert/C2DColorConverter.h
@@ -65,6 +65,9 @@ typedef C2D_STATUS (*LINK_c2dMapAddr)( int mem_fd, void * hostptr, uint32 len, u
typedef C2D_STATUS (*LINK_c2dUnMapAddr)(void * gpuaddr);
+typedef void (*LINK_AdrenoComputeAlignedWidthAndHeight) (int width, int height, int bpp, int tile_mode, int raster_mode,
+ int padding_threshold, int *aligned_width, int * aligned_height);
+
namespace android {
/*TODO: THIS NEEDS TO ENABLED FOR JB PLUS*/