Skip to content

Commit

Permalink
llrender and lldir merge. Removed duplicate assets from skins. cleane…
Browse files Browse the repository at this point in the history
…d up skin textures.xml files to only include changes from default.
  • Loading branch information
Shyotl committed Apr 11, 2016
1 parent d40256f commit be5d2f2
Show file tree
Hide file tree
Showing 1,280 changed files with 2,334 additions and 10,672 deletions.
24 changes: 23 additions & 1 deletion indra/llrender/llfontfreetype.cpp
Expand Up @@ -104,14 +104,14 @@ LLFontGlyphInfo::LLFontGlyphInfo(U32 index)

LLFontFreetype::LLFontFreetype()
: mFontBitmapCachep(new LLFontBitmapCache),
mValid(FALSE),
mAscender(0.f),
mDescender(0.f),
mLineHeight(0.f),
mIsFallback(FALSE),
mFTFace(NULL),
mRenderGlyphCount(0),
mAddGlyphCount(0),
mStyle(0),
mPointSize(0)
{
}
Expand Down Expand Up @@ -204,6 +204,19 @@ BOOL LLFontFreetype::loadFace(const std::string& filename, const F32 point_size,
mName = filename;
mPointSize = point_size;

mStyle = LLFontGL::NORMAL;
if(mFTFace->style_flags & FT_STYLE_FLAG_BOLD)
{
mStyle |= LLFontGL::BOLD;
mStyle &= ~LLFontGL::NORMAL;
}

if(mFTFace->style_flags & FT_STYLE_FLAG_ITALIC)
{
mStyle |= LLFontGL::ITALIC;
mStyle &= ~LLFontGL::NORMAL;
}

return TRUE;
}

Expand Down Expand Up @@ -536,6 +549,15 @@ const LLPointer<LLFontBitmapCache> LLFontFreetype::getFontBitmapCache() const
return mFontBitmapCachep;
}

void LLFontFreetype::setStyle(U8 style)
{
mStyle = style;
}

