usb_ecm: Use the current configuration instead of a fixed one.
[haiku.git] / src / servers / app / font / FontCacheEntry.h
blobabe085adec6a463e42bf7dc7d5089fd5462ae88e
1 /*
2 * Copyright 2007-2009, Haiku. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Maxim Shemanarev <mcseemagg@yahoo.com>
7 * Stephan Aßmus <superstippi@gmx.de>
8 * Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk>
9 */
11 //----------------------------------------------------------------------------
12 // Anti-Grain Geometry - Version 2.4
13 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
15 // Permission to copy, use, modify, sell and distribute this software
16 // is granted provided this copyright notice appears in all copies.
17 // This software is provided "as is" without express or implied
18 // warranty, and with no claim as to its suitability for any purpose.
20 //----------------------------------------------------------------------------
21 // Contact: mcseem@antigrain.com
22 // mcseemagg@yahoo.com
23 // http://www.antigrain.com
24 //----------------------------------------------------------------------------
26 #ifndef FONT_CACHE_ENTRY_H
27 #define FONT_CACHE_ENTRY_H
30 #include <Locker.h>
32 #include <agg_conv_curve.h>
33 #include <agg_conv_contour.h>
34 #include <agg_conv_transform.h>
36 #include "ServerFont.h"
37 #include "FontEngine.h"
38 #include "MultiLocker.h"
39 #include "Referenceable.h"
40 #include "Transformable.h"
43 struct GlyphCache {
44 GlyphCache(uint32 glyphIndex, uint32 dataSize, glyph_data_type dataType,
45 const agg::rect_i& bounds, float advanceX, float advanceY,
46 float preciseAdvanceX, float preciseAdvanceY,
47 float insetLeft, float insetRight)
49 glyph_index(glyphIndex),
50 data((uint8*)malloc(dataSize)),
51 data_size(dataSize),
52 data_type(dataType),
53 bounds(bounds),
54 advance_x(advanceX),
55 advance_y(advanceY),
56 precise_advance_x(preciseAdvanceX),
57 precise_advance_y(preciseAdvanceY),
58 inset_left(insetLeft),
59 inset_right(insetRight),
60 hash_link(NULL)
64 ~GlyphCache()
66 free(data);
69 uint32 glyph_index;
70 uint8* data;
71 uint32 data_size;
72 glyph_data_type data_type;
73 agg::rect_i bounds;
74 float advance_x;
75 float advance_y;
76 float precise_advance_x;
77 float precise_advance_y;
78 float inset_left;
79 float inset_right;
81 GlyphCache* hash_link;
84 class FontCache;
86 class FontCacheEntry : public MultiLocker, public BReferenceable {
87 public:
88 typedef FontEngine::PathAdapter GlyphPathAdapter;
89 typedef FontEngine::Gray8Adapter GlyphGray8Adapter;
90 typedef GlyphGray8Adapter::embedded_scanline GlyphGray8Scanline;
91 typedef FontEngine::MonoAdapter GlyphMonoAdapter;
92 typedef GlyphMonoAdapter::embedded_scanline GlyphMonoScanline;
93 typedef FontEngine::SubpixAdapter SubpixAdapter;
94 typedef agg::conv_curve<GlyphPathAdapter> CurveConverter;
95 typedef agg::conv_contour<CurveConverter> ContourConverter;
97 typedef agg::conv_transform<CurveConverter, Transformable>
98 TransformedOutline;
100 typedef agg::conv_transform<ContourConverter, Transformable>
101 TransformedContourOutline;
104 FontCacheEntry();
105 virtual ~FontCacheEntry();
107 bool Init(const ServerFont& font, bool forceVector);
109 bool HasGlyphs(const char* utf8String,
110 ssize_t glyphCount) const;
112 const GlyphCache* CachedGlyph(uint32 glyphCode);
113 const GlyphCache* CreateGlyph(uint32 glyphCode,
114 FontCacheEntry* fallbackEntry = NULL);
116 void InitAdaptors(const GlyphCache* glyph,
117 double x, double y,
118 GlyphMonoAdapter& monoAdapter,
119 GlyphGray8Adapter& gray8Adapter,
120 GlyphPathAdapter& pathAdapter,
121 double scale = 1.0);
123 bool GetKerning(uint32 glyphCode1,
124 uint32 glyphCode2, double* x, double* y);
126 static void GenerateSignature(char* signature,
127 size_t signatureSize,
128 const ServerFont& font, bool forceVector);
130 // private to FontCache class:
131 void UpdateUsage();
132 bigtime_t LastUsed() const
133 { return fLastUsedTime; }
134 uint64 UsedCount() const
135 { return fUseCounter; }
137 private:
138 FontCacheEntry(const FontCacheEntry&);
139 const FontCacheEntry& operator=(const FontCacheEntry&);
141 static glyph_rendering _RenderTypeFor(const ServerFont& font,
142 bool forceVector);
144 class GlyphCachePool;
146 GlyphCachePool* fGlyphCache;
147 FontEngine fEngine;
149 static BLocker sUsageUpdateLock;
150 bigtime_t fLastUsedTime;
151 uint64 fUseCounter;
154 #endif // FONT_CACHE_ENTRY_H