1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
/*
* Copyright 2006 The Android Open Source Project
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkGraphics.h"
#include "Sk64.h"
#include "SkBlitter.h"
#include "SkCanvas.h"
#include "SkFloat.h"
#include "SkGeometry.h"
#include "SkMath.h"
#include "SkMatrix.h"
#include "SkPath.h"
#include "SkPathEffect.h"
#include "SkRandom.h"
#include "SkRefCnt.h"
#include "SkScalerContext.h"
#include "SkShader.h"
#include "SkStream.h"
#include "SkTSearch.h"
#include "SkTime.h"
#include "SkUtils.h"
#include "SkXfermode.h"
void SkGraphics::GetVersion(int32_t* major, int32_t* minor, int32_t* patch) {
if (major) {
*major = SKIA_VERSION_MAJOR;
}
if (minor) {
*minor = SKIA_VERSION_MINOR;
}
if (patch) {
*patch = SKIA_VERSION_PATCH;
}
}
#define typesizeline(type) { #type , sizeof(type) }
#ifdef BUILD_EMBOSS_TABLE
extern void SkEmbossMask_BuildTable();
#endif
#ifdef BUILD_RADIALGRADIENT_TABLE
extern void SkRadialGradient_BuildTable();
#endif
void SkGraphics::Init() {
#ifdef BUILD_EMBOSS_TABLE
SkEmbossMask_BuildTable();
#endif
#ifdef BUILD_RADIALGRADIENT_TABLE
SkRadialGradient_BuildTable();
#endif
#ifdef SK_DEBUGx
int i;
static const struct {
const char* fTypeName;
size_t fSizeOf;
} gTypeSize[] = {
typesizeline(char),
typesizeline(short),
typesizeline(int),
typesizeline(long),
typesizeline(size_t),
typesizeline(void*),
typesizeline(S8CPU),
typesizeline(U8CPU),
typesizeline(S16CPU),
typesizeline(U16CPU),
typesizeline(SkPoint),
typesizeline(SkRect),
typesizeline(SkMatrix),
typesizeline(SkPath),
typesizeline(SkGlyph),
typesizeline(SkRefCnt),
typesizeline(SkPaint),
typesizeline(SkCanvas),
typesizeline(SkBlitter),
typesizeline(SkShader),
typesizeline(SkXfermode),
typesizeline(SkPathEffect)
};
#ifdef SK_CPU_BENDIAN
SkDebugf("SkGraphics: big-endian\n");
#else
SkDebugf("SkGraphics: little-endian\n");
#endif
{
char test = 0xFF;
int itest = test; // promote to int, see if it sign-extended
if (itest < 0)
SkDebugf("SkGraphics: char is signed\n");
else
SkDebugf("SkGraphics: char is unsigned\n");
}
for (i = 0; i < (int)SK_ARRAY_COUNT(gTypeSize); i++) {
SkDebugf("SkGraphics: sizeof(%s) = %d\n",
gTypeSize[i].fTypeName, gTypeSize[i].fSizeOf);
}
SkDebugf("SkGraphics: font cache limit %dK\n",
GetFontCacheLimit() >> 10);
#endif
}
///////////////////////////////////////////////////////////////////////////////
#include "SkGlyphCache.h"
#include "SkTypefaceCache.h"
void SkGraphics::Term() {
SkGlyphCache::SetCacheUsed(0);
SkTypefaceCache::PurgeAll();
}
#ifndef SK_DEFAULT_FONT_CACHE_LIMIT
#define SK_DEFAULT_FONT_CACHE_LIMIT (2 * 1024 * 1024)
#endif
#define SK_MIN_FONT_CACHE_LIMIT (256 * 1024)
static size_t gFontCacheLimit = SK_DEFAULT_FONT_CACHE_LIMIT;
size_t SkGraphics::GetFontCacheLimit() {
return gFontCacheLimit;
}
size_t SkGraphics::SetFontCacheLimit(size_t bytes) {
size_t prev = gFontCacheLimit;
if (bytes < SK_MIN_FONT_CACHE_LIMIT) {
bytes = SK_MIN_FONT_CACHE_LIMIT;
}
gFontCacheLimit = bytes;
// trigger a purge if the new size is smaller that our currently used amount
if (bytes < SkGlyphCache::GetCacheUsed()) {
SkGlyphCache::SetCacheUsed(bytes);
}
return prev;
}
void SkGraphics::PurgeFontCache() {
SkGlyphCache::SetCacheUsed(0);
}
|