Wed, 31 Dec 2014 07:16:47 +0100
Revert simplistic fix pending revisit of Mozilla integration attempt.
1 //
2 // Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
7 #ifndef COMPILER_MAP_LONG_VARIABLE_NAMES_H_
8 #define COMPILER_MAP_LONG_VARIABLE_NAMES_H_
10 #include "GLSLANG/ShaderLang.h"
12 #include "compiler/intermediate.h"
13 #include "compiler/VariableInfo.h"
15 // This size does not include '\0' in the end.
16 #define MAX_SHORTENED_IDENTIFIER_SIZE 32
18 // This is a ref-counted singleton. GetInstance() returns a pointer to the
19 // singleton, and after use, call Release(). GetInstance() and Release() should
20 // be paired.
21 class LongNameMap {
22 public:
23 static LongNameMap* GetInstance();
24 void Release();
26 // Return the mapped name if <originalName, mappedName> is in the map;
27 // otherwise, return NULL.
28 const char* Find(const char* originalName) const;
30 // Insert a pair into the map.
31 void Insert(const char* originalName, const char* mappedName);
33 // Return the number of entries in the map.
34 size_t Size() const;
36 private:
37 LongNameMap();
38 ~LongNameMap();
40 size_t refCount;
41 std::map<std::string, std::string> mLongNameMap;
42 };
44 // Traverses intermediate tree to map attributes and uniforms names that are
45 // longer than MAX_SHORTENED_IDENTIFIER_SIZE to MAX_SHORTENED_IDENTIFIER_SIZE.
46 class MapLongVariableNames : public TIntermTraverser {
47 public:
48 MapLongVariableNames(LongNameMap* globalMap);
50 virtual void visitSymbol(TIntermSymbol*);
51 virtual bool visitLoop(Visit, TIntermLoop*);
53 private:
54 TString mapGlobalLongName(const TString& name);
56 LongNameMap* mGlobalMap;
57 };
59 #endif // COMPILER_MAP_LONG_VARIABLE_NAMES_H_