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

Commit 2d8ef499 authored by Alex Sakhartchouk's avatar Alex Sakhartchouk
Browse files

Fixing FBO font rendering bug that resulted from using old surface size.

Change-Id: I31d0967bb36ca6ffb6a4c8194597d3c523cfe954
parent 7b95eba9
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -472,6 +472,30 @@ void Context::setSurface(uint32_t w, uint32_t h, RsNativeWindow sur) {
    }
}

uint32_t Context::getCurrentSurfaceWidth() const {
    for (uint32_t i = 0; i < mFBOCache.mHal.state.colorTargetsCount; i ++) {
        if (mFBOCache.mHal.state.colorTargets[i] != NULL) {
            return mFBOCache.mHal.state.colorTargets[i]->getType()->getDimX();
        }
    }
    if (mFBOCache.mHal.state.depthTarget != NULL) {
        return mFBOCache.mHal.state.depthTarget->getType()->getDimX();
    }
    return mWidth;
}

uint32_t Context::getCurrentSurfaceHeight() const {
    for (uint32_t i = 0; i < mFBOCache.mHal.state.colorTargetsCount; i ++) {
        if (mFBOCache.mHal.state.colorTargets[i] != NULL) {
            return mFBOCache.mHal.state.colorTargets[i]->getType()->getDimY();
        }
    }
    if (mFBOCache.mHal.state.depthTarget != NULL) {
        return mFBOCache.mHal.state.depthTarget->getType()->getDimY();
    }
    return mHeight;
}

void Context::pause() {
    rsAssert(mIsGraphicsContext);
    mPaused = true;
+3 −0
Original line number Diff line number Diff line
@@ -164,6 +164,9 @@ public:
    uint32_t getWidth() const {return mWidth;}
    uint32_t getHeight() const {return mHeight;}

    uint32_t getCurrentSurfaceWidth() const;
    uint32_t getCurrentSurfaceHeight() const;

    mutable ThreadIO mIO;

    // Timers
+5 −5
Original line number Diff line number Diff line
@@ -654,11 +654,7 @@ void FontState::appendMeshQuad(float x1, float y1, float z1,
    const uint32_t floatsPerVert = 5;
    float *currentPos = mTextMeshPtr + mCurrentQuadIndex * vertsPerQuad * floatsPerVert;

    // Cull things that are off the screen
    float width = (float)mRSC->getWidth();
    float height = (float)mRSC->getHeight();

    if (x1 > width || y1 < 0.0f || x2 < 0 || y4 > height) {
    if (x1 > mSurfaceWidth || y1 < 0.0f || x2 < 0 || y4 > mSurfaceHeight) {
        return;
    }

@@ -746,6 +742,10 @@ void FontState::renderText(const char *text, uint32_t len, int32_t x, int32_t y,
        return;
    }

    // Cull things that are off the screen
    mSurfaceWidth = (float)mRSC->getCurrentSurfaceWidth();
    mSurfaceHeight = (float)mRSC->getCurrentSurfaceHeight();

    currentFont->renderUTF(text, len, x, y, startIndex, numGlyphs,
                           mode, bounds, bitmap, bitmapW, bitmapH);

+3 −0
Original line number Diff line number Diff line
@@ -160,6 +160,9 @@ public:

protected:

    float mSurfaceWidth;
    float mSurfaceHeight;

    friend class Font;

    struct CacheTextureLine {
+4 −1
Original line number Diff line number Diff line
@@ -206,8 +206,11 @@ void ProgramVertexState::init(Context *rsc) {
void ProgramVertexState::updateSize(Context *rsc) {
    float *f = static_cast<float *>(mDefaultAlloc->getPtr());

    float surfaceWidth = (float)rsc->getCurrentSurfaceWidth();
    float surfaceHeight = (float)rsc->getCurrentSurfaceHeight();

    Matrix4x4 m;
    m.loadOrtho(0,rsc->getWidth(), rsc->getHeight(),0, -1,1);
    m.loadOrtho(0, surfaceWidth, surfaceHeight, 0, -1, 1);
    memcpy(&f[RS_PROGRAM_VERTEX_PROJECTION_OFFSET], m.m, sizeof(m));
    memcpy(&f[RS_PROGRAM_VERTEX_MVP_OFFSET], m.m, sizeof(m));

Loading