aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ViewStyle.h
diff options
context:
space:
mode:
authornyamatongwe <unknown>2011-03-30 10:27:05 +1100
committernyamatongwe <unknown>2011-03-30 10:27:05 +1100
commitf88ad3864ccdf534e46cc004b377b2c08d318a04 (patch)
tree2efa44a4ecfe7b1b864c2c049d1bc6397b779bc3 /src/ViewStyle.h
parentef7f8a349a89dd7d72d62f7a162cb3e553ca4ba6 (diff)
downloadscintilla-mirror-f88ad3864ccdf534e46cc004b377b2c08d318a04.tar.gz
Optimize font use by only allocating platform font resources for unique fonts
and using aliases of these in the Style objects. Font measurement is also performed once for each unique font and the results copied into each style. No change is needed in callers. On PLAT_WX, the font ascent is cached in the Font object when Ascent is called but this is not copied into the aliases as ascent is protected. Therefore the code that copies the FontID into the alias also calls Ascent to ensure the ascent value is cached.
Diffstat (limited to 'src/ViewStyle.h')
-rw-r--r--src/ViewStyle.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/ViewStyle.h b/src/ViewStyle.h
index 6ca488dff..cf45be41f 100644
--- a/src/ViewStyle.h
+++ b/src/ViewStyle.h
@@ -39,6 +39,19 @@ public:
const char *Save(const char *name);
};
+class FontRealised : public Font, public FontSpecification, public FontMeasurements {
+ // Private so FontRealised objects can not be copied
+ FontRealised(const FontRealised &);
+ FontRealised &operator=(const FontRealised &);
+public:
+ FontRealised *frNext;
+ FontRealised(const FontSpecification &fs);
+ virtual ~FontRealised();
+ void Realise(Surface &surface, int zoomLevel);
+ FontRealised *Find(const FontSpecification &fs);
+ void FindMaxAscentDescent(unsigned int &maxAscent, unsigned int &maxDescent);
+};
+
enum IndentView {ivNone, ivReal, ivLookForward, ivLookBoth};
enum WhiteSpaceVisibility {wsInvisible=0, wsVisibleAlways=1, wsVisibleAfterIndent=2};
@@ -48,6 +61,7 @@ enum WhiteSpaceVisibility {wsInvisible=0, wsVisibleAlways=1, wsVisibleAfterInden
class ViewStyle {
public:
FontNames fontNames;
+ FontRealised *frFirst;
size_t stylesSize;
Style *styles;
LineMarker markers[MARKER_MAX + 1];
@@ -119,6 +133,7 @@ public:
ViewStyle(const ViewStyle &source);
~ViewStyle();
void Init(size_t stylesSize_=64);
+ void CreateFont(const FontSpecification &fs);
void RefreshColourPalette(Palette &pal, bool want);
void Refresh(Surface &surface);
void AllocStyles(size_t sizeNew);