gfx/angle/src/compiler/MapLongVariableNames.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial