3 * Copyright 2006 The Android Open Source Project
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
10 #include "SkGraphics.h"
12 #include "SkBlitter.h"
15 #include "SkGeometry.h"
19 #include "SkPathEffect.h"
20 #include "SkPixelRef.h"
23 #include "SkScalerContext.h"
26 #include "SkTSearch.h"
29 #include "SkXfermode.h"
31 void SkGraphics::GetVersion(int32_t* major, int32_t* minor, int32_t* patch) {
33 *major = SKIA_VERSION_MAJOR;
36 *minor = SKIA_VERSION_MINOR;
39 *patch = SKIA_VERSION_PATCH;
43 #define typesizeline(type) { #type , sizeof(type) }
45 #ifdef BUILD_EMBOSS_TABLE
46 extern void SkEmbossMask_BuildTable();
49 #ifdef BUILD_RADIALGRADIENT_TABLE
50 extern void SkRadialGradient_BuildTable();
53 void SkGraphics::Init() {
55 skRTConfRegistry().possiblyDumpFile();
56 skRTConfRegistry().validate();
57 if (skRTConfRegistry().hasNonDefault()) {
58 SkDebugf("Non-default runtime configuration options:\n");
59 skRTConfRegistry().printNonDefault();
63 #ifdef BUILD_EMBOSS_TABLE
64 SkEmbossMask_BuildTable();
66 #ifdef BUILD_RADIALGRADIENT_TABLE
67 SkRadialGradient_BuildTable();
74 const char* fTypeName;
89 typesizeline(SkPoint),
91 typesizeline(SkMatrix),
93 typesizeline(SkGlyph),
94 typesizeline(SkRefCnt),
96 typesizeline(SkPaint),
97 typesizeline(SkCanvas),
98 typesizeline(SkBlitter),
99 typesizeline(SkShader),
100 typesizeline(SkXfermode),
101 typesizeline(SkPathEffect)
104 #ifdef SK_CPU_BENDIAN
105 SkDebugf("SkGraphics: big-endian\n");
107 SkDebugf("SkGraphics: little-endian\n");
112 int itest = test; // promote to int, see if it sign-extended
114 SkDebugf("SkGraphics: char is signed\n");
116 SkDebugf("SkGraphics: char is unsigned\n");
118 for (i = 0; i < (int)SK_ARRAY_COUNT(gTypeSize); i++) {
119 SkDebugf("SkGraphics: sizeof(%s) = %d\n",
120 gTypeSize[i].fTypeName, gTypeSize[i].fSizeOf);
122 SkDebugf("SkGraphics: font cache limit %dK\n",
123 GetFontCacheLimit() >> 10);
129 void SkGraphics::Term() {
135 ///////////////////////////////////////////////////////////////////////////////
137 static const char kFontCacheLimitStr[] = "font-cache-limit";
138 static const size_t kFontCacheLimitLen = sizeof(kFontCacheLimitStr) - 1;
140 static const struct {
143 size_t (*fFunc)(size_t);
145 { kFontCacheLimitStr, kFontCacheLimitLen, SkGraphics::SetFontCacheLimit }
148 /* flags are of the form param; or param=value; */
149 void SkGraphics::SetFlags(const char* flags) {
153 const char* nextSemi;
155 size_t len = strlen(flags);
156 const char* paramEnd = flags + len;
157 const char* nextEqual = strchr(flags, '=');
158 if (nextEqual && paramEnd > nextEqual) {
159 paramEnd = nextEqual;
161 nextSemi = strchr(flags, ';');
162 if (nextSemi && paramEnd > nextSemi) {
165 size_t paramLen = paramEnd - flags;
166 for (int i = 0; i < (int)SK_ARRAY_COUNT(gFlags); ++i) {
167 if (paramLen != gFlags[i].fLen) {
170 if (strncmp(flags, gFlags[i].fStr, paramLen) == 0) {
173 val = (size_t) atoi(nextEqual + 1);
175 (gFlags[i].fFunc)(val);
179 flags = nextSemi + 1;