PageRenderTime 10ms CodeModel.GetById 1ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/indra/llrender/llfontbitmapcache.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 72 lines | 33 code | 11 blank | 28 comment | 0 complexity | 9cae316ca98260f683e5d2f47b5de4f3 MD5 | raw file
 1/** 
 2 * @file llfontbitmapcache.h
 3 * @brief Storage for previously rendered glyphs.
 4 *
 5 * $LicenseInfo:firstyear=2008&license=viewerlgpl$
 6 * Second Life Viewer Source Code
 7 * Copyright (C) 2010, Linden Research, Inc.
 8 * 
 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation;
12 * version 2.1 of the License only.
13 * 
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * Lesser General Public License for more details.
18 * 
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22 * 
23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
24 * $/LicenseInfo$
25 */
26
27#ifndef LL_LLFONTBITMAPCACHE_H
28#define LL_LLFONTBITMAPCACHE_H
29
30#include <vector>
31
32// Maintain a collection of bitmaps containing rendered glyphs.
33// Generalizes the single-bitmap logic from LLFontFreetype and LLFontGL.
34class LLFontBitmapCache: public LLRefCount
35{
36public:
37	LLFontBitmapCache();
38	~LLFontBitmapCache();
39
40	// Need to call this once, before caching any glyphs.
41 	void init(S32 num_components,
42			  S32 max_char_width,
43			  S32 max_char_height);
44
45	void reset();
46
47	BOOL nextOpenPos(S32 width, S32 &posX, S32 &posY, S32 &bitmapNum);
48	
49	void destroyGL();
50	
51 	LLImageRaw *getImageRaw(U32 bitmapNum = 0) const;
52 	LLImageGL *getImageGL(U32 bitmapNum = 0) const;
53	
54	S32 getMaxCharWidth() const { return mMaxCharWidth; }
55	S32 getNumComponents() const { return mNumComponents; }
56	S32 getBitmapWidth() const { return mBitmapWidth; }
57	S32 getBitmapHeight() const { return mBitmapHeight; }
58
59private:
60	S32 mNumComponents;
61	S32 mBitmapWidth;
62	S32 mBitmapHeight;
63	S32 mBitmapNum;
64	S32 mMaxCharWidth;
65	S32 mMaxCharHeight;
66	S32 mCurrentOffsetX;
67	S32 mCurrentOffsetY;
68	std::vector<LLPointer<LLImageRaw> >	mImageRawVec;
69	std::vector<LLPointer<LLImageGL> > mImageGLVec;
70};
71
72#endif //LL_LLFONTBITMAPCACHE_H