Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f8f669d7 authored by Chong Zhang's avatar Chong Zhang Committed by Android (Google) Code Review
Browse files

Merge "fix soft renderer rotation" into mnc-dev

parents 51390b48 505aab41
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -299,6 +299,7 @@ private:
    bool mIsVideo;
    int32_t mVideoWidth;
    int32_t mVideoHeight;
    int32_t mRotationDegrees;

    // initial create parameters
    AString mInitName;
+5 −1
Original line number Diff line number Diff line
@@ -247,6 +247,7 @@ MediaCodec::MediaCodec(const sp<ALooper> &looper)
      mIsVideo(false),
      mVideoWidth(0),
      mVideoHeight(0),
      mRotationDegrees(0),
      mDequeueInputTimeoutGeneration(0),
      mDequeueInputReplyID(0),
      mDequeueOutputTimeoutGeneration(0),
@@ -409,6 +410,9 @@ status_t MediaCodec::configure(
    if (mIsVideo) {
        format->findInt32("width", &mVideoWidth);
        format->findInt32("height", &mVideoHeight);
        if (!format->findInt32("rotation-degrees", &mRotationDegrees)) {
            mRotationDegrees = 0;
        }
    }

    msg->setMessage("format", format);
@@ -1309,7 +1313,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
                        CHECK(msg->findString("mime", &mime));

                        if (mime.startsWithIgnoreCase("video/")) {
                            mSoftRenderer = new SoftwareRenderer(mSurface);
                            mSoftRenderer = new SoftwareRenderer(mSurface, mRotationDegrees);
                        }
                    }

+5 −3
Original line number Diff line number Diff line
@@ -38,7 +38,8 @@ static int ALIGN(int x, int y) {
    return (x + y - 1) & ~(y - 1);
}

SoftwareRenderer::SoftwareRenderer(const sp<ANativeWindow> &nativeWindow)
SoftwareRenderer::SoftwareRenderer(
        const sp<ANativeWindow> &nativeWindow, int32_t rotation)
    : mColorFormat(OMX_COLOR_FormatUnused),
      mConverter(NULL),
      mYUVMode(None),
@@ -50,7 +51,8 @@ SoftwareRenderer::SoftwareRenderer(const sp<ANativeWindow> &nativeWindow)
      mCropRight(0),
      mCropBottom(0),
      mCropWidth(0),
      mCropHeight(0) {
      mCropHeight(0),
      mRotationDegrees(rotation) {
}

SoftwareRenderer::~SoftwareRenderer() {
@@ -181,7 +183,7 @@ void SoftwareRenderer::resetFormatIfChanged(const sp<AMessage> &format) {

    int32_t rotationDegrees;
    if (!format->findInt32("rotation-degrees", &rotationDegrees)) {
        rotationDegrees = 0;
        rotationDegrees = mRotationDegrees;
    }
    uint32_t transform;
    switch (rotationDegrees) {
+3 −1
Original line number Diff line number Diff line
@@ -31,7 +31,8 @@ struct AMessage;

class SoftwareRenderer {
public:
    explicit SoftwareRenderer(const sp<ANativeWindow> &nativeWindow);
    explicit SoftwareRenderer(
            const sp<ANativeWindow> &nativeWindow, int32_t rotation = 0);

    ~SoftwareRenderer();

@@ -52,6 +53,7 @@ private:
    int32_t mWidth, mHeight;
    int32_t mCropLeft, mCropTop, mCropRight, mCropBottom;
    int32_t mCropWidth, mCropHeight;
    int32_t mRotationDegrees;
    FrameRenderTracker mRenderTracker;

    SoftwareRenderer(const SoftwareRenderer &);