From 3a5f8cd7970f0e9b34e2637596a7f36f990dad77 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Thu, 4 Nov 2010 14:05:31 -0700 Subject: Support for rotated display of video content. Change-Id: If2662682811ffb339775b1101189338285d93fcc related-to-bug: 3166122 --- libstagefrighthw/SecHardwareRenderer.cpp | 15 +++++++++++++-- libstagefrighthw/SecHardwareRenderer.h | 1 + libstagefrighthw/stagefright_overlay_output.cpp | 6 ++++-- 3 files changed, 18 insertions(+), 4 deletions(-) (limited to 'libstagefrighthw') diff --git a/libstagefrighthw/SecHardwareRenderer.cpp b/libstagefrighthw/SecHardwareRenderer.cpp index d975462..f534b10 100644 --- a/libstagefrighthw/SecHardwareRenderer.cpp +++ b/libstagefrighthw/SecHardwareRenderer.cpp @@ -43,6 +43,7 @@ SecHardwareRenderer::SecHardwareRenderer( size_t displayWidth, size_t displayHeight, size_t decodedWidth, size_t decodedHeight, OMX_COLOR_FORMATTYPE colorFormat, + int32_t rotationDegrees, bool fromHardwareDecoder) : mISurface(surface), mDisplayWidth(displayWidth), @@ -67,18 +68,28 @@ SecHardwareRenderer::SecHardwareRenderer( return; } + uint32_t orientation; + switch (rotationDegrees) { + case 0: orientation = ISurface::BufferHeap::ROT_0; break; + case 90: orientation = ISurface::BufferHeap::ROT_90; break; + case 180: orientation = ISurface::BufferHeap::ROT_180; break; + case 270: orientation = ISurface::BufferHeap::ROT_270; break; + default: orientation = ISurface::BufferHeap::ROT_0; break; + } + sp ref; #if defined (USE_ZERO_COPY) if (fromHardwareDecoder) { ref = mISurface->createOverlay( mDecodedWidth, mDecodedHeight, - HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP, 0); + HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP, orientation); mCustomFormat = true; } else #else ref = mISurface->createOverlay( - mDecodedWidth, mDecodedHeight, HAL_PIXEL_FORMAT_YCbCr_420_P, 0); + mDecodedWidth, mDecodedHeight, HAL_PIXEL_FORMAT_YCbCr_420_P, + orientation); #endif if (ref.get() == NULL) { diff --git a/libstagefrighthw/SecHardwareRenderer.h b/libstagefrighthw/SecHardwareRenderer.h index 42f93b2..3fad243 100644 --- a/libstagefrighthw/SecHardwareRenderer.h +++ b/libstagefrighthw/SecHardwareRenderer.h @@ -39,6 +39,7 @@ public: size_t displayWidth, size_t displayHeight, size_t decodedWidth, size_t decodedHeight, OMX_COLOR_FORMATTYPE colorFormat, + int32_t rotationDegrees, bool fromHardwareDecoder); virtual ~SecHardwareRenderer(); diff --git a/libstagefrighthw/stagefright_overlay_output.cpp b/libstagefrighthw/stagefright_overlay_output.cpp index 3ac46a6..fce1d7e 100644 --- a/libstagefrighthw/stagefright_overlay_output.cpp +++ b/libstagefrighthw/stagefright_overlay_output.cpp @@ -22,12 +22,13 @@ using android::sp; using android::ISurface; using android::VideoRenderer; -VideoRenderer *createRenderer( +VideoRenderer *createRendererWithRotation( const sp &surface, const char *componentName, OMX_COLOR_FORMATTYPE colorFormat, size_t displayWidth, size_t displayHeight, - size_t decodedWidth, size_t decodedHeight) { + size_t decodedWidth, size_t decodedHeight, + int32_t rotationDegrees) { using android::SecHardwareRenderer; bool fromHardwareDecoder = !strncmp(componentName, "OMX.SEC.", 8); @@ -37,6 +38,7 @@ VideoRenderer *createRenderer( surface, displayWidth, displayHeight, decodedWidth, decodedHeight, colorFormat, + rotationDegrees, fromHardwareDecoder); if (renderer->initCheck() != android::OK) { -- cgit v1.1