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

Commit 470e41c5 authored by Steve Kondik's avatar Steve Kondik
Browse files

hwui: Add option to enable subpixel font positioning

 * Off by default as there is an issue with metrics calculation.

Change-Id: I39c9d74beeac5f28e4014d54e3c658b0f0fed86e
parent fb9e23c6
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include "DisplayListLogBuffer.h"
#include "DisplayListRenderer.h"
#include "Caches.h"
#include "Properties.h"

namespace android {
namespace uirenderer {
@@ -1295,6 +1296,12 @@ status_t DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, int32_t flag

DisplayListRenderer::DisplayListRenderer() : mWriter(MIN_WRITER_SIZE),
        mTranslateX(0.0f), mTranslateY(0.0f), mHasTranslate(false), mHasDrawOps(false) {

    mSubpixelText = DEFAULT_TEXT_SUBPIXEL_POSITIONING;
    char property[PROPERTY_VALUE_MAX];
    if (property_get(PROPERTY_TEXT_SUBPIXEL_POSITIONING, property, NULL) > 0) {
        mSubpixelText = strcmp(property, "true") == 0;
    }
}

DisplayListRenderer::~DisplayListRenderer() {
@@ -1677,6 +1684,8 @@ status_t DisplayListRenderer::drawText(const char* text, int bytesCount, int cou
    //       its own copy as it does right now.
    // Beware: this needs Glyph encoding (already done on the Paint constructor)
    paint->setAntiAlias(true);
    if (mSubpixelText)
        paint->setSubpixelText(true);
    if (length < 0.0f) length = paint->measureText(text, bytesCount);

    bool reject = false;
@@ -1706,6 +1715,8 @@ status_t DisplayListRenderer::drawTextOnPath(const char* text, int bytesCount, i
    addFloat(hOffset);
    addFloat(vOffset);
    paint->setAntiAlias(true);
    if (mSubpixelText)
        paint->setSubpixelText(true);
    addPaint(paint);
    return DrawGlInfo::kStatusDone;
}
@@ -1718,6 +1729,8 @@ status_t DisplayListRenderer::drawPosText(const char* text, int bytesCount, int
    addInt(count);
    addFloats(positions, count * 2);
    paint->setAntiAlias(true);
    if (mSubpixelText)
        paint->setSubpixelText(true);
    addPaint(paint);
    return DrawGlInfo::kStatusDone;
}
+2 −0
Original line number Diff line number Diff line
@@ -871,6 +871,8 @@ private:

    bool mHasDrawOps;

    bool mSubpixelText;

    friend class DisplayList;

}; // class DisplayListRenderer
+4 −0
Original line number Diff line number Diff line
@@ -78,6 +78,9 @@ enum DebugLevel {
#define PROPERTY_TEXT_BLACK_GAMMA_THRESHOLD "ro.text_gamma.black_threshold"
#define PROPERTY_TEXT_WHITE_GAMMA_THRESHOLD "ro.text_gamma.white_threshold"

// Subpixel positioning
#define PROPERTY_TEXT_SUBPIXEL_POSITIONING "ro.text_subpixel_positioning"

// TODO: This should be set by a system property
#define PANEL_BIT_DEPTH 20

@@ -92,6 +95,7 @@ enum DebugLevel {
#define DEFAULT_GRADIENT_CACHE_SIZE 0.5f
#define DEFAULT_DROP_SHADOW_CACHE_SIZE 2.0f
#define DEFAULT_FBO_CACHE_SIZE 16
#define DEFAULT_TEXT_SUBPIXEL_POSITIONING false

#define DEFAULT_TEXTURE_CACHE_FLUSH_RATE 0.6f