Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2071)

Side by Side Diff: src/sksl/ir/SkSLVariable.h

Issue 2131223002: SkSL performance improvements (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/sksl/ir/SkSLVarDeclaration.h ('k') | src/sksl/ir/SkSLVariableReference.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SKSL_VARIABLE 8 #ifndef SKSL_VARIABLE
9 #define SKSL_VARIABLE 9 #define SKSL_VARIABLE
10 10
11 #include "SkSLModifiers.h" 11 #include "SkSLModifiers.h"
12 #include "SkSLPosition.h" 12 #include "SkSLPosition.h"
13 #include "SkSLSymbol.h" 13 #include "SkSLSymbol.h"
14 #include "SkSLType.h" 14 #include "SkSLType.h"
15 15
16 namespace SkSL { 16 namespace SkSL {
17 17
18 /** 18 /**
19 * Represents a variable, whether local, global, or a function parameter. This r epresents the 19 * Represents a variable, whether local, global, or a function parameter. This r epresents the
20 * variable itself (the storage location), which is shared between all VariableR eferences which 20 * variable itself (the storage location), which is shared between all VariableR eferences which
21 * read or write that storage location. 21 * read or write that storage location.
22 */ 22 */
23 struct Variable : public Symbol { 23 struct Variable : public Symbol {
24 enum Storage { 24 enum Storage {
25 kGlobal_Storage, 25 kGlobal_Storage,
26 kLocal_Storage, 26 kLocal_Storage,
27 kParameter_Storage 27 kParameter_Storage
28 }; 28 };
29 29
30 Variable(Position position, Modifiers modifiers, std::string name, std::shar ed_ptr<Type> type, 30 Variable(Position position, Modifiers modifiers, std::string name, const Typ e& type,
31 Storage storage) 31 Storage storage)
32 : INHERITED(position, kVariable_Kind, std::move(name)) 32 : INHERITED(position, kVariable_Kind, std::move(name))
33 , fModifiers(modifiers) 33 , fModifiers(modifiers)
34 , fType(type) 34 , fType(type)
35 , fStorage(storage) 35 , fStorage(storage)
36 , fIsReadFrom(false) 36 , fIsReadFrom(false)
37 , fIsWrittenTo(false) {} 37 , fIsWrittenTo(false) {}
38 38
39 virtual std::string description() const override { 39 virtual std::string description() const override {
40 return fModifiers.description() + fType->fName + " " + fName; 40 return fModifiers.description() + fType.fName + " " + fName;
41 } 41 }
42 42
43 const Modifiers fModifiers; 43 const Modifiers fModifiers;
44 const std::string fValue; 44 const Type& fType;
45 const std::shared_ptr<Type> fType;
46 const Storage fStorage; 45 const Storage fStorage;
47 46
48 mutable bool fIsReadFrom; 47 mutable bool fIsReadFrom;
49 mutable bool fIsWrittenTo; 48 mutable bool fIsWrittenTo;
50 49
51 typedef Symbol INHERITED; 50 typedef Symbol INHERITED;
52 }; 51 };
53 52
54 } // namespace SkSL 53 } // namespace SkSL
55 54
56 namespace std {
57 template <>
58 struct hash<SkSL::Variable> {
59 public :
60 size_t operator()(const SkSL::Variable &var) const{
61 return hash<std::string>()(var.fName) ^ hash<std::string>()(var.fTyp e->description());
62 }
63 };
64 } // namespace std
65
66 #endif 55 #endif
OLDNEW
« no previous file with comments | « src/sksl/ir/SkSLVarDeclaration.h ('k') | src/sksl/ir/SkSLVariableReference.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698