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

Commit 1cb600fb authored by Pranjal Nayak's avatar Pranjal Nayak Committed by Gerrit - the friendly Code Review server
Browse files

Rendering Engine: integrate font rendering engine

Changes in core/jni/android/graphics/ are related to the text
metrics measurements that are used for text layout modules.
The hardware accelerator uses the rendering engine separately.
Modifications in libs/hwui/ enable the hardware accelerator
to use the 3rd party's rendering engine.

(cherry picked from commit 0101fdb858a5c9ac9be49cdb839fb31b2b29e838)

Conflicts:
    data/fonts/fonts.mk

Change-Id: I22e927209c3e27b8c70651c139bc7521cf28cdf5
parent 70302163
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -15,6 +15,10 @@ ifeq ($(USE_OPENGL_RENDERER),true)
	LOCAL_CFLAGS += -DUSE_OPENGL_RENDERER
endif

ifeq ($(MULTI_LANG_ENGINE),REVERIE)
        LOCAL_CFLAGS += -DREVERIE
endif

LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES

LOCAL_SRC_FILES:= \
+39 −0
Original line number Diff line number Diff line
@@ -67,6 +67,45 @@ void TextLayout::handleText(SkPaint *paint, const jchar* text, jsize len,
void TextLayout::getTextRunAdvances(SkPaint* paint, const jchar* chars, jint start,
                                    jint count, jint contextCount, jint dirFlags,
                                    jfloat* resultAdvances, jfloat* resultTotalAdvance) {

#ifdef REVERIE
    int ii = 0;
    for(int i = 0; i < count; i++){
        if((chars[i + start] > 0x900 && chars[i + start] < 0xaff) || (chars[i + start] >0xb80 &&
            chars[i + start] < 0xd7f) || (chars[i + start] >= 0xe00 && chars[i + start] <0xe7f))
            ii = 1;
    }
    if(ii == 1 ){
        jfloat totalAdvance = 0;
        SkScalar* scalarArray = new SkScalar[(count + 2)];
        size_t widths;
        char* text = new char[(count * 2) + 2];
        for(int i = 0; i < count * 2; i += 2){
            int unichar = paint->unicharToGlyph(chars[(i / 2) + start]);
            text[i] = (char)(unichar & 0xff);
            text[i+1] = (char)((unichar & 0xff00) >> 8);
        }
        const char *text2 = text;
        widths = paint->getTextWidths(text2, count << 1, scalarArray);
        for (size_t i = 0; i < widths; i++) {
            totalAdvance += SkScalarToFloat(scalarArray[i]);
            if (resultAdvances)
                resultAdvances[i] = SkScalarToFloat(scalarArray[i]);
        }
        if (resultTotalAdvance)
            *resultTotalAdvance = totalAdvance;
        if(text){
            delete(text);
            text = NULL;
        }
        if(scalarArray){
            delete(scalarArray);
            scalarArray = NULL;
        }
        return;
    }
#endif

    sp<TextLayoutValue> value = TextLayoutEngine::getInstance().getValue(paint,
            chars, start, count, contextCount, dirFlags);
    if (value == NULL) {
+53 −0
Original line number Diff line number Diff line
@@ -700,6 +700,11 @@ void TextLayoutShaper::computeRunValues(const SkPaint* paint, const UChar* conte
    // into the shaperItem
    ssize_t indexFontRun = isRTL ? count - 1 : 0;
    jfloat totalAdvance = *outTotalAdvance;

#ifdef REVERIE
    jfloat totalAdvance1 =totalAdvance;
#endif

    ScriptRun run;  // relative to chars
    while ((isRTL) ?
            hb_utf16_script_run_prev(&run, chars, count, &indexFontRun):
@@ -767,6 +772,42 @@ void TextLayoutShaper::computeRunValues(const SkPaint* paint, const UChar* conte

    *outTotalAdvance = totalAdvance;

#ifdef REVERIE
    int ii = 0;
    for(int i = 0; i < count; i++){
        if((chars[i] > 0x900 && chars[i] < 0xaff) || (chars[i] > 0xb80 &&
            chars[i] < 0xd7f) || (chars[i] >= 0xe00 && chars[i] < 0xe7f) ){
            ii = 1;
            break;
        }
     }
    if(ii == 1){
        SkScalar * scalarArray = new SkScalar[count + 2];//(SkScalar*)resultAdvances;
        size_t widths;
        char* text = new char[ (count * 2) + 2];
        for(int i = 0; i < count * 2; i+=2){
            int unichar = paint->unicharToGlyph(chars[(i / 2)]);
            text[i] = (char)(unichar & 0xff);
            text[i+1] = (char)((unichar & 0xff00) >> 8);
        }
        const char * text2 = text;
        widths = paint->getTextWidths(text2, count << 1, scalarArray);
        for (size_t i = 0; i < widths; i++) {
            if(scalarArray[i]!=0)
                totalAdvance1 += SkScalarToFloat(scalarArray[i]);
        }
        *outTotalAdvance = totalAdvance1;
        if(text){
            delete(text);
            text = NULL;
        }
        if(scalarArray){
            delete(scalarArray);
            scalarArray = NULL;
        }
    }
#endif

#if DEBUG_GLYPHS
    ALOGD("         -- final totalAdvance = %f", totalAdvance);
    ALOGD("-------- End of Script Run --------");
@@ -800,6 +841,18 @@ bool TextLayoutShaper::isComplexScript(hb_script_t script) {
    case HB_SCRIPT_HAN:
    case HB_SCRIPT_KATAKANA:
    case HB_SCRIPT_HIRAGANA:
#ifdef REVERIE
    case HB_SCRIPT_DEVANAGARI:
    case HB_SCRIPT_BENGALI:
    case HB_SCRIPT_GURMUKHI:
    case HB_SCRIPT_GUJARATI:
    case HB_SCRIPT_TAMIL:
    case HB_SCRIPT_TELUGU:
    case HB_SCRIPT_KANNADA:
    case HB_SCRIPT_MALAYALAM:
    case HB_SCRIPT_ORIYA:
    case HB_SCRIPT_THAI:
#endif
        return false;
    default:
        return true;
+13 −2
Original line number Diff line number Diff line
@@ -15,8 +15,14 @@
# Warning: this is actually a product definition, to be inherited from

PRODUCT_COPY_FILES := \
    frameworks/base/data/fonts/system_fonts.xml:$(TARGET_COPY_OUT_SYSTEM)/etc/system_fonts.xml \
    frameworks/base/data/fonts/system_fonts.xml:$(TARGET_COPY_OUT_SYSTEM)/etc/system_fonts.xml
ifeq ($(MULTI_LANG_ENGINE),REVERIE)
PRODUCT_COPY_FILES += \
    $(PRODUCT_RENDERING_ENGINE_PATH)/$(PRODUCT_RENDERING_ENGINE_FONTS_XML):$(TARGET_COPY_OUT_SYSTEM)/etc/fallback_fonts.xml
else
PRODUCT_COPY_FILES += \
    frameworks/base/data/fonts/fallback_fonts.xml:$(TARGET_COPY_OUT_SYSTEM)/etc/fallback_fonts.xml
endif

PRODUCT_PACKAGES := \
    DroidSansFallback.ttf \
@@ -47,4 +53,9 @@ PRODUCT_PACKAGES := \
    Clockopia.ttf \
    AndroidClock.ttf \
    AndroidClock_Highlight.ttf \
    AndroidClock_Solid.ttf \
    AndroidClock_Solid.ttf

ifeq ($(MULTI_LANG_ENGINE),REVERIE)
PRODUCT_PACKAGES += \
     $(PRODUCT_RENDERING_ENGINE_TTF_FILES)
endif
+5 −0
Original line number Diff line number Diff line
@@ -4,6 +4,11 @@ include $(CLEAR_VARS)
# Only build libhwui when USE_OPENGL_RENDERER is
# defined in the current device/board configuration
ifeq ($(USE_OPENGL_RENDERER),true)

ifeq ($(MULTI_LANG_ENGINE),REVERIE)
        LOCAL_CFLAGS += -DREVERIE
endif

	LOCAL_SRC_FILES:= \
		utils/Blur.cpp \
		utils/SortedListImpl.cpp \
Loading