OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkGraphics.h" | 10 #include "SkGraphics.h" |
11 | 11 |
12 #include "SkBlitter.h" | 12 #include "SkBlitter.h" |
13 #include "SkCanvas.h" | 13 #include "SkCanvas.h" |
14 #include "SkGeometry.h" | 14 #include "SkGeometry.h" |
15 #include "SkMath.h" | 15 #include "SkMath.h" |
16 #include "SkMatrix.h" | 16 #include "SkMatrix.h" |
| 17 #include "SkOpts.h" |
17 #include "SkPath.h" | 18 #include "SkPath.h" |
18 #include "SkPathEffect.h" | 19 #include "SkPathEffect.h" |
19 #include "SkPixelRef.h" | 20 #include "SkPixelRef.h" |
20 #include "SkRefCnt.h" | 21 #include "SkRefCnt.h" |
21 #include "SkRTConf.h" | 22 #include "SkRTConf.h" |
22 #include "SkScalerContext.h" | 23 #include "SkScalerContext.h" |
23 #include "SkShader.h" | 24 #include "SkShader.h" |
24 #include "SkStream.h" | 25 #include "SkStream.h" |
25 #include "SkTSearch.h" | 26 #include "SkTSearch.h" |
26 #include "SkTime.h" | 27 #include "SkTime.h" |
27 #include "SkUtils.h" | 28 #include "SkUtils.h" |
28 #include "SkXfermode.h" | 29 #include "SkXfermode.h" |
29 | 30 |
30 void SkGraphics::GetVersion(int32_t* major, int32_t* minor, int32_t* patch) { | 31 void SkGraphics::GetVersion(int32_t* major, int32_t* minor, int32_t* patch) { |
31 if (major) { | 32 if (major) { |
32 *major = SKIA_VERSION_MAJOR; | 33 *major = SKIA_VERSION_MAJOR; |
33 } | 34 } |
34 if (minor) { | 35 if (minor) { |
35 *minor = SKIA_VERSION_MINOR; | 36 *minor = SKIA_VERSION_MINOR; |
36 } | 37 } |
37 if (patch) { | 38 if (patch) { |
38 *patch = SKIA_VERSION_PATCH; | 39 *patch = SKIA_VERSION_PATCH; |
39 } | 40 } |
40 } | 41 } |
41 | 42 |
42 #define typesizeline(type) { #type , sizeof(type) } | 43 void SkGraphics::Init() { |
| 44 // SkGraphics::Init() must be thread-safe and idempotent. |
| 45 SkOpts::Init(); |
43 | 46 |
44 #ifdef BUILD_EMBOSS_TABLE | |
45 extern void SkEmbossMask_BuildTable(); | |
46 #endif | |
47 | |
48 #ifdef BUILD_RADIALGRADIENT_TABLE | |
49 extern void SkRadialGradient_BuildTable(); | |
50 #endif | |
51 | |
52 void SkGraphics::Init() { | |
53 #ifdef SK_DEVELOPER | 47 #ifdef SK_DEVELOPER |
54 skRTConfRegistry().possiblyDumpFile(); | 48 skRTConfRegistry().possiblyDumpFile(); |
55 skRTConfRegistry().validate(); | 49 skRTConfRegistry().validate(); |
56 if (skRTConfRegistry().hasNonDefault()) { | 50 if (skRTConfRegistry().hasNonDefault()) { |
57 SkDebugf("Non-default runtime configuration options:\n"); | 51 SkDebugf("Non-default runtime configuration options:\n"); |
58 skRTConfRegistry().printNonDefault(); | 52 skRTConfRegistry().printNonDefault(); |
59 } | 53 } |
60 #endif | 54 #endif |
61 | |
62 #ifdef BUILD_EMBOSS_TABLE | |
63 SkEmbossMask_BuildTable(); | |
64 #endif | |
65 #ifdef BUILD_RADIALGRADIENT_TABLE | |
66 SkRadialGradient_BuildTable(); | |
67 #endif | |
68 | |
69 #ifdef SK_DEBUGx | |
70 int i; | |
71 | |
72 static const struct { | |
73 const char* fTypeName; | |
74 size_t fSizeOf; | |
75 } gTypeSize[] = { | |
76 typesizeline(char), | |
77 typesizeline(short), | |
78 typesizeline(int), | |
79 typesizeline(long), | |
80 typesizeline(size_t), | |
81 typesizeline(void*), | |
82 | |
83 typesizeline(S8CPU), | |
84 typesizeline(U8CPU), | |
85 typesizeline(S16CPU), | |
86 typesizeline(U16CPU), | |
87 | |
88 typesizeline(SkPoint), | |
89 typesizeline(SkRect), | |
90 typesizeline(SkMatrix), | |
91 typesizeline(SkPath), | |
92 typesizeline(SkGlyph), | |
93 typesizeline(SkRefCnt), | |
94 | |
95 typesizeline(SkPaint), | |
96 typesizeline(SkCanvas), | |
97 typesizeline(SkBlitter), | |
98 typesizeline(SkShader), | |
99 typesizeline(SkXfermode), | |
100 typesizeline(SkPathEffect) | |
101 }; | |
102 | |
103 #ifdef SK_CPU_BENDIAN | |
104 SkDebugf("SkGraphics: big-endian\n"); | |
105 #else | |
106 SkDebugf("SkGraphics: little-endian\n"); | |
107 #endif | |
108 | |
109 { | |
110 char test = 0xFF; | |
111 int itest = test; // promote to int, see if it sign-extended | |
112 if (itest < 0) | |
113 SkDebugf("SkGraphics: char is signed\n"); | |
114 else | |
115 SkDebugf("SkGraphics: char is unsigned\n"); | |
116 } | |
117 for (i = 0; i < (int)SK_ARRAY_COUNT(gTypeSize); i++) { | |
118 SkDebugf("SkGraphics: sizeof(%s) = %d\n", | |
119 gTypeSize[i].fTypeName, gTypeSize[i].fSizeOf); | |
120 } | |
121 SkDebugf("SkGraphics: font cache limit %dK\n", | |
122 GetFontCacheLimit() >> 10); | |
123 | |
124 #endif | |
125 | |
126 } | 55 } |
127 | 56 |
128 void SkGraphics::Term() { | 57 void SkGraphics::Term() { |
129 PurgeFontCache(); | 58 PurgeFontCache(); |
130 PurgeResourceCache(); | 59 PurgeResourceCache(); |
131 SkPaint::Term(); | 60 SkPaint::Term(); |
132 } | 61 } |
133 | 62 |
134 /////////////////////////////////////////////////////////////////////////////// | 63 /////////////////////////////////////////////////////////////////////////////// |
135 | 64 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 if (nextEqual) { | 100 if (nextEqual) { |
172 val = (size_t) atoi(nextEqual + 1); | 101 val = (size_t) atoi(nextEqual + 1); |
173 } | 102 } |
174 (gFlags[i].fFunc)(val); | 103 (gFlags[i].fFunc)(val); |
175 break; | 104 break; |
176 } | 105 } |
177 } | 106 } |
178 flags = nextSemi + 1; | 107 flags = nextSemi + 1; |
179 } while (nextSemi); | 108 } while (nextSemi); |
180 } | 109 } |
OLD | NEW |