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

Commit 7975fb6d authored by Romain Guy's avatar Romain Guy
Browse files

Apply bilinear filtering to text.

Change-Id: I2c81ad657ee2a11a2139e0b11ae3749db54c0749
parent d1034c19
Loading
Loading
Loading
Loading
+56 −0
Original line number Diff line number Diff line
@@ -21,6 +21,62 @@
namespace android {
namespace uirenderer {

///////////////////////////////////////////////////////////////////////////////
// Defines
///////////////////////////////////////////////////////////////////////////////

#define PATH_HEAP_SIZE 64

///////////////////////////////////////////////////////////////////////////////
// Helpers
///////////////////////////////////////////////////////////////////////////////

PathHeap::PathHeap(): mHeap(PATH_HEAP_SIZE * sizeof(SkPath)) {
}

PathHeap::PathHeap(SkFlattenableReadBuffer& buffer): mHeap(PATH_HEAP_SIZE * sizeof(SkPath)) {
    int count = buffer.readS32();

    mPaths.setCount(count);
    SkPath** ptr = mPaths.begin();
    SkPath* p = (SkPath*) mHeap.allocThrow(count * sizeof(SkPath));

    for (int i = 0; i < count; i++) {
        new (p) SkPath;
        p->unflatten(buffer);
        *ptr++ = p;
        p++;
    }
}

PathHeap::~PathHeap() {
    SkPath** iter = mPaths.begin();
    SkPath** stop = mPaths.end();
    while (iter < stop) {
        (*iter)->~SkPath();
        iter++;
    }
}

int PathHeap::append(const SkPath& path) {
    SkPath* p = (SkPath*) mHeap.allocThrow(sizeof(SkPath));
    new (p) SkPath(path);
    *mPaths.append() = p;
    return mPaths.count();
}

void PathHeap::flatten(SkFlattenableWriteBuffer& buffer) const {
    int count = mPaths.count();

    buffer.write32(count);
    SkPath** iter = mPaths.begin();
    SkPath** stop = mPaths.end();
    while (iter < stop) {
        (*iter)->flatten(buffer);
        iter++;
    }
}

///////////////////////////////////////////////////////////////////////////////
// Display list
///////////////////////////////////////////////////////////////////////////////
+5 −43
Original line number Diff line number Diff line
@@ -45,39 +45,11 @@ namespace uirenderer {

class PathHeap: public SkRefCnt {
public:
    PathHeap(): mHeap(64 * sizeof(SkPath)) {
    };

    PathHeap(SkFlattenableReadBuffer& buffer): mHeap(64 * sizeof(SkPath)) {
        int count = buffer.readS32();

        mPaths.setCount(count);
        SkPath** ptr = mPaths.begin();
        SkPath* p = (SkPath*) mHeap.allocThrow(count * sizeof(SkPath));

        for (int i = 0; i < count; i++) {
            new (p) SkPath;
            p->unflatten(buffer);
            *ptr++ = p;
            p++;
        }
    }
    PathHeap();
    PathHeap(SkFlattenableReadBuffer& buffer);
    ~PathHeap();

    ~PathHeap() {
        SkPath** iter = mPaths.begin();
        SkPath** stop = mPaths.end();
        while (iter < stop) {
            (*iter)->~SkPath();
            iter++;
        }
    }

    int append(const SkPath& path) {
        SkPath* p = (SkPath*) mHeap.allocThrow(sizeof(SkPath));
        new (p) SkPath(path);
        *mPaths.append() = p;
        return mPaths.count();
    }
    int append(const SkPath& path);

    int count() const { return mPaths.count(); }

@@ -85,17 +57,7 @@ public:
        return *mPaths[index];
    }

    void flatten(SkFlattenableWriteBuffer& buffer) const {
        int count = mPaths.count();

        buffer.write32(count);
        SkPath** iter = mPaths.begin();
        SkPath** stop = mPaths.end();
        while (iter < stop) {
            (*iter)->flatten(buffer);
            iter++;
        }
    }
    void flatten(SkFlattenableWriteBuffer& buffer) const;

private:
    SkChunkAlloc mHeap;
+11 −10
Original line number Diff line number Diff line
@@ -435,25 +435,25 @@ void FontRenderer::initTextTexture() {
    glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, mCacheWidth, mCacheHeight, 0,
            GL_ALPHA, GL_UNSIGNED_BYTE, 0);

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

    // Split up our cache texture into lines of certain widths
    int nextLine = 0;
    mCacheLines.push(new CacheTextureLine(mCacheWidth, 16, nextLine, 0));
    mCacheLines.push(new CacheTextureLine(mCacheWidth, 18, nextLine, 0));
    nextLine += mCacheLines.top()->mMaxHeight;
    mCacheLines.push(new CacheTextureLine(mCacheWidth, 24, nextLine, 0));
    mCacheLines.push(new CacheTextureLine(mCacheWidth, 26, nextLine, 0));
    nextLine += mCacheLines.top()->mMaxHeight;
    mCacheLines.push(new CacheTextureLine(mCacheWidth, 24, nextLine, 0));
    mCacheLines.push(new CacheTextureLine(mCacheWidth, 26, nextLine, 0));
    nextLine += mCacheLines.top()->mMaxHeight;
    mCacheLines.push(new CacheTextureLine(mCacheWidth, 32, nextLine, 0));
    mCacheLines.push(new CacheTextureLine(mCacheWidth, 34, nextLine, 0));
    nextLine += mCacheLines.top()->mMaxHeight;
    mCacheLines.push(new CacheTextureLine(mCacheWidth, 32, nextLine, 0));
    mCacheLines.push(new CacheTextureLine(mCacheWidth, 34, nextLine, 0));
    nextLine += mCacheLines.top()->mMaxHeight;
    mCacheLines.push(new CacheTextureLine(mCacheWidth, 40, nextLine, 0));
    mCacheLines.push(new CacheTextureLine(mCacheWidth, 42, nextLine, 0));
    nextLine += mCacheLines.top()->mMaxHeight;
    mCacheLines.push(new CacheTextureLine(mCacheWidth, mCacheHeight - nextLine, nextLine, 0));
}
@@ -631,6 +631,7 @@ void FontRenderer::setFont(SkPaint* paint, uint32_t fontId, float fontSize) {
        precacheLatin(paint);
    }
}

FontRenderer::DropShadow FontRenderer::renderDropShadow(SkPaint* paint, const char *text,
        uint32_t startIndex, uint32_t len, int numGlyphs, uint32_t radius) {
    checkInit();
+5 −5
Original line number Diff line number Diff line
@@ -183,14 +183,14 @@ protected:
        }

        bool fitBitmap(const SkGlyph& glyph, uint32_t *retOriginX, uint32_t *retOriginY) {
            if (glyph.fHeight > mMaxHeight) {
            if (glyph.fHeight + 2 > mMaxHeight) {
                return false;
            }

            if (mCurrentCol + glyph.fWidth < mMaxWidth) {
                *retOriginX = mCurrentCol;
                *retOriginY = mCurrentRow;
                mCurrentCol += glyph.fWidth;
            if (mCurrentCol + glyph.fWidth + 2 < mMaxWidth) {
                *retOriginX = mCurrentCol + 1;
                *retOriginY = mCurrentRow + 1;
                mCurrentCol += glyph.fWidth + 2;
                mDirty = true;
                return true;
            }
+9 −0
Original line number Diff line number Diff line
@@ -39,6 +39,15 @@
            </intent-filter>
        </activity>
        
        <activity
                android:name="LabelsActivity"
                android:label="_Labels">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
                android:name="ResizeActivity"
                android:label="_Resize"
Loading