U8 LLFontFreetype::getStyle() const
{
return mStyle;
}
void LLFontFreetype::setSubImageLuminanceAlpha(const U32 x, const U32 y, const U32 bitmap_num, const U32 width, const U32 height, const U8 *data, S32 stride) const
{
LLImageRaw *image_raw = mFontBitmapCachep->getImageRaw(bitmap_num);
Expand Down
9 changes: 5 additions & 4 deletions indra/llrender/llfontfreetype.h
Expand Up @@ -93,8 +93,6 @@ class LLFontFreetype : public LLRefCount
void setFallbackFonts(const font_vector_t &font);
const font_vector_t &getFallbackFonts() const;

void setCharToGlyphMap(llwchar wch, U32 glyph_index) const;

// Global font metrics - in units of pixels
F32 getLineHeight() const;
F32 getAscenderHeight() const;
Expand Down Expand Up @@ -140,6 +138,9 @@ class LLFontFreetype : public LLRefCount
const std::string& getName() const;

const LLPointer<LLFontBitmapCache> getFontBitmapCache() const;

void setStyle(U8 style);
U8 getStyle() const;

static bool sOpenGLcrashOnRestart;

Expand All @@ -154,6 +155,8 @@ class LLFontFreetype : public LLRefCount

std::string mName;

U8 mStyle;

F32 mPointSize;
F32 mAscender;
F32 mDescender;
Expand All @@ -164,8 +167,6 @@ class LLFontFreetype : public LLRefCount
BOOL mIsFallback;
font_vector_t mFallbackFonts; // A list of fallback fonts to look for glyphs in (for Unicode chars)

BOOL mValid;

typedef boost::unordered_map<llwchar, LLFontGlyphInfo*> char_glyph_info_map_t;
mutable char_glyph_info_map_t mCharGlyphInfoMap; // Information about glyph location in bitmap

Expand Down
31 changes: 10 additions & 21 deletions indra/llrender/llfontgl.cpp
Expand Up @@ -36,6 +36,7 @@
#include "llfontregistry.h"
#include "llgl.h"
#include "llrender.h"
#include "lltexture.h"
#include "v4color.h"
#include "llstl.h"
#include "llfasttimer.h"
Expand Down Expand Up @@ -69,20 +70,6 @@ const F32 PIXEL_CORRECTION_DISTANCE = 0.01f;
const F32 PAD_UVY = 0.5f; // half of vertical padding between glyphs in the glyph texture
const F32 DROP_SHADOW_SOFT_STRENGTH = 0.3f;

F32 llfont_round_x(F32 x)
{
//return llfloor((x-LLFontGL::sCurOrigin.mX)/LLFontGL::sScaleX+0.5f)*LLFontGL::sScaleX+LLFontGL::sCurOrigin.mX;
//return llfloor(x/LLFontGL::sScaleX+0.5f)*LLFontGL::sScaleY;
return x;
}

F32 llfont_round_y(F32 y)
{
//return llfloor((y-LLFontGL::sCurOrigin.mY)/LLFontGL::sScaleY+0.5f)*LLFontGL::sScaleY+LLFontGL::sCurOrigin.mY;
//return llfloor(y+0.5f);
return y;
}

LLFontGL::LLFontGL()
{
clearEmbeddedChars();
Expand Down Expand Up @@ -166,8 +153,9 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons

S32 scaled_max_pixels = max_pixels == S32_MAX ? S32_MAX : llceil((F32)max_pixels * sScaleX);

// Strip off any style bits that are already accounted for by the font.
style = style & (~getFontDesc().getStyle());
// determine which style flags need to be added programmatically by stripping off the
// style bits that are drawn by the underlying Freetype font
U8 style_to_add = (style | mFontDescriptor.getStyle()) & ~mFontFreetype->getStyle();

F32 drop_shadow_strength = 0.f;
if (shadow != NO_SHADOW)
Expand Down Expand Up @@ -412,7 +400,7 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
glyph_count = 0;
}

drawGlyph(glyph_count, vertices, uvs, colors, screen_rect, uv_rect, text_color, style, shadow, drop_shadow_strength);
drawGlyph(glyph_count, vertices, uvs, colors, screen_rect, uv_rect, text_color, style_to_add, shadow, drop_shadow_strength);

chars_drawn++;
cur_x += fgi->mXAdvance;
Expand Down Expand Up @@ -453,7 +441,8 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
*right_x = (cur_x - origin.mV[VX]) / sScaleX;
}

if (style & UNDERLINE)
//FIXME: add underline as glyph?
if (style_to_add & UNDERLINE)
{
F32 descender = (F32)llfloor(mFontFreetype->getDescenderHeight());

Expand All @@ -475,7 +464,7 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
(cur_x - origin.mV[VX]) / sScaleX, (F32)y,
color,
LEFT, valign,
style,
style_to_add,
shadow,
S32_MAX, max_pixels,
right_x,
Expand Down Expand Up @@ -940,7 +929,7 @@ void LLFontGL::removeEmbeddedChar( llwchar wc ) const
}

