-
Notifications
You must be signed in to change notification settings - Fork 578
Expand file tree
/
Copy pathCKTextKitRendererCache.mm
More file actions
41 lines (37 loc) · 1.69 KB
/
CKTextKitRendererCache.mm
File metadata and controls
41 lines (37 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#import <ComponentTextKit/CKTextKitRendererCache.h>
#import <ComponentKit/RCEqualityHelpers.h>
#import <ComponentKit/CKMacros.h>
namespace CK {
namespace TextKit {
void lowMemoryNotificationHandler(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
// Compaction is a relatively cheap operation and it's important that we get it done ASAP, so use the high-pri queue.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
(static_cast<ApplicationObserver *>(observer))->onLowMemory();
});
}
void enteredBackgroundNotificationHandler(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
(static_cast<ApplicationObserver *>(observer))->onEnterBackground();
}
namespace Renderer {
Key::Key(NSInteger u, CKTextKitAttributes a, CGSize cs) : userInterfaceStyle(u), attributes(a), constrainedSize(cs) {
// Precompute hash to avoid paying cost every time getHash is called.
NSUInteger subhashes[] = {
attributes.hash(),
std::hash<CGFloat>()(constrainedSize.width),
std::hash<CGFloat>()(constrainedSize.height),
std::hash<NSInteger>()(userInterfaceStyle)
};
hash = RCIntegerArrayHash(subhashes, CK_ARRAY_COUNT(subhashes));
}
}
}
}