180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/*
380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Copyright 2006 The Android Open Source Project
480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru *
580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Use of this source code is governed by a BSD-style license that can be
680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * found in the LICENSE file.
780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */
880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkTypes.h"
1180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#if defined SK_BUILD_CONDENSED
1280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkMemberInfo.h"
1380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#if SK_USE_CONDENSED_INFO == 1
1480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#error "SK_USE_CONDENSED_INFO must be zero to build condensed info"
1580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif
1680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#if !defined SK_BUILD_FOR_WIN32
1780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#error "SK_BUILD_FOR_WIN32 must be defined to build condensed info"
1880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif
1980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkDisplayType.h"
2080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkIntArray.h"
2180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include <stdio.h>
2280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
2380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste QueruSkTDMemberInfoArray gInfos;
2480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste QueruSkTDIntArray gInfosCounts;
2580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste QueruSkTDDisplayTypesArray gInfosTypeIDs;
2680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste QueruSkTDMemberInfoArray gUnknowns;
2780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste QueruSkTDIntArray gUnknownsCounts;
2880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
2980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querustatic void AddInfo(SkDisplayTypes type, const SkMemberInfo* info, int infoCount) {
3080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkASSERT(gInfos[type] == NULL);
3180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    gInfos[type] = info;
3280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    gInfosCounts[type] = infoCount;
3380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    *gInfosTypeIDs.append() = type;
3480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    size_t allStrs = 0;
3580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    for (int inner = 0; inner < infoCount; inner++) {
3680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkASSERT(info[inner].fCount < 256);
3780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        int offset = (int) info[inner].fOffset;
3880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkASSERT(offset < 128 && offset > -129);
3980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkASSERT(allStrs < 256);
4080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        if (info[inner].fType == SkType_BaseClassInfo) {
4180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            const SkMemberInfo* innerInfo = (const SkMemberInfo*) info[inner].fName;
4280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            if (gUnknowns.find(innerInfo) == -1) {
4380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                *gUnknowns.append() = innerInfo;
4480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                *gUnknownsCounts.append() = info[inner].fCount;
4580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            }
4680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        }
4780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        if (info[inner].fType != SkType_BaseClassInfo && info[inner].fName)
4880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            allStrs += strlen(info[inner].fName);
4980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        allStrs += 1;
5080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkASSERT(info[inner].fType < 256);
5180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
5280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}
5380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
5480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querustatic void WriteInfo(FILE* condensed, const SkMemberInfo* info, int infoCount,
5580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            const char* typeName, bool draw, bool display) {
5680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    fprintf(condensed, "static const char g%sStrings[] = \n", typeName);
5780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    int inner;
5880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // write strings
5980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    for (inner = 0; inner < infoCount; inner++) {
6080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        const char* name = (info[inner].fType != SkType_BaseClassInfo && info[inner].fName) ?
6180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            info[inner].fName : "";
6280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        const char* zero = inner < infoCount - 1 ? "\\0" : "";
6380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        fprintf(condensed, "\t\"%s%s\"\n", name, zero);
6480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
6580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    fprintf(condensed, ";\n\nstatic const SkMemberInfo g%s", draw ? "Draw" : display ? "Display" : "");
6680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    fprintf(condensed, "%sInfo[] = {", typeName);
6780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    size_t nameOffset = 0;
6880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // write info tables
6980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    for (inner = 0; inner < infoCount; inner++) {
7080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        size_t offset = info[inner].fOffset;
7180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        if (info[inner].fType == SkType_BaseClassInfo) {
7280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            offset = (size_t) gInfos.find((const SkMemberInfo* ) info[inner].fName);
7380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            SkASSERT((int) offset >= 0);
7480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            offset = gInfosTypeIDs.find((SkDisplayTypes) offset);
7580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            SkASSERT((int) offset >= 0);
7680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        }
7780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        fprintf(condensed, "\n\t{%d, %d, %d, %d}", nameOffset, offset,
7880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            info[inner].fType, info[inner].fCount);
7980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        if (inner < infoCount - 1)
8080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            putc(',', condensed);
8180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        if (info[inner].fType != SkType_BaseClassInfo && info[inner].fName)
8280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            nameOffset += strlen(info[inner].fName);
8380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        nameOffset += 1;
8480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
8580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    fprintf(condensed, "\n};\n\n");
8680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}
8780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
8880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querustatic void Get3DName(char* scratch, const char* name) {
8980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    if (strncmp("skia3d:", name, sizeof("skia3d:") - 1) == 0) {
9080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        strcpy(scratch, "3D_");
9180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        scratch[3]= name[7] & ~0x20;
9280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        strcpy(&scratch[4], &name[8]);
9380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    } else {
9480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        scratch[0] = name[0] & ~0x20;
9580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        strcpy(&scratch[1], &name[1]);
9680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
9780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}
9880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
9980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruint type_compare(const void* a, const void* b) {
10080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkDisplayTypes first = *(SkDisplayTypes*) a;
10180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkDisplayTypes second = *(SkDisplayTypes*) b;
10280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    return first < second ? -1 : first == second ? 0 : 1;
10380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}
10480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
10580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruvoid SkDisplayType::BuildCondensedInfo(SkAnimateMaker* maker) {
10680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    gInfos.setCount(kNumberOfTypes);
10780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    memset(gInfos.begin(), 0, sizeof(gInfos[0]) * kNumberOfTypes);
10880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    gInfosCounts.setCount(kNumberOfTypes);
10980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    memset(gInfosCounts.begin(), -1, sizeof(gInfosCounts[0]) * kNumberOfTypes);
11080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // check to see if it is condensable
11180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    int index, infoCount;
11280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    for (index = 0; index < kTypeNamesSize; index++) {
11380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        const SkMemberInfo* info = GetMembers(maker, gTypeNames[index].fType, &infoCount);
11480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        if (info == NULL)
11580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            continue;
11680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        AddInfo(gTypeNames[index].fType, info, infoCount);
11780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
11880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    const SkMemberInfo* extraInfo =
11980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkDisplayType::GetMembers(maker, SkType_3D_Point, &infoCount);
12080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    AddInfo(SkType_Point, extraInfo, infoCount);
12180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    AddInfo(SkType_3D_Point, extraInfo, infoCount);
12280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru//  int baseInfos = gInfos.count();
12380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    do {
12480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkTDMemberInfoArray oldRefs = gUnknowns;
12580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkTDIntArray oldRefCounts = gUnknownsCounts;
12680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        gUnknowns.reset();
12780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        gUnknownsCounts.reset();
12880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        for (index = 0; index < oldRefs.count(); index++) {
12980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            const SkMemberInfo* info = oldRefs[index];
13080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            if (gInfos.find(info) == -1) {
13180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                int typeIndex = 0;
13280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                for (; typeIndex < kNumberOfTypes; typeIndex++) {
13380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                    const SkMemberInfo* temp = SkDisplayType::GetMembers(
13480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                        maker, (SkDisplayTypes) typeIndex, NULL);
13580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                    if (temp == info)
13680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                        break;
13780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                }
13880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                SkASSERT(typeIndex < kNumberOfTypes);
13980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                AddInfo((SkDisplayTypes) typeIndex, info, oldRefCounts[index]);
14080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            }
14180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        }
14280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    } while (gUnknowns.count() > 0);
14380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    qsort(gInfosTypeIDs.begin(), gInfosTypeIDs.count(), sizeof(gInfosTypeIDs[0]), &type_compare);
14480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifdef SK_DEBUG
14580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    FILE* condensed = fopen("../../src/animator/SkCondensedDebug.cpp", "w+");
14680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    fprintf(condensed, "#include \"SkTypes.h\"\n");
14780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    fprintf(condensed, "#ifdef SK_DEBUG\n");
14880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#else
14980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    FILE* condensed = fopen("../../src/animator/SkCondensedRelease.cpp", "w+");
15080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    fprintf(condensed, "#include \"SkTypes.h\"\n");
15180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    fprintf(condensed, "#ifdef SK_RELEASE\n");
15280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif
15380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // write header
15480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    fprintf(condensed, "// This file was automatically generated.\n");
15580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    fprintf(condensed, "// To change it, edit the file with the matching debug info.\n");
15680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    fprintf(condensed, "// Then execute SkDisplayType::BuildCondensedInfo() to "
15780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        "regenerate this file.\n\n");
15880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // write name of memberInfo
15980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    int typeNameIndex = 0;
16080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    int unknown = 1;
16180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    for (index = 0; index < gInfos.count(); index++) {
16280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        const SkMemberInfo* info = gInfos[index];
16380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        if (info == NULL)
16480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            continue;
16580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        char scratch[64];
16680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        bool drawPrefix, displayPrefix;
16780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        while (gTypeNames[typeNameIndex].fType < index)
16880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            typeNameIndex++;
16980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        if (gTypeNames[typeNameIndex].fType == index) {
17080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            Get3DName(scratch, gTypeNames[typeNameIndex].fName);
17180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            drawPrefix = gTypeNames[typeNameIndex].fDrawPrefix;
17280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            displayPrefix = gTypeNames[typeNameIndex].fDisplayPrefix;
17380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        } else {
17480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            sprintf(scratch, "Unknown%d", unknown++);
17580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            drawPrefix = displayPrefix = false;
17680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        }
17780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        WriteInfo(condensed, info, gInfosCounts[index], scratch, drawPrefix, displayPrefix);
17880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
17980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // write array of table pointers
18080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru//  start here;
18180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    fprintf(condensed, "static const SkMemberInfo* const gInfoTables[] = {");
18280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    typeNameIndex = 0;
18380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    unknown = 1;
18480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    for (index = 0; index < gInfos.count(); index++) {
18580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        const SkMemberInfo* info = gInfos[index];
18680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        if (info == NULL)
18780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            continue;
18880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        char scratch[64];
18980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        bool drawPrefix, displayPrefix;
19080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        while (gTypeNames[typeNameIndex].fType < index)
19180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            typeNameIndex++;
19280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        if (gTypeNames[typeNameIndex].fType == index) {
19380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            Get3DName(scratch, gTypeNames[typeNameIndex].fName);
19480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            drawPrefix = gTypeNames[typeNameIndex].fDrawPrefix;
19580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            displayPrefix = gTypeNames[typeNameIndex].fDisplayPrefix;
19680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        } else {
19780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            sprintf(scratch, "Unknown%d", unknown++);
19880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            drawPrefix = displayPrefix = false;
19980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        }
20080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        fprintf(condensed, "\n\tg");
20180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        if (drawPrefix)
20280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            fprintf(condensed, "Draw");
20380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        if (displayPrefix)
20480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            fprintf(condensed, "Display");
20580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        fprintf(condensed, "%sInfo", scratch);
20680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        if (index < gInfos.count() - 1)
20780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                putc(',', condensed);
20880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
20980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    fprintf(condensed, "\n};\n\n");
21080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // write the array of number of entries in the info table
21180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    fprintf(condensed, "static const unsigned char gInfoCounts[] = {\n\t");
21280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    int written = 0;
21380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    for (index = 0; index < gInfosCounts.count(); index++) {
21480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        int count = gInfosCounts[index];
21580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        if (count < 0)
21680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            continue;
21780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        if (written > 0)
21880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            putc(',', condensed);
21980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        if (written % 20 == 19)
22080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            fprintf(condensed, "\n\t");
22180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        fprintf(condensed, "%d",count);
22280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        written++;
22380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
22480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    fprintf(condensed, "\n};\n\n");
22580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // write array of type ids table entries correspond to
22680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    fprintf(condensed, "static const unsigned char gTypeIDs[] = {\n\t");
22780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    int typeIDCount = 0;
22880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    typeNameIndex = 0;
22980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    unknown = 1;
23080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    for (index = 0; index < gInfosCounts.count(); index++) {
23180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        const SkMemberInfo* info = gInfos[index];
23280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        if (info == NULL)
23380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            continue;
23480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        typeIDCount++;
23580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        char scratch[64];
23680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        while (gTypeNames[typeNameIndex].fType < index)
23780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            typeNameIndex++;
23880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        if (gTypeNames[typeNameIndex].fType == index) {
23980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            Get3DName(scratch, gTypeNames[typeNameIndex].fName);
24080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        } else
24180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            sprintf(scratch, "Unknown%d", unknown++);
24280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        fprintf(condensed, "%d%c // %s\n\t", index,
24380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            index < gInfosCounts.count() ? ',' : ' ', scratch);
24480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
24580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    fprintf(condensed, "\n};\n\n");
24680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    fprintf(condensed, "static const int kTypeIDs = %d;\n\n", typeIDCount);
24780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // write the array of string pointers
24880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    fprintf(condensed, "static const char* const gInfoNames[] = {");
24980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    typeNameIndex = 0;
25080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    unknown = 1;
25180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    written = 0;
25280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    for (index = 0; index < gInfosCounts.count(); index++) {
25380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        const SkMemberInfo* info = gInfos[index];
25480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        if (info == NULL)
25580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            continue;
25680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        if (written > 0)
25780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                putc(',', condensed);
25880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        written++;
25980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        fprintf(condensed, "\n\tg");
26080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        char scratch[64];
26180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        while (gTypeNames[typeNameIndex].fType < index)
26280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            typeNameIndex++;
26380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        if (gTypeNames[typeNameIndex].fType == index) {
26480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            Get3DName(scratch, gTypeNames[typeNameIndex].fName);
26580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        } else
26680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            sprintf(scratch, "Unknown%d", unknown++);
26780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        fprintf(condensed, "%sStrings", scratch);
26880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
26980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    fprintf(condensed, "\n};\n\n");
27080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    fprintf(condensed, "#endif\n");
27180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    fclose(condensed);
27280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    gInfos.reset();
27380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    gInfosCounts.reset();
27480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    gInfosTypeIDs.reset();
27580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    gUnknowns.reset();
27680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    gUnknownsCounts.reset();
27780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}
27880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
27980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#elif defined SK_DEBUG
28080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkDisplayType.h"
28180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruvoid SkDisplayType::BuildCondensedInfo(SkAnimateMaker* ) {}
28280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif
283