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

Commit b7e33a09 authored by Seigo Nonaka's avatar Seigo Nonaka
Browse files

Remove obsolete interface GetTable.

GetTable is only used in test.
To use production interface, need to pass the raw buffer and size to the
MinikinSkia.  This CL does not change any production behaviors.

Test: ran hwui microbench, macrobench, hwui_unit_tests
Change-Id: Ia657a0d061984d705f333ed3944effb1eba8ca4d
parent 1a625911
Loading
Loading
Loading
Loading
+0 −17
Original line number Diff line number Diff line
@@ -65,23 +65,6 @@ void MinikinFontSkia::GetBounds(minikin::MinikinRect* bounds, uint32_t glyph_id,
    bounds->mBottom = skBounds.fBottom;
}

const void* MinikinFontSkia::GetTable(uint32_t tag, size_t* size,
        minikin::MinikinDestroyFunc* destroy) {
    // we don't have a buffer to the font data, copy to own buffer
    const size_t tableSize = mTypeface->getTableSize(tag);
    *size = tableSize;
    if (tableSize == 0) {
        return nullptr;
    }
    void* buf = malloc(tableSize);
    if (buf == nullptr) {
        return nullptr;
    }
    mTypeface->getTableData(tag, 0, tableSize, buf);
    *destroy = free;
    return buf;
}

SkTypeface *MinikinFontSkia::GetSkTypeface() const {
    return mTypeface.get();
}
+0 −2
Original line number Diff line number Diff line
@@ -37,8 +37,6 @@ public:
    void GetBounds(minikin::MinikinRect* bounds, uint32_t glyph_id,
        const minikin::MinikinPaint &paint) const;

    const void* GetTable(uint32_t tag, size_t* size, minikin::MinikinDestroyFunc* destroy);

    SkTypeface* GetSkTypeface() const;
    sk_sp<SkTypeface> RefSkTypeface() const;

+13 −2
Original line number Diff line number Diff line
@@ -23,10 +23,14 @@
#include "Typeface.h"

#include <pthread.h>
#include <fcntl.h>  // For tests.
#include <sys/stat.h>  // For tests.
#include <sys/mman.h>  // For tests.

#include "MinikinSkia.h"
#include "SkTypeface.h"
#include "SkPaint.h"
#include "SkStream.h"  // Fot tests.

#include <minikin/FontCollection.h>
#include <minikin/FontFamily.h>
@@ -116,11 +120,18 @@ void Typeface::setDefault(Typeface* face) {

void Typeface::setRobotoTypefaceForTest() {
    const char* kRobotoFont = "/system/fonts/Roboto-Regular.ttf";
    sk_sp<SkTypeface> typeface = SkTypeface::MakeFromFile(kRobotoFont);

    int fd = open(kRobotoFont, O_RDONLY);
    LOG_ALWAYS_FATAL_IF(fd == -1, "Failed to open file %s", kRobotoFont);
    struct stat st = {};
    LOG_ALWAYS_FATAL_IF(fstat(fd, &st) == -1, "Failed to stat file %s", kRobotoFont);
    void* data = mmap(nullptr, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
    std::unique_ptr<SkMemoryStream> fontData(new SkMemoryStream(data, st.st_size));
    sk_sp<SkTypeface> typeface = SkTypeface::MakeFromStream(fontData.release());
    LOG_ALWAYS_FATAL_IF(typeface == nullptr, "Failed to make typeface from %s", kRobotoFont);

    minikin::FontFamily* family = new minikin::FontFamily();
    minikin::MinikinFont* font = new MinikinFontSkia(std::move(typeface), nullptr, 0, 0);
    minikin::MinikinFont* font = new MinikinFontSkia(std::move(typeface), data, st.st_size, 0);
    family->addFont(font);
    font->Unref();