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

Commit 37d15dff authored by Romain Guy's avatar Romain Guy Committed by Android Git Automerger
Browse files

am 1ab46154: am 0a332e39: Merge "Draw an empty border around glyphs to avoid...

am 1ab46154: am 0a332e39: Merge "Draw an empty border around glyphs to avoid sampling issues Bug #6942209" into jb-mr1-dev

* commit '1ab46154':
  Draw an empty border around glyphs to avoid sampling issues Bug #6942209
parents e8af49bc 1ab46154
Loading
Loading
Loading
Loading
+22 −13
Original line number Original line Diff line number Diff line
@@ -37,7 +37,7 @@ namespace uirenderer {
#define DEFAULT_TEXT_CACHE_WIDTH 1024
#define DEFAULT_TEXT_CACHE_WIDTH 1024
#define DEFAULT_TEXT_CACHE_HEIGHT 256
#define DEFAULT_TEXT_CACHE_HEIGHT 256
#define MAX_TEXT_CACHE_WIDTH 2048
#define MAX_TEXT_CACHE_WIDTH 2048
#define TEXTURE_BORDER_SIZE 2
#define TEXTURE_BORDER_SIZE 1


#define AUTO_KERN(prev, next) (((next) - (prev) + 32) >> 6 << 16)
#define AUTO_KERN(prev, next) (((next) - (prev) + 32) >> 6 << 16)


@@ -50,10 +50,10 @@ bool CacheTextureLine::fitBitmap(const SkGlyph& glyph, uint32_t *retOriginX, uin
        return false;
        return false;
    }
    }


    if (mCurrentCol + glyph.fWidth + TEXTURE_BORDER_SIZE < mMaxWidth) {
    if (mCurrentCol + glyph.fWidth + TEXTURE_BORDER_SIZE * 2 < mMaxWidth) {
        *retOriginX = mCurrentCol + 1;
        *retOriginX = mCurrentCol + TEXTURE_BORDER_SIZE;
        *retOriginY = mCurrentRow + 1;
        *retOriginY = mCurrentRow + TEXTURE_BORDER_SIZE;
        mCurrentCol += glyph.fWidth + TEXTURE_BORDER_SIZE;
        mCurrentCol += glyph.fWidth + TEXTURE_BORDER_SIZE * 2;
        mDirty = true;
        mDirty = true;
        return true;
        return true;
    }
    }
