summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2015-04-16 15:27:12 -0700
committerJohn Reck <jreck@google.com>2015-04-27 17:23:29 +0000
commit8920e81717c6e51b92ff8f4479a1f959af260556 (patch)
tree3b2e119d4c5dbd14500898fabefa8467897d8608 /libs
parent68ae337aa05f598af18b09fe4125146d4d67db83 (diff)
downloadandroid_frameworks_minikin-8920e81717c6e51b92ff8f4479a1f959af260556.tar.gz
android_frameworks_minikin-8920e81717c6e51b92ff8f4479a1f959af260556.tar.bz2
android_frameworks_minikin-8920e81717c6e51b92ff8f4479a1f959af260556.zip
Move Bitmap to a different namespace
namespace naming collision. Move minikin's Bitmap out of android:: and into minikin:: Change-Id: I5ae3925f81b848dc79576429ab55243b96f7fed2
Diffstat (limited to 'libs')
-rw-r--r--libs/minikin/Layout.cpp82
1 files changed, 43 insertions, 39 deletions
diff --git a/libs/minikin/Layout.cpp b/libs/minikin/Layout.cpp
index 28dac7f..88baeac 100644
--- a/libs/minikin/Layout.cpp
+++ b/libs/minikin/Layout.cpp
@@ -41,6 +41,48 @@
using std::string;
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 {
const int kDirection_Mask = 0x1;
@@ -218,44 +260,6 @@ hash_t hash_type(const LayoutCacheKey& key) {
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) {
if (isEmpty()) {
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
if (mProps.hasTag(minikinHinting)) {