// static
void LLFontGL::initClass(F32 screen_dpi, F32 x_scale, F32 y_scale, const std::string& app_dir, const std::vector<std::string>& xui_paths, bool create_gl_textures)
void LLFontGL::initClass(F32 screen_dpi, F32 x_scale, F32 y_scale, const std::string& app_dir, bool create_gl_textures)
{
sVertDPI = (F32)llfloor(screen_dpi * y_scale);
sHorizDPI = (F32)llfloor(screen_dpi * x_scale);
Expand All @@ -951,7 +940,7 @@ void LLFontGL::initClass(F32 screen_dpi, F32 x_scale, F32 y_scale, const std::st
// Font registry init
if (!sFontRegistry)
{
sFontRegistry = new LLFontRegistry(xui_paths,create_gl_textures);
sFontRegistry = new LLFontRegistry(create_gl_textures);
sFontRegistry->parseFontInfo("fonts.xml");
}
else
Expand Down
4 changes: 2 additions & 2 deletions indra/llrender/llfontgl.h
Expand Up @@ -30,7 +30,7 @@

#include "llcoord.h"
#include "llfontregistry.h"
#include "lltexture.h"
#include "llimagegl.h"
#include "llpointer.h"
#include "llrect.h"
#include "v2math.h"
Expand Down Expand Up @@ -152,7 +152,7 @@ class LLFontGL
void addEmbeddedChar( llwchar wc, LLTexture* image, const LLWString& label) const;
void removeEmbeddedChar( llwchar wc ) const;

static void initClass(F32 screen_dpi, F32 x_scale, F32 y_scale, const std::string& app_dir, const std::vector<std::string>& xui_paths, bool create_gl_textures = true);
static void initClass(F32 screen_dpi, F32 x_scale, F32 y_scale, const std::string& app_dir, bool create_gl_textures = true);

// Load sans-serif, sans-serif-small, etc.
// Slow, requires multiple seconds to load fonts.
Expand Down
51 changes: 26 additions & 25 deletions indra/llrender/llfontregistry.cpp
Expand Up @@ -34,13 +34,15 @@
#include "llcontrol.h"
#include "lldir.h"
#include "llwindow.h"
#include "llxmlnode.h"

extern LLControlGroup gSavedSettings;

using std::string;
using std::map;

bool fontDescInitFromXML(LLXMLNodePtr node, LLFontDescriptor& desc);
bool font_desc_init_from_xml(LLXMLNodePtr node, LLFontDescriptor& desc);
bool init_from_xml(LLFontRegistry* registry, LLXMLNodePtr node);

LLFontDescriptor::LLFontDescriptor():
mStyle(0)
Expand Down Expand Up @@ -163,14 +165,9 @@ LLFontDescriptor LLFontDescriptor::normalize() const
return LLFontDescriptor(new_name,new_size,new_style,getFileNames());
}

LLFontRegistry::LLFontRegistry(const string_vec_t& xui_paths,
bool create_gl_textures)
LLFontRegistry::LLFontRegistry(bool create_gl_textures)
: mCreateGLTextures(create_gl_textures)
{
// Propagate this down from LLUICtrlFactory so LLRender doesn't
// need an upstream dependency on LLUI.
mXUIPaths = xui_paths;

// This is potentially a slow directory traversal, so we want to
// cache the result.
mUltimateFallbackList = LLWindow::getDynamicFallbackFontList();
Expand All @@ -183,23 +180,27 @@ LLFontRegistry::~LLFontRegistry()

bool LLFontRegistry::parseFontInfo(const std::string& xml_filename)
{
bool success = false; // Succeed if we find at least one XUI file
const string_vec_t& xml_paths = mXUIPaths;
bool success = false; // Succeed if we find and read at least one XUI file
const string_vec_t xml_paths = gDirUtilp->findSkinnedFilenames(LLDir::XUI, xml_filename);
if (xml_paths.empty())
{
// We didn't even find one single XUI file
return false;
}

for (string_vec_t::const_iterator path_it = xml_paths.begin();
path_it != xml_paths.end();
++path_it)
{
LLXMLNodePtr root;
std::string full_filename = gDirUtilp->findSkinnedFilename(*path_it, xml_filename);
bool parsed_file = LLXMLNode::parseFile(full_filename, root, NULL);
bool parsed_file = LLXMLNode::parseFile(*path_it, root, NULL);

if (!parsed_file)
continue;

if ( root.isNull() || ! root->hasName( "fonts" ) )
{
LL_WARNS() << "Bad font info file: "
<< full_filename << LL_ENDL;
LL_WARNS() << "Bad font info file: " << *path_it << LL_ENDL;
continue;
}

Expand All @@ -208,12 +209,12 @@ bool LLFontRegistry::parseFontInfo(const std::string& xml_filename)
if (root->hasName("fonts"))
{
// Expect a collection of children consisting of "font" or "font_size" entries
bool init_succ = initFromXML(root);
bool init_succ = init_from_xml(this, root);
success = success || init_succ;
}
}
if (success)
dump();
//if (success)
// dump();

return success;
}
Expand All @@ -231,7 +232,7 @@ std::string currentOsName()
#endif
}

bool fontDescInitFromXML(LLXMLNodePtr node, LLFontDescriptor& desc)
bool font_desc_init_from_xml(LLXMLNodePtr node, LLFontDescriptor& desc)
{
if (node->hasName("font"))
{
Expand Down Expand Up @@ -264,14 +265,14 @@ bool fontDescInitFromXML(LLXMLNodePtr node, LLFontDescriptor& desc)
{
if (child_name == currentOsName())
{
fontDescInitFromXML(child, desc);
font_desc_init_from_xml(child, desc);
}
}
}
return true;
}

bool LLFontRegistry::initFromXML(LLXMLNodePtr node)
bool init_from_xml(LLFontRegistry* registry, LLXMLNodePtr node)
{
LLXMLNodePtr child;

Expand All @@ -282,17 +283,17 @@ bool LLFontRegistry::initFromXML(LLXMLNodePtr node)
if (child->hasName("font"))
{
LLFontDescriptor desc;
bool font_succ = fontDescInitFromXML(child, desc);
bool font_succ = font_desc_init_from_xml(child, desc);
LLFontDescriptor norm_desc = desc.normalize();
if (font_succ)
{
// if this is the first time we've seen this font name,
// create a new template map entry for it.
const LLFontDescriptor *match_desc = getMatchingFontDesc(desc);
const LLFontDescriptor *match_desc = registry->getMatchingFontDesc(desc);
if (match_desc == NULL)
{
// Create a new entry (with no corresponding font).
mFontMap[norm_desc] = NULL;
registry->mFontMap[norm_desc] = NULL;
}
// otherwise, find the existing entry and combine data.
else
Expand All @@ -307,8 +308,8 @@ bool LLFontRegistry::initFromXML(LLXMLNodePtr node)
desc.getFileNames().end());
LLFontDescriptor new_desc = *match_desc;
new_desc.getFileNames() = match_file_names;
mFontMap.erase(*match_desc);
mFontMap[new_desc] = NULL;
registry->mFontMap.erase(*match_desc);
registry->mFontMap[new_desc] = NULL;
}
}
}
Expand All @@ -319,7 +320,7 @@ bool LLFontRegistry::initFromXML(LLXMLNodePtr node)
if (child->getAttributeString("name",size_name) &&
child->getAttributeF32("size",size_value))
{
mFontSizes[size_name] = size_value;
registry->mFontSizes[size_name] = size_value;
}

}
Expand Down
9 changes: 4 additions & 5 deletions indra/llrender/llfontregistry.h
Expand Up @@ -28,7 +28,7 @@
#ifndef LL_LLFONTREGISTRY_H
#define LL_LLFONTREGISTRY_H

