Remove unused classes and methods
am: 7708c89648
Change-Id: I9d0e82f8f6cf4889c9e4bd0c229c77e66089a8b9
This commit is contained in:
@@ -23,25 +23,9 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <minikin/FontCollection.h>
|
#include <minikin/FontCollection.h>
|
||||||
#include <minikin/MinikinFontFreeType.h>
|
|
||||||
|
|
||||||
namespace minikin {
|
namespace minikin {
|
||||||
|
|
||||||
// The Bitmap class is for debugging. We'll probably move it out
|
|
||||||
// of here into a separate lightweight software rendering module
|
|
||||||
// (optional, as we'd hope most clients would do their own)
|
|
||||||
class Bitmap {
|
|
||||||
public:
|
|
||||||
Bitmap(int width, int height);
|
|
||||||
~Bitmap();
|
|
||||||
void writePnm(std::ofstream& o) const;
|
|
||||||
void drawGlyph(const GlyphBitmap& bitmap, int x, int y);
|
|
||||||
private:
|
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
uint8_t* buf;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct LayoutGlyph {
|
struct LayoutGlyph {
|
||||||
// index into mFaces and mHbFonts vectors. We could imagine
|
// index into mFaces and mHbFonts vectors. We could imagine
|
||||||
// moving this into a run length representation, because it's
|
// moving this into a run length representation, because it's
|
||||||
@@ -95,8 +79,6 @@ public:
|
|||||||
int bidiFlags, const FontStyle &style, const MinikinPaint &paint,
|
int bidiFlags, const FontStyle &style, const MinikinPaint &paint,
|
||||||
const std::shared_ptr<FontCollection>& collection, float* advances);
|
const std::shared_ptr<FontCollection>& collection, float* advances);
|
||||||
|
|
||||||
void draw(minikin::Bitmap*, int x0, int y0, float size) const;
|
|
||||||
|
|
||||||
// public accessors
|
// public accessors
|
||||||
size_t nGlyphs() const;
|
size_t nGlyphs() const;
|
||||||
const MinikinFont* getFont(int i) const;
|
const MinikinFont* getFont(int i) const;
|
||||||
|
|||||||
@@ -81,8 +81,6 @@ struct MinikinRect {
|
|||||||
void join(const MinikinRect& r);
|
void join(const MinikinRect& r);
|
||||||
};
|
};
|
||||||
|
|
||||||
class MinikinFontFreeType;
|
|
||||||
|
|
||||||
// Callback for freeing data
|
// Callback for freeing data
|
||||||
typedef void (*MinikinDestroyFunc) (void* data);
|
typedef void (*MinikinDestroyFunc) (void* data);
|
||||||
|
|
||||||
|
|||||||
@@ -1,75 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2013 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef MINIKIN_FONT_FREETYPE_H
|
|
||||||
#define MINIKIN_FONT_FREETYPE_H
|
|
||||||
|
|
||||||
#include <ft2build.h>
|
|
||||||
#include FT_FREETYPE_H
|
|
||||||
#include FT_TRUETYPE_TABLES_H
|
|
||||||
|
|
||||||
#include <minikin/MinikinFont.h>
|
|
||||||
|
|
||||||
// An abstraction for platform fonts, allowing Minikin to be used with
|
|
||||||
// multiple actual implementations of fonts.
|
|
||||||
|
|
||||||
namespace minikin {
|
|
||||||
|
|
||||||
struct GlyphBitmap {
|
|
||||||
uint8_t *buffer;
|
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
int left;
|
|
||||||
int top;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MinikinFontFreeType : public MinikinFont {
|
|
||||||
public:
|
|
||||||
explicit MinikinFontFreeType(FT_Face typeface);
|
|
||||||
|
|
||||||
~MinikinFontFreeType();
|
|
||||||
|
|
||||||
float GetHorizontalAdvance(uint32_t glyph_id,
|
|
||||||
const MinikinPaint &paint) const;
|
|
||||||
|
|
||||||
void GetBounds(MinikinRect* bounds, uint32_t glyph_id,
|
|
||||||
const MinikinPaint& paint) const;
|
|
||||||
|
|
||||||
const void* GetTable(uint32_t tag, size_t* size, MinikinDestroyFunc* destroy);
|
|
||||||
|
|
||||||
const std::vector<minikin::FontVariation>& GetAxes() const {
|
|
||||||
return mAxes;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: provide access to raw data, as an optimization.
|
|
||||||
|
|
||||||
// Not a virtual method, as the protocol to access rendered
|
|
||||||
// glyph bitmaps is probably different depending on the
|
|
||||||
// backend.
|
|
||||||
bool Render(uint32_t glyph_id,
|
|
||||||
const MinikinPaint &paint, GlyphBitmap *result);
|
|
||||||
|
|
||||||
MinikinFontFreeType* GetFreeType();
|
|
||||||
|
|
||||||
private:
|
|
||||||
FT_Face mTypeface;
|
|
||||||
static int32_t sIdCounter;
|
|
||||||
std::vector<minikin::FontVariation> mAxes;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace minikin
|
|
||||||
|
|
||||||
#endif // MINIKIN_FONT_FREETYPE_H
|
|
||||||
@@ -33,13 +33,11 @@ minikin_src_files := \
|
|||||||
Measurement.cpp \
|
Measurement.cpp \
|
||||||
MinikinInternal.cpp \
|
MinikinInternal.cpp \
|
||||||
MinikinFont.cpp \
|
MinikinFont.cpp \
|
||||||
MinikinFontFreeType.cpp \
|
|
||||||
SparseBitSet.cpp \
|
SparseBitSet.cpp \
|
||||||
WordBreaker.cpp
|
WordBreaker.cpp
|
||||||
|
|
||||||
minikin_c_includes := \
|
minikin_c_includes := \
|
||||||
external/harfbuzz_ng/src \
|
external/harfbuzz_ng/src \
|
||||||
external/freetype/include \
|
|
||||||
frameworks/minikin/include \
|
frameworks/minikin/include \
|
||||||
$(intermediates)
|
$(intermediates)
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,6 @@
|
|||||||
#include "HbFontCache.h"
|
#include "HbFontCache.h"
|
||||||
#include "LayoutUtils.h"
|
#include "LayoutUtils.h"
|
||||||
#include "MinikinInternal.h"
|
#include "MinikinInternal.h"
|
||||||
#include <minikin/MinikinFontFreeType.h>
|
|
||||||
#include <minikin/Layout.h>
|
#include <minikin/Layout.h>
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
@@ -47,44 +46,6 @@ using std::vector;
|
|||||||
|
|
||||||
namespace minikin {
|
namespace minikin {
|
||||||
|
|
||||||
Bitmap::Bitmap(int width, int height) : width(width), height(height) {
|
|
||||||
buf = new uint8_t[width * height]();
|
|
||||||
}
|
|
||||||
|
|
||||||
Bitmap::~Bitmap() {
|
|
||||||
delete[] buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Bitmap::writePnm(std::ofstream &o) const {
|
|
||||||
o << "P5" << std::endl;
|
|
||||||
o << width << " " << height << std::endl;
|
|
||||||
o << "255" << std::endl;
|
|
||||||
o.write((const char *)buf, width * height);
|
|
||||||
o.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Bitmap::drawGlyph(const GlyphBitmap& bitmap, int x, int y) {
|
|
||||||
int bmw = bitmap.width;
|
|
||||||
int bmh = bitmap.height;
|
|
||||||
x += bitmap.left;
|
|
||||||
y -= bitmap.top;
|
|
||||||
int x0 = std::max(0, x);
|
|
||||||
int x1 = std::min(width, x + bmw);
|
|
||||||
int y0 = std::max(0, y);
|
|
||||||
int y1 = std::min(height, y + bmh);
|
|
||||||
const unsigned char* src = bitmap.buffer + (y0 - y) * bmw + (x0 - x);
|
|
||||||
uint8_t* dst = buf + y0 * width;
|
|
||||||
for (int yy = y0; yy < y1; yy++) {
|
|
||||||
for (int xx = x0; xx < x1; xx++) {
|
|
||||||
int pixel = (int)dst[xx] + (int)src[xx - x];
|
|
||||||
pixel = pixel > 0xff ? 0xff : pixel;
|
|
||||||
dst[xx] = pixel;
|
|
||||||
}
|
|
||||||
src += bmw;
|
|
||||||
dst += width;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const int kDirection_Mask = 0x1;
|
const int kDirection_Mask = 0x1;
|
||||||
|
|
||||||
struct LayoutContext {
|
struct LayoutContext {
|
||||||
@@ -1091,34 +1052,6 @@ void Layout::appendLayout(Layout* src, size_t start, float extraAdvance) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layout::draw(minikin::Bitmap* surface, int x0, int y0, float size) const {
|
|
||||||
/*
|
|
||||||
TODO: redo as MinikinPaint settings
|
|
||||||
if (mProps.hasTag(minikinHinting)) {
|
|
||||||
int hintflags = mProps.value(minikinHinting).getIntValue();
|
|
||||||
if (hintflags & 1) load_flags |= FT_LOAD_NO_HINTING;
|
|
||||||
if (hintflags & 2) load_flags |= FT_LOAD_NO_AUTOHINT;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
for (size_t i = 0; i < mGlyphs.size(); i++) {
|
|
||||||
const LayoutGlyph& glyph = mGlyphs[i];
|
|
||||||
MinikinFont* mf = mFaces[glyph.font_ix].font;
|
|
||||||
MinikinFontFreeType* face = static_cast<MinikinFontFreeType*>(mf);
|
|
||||||
GlyphBitmap glyphBitmap;
|
|
||||||
MinikinPaint paint;
|
|
||||||
paint.size = size;
|
|
||||||
bool ok = face->Render(glyph.glyph_id, paint, &glyphBitmap);
|
|
||||||
#ifdef VERBOSE_DEBUG
|
|
||||||
ALOGD("glyphBitmap.width=%d, glyphBitmap.height=%d (%d, %d) x=%f, y=%f, ok=%d",
|
|
||||||
glyphBitmap.width, glyphBitmap.height, glyphBitmap.left, glyphBitmap.top, glyph.x, glyph.y, ok);
|
|
||||||
#endif
|
|
||||||
if (ok) {
|
|
||||||
surface->drawGlyph(glyphBitmap,
|
|
||||||
x0 + int(floor(glyph.x + 0.5)), y0 + int(floor(glyph.y + 0.5)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t Layout::nGlyphs() const {
|
size_t Layout::nGlyphs() const {
|
||||||
return mGlyphs.size();
|
return mGlyphs.size();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,100 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2013 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Implementation of MinikinFont abstraction specialized for FreeType
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <ft2build.h>
|
|
||||||
#include FT_FREETYPE_H
|
|
||||||
#include FT_TRUETYPE_TABLES_H
|
|
||||||
#include FT_ADVANCES_H
|
|
||||||
|
|
||||||
#include <minikin/MinikinFontFreeType.h>
|
|
||||||
|
|
||||||
namespace minikin {
|
|
||||||
|
|
||||||
int32_t MinikinFontFreeType::sIdCounter = 0;
|
|
||||||
|
|
||||||
MinikinFontFreeType::MinikinFontFreeType(FT_Face typeface) :
|
|
||||||
MinikinFont(sIdCounter++),
|
|
||||||
mTypeface(typeface) {
|
|
||||||
}
|
|
||||||
|
|
||||||
MinikinFontFreeType::~MinikinFontFreeType() {
|
|
||||||
FT_Done_Face(mTypeface);
|
|
||||||
}
|
|
||||||
|
|
||||||
float MinikinFontFreeType::GetHorizontalAdvance(uint32_t glyph_id,
|
|
||||||
const MinikinPaint &paint) const {
|
|
||||||
FT_Set_Pixel_Sizes(mTypeface, 0, paint.size);
|
|
||||||
FT_UInt32 flags = FT_LOAD_DEFAULT; // TODO: respect hinting settings
|
|
||||||
FT_Fixed advance;
|
|
||||||
FT_Get_Advance(mTypeface, glyph_id, flags, &advance);
|
|
||||||
return advance * (1.0 / 65536);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MinikinFontFreeType::GetBounds(MinikinRect* /* bounds */, uint32_t /* glyph_id*/,
|
|
||||||
const MinikinPaint& /* paint */) const {
|
|
||||||
// TODO: NYI
|
|
||||||
}
|
|
||||||
|
|
||||||
const void* MinikinFontFreeType::GetTable(uint32_t tag, size_t* size, MinikinDestroyFunc* destroy) {
|
|
||||||
FT_ULong ftsize = 0;
|
|
||||||
FT_Error error = FT_Load_Sfnt_Table(mTypeface, tag, 0, nullptr, &ftsize);
|
|
||||||
if (error != 0) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
FT_Byte* buf = reinterpret_cast<FT_Byte*>(malloc(ftsize));
|
|
||||||
if (buf == nullptr) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
error = FT_Load_Sfnt_Table(mTypeface, tag, 0, buf, &ftsize);
|
|
||||||
if (error != 0) {
|
|
||||||
free(buf);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
*destroy = free;
|
|
||||||
*size = ftsize;
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MinikinFontFreeType::Render(uint32_t glyph_id, const MinikinPaint& /* paint */,
|
|
||||||
GlyphBitmap *result) {
|
|
||||||
FT_Error error;
|
|
||||||
FT_Int32 load_flags = FT_LOAD_DEFAULT; // TODO: respect hinting settings
|
|
||||||
error = FT_Load_Glyph(mTypeface, glyph_id, load_flags);
|
|
||||||
if (error != 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
error = FT_Render_Glyph(mTypeface->glyph, FT_RENDER_MODE_NORMAL);
|
|
||||||
if (error != 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
FT_Bitmap &bitmap = mTypeface->glyph->bitmap;
|
|
||||||
result->buffer = bitmap.buffer;
|
|
||||||
result->width = bitmap.width;
|
|
||||||
result->height = bitmap.rows;
|
|
||||||
result->left = mTypeface->glyph->bitmap_left;
|
|
||||||
result->top = mTypeface->glyph->bitmap_top;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
MinikinFontFreeType* MinikinFontFreeType::GetFreeType() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace minikin
|
|
||||||
@@ -84,7 +84,6 @@ LOCAL_SRC_FILES += \
|
|||||||
LOCAL_C_INCLUDES := \
|
LOCAL_C_INCLUDES := \
|
||||||
$(LOCAL_PATH)/../../libs/minikin/ \
|
$(LOCAL_PATH)/../../libs/minikin/ \
|
||||||
$(LOCAL_PATH)/../util \
|
$(LOCAL_PATH)/../util \
|
||||||
external/freetype/include \
|
|
||||||
external/harfbuzz_ng/src \
|
external/harfbuzz_ng/src \
|
||||||
external/libxml2/include \
|
external/libxml2/include \
|
||||||
external/skia/src/core
|
external/skia/src/core
|
||||||
|
|||||||
Reference in New Issue
Block a user