Repository: incubator-weex
Updated Branches:
  refs/heads/master ade8400f8 -> af911f780


[WEEX-122][iOS]bugfix round float pixel lead to the lack of pixel

 this action will let iOS decide whether it should draw float pixel.

Bug:122


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/c774c4df
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/c774c4df
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/c774c4df

Branch: refs/heads/master
Commit: c774c4dff285ca45c7bb865b50b718d4d3536023
Parents: 78f2312
Author: acton393 <[email protected]>
Authored: Wed Nov 15 22:40:48 2017 +0800
Committer: acton393 <[email protected]>
Committed: Wed Nov 15 22:40:48 2017 +0800

----------------------------------------------------------------------
 ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m |  5 ++++
 ios/sdk/WeexSDK/Sources/Utility/WXUtility.h   |  3 +++
 ios/sdk/WeexSDK/Sources/Utility/WXUtility.m   | 31 +++++++++++++++++-----
 3 files changed, 33 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/c774c4df/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m 
b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
index 8fc2511..3350f12 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
+++ b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
@@ -224,6 +224,11 @@ typedef enum : NSUInteger {
     if ([configCenter 
respondsToSelector:@selector(configForKey:defaultValue:isDefault:)]) {
         BOOL useCoreText = [[configCenter 
configForKey:@"iOS_weex_ext_config.text_render_useCoreText" defaultValue:@YES 
isDefault:NULL] boolValue];
         [WXTextComponent setRenderUsingCoreText:useCoreText];
+        
+        //handler pixel round
+        BOOL shouldRoudPixel = [[configCenter 
configForKey:@"iOS_weex_ext_config.utilityShouldRoundPixel" defaultValue:@(NO) 
isDefault:NULL] boolValue];
+        [WXUtility setShouldRoudPixel:shouldRoudPixel];
+        
         id sliderConfig =  [configCenter 
configForKey:@"iOS_weex_ext_config.slider_class_name" 
defaultValue:@"WXCycleSliderComponent" isDefault:NULL];
         if(sliderConfig){
             NSString *sliderClassName = [WXConvert NSString:sliderConfig];

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/c774c4df/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h 
b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h
index dfbc303..fac6a9c 100644
--- a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h
+++ b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h
@@ -460,4 +460,7 @@ BOOL WXFloatGreaterThanWithPrecision(CGFloat a,CGFloat 
b,double precision);
  */
 + (NSData *_Nonnull)base64DictToData:(NSDictionary *_Nullable)base64Dict;
 
+
++ (void)setShouldRoudPixel:(BOOL)shouldRoundPixel;
+
 @end

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/c774c4df/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m 
b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
index 621cf68..f96a68e 100644
--- a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
+++ b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
@@ -41,6 +41,8 @@
 #define KEY_PASSWORD  @"com.taobao.Weex.123456"
 #define KEY_USERNAME_PASSWORD  @"com.taobao.Weex.weex123456"
 
+static BOOL utilityShouldRoundPixel = NO;
+
 void WXPerformBlockOnMainThread(void (^ _Nonnull block)())
 {
     if (!block) return;
@@ -117,20 +119,29 @@ CGFloat WXPixelScale(CGFloat value, CGFloat scaleFactor)
 
 CGFloat WXRoundPixelValue(CGFloat value)
 {
-    CGFloat scale = WXScreenScale();
-    return round(value * scale) / scale;
+    if (utilityShouldRoundPixel) {
+        CGFloat scale = WXScreenScale();
+        return round(value * scale) / scale;
+    }
+    return value;
 }
 
 CGFloat WXCeilPixelValue(CGFloat value)
 {
-    CGFloat scale = WXScreenScale();
-    return ceil(value * scale) / scale;
+    if (utilityShouldRoundPixel) {
+        CGFloat scale = WXScreenScale();
+        return ceil(value * scale) / scale;
+    }
+    return value;
 }
 
 CGFloat WXFloorPixelValue(CGFloat value)
 {
-    CGFloat scale = WXScreenScale();
-    return floor(value * scale) / scale;
+    if (utilityShouldRoundPixel) {
+        CGFloat scale = WXScreenScale();
+        return floor(value * scale) / scale;
+    }
+    return value;
 }
 
 @implementation WXUtility
@@ -154,6 +165,14 @@ CGFloat WXFloorPixelValue(CGFloat value)
     block();
 }
 
++ (void)setShouldRoudPixel:(BOOL)shouldRoundPixel
+{
+    utilityShouldRoundPixel = shouldRoundPixel;
+}
++ (BOOL)shouldRoudPixel
+{
+    return utilityShouldRoundPixel;
+}
 
 + (NSDictionary *)getEnvironment
 {

Reply via email to