#include "llxmlnode.h"
#include "llpointer.h"

class LLFontGL;

Expand Down Expand Up @@ -65,15 +65,14 @@ class LLFontDescriptor
class LLFontRegistry
{
public:
friend bool init_from_xml(LLFontRegistry*, LLPointer<class LLXMLNode>);
// create_gl_textures - set to false for test apps with no OpenGL window,
// such as llui_libtest
LLFontRegistry(const string_vec_t& xui_paths,
bool create_gl_textures);
LLFontRegistry(bool create_gl_textures);
~LLFontRegistry();

// Load standard font info from XML file(s).
bool parseFontInfo(const std::string& xml_filename);
bool initFromXML(LLXMLNodePtr node);

// Clear cached glyphs for all fonts.
void reset();
Expand All @@ -95,6 +94,7 @@ class LLFontRegistry
const string_vec_t& getUltimateFallbackList() const;

private:
LLFontRegistry(const LLFontRegistry& other); // no-copy
LLFontGL *createFont(const LLFontDescriptor& desc);
typedef std::map<LLFontDescriptor,LLFontGL*> font_reg_map_t;
typedef std::map<std::string,F32> font_size_map_t;
Expand All @@ -105,7 +105,6 @@ class LLFontRegistry
font_size_map_t mFontSizes;

string_vec_t mUltimateFallbackList;
string_vec_t mXUIPaths;
bool mCreateGLTextures;
};

Expand Down

0 comments on commit be5d2f2

Please sign in to comment.