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

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: minor fixes 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
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 std::string fValue;
dogben 2016/07/08 19:56:40 nit: unused?
45 const std::shared_ptr<Type> fType; 45 const Type& fType;
46 const Storage fStorage; 46 const Storage fStorage;
47 47
48 mutable bool fIsReadFrom; 48 mutable bool fIsReadFrom;
49 mutable bool fIsWrittenTo; 49 mutable bool fIsWrittenTo;
50 50
51 typedef Symbol INHERITED; 51 typedef Symbol INHERITED;
52 }; 52 };
53 53
54 } // namespace SkSL 54 } // namespace SkSL
55 55
56 namespace std { 56 namespace std {
57 template <> 57 template <>
58 struct hash<SkSL::Variable> { 58 struct hash<SkSL::Variable> {
dogben 2016/07/08 19:56:40 (Not exactly related to this CL, but...) Is this u
59 public : 59 public :
60 size_t operator()(const SkSL::Variable &var) const{ 60 size_t operator()(const SkSL::Variable &var) const{
61 return hash<std::string>()(var.fName) ^ hash<std::string>()(var.fTyp e->description()); 61 return hash<std::string>()(var.fName) ^ hash<std::string>()(var.fTyp e.description());
62 } 62 }
63 }; 63 };
64 } // namespace std 64 } // namespace std
65 65
66 #endif 66 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698