You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ac...@apache.org on 2017/07/03 07:46:20 UTC
[1/2] incubator-weex git commit: * [ios] add mutex for text
attributedString and coreText framesetter
Repository: incubator-weex
Updated Branches:
refs/heads/0.15-dev 22a338ee6 -> 2552f7ff3
* [ios] add mutex for text attributedString and coreText framesetter
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/a82e521a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/a82e521a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/a82e521a
Branch: refs/heads/0.15-dev
Commit: a82e521a519d4d5377828d55eed951bf6284cf24
Parents: e0704ae
Author: acton393 <zh...@gmail.com>
Authored: Mon Jul 3 15:15:07 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Mon Jul 3 15:15:07 2017 +0800
----------------------------------------------------------------------
ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/a82e521a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
index 6cbe8e0..a092019 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
@@ -120,6 +120,10 @@ CGFloat WXTextDefaultLineThroughWidth = 1.2;
BOOL _needsRemoveObserver;
NSAttributedString * _ctAttributedString;
CTFramesetterRef _ctframeSetter;
+
+ pthread_mutex_t _ctFrameSetterMutex;
+ pthread_mutex_t _ctAttributedStringMutex;
+ pthread_mutexattr_t _propertMutexAttr;
}
+ (void)setRenderUsingCoreText:(BOOL)usingCoreText
@@ -143,6 +147,11 @@ CGFloat WXTextDefaultLineThroughWidth = 1.2;
if (self) {
// just for coretext and textkit render replacement
_needsRemoveObserver = NO;
+ pthread_mutexattr_init(&(_propertMutexAttr));
+ pthread_mutexattr_settype(&(_propertMutexAttr), PTHREAD_MUTEX_RECURSIVE);
+ pthread_mutex_init(&(_ctFrameSetterMutex), &(_propertMutexAttr));
+ pthread_mutex_init(&(_ctAttributedStringMutex), &(_propertMutexAttr));
+
if ([attributes objectForKey:@"coretext"]) {
_useCoreTextAttr = [WXConvert NSString:attributes[@"coretext"]];
} else {
@@ -181,6 +190,9 @@ CGFloat WXTextDefaultLineThroughWidth = 1.2;
CFRelease(_ctframeSetter);
_ctframeSetter = NULL;
}
+ pthread_mutex_destroy(&_ctAttributedStringMutex);
+ pthread_mutex_destroy(&_ctFrameSetterMutex);
+ pthread_mutexattr_destroy(&_propertMutexAttr);
}
#define WX_STYLE_FILL_TEXT(key, prop, type, needLayout)\
@@ -348,17 +360,21 @@ do {\
- (NSAttributedString *)ctAttributedString
{
+ pthread_mutex_lock(&(_ctAttributedStringMutex));
if (!_ctAttributedString) {
_ctAttributedString = [[self buildCTAttributeString] copy];
}
+ pthread_mutex_unlock(&(_ctAttributedStringMutex));
return [_ctAttributedString copy];
}
- (CTFramesetterRef)ctFramesetterRef
{
+ pthread_mutex_lock(&(_ctFrameSetterMutex));
if (NULL == _ctframeSetter) {
_ctframeSetter = CTFramesetterCreateWithAttributedString((CFTypeRef)[self ctAttributedString]);
}
+ pthread_mutex_unlock(&(_ctFrameSetterMutex));
return _ctframeSetter;
}
[2/2] incubator-weex git commit: Merge branch
'ios-feature-0.15-text-lock' of https://github.com/acton393/incubator-weex
into wip-us-0.15-dev
Posted by ac...@apache.org.
Merge branch 'ios-feature-0.15-text-lock' of https://github.com/acton393/incubator-weex into wip-us-0.15-dev
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/2552f7ff
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/2552f7ff
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/2552f7ff
Branch: refs/heads/0.15-dev
Commit: 2552f7ff33db86913209e6ccf2332d22fc6c3157
Parents: 22a338e a82e521
Author: acton393 <zh...@gmail.com>
Authored: Mon Jul 3 15:45:47 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Mon Jul 3 15:45:47 2017 +0800
----------------------------------------------------------------------
ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
----------------------------------------------------------------------