@@ -412,10 +412,10 @@ void Font::updateGlyphCache(SkPaint* paint, const SkGlyph& skiaGlyph, CachedGlyp
    uint32_t cacheWidth = glyph->mCachedTextureLine->mCacheTexture->mWidth;
    uint32_t cacheWidth = glyph->mCachedTextureLine->mCacheTexture->mWidth;
    uint32_t cacheHeight = glyph->mCachedTextureLine->mCacheTexture->mHeight;
    uint32_t cacheHeight = glyph->mCachedTextureLine->mCacheTexture->mHeight;


    glyph->mBitmapMinU = (float) startX / (float) cacheWidth;
    glyph->mBitmapMinU = startX / (float) cacheWidth;
    glyph->mBitmapMinV = (float) startY / (float) cacheHeight;
    glyph->mBitmapMinV = startY / (float) cacheHeight;
    glyph->mBitmapMaxU = (float) endX / (float) cacheWidth;
    glyph->mBitmapMaxU = endX / (float) cacheWidth;
    glyph->mBitmapMaxV = (float) endY / (float) cacheHeight;
    glyph->mBitmapMaxV = endY / (float) cacheHeight;


    mState->mUploadTexture = true;
    mState->mUploadTexture = true;
}
}
@@ -590,9 +590,6 @@ void FontRenderer::allocateTextureMemory(CacheTexture* cacheTexture) {
    int height = cacheTexture->mHeight;
    int height = cacheTexture->mHeight;


    cacheTexture->mTexture = new uint8_t[width * height];
    cacheTexture->mTexture = new uint8_t[width * height];
#if DEBUG_FONT_RENDERER
    memset(cacheTexture->mTexture, 0, width * height * sizeof(uint8_t));
#endif


    if (!cacheTexture->mTextureId) {
    if (!cacheTexture->mTextureId) {
        glGenTextures(1, &cacheTexture->mTextureId);
        glGenTextures(1, &cacheTexture->mTextureId);
@@ -617,7 +614,7 @@ void FontRenderer::cacheBitmap(const SkGlyph& glyph, CachedGlyphInfo* cachedGlyp
        uint32_t* retOriginX, uint32_t* retOriginY) {
        uint32_t* retOriginX, uint32_t* retOriginY) {
    cachedGlyph->mIsValid = false;
    cachedGlyph->mIsValid = false;
    // If the glyph is too tall, don't cache it
    // If the glyph is too tall, don't cache it
    if (glyph.fHeight + TEXTURE_BORDER_SIZE > mCacheLines[mCacheLines.size() - 1]->mMaxHeight) {
    if (glyph.fHeight + TEXTURE_BORDER_SIZE * 2 > mCacheLines[mCacheLines.size() - 1]->mMaxHeight) {
        ALOGE("Font size to large to fit in cache. width, height = %i, %i",
        ALOGE("Font size to large to fit in cache. width, height = %i, %i",
                (int) glyph.fWidth, (int) glyph.fHeight);
                (int) glyph.fWidth, (int) glyph.fHeight);
        return;
        return;
@@ -677,6 +674,18 @@ void FontRenderer::cacheBitmap(const SkGlyph& glyph, CachedGlyphInfo* cachedGlyp
    unsigned int stride = glyph.rowBytes();
    unsigned int stride = glyph.rowBytes();


    uint32_t cacheX = 0, bX = 0, cacheY = 0, bY = 0;
    uint32_t cacheX = 0, bX = 0, cacheY = 0, bY = 0;

    for (cacheX = startX - TEXTURE_BORDER_SIZE; cacheX < endX + TEXTURE_BORDER_SIZE; cacheX++) {
        cacheBuffer[(startY - TEXTURE_BORDER_SIZE) * cacheWidth + cacheX] = 0;
        cacheBuffer[(endY + TEXTURE_BORDER_SIZE - 1) * cacheWidth + cacheX] = 0;
    }

    for (cacheY = startY - TEXTURE_BORDER_SIZE + 1;
            cacheY < endY + TEXTURE_BORDER_SIZE - 1; cacheY++) {
        cacheBuffer[cacheY * cacheWidth + startX - TEXTURE_BORDER_SIZE] = 0;
        cacheBuffer[cacheY * cacheWidth + endX + TEXTURE_BORDER_SIZE - 1] = 0;
    }

    if (mGammaTable) {
    if (mGammaTable) {
        for (cacheX = startX, bX = 0; cacheX < endX; cacheX++, bX++) {
        for (cacheX = startX, bX = 0; cacheX < endX; cacheX++, bX++) {
            for (cacheY = startY, bY = 0; cacheY < endY; cacheY++, bY++) {
            for (cacheY = startY, bY = 0; cacheY < endY; cacheY++, bY++) {
+1 −1
Original line number Original line Diff line number Diff line
@@ -2892,7 +2892,7 @@ void OpenGLRenderer::chooseBlending(bool blend, SkXfermode::Mode mode,
        // the blending, turn blending off here
        // the blending, turn blending off here
        // If the blend mode cannot be implemented using shaders, fall
        // If the blend mode cannot be implemented using shaders, fall
        // back to the default SrcOver blend mode instead
        // back to the default SrcOver blend mode instead
        if CC_UNLIKELY((mode > SkXfermode::kScreen_Mode)) {
        if (CC_UNLIKELY(mode > SkXfermode::kScreen_Mode)) {
            if (CC_UNLIKELY(mCaches.extensions.hasFramebufferFetch())) {
            if (CC_UNLIKELY(mCaches.extensions.hasFramebufferFetch())) {
                description.framebufferMode = mode;
                description.framebufferMode = mode;
                description.swapSrcDst = swapSrcDst;
                description.swapSrcDst = swapSrcDst;
+6 −0
Original line number Original line Diff line number Diff line
@@ -153,6 +153,12 @@ public class TextActivity extends Activity {
            canvas.drawText("Hello OpenGL renderer!", 100, 300, mLargePaint);
            canvas.drawText("Hello OpenGL renderer!", 100, 300, mLargePaint);
            canvas.restore();
            canvas.restore();


//            mStrikePaint.setUnderlineText(false);
//            canvas.save();
//            canvas.scale(20.0f, 20.0f);
//            canvas.drawText("aeiouyw", 5.0f, 750 / 20.0f, mStrikePaint);
//            canvas.restore();
//            mStrikePaint.setUnderlineText(true);
        }
        }
    }
    }
}
}