Move Bitmap to a different namespace
namespace naming collision. Move minikin's Bitmap out of android:: and into minikin:: Change-Id: I5ae3925f81b848dc79576429ab55243b96f7fed2
This commit is contained in:
parent
d24df3eb94
commit
1be122da96
@ -24,7 +24,7 @@
|
|||||||
#include <minikin/FontCollection.h>
|
#include <minikin/FontCollection.h>
|
||||||
#include <minikin/MinikinFontFreeType.h>
|
#include <minikin/MinikinFontFreeType.h>
|
||||||
|
|
||||||
namespace android {
|
namespace minikin {
|
||||||
|
|
||||||
// The Bitmap class is for debugging. We'll probably move it out
|
// The Bitmap class is for debugging. We'll probably move it out
|
||||||
// of here into a separate lightweight software rendering module
|
// of here into a separate lightweight software rendering module
|
||||||
@ -34,13 +34,17 @@ public:
|
|||||||
Bitmap(int width, int height);
|
Bitmap(int width, int height);
|
||||||
~Bitmap();
|
~Bitmap();
|
||||||
void writePnm(std::ofstream& o) const;
|
void writePnm(std::ofstream& o) const;
|
||||||
void drawGlyph(const GlyphBitmap& bitmap, int x, int y);
|
void drawGlyph(const android::GlyphBitmap& bitmap, int x, int y);
|
||||||
private:
|
private:
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
uint8_t* buf;
|
uint8_t* buf;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace minikin
|
||||||
|
|
||||||
|
namespace android {
|
||||||
|
|
||||||
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
|
||||||
@ -89,7 +93,7 @@ public:
|
|||||||
void doLayout(const uint16_t* buf, size_t start, size_t count, size_t bufSize,
|
void doLayout(const uint16_t* buf, size_t start, size_t count, size_t bufSize,
|
||||||
int bidiFlags, const FontStyle &style, const MinikinPaint &paint);
|
int bidiFlags, const FontStyle &style, const MinikinPaint &paint);
|
||||||
|
|
||||||
void draw(Bitmap*, int x0, int y0, float size) const;
|
void draw(minikin::Bitmap*, int x0, int y0, float size) const;
|
||||||
|
|
||||||
// Deprecated. Nont needed. Remove when callers are removed.
|
// Deprecated. Nont needed. Remove when callers are removed.
|
||||||
static void init();
|
static void init();
|
||||||
|
@ -41,6 +41,48 @@
|
|||||||
using std::string;
|
using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
|
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 android::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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace minikin
|
||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
|
|
||||||
const int kDirection_Mask = 0x1;
|
const int kDirection_Mask = 0x1;
|
||||||
@ -218,44 +260,6 @@ hash_t hash_type(const LayoutCacheKey& key) {
|
|||||||
return key.hash();
|
return key.hash();
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MinikinRect::join(const MinikinRect& r) {
|
void MinikinRect::join(const MinikinRect& r) {
|
||||||
if (isEmpty()) {
|
if (isEmpty()) {
|
||||||
set(r);
|
set(r);
|
||||||
@ -814,7 +818,7 @@ void Layout::appendLayout(Layout* src, size_t start) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layout::draw(Bitmap* surface, int x0, int y0, float size) const {
|
void Layout::draw(minikin::Bitmap* surface, int x0, int y0, float size) const {
|
||||||
/*
|
/*
|
||||||
TODO: redo as MinikinPaint settings
|
TODO: redo as MinikinPaint settings
|
||||||
if (mProps.hasTag(minikinHinting)) {
|
if (mProps.hasTag(minikinHinting)) {
|
||||||
|
@ -28,8 +28,8 @@
|
|||||||
#include <minikin/Layout.h>
|
#include <minikin/Layout.h>
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
using namespace android;
|
||||||
namespace android {
|
using namespace minikin;
|
||||||
|
|
||||||
FT_Library library; // TODO: this should not be a global
|
FT_Library library; // TODO: this should not be a global
|
||||||
|
|
||||||
@ -99,8 +99,6 @@ int runMinikinTest() {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, const char** argv) {
|
int main(int argc, const char** argv) {
|
||||||
return android::runMinikinTest();
|
return runMinikinTest();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user