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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/opentype/FontSettings.cpp

Issue 2581083003: Initial OpenType Font Variations Support (Closed)
Patch Set: Fix Windows compilation by avoiding VLA Created 4 years 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "platform/fonts/opentype/FontSettings.h"
6
7 #include "wtf/StringHasher.h"
8 #include "wtf/text/AtomicStringHash.h"
9 #include "wtf/text/StringHash.h"
10
11 namespace blink {
12
13 static inline void addToHash(unsigned& hash, unsigned key) {
14 hash = ((hash << 5) + hash) + key; // Djb2
15 };
16
17 static inline void addFloatToHash(unsigned& hash, float value) {
18 addToHash(hash, StringHasher::hashMemory(&value, sizeof(value)));
19 };
20
21 unsigned FontVariationSettings::hash() const {
22 unsigned computedHash = size() ? 5381 : 0;
23 unsigned numFeatures = size();
24 for (unsigned i = 0; i < numFeatures; ++i) {
25 StringHasher stringHasher;
26 const AtomicString& tag = at(i).tag();
27 for (unsigned j = 0; j < tag.length(); j++) {
28 stringHasher.addCharacter(tag[j]);
29 }
30 addToHash(computedHash, stringHasher.hash());
31 addFloatToHash(computedHash, at(i).value());
32 }
33 return computedHash;
34 }
35
36 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698