You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by cx...@apache.org on 2017/04/10 05:53:51 UTC

[01/15] incubator-weex git commit: Merge remote-tracking branch 'upstream/0.12-dev' into ios-feature-composite

Repository: incubator-weex
Updated Branches:
  refs/heads/0.12-dev 68b2b5710 -> 219cd30a5


Merge remote-tracking branch 'upstream/0.12-dev' into ios-feature-composite


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

Branch: refs/heads/0.12-dev
Commit: 5312427202b1fffd034bbe41409fa10433c12dd3
Parents: 5445c92 247e732
Author: \u9690\u98ce <cx...@apache.org>
Authored: Fri Mar 31 16:45:57 2017 +0800
Committer: \u9690\u98ce <cx...@apache.org>
Committed: Fri Mar 31 16:45:57 2017 +0800

----------------------------------------------------------------------
 .eslintrc                                       |   5 +-
 README.md                                       |  50 +--
 android/commons/build.gradle                    |   3 +-
 .../weex/commons/AbstractWeexActivity.java      |  24 ++
 android/playground/app/build.gradle             |   3 +-
 .../playground/app/src/main/assets/animation.js |  11 +-
 .../app/src/main/assets/component/a-demo.js     |  11 +-
 .../src/main/assets/component/countdown-demo.js |  11 +-
 .../app/src/main/assets/component/image-demo.js |  11 +-
 .../app/src/main/assets/component/input-demo.js |  11 +-
 .../main/assets/component/list/list-basic.js    |   8 +
 .../assets/component/list/list-demo-horizon.js  |   8 +
 .../src/main/assets/component/list/list-demo.js |   8 +
 .../src/main/assets/component/marquee-demo.js   |  11 +-
 .../src/main/assets/component/navigator-demo.js |  15 +-
 .../main/assets/component/process-bar-demo.js   |  11 +-
 .../src/main/assets/component/scroller-demo.js  |  11 +-
 .../slider-neighbor/slider-neighbor-item.js     |   8 +
 .../slider-neighbor/slider-neighbor-page.js     |   8 +
 .../src/main/assets/component/slider/index.js   |  11 +-
 .../main/assets/component/slider/slider-item.js |   8 +
 .../main/assets/component/slider/slider-page.js |   8 +
 .../main/assets/component/tabbar/tabbar-demo.js |  15 +-
 .../main/assets/component/tabbar/tabbar-item.js |   8 +
 .../app/src/main/assets/component/text-demo.js  |  11 +-
 .../app/src/main/assets/component/video-demo.js |  11 +-
 .../app/src/main/assets/component/web-demo.js   |  11 +-
 android/playground/app/src/main/assets/hello.js |   8 +
 .../playground/app/src/main/assets/iconfont.js  |   8 +
 .../app/src/main/assets/module/clipboard.js     |  11 +-
 .../java/com/alibaba/weex/IndexActivity.java    |   6 +
 .../java/com/alibaba/weex/WXApplication.java    |   4 +
 .../extend/WXInstanceStatisticsListener.java    | 268 +++++++++++++++++
 android/sdk/build.gradle                        |   2 +
 android/sdk/libs/armeabi/libweexv8.so           | Bin 3583820 -> 3563544 bytes
 android/sdk/libs/x86/libweexv8.so               | Bin 4336768 -> 4545544 bytes
 .../com/taobao/weex/IWXStatisticsListener.java  | 252 ++++++++++++++++
 .../main/java/com/taobao/weex/InitConfig.java   |  14 +
 .../java/com/taobao/weex/WXEnvironment.java     |  18 ++
 .../main/java/com/taobao/weex/WXSDKEngine.java  |   5 +-
 .../java/com/taobao/weex/WXSDKInstance.java     |  65 +++-
 .../main/java/com/taobao/weex/WXSDKManager.java |  79 ++++-
 .../taobao/weex/adapter/IWXSoLoaderAdapter.java | 236 +++++++++++++++
 .../java/com/taobao/weex/bridge/WXBridge.java   |   6 +
 .../com/taobao/weex/bridge/WXBridgeManager.java |  59 +++-
 .../java/com/taobao/weex/bridge/WXParams.java   |  13 +
 .../java/com/taobao/weex/common/Constants.java  |   8 +
 .../java/com/taobao/weex/common/IWXBridge.java  |   7 +
 .../taobao/weex/common/WXJSBridgeMsgType.java   |   1 +
 .../taobao/weex/ui/IExternalMoudleGetter.java   | 215 +++++++++++++
 .../java/com/taobao/weex/utils/OsVersion.java   | 233 ++++++++++++++
 .../main/java/com/taobao/weex/utils/Trace.java  | 301 +++++++++++++++++++
 .../taobao/weex/utils/WXSoInstallMgrSdk.java    |  51 +++-
 .../java/com/taobao/weex/utils/WXUtils.java     |  84 +++++-
 .../taobao/weex/bridge/WXWebsocketBridge.java   |   3 +
 build/build.js                                  |   2 +
 build/examples-banner-plugin.js                 |  65 ++++
 build/webpack.examples.config.js                |   3 +-
 html5/frameworks/legacy/app/ctrl/init.js        |  55 +++-
 html5/frameworks/legacy/static/create.js        |   5 +-
 html5/frameworks/legacy/static/life.js          |  17 ++
 .../Sources/Manager/WXComponentManager.m        |   4 +-
 62 files changed, 2327 insertions(+), 92 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/53124272/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m
----------------------------------------------------------------------


[02/15] incubator-weex git commit: Merge remote-tracking branch 'upstream/0.12-dev' into ios-feature-composite

Posted by cx...@apache.org.
Merge remote-tracking branch 'upstream/0.12-dev' into ios-feature-composite


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

Branch: refs/heads/0.12-dev
Commit: 82412d7a6782a178ac45cada69aa7ce184fa06ae
Parents: 5312427 d240048
Author: \u9690\u98ce <cx...@apache.org>
Authored: Wed Apr 5 14:38:19 2017 +0800
Committer: \u9690\u98ce <cx...@apache.org>
Committed: Wed Apr 5 14:38:19 2017 +0800

----------------------------------------------------------------------
 .eslintrc                                       |   13 +-
 .flowconfig                                     |   16 +
 .../src/main/java/com/alibaba/weex/Utility.java |  277 +
 .../java/com/alibaba/weex/WXPageActivity.java   |   58 +
 .../app/src/main/res/layout/id_stub.xml         |   57 +
 .../java/com/taobao/weex/WXSDKInstance.java     |   12 +-
 .../taobao/weex/ui/component/WXComponent.java   |    7 +-
 .../com/taobao/weex/ui/component/WXImage.java   |    6 +
 bin/dist-vue.sh                                 |   42 +
 build/config.js                                 |    9 +-
 build/karma.vue.conf.js                         |   64 +-
 build/webpack.examples.web.config.js            |   24 +-
 dangerfile.js                                   |   30 +
 examples/vue/animation.vue                      |    4 +-
 examples/vue/components/countdown.vue           |    2 +-
 examples/vue/components/image.vue               |    2 +-
 examples/vue/components/list.vue                |   19 +-
 examples/vue/components/marquee.vue             |    3 +-
 examples/vue/components/navigator.vue           |    7 +-
 examples/vue/components/scroller.vue            |   34 +-
 examples/vue/components/slider.vue              |   22 +-
 examples/vue/components/text.vue                |    2 +-
 examples/vue/components/textarea.vue            |   57 +
 examples/vue/components/video.vue               |    2 +-
 examples/vue/components/web.vue                 |    2 +-
 examples/vue/iconfont.vue                       |    2 +-
 examples/vue/include/base-url.js                |    4 +-
 examples/vue/include/button.vue                 |    2 +-
 examples/vue/include/countdown.vue              |    2 +-
 examples/vue/include/example-list-item.vue      |    2 +-
 examples/vue/include/example-list.vue           |    2 +-
 examples/vue/include/h1.vue                     |    2 +-
 examples/vue/include/h2.vue                     |    2 +-
 examples/vue/include/h3.vue                     |    2 +-
 examples/vue/include/hn.vue                     |    2 +-
 examples/vue/include/list-item.vue              |    2 +-
 examples/vue/include/marquee.vue                |    4 +-
 examples/vue/include/navbar.vue                 |    2 +-
 examples/vue/include/navpage.vue                |    2 +-
 examples/vue/include/panel.vue                  |   10 +-
 examples/vue/include/slider-item.vue            |    2 +-
 examples/vue/include/slider-page.vue            |    5 +-
 examples/vue/include/tabbar.vue                 |    6 +-
 examples/vue/include/tabitem.vue                |    2 +-
 examples/vue/include/tip.vue                    |    2 +-
 examples/vue/include/wxc-list-item.vue          |    2 +-
 examples/vue/modules/stream.vue                 |    2 +-
 examples/vue/showcase/calculator.vue            |    2 +-
 examples/vue/showcase/include/banners.vue       |    4 +-
 examples/vue/showcase/include/brand.vue         |    2 +-
 examples/vue/showcase/include/category.vue      |    8 +-
 examples/vue/showcase/include/coupon.vue        |    2 +-
 examples/vue/showcase/include/goods.vue         |    4 +-
 examples/vue/showcase/include/headlines.vue     |    2 +-
 examples/vue/showcase/include/match.vue         |    4 +-
 examples/vue/showcase/include/resource.vue      |    2 +-
 examples/vue/showcase/include/scene.vue         |    4 +-
 examples/vue/showcase/itemlist.vue              |  246 +-
 examples/vue/showcase/new-fashion.vue           |    2 +-
 examples/vue/style/index.vue                    |    2 +-
 examples/vue/style/style-box.vue                |    2 +-
 examples/vue/style/style-flex.vue               |    2 +-
 examples/vue/style/style-item.vue               |    2 +-
 examples/vue/syntax/hello-world-3.vue           |    4 +-
 examples/vue/syntax/hello-world-4.vue           |    4 +-
 examples/vue/syntax/hello-world-5.vue           |    4 +-
 examples/vue/syntax/hello-world.vue             |    4 +-
 examples/vue/syntax/include/btn.vue             |    2 +-
 examples/vue/syntax/include/sub.vue             |    2 +-
 examples/vue/syntax/script-component.vue        |    2 +-
 examples/vue/syntax/script-data.vue             |    2 +-
 examples/vue/syntax/script-events.vue           |    4 +-
 examples/vue/syntax/script-instance.vue         |    2 +-
 examples/vue/syntax/script-lifecycle.vue        |    4 +-
 examples/vue/syntax/script-module.vue           |    2 +-
 examples/vue/syntax/script-options.vue          |    2 +-
 examples/vue/syntax/template-class.vue          |    2 +-
 examples/vue/syntax/template-event.vue          |    2 +-
 examples/vue/syntax/template-if.vue             |    2 +-
 examples/vue/syntax/template-repeat-update.vue  |    2 +-
 examples/vue/syntax/template-repeat.vue         |    8 +-
 flow-typed/npm/animationjs_vx.x.x.js            |   60 +
 flow-typed/npm/babel-core_vx.x.x.js             |  227 +
 flow-typed/npm/babel-eslint_vx.x.x.js           |   73 +
 flow-typed/npm/babel-istanbul_vx.x.x.js         |  353 +
 flow-typed/npm/babel-loader_vx.x.x.js           |   67 +
 flow-typed/npm/babel-plugin-coverage_vx.x.x.js  |   32 +
 flow-typed/npm/babel-preset-es2015_vx.x.x.js    |   32 +
 flow-typed/npm/babel-runtime_vx.x.x.js          | 1691 ++++
 flow-typed/npm/chai_v3.5.x.js                   |  212 +
 flow-typed/npm/chromedriver_vx.x.x.js           |   46 +
 flow-typed/npm/core-js_vx.x.x.js                | 9390 ++++++++++++++++++
 flow-typed/npm/cross-spawn_vx.x.x.js            |   59 +
 flow-typed/npm/css-loader_vx.x.x.js             |   87 +
 flow-typed/npm/cubicbezier_vx.x.x.js            |  109 +
 flow-typed/npm/danger_vx.x.x.js                 |  284 +
 flow-typed/npm/envd_vx.x.x.js                   |  109 +
 flow-typed/npm/eslint-plugin-flowtype_vx.x.x.js |  319 +
 flow-typed/npm/eslint_vx.x.x.js                 | 1978 ++++
 flow-typed/npm/flow-bin_v0.x.x.js               |    6 +
 flow-typed/npm/fs-extra_vx.x.x.js               |  221 +
 flow-typed/npm/http-server_vx.x.x.js            |   39 +
 flow-typed/npm/httpurl_vx.x.x.js                |   67 +
 flow-typed/npm/inline-style-prefixer_vx.x.x.js  |  347 +
 flow-typed/npm/json-loader_vx.x.x.js            |   33 +
 flow-typed/npm/karma-coverage_vx.x.x.js         |   81 +
 flow-typed/npm/karma-mocha-reporter_vx.x.x.js   |   38 +
 flow-typed/npm/karma-mocha_vx.x.x.js            |   53 +
 .../npm/karma-phantomjs-launcher_vx.x.x.js      |   59 +
 flow-typed/npm/karma-sourcemap-loader_vx.x.x.js |   33 +
 flow-typed/npm/karma-webpack_vx.x.x.js          |   45 +
 flow-typed/npm/karma_vx.x.x.js                  |  445 +
 flow-typed/npm/lazyimg_vx.x.x.js                |   32 +
 flow-typed/npm/macaca-cli_vx.x.x.js             |  123 +
 flow-typed/npm/macaca-utils_vx.x.x.js           |   39 +
 flow-typed/npm/mocha_v2.4.x.js                  |   25 +
 flow-typed/npm/modals_vx.x.x.js                 |   81 +
 flow-typed/npm/nightwatch_vx.x.x.js             |  633 ++
 flow-typed/npm/phantomjs-prebuilt_vx.x.x.js     |  389 +
 flow-typed/npm/query-string_vx.x.x.js           |   33 +
 flow-typed/npm/reify_vx.x.x.js                  |   95 +
 flow-typed/npm/rollup-plugin-buble_vx.x.x.js    |   39 +
 flow-typed/npm/rollup-plugin-commonjs_vx.x.x.js |   81 +
 flow-typed/npm/rollup-plugin-eslint_vx.x.x.js   |   39 +
 .../rollup-plugin-flow-no-whitespace_vx.x.x.js  |   33 +
 flow-typed/npm/rollup-plugin-flow_vx.x.x.js     |   33 +
 flow-typed/npm/rollup-plugin-json_vx.x.x.js     |   46 +
 .../npm/rollup-plugin-node-resolve_vx.x.x.js    |   53 +
 flow-typed/npm/rollup-plugin-postcss_vx.x.x.js  |   38 +
 flow-typed/npm/rollup-plugin-replace_vx.x.x.js  |   46 +
 flow-typed/npm/rollup-plugin-uglify_vx.x.x.js   |   32 +
 flow-typed/npm/rollup-watch_vx.x.x.js           |   67 +
 flow-typed/npm/rollup_vx.x.x.js                 |   46 +
 flow-typed/npm/scroll-to_vx.x.x.js              |   33 +
 flow-typed/npm/selenium-server_vx.x.x.js        |   39 +
 flow-typed/npm/semver_v5.1.x.js                 |   81 +
 flow-typed/npm/serve_vx.x.x.js                  |   18 +
 flow-typed/npm/sinon-chai_vx.x.x.js             |   32 +
 flow-typed/npm/sinon_vx.x.x.js                  |  263 +
 flow-typed/npm/uglify-js_vx.x.x.js              |  116 +
 flow-typed/npm/vue-loader_vx.x.x.js             |  122 +
 flow-typed/npm/vue-template-compiler_vx.x.x.js  |   38 +
 flow-typed/npm/vue_vx.x.x.js                    | 1089 ++
 flow-typed/npm/webdriver-client_vx.x.x.js       |  129 +
 flow-typed/npm/webpack_vx.x.x.js                | 1523 +++
 flow-typed/npm/weex-components_vx.x.x.js        |   33 +
 flow-typed/npm/weex-loader_vx.x.x.js            |  108 +
 flow-typed/npm/weex-picker_vx.x.x.js            |   81 +
 flow-typed/npm/weex-rax-framework_vx.x.x.js     |  165 +
 flow-typed/npm/weex-styler_vx.x.x.js            |   66 +
 flow-typed/npm/weex-vdom-tester_vx.x.x.js       |  108 +
 flow-typed/npm/weex-vue-framework_vx.x.x.js     |   33 +
 flow-typed/npm/weex-wd_vx.x.x.js                |   38 +
 flow-typed/npm/wwp_vx.x.x.js                    |   39 +
 flow-typed/npm/xml2map_vx.x.x.js                |   45 +
 html5/render/browser/extend/api/stream.js       |    2 +-
 html5/render/browser/extend/components/input.js |   33 +
 .../browser/extend/components/textarea.js       |   32 +
 html5/render/browser/utils/index.js             |    9 +
 html5/render/vue/README.md                      |   51 +-
 html5/render/vue/components/a.js                |   18 +-
 html5/render/vue/components/div.js              |   25 +-
 html5/render/vue/components/image.js            |   81 +-
 html5/render/vue/components/index.js            |    9 +-
 html5/render/vue/components/input.js            |   31 +-
 .../render/vue/components/scrollable/header.js  |   40 +-
 .../vue/components/scrollable/list/cell.js      |   15 +-
 .../vue/components/scrollable/list/index.js     |   32 +-
 .../vue/components/scrollable/list/listMixin.js |  118 +-
 .../components/scrollable/loading-indicator.js  |    3 +-
 .../render/vue/components/scrollable/loading.js |   55 +-
 .../render/vue/components/scrollable/refresh.js |   64 +-
 .../vue/components/scrollable/scroller.js       |   30 +-
 .../render/vue/components/scrollable/shared.js  |   22 -
 html5/render/vue/components/slider/index.js     |   40 +-
 html5/render/vue/components/slider/indicator.js |  115 +-
 .../render/vue/components/slider/slideMixin.js  |  141 +-
 html5/render/vue/components/switch.js           |   11 +-
 html5/render/vue/components/text.js             |   45 +-
 html5/render/vue/components/textarea.js         |   29 +-
 html5/render/vue/components/video.js            |   14 +-
 html5/render/vue/components/web.js              |   19 +-
 html5/render/vue/env/WXEnvironment.js           |   39 -
 html5/render/vue/env/index.js                   |   17 +-
 html5/render/vue/env/viewport.js                |   56 +-
 html5/render/vue/env/weex.js                    |   30 +-
 html5/render/vue/env/wx-env.js                  |   48 +
 html5/render/vue/index.js                       |   64 +-
 html5/render/vue/mixins/base.js                 |  110 +-
 html5/render/vue/mixins/event.js                |   76 -
 html5/render/vue/mixins/index.js                |    8 +-
 html5/render/vue/mixins/input-common.js         |   47 +
 html5/render/vue/mixins/scrollable.js           |  110 +
 html5/render/vue/mixins/style.js                |  265 +-
 html5/render/vue/modules/dom.js                 |   69 +-
 html5/render/vue/modules/index.js               |   42 +-
 html5/render/vue/styles/components.css          |  225 +-
 html5/render/vue/styles/reset.css               |   44 +-
 html5/render/vue/utils/component.js             |   83 +-
 html5/render/vue/utils/event.js                 |   91 +-
 html5/render/vue/utils/func.js                  |   81 +-
 html5/render/vue/utils/index.js                 |   55 +-
 html5/render/vue/utils/lazyload.js              |  102 +
 html5/render/vue/utils/perf.js                  |  170 +
 html5/render/vue/utils/style.js                 |   21 +
 html5/render/vue/utils/type.js                  |   20 +
 html5/test/render/index.js                      |    3 -
 html5/test/render/vue/components/a.js           |   38 +
 html5/test/render/vue/components/div.js         |   29 +
 html5/test/render/vue/components/image.js       |   44 +-
 html5/test/render/vue/components/list.js        |   21 +-
 html5/test/render/vue/components/switch.js      |   35 +-
 html5/test/render/vue/components/text.js        |   42 +-
 html5/test/render/vue/components/web.js         |   14 +-
 html5/test/render/vue/examples/list-cell.js     |   16 +-
 html5/test/render/vue/helper.js                 |  157 +-
 html5/test/render/vue/utils.js                  |    1 -
 html5/test/render/vue/validator/check.js        |    1 -
 html5/test/render/vue/validator/index.js        |    1 -
 html5/test/render/vue/validator/prop.js         |    1 -
 html5/test/render/vue/validator/style.js        |    1 -
 index.html                                      |    3 +-
 ios/sdk/WeexSDK.xcodeproj/project.pbxproj       |    8 -
 .../Recycler/WXRecyclerDataController.m         |    2 +-
 .../Component/WXComponent+GradientColor.h       |   21 -
 .../Component/WXComponent+GradientColor.m       |  124 -
 .../Sources/Component/WXComponent_internal.h    |    3 +
 .../Sources/Display/WXComponent+BoxShadow.h     |    2 +-
 .../Sources/Display/WXComponent+BoxShadow.m     |   10 +-
 ios/sdk/WeexSDK/Sources/Display/WXInnerLayer.h  |    2 +-
 ios/sdk/WeexSDK/Sources/Display/WXInnerLayer.m  |    4 +-
 .../WeexSDK/Sources/Layout/WXComponent+Layout.m |    3 +-
 ios/sdk/WeexSDK/Sources/Model/WXComponent.m     |   29 +-
 ios/sdk/WeexSDK/Sources/Utility/WXBoxShadow.h   |    2 +-
 ios/sdk/WeexSDK/Sources/Utility/WXBoxShadow.m   |   21 +-
 ios/sdk/WeexSDK/Sources/Utility/WXUtility.h     |   27 +
 ios/sdk/WeexSDK/Sources/Utility/WXUtility.m     |  101 +
 .../Sources/View/WXComponent+ViewManagement.m   |    1 -
 ios/sdk/WeexSDK/Sources/WeexSDK.h               |    1 +
 package.json                                    |   24 +-
 packages/weex-vue-render/README.md              |   51 +-
 packages/weex-vue-render/package.json           |   13 +-
 test/ci-funcs.sh                                |    3 +
 test/pages/image-onload.vue                     |    2 +-
 test/pages/index.vue                            |   10 +-
 test/scripts/index.test.js                      |   14 +-
 vue.html                                        |   53 +-
 247 files changed, 26287 insertions(+), 1583 deletions(-)
----------------------------------------------------------------------



[09/15] incubator-weex git commit: * [ios] bring triggerDisplay to main thread

Posted by cx...@apache.org.
* [ios] bring triggerDisplay to main thread


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

Branch: refs/heads/0.12-dev
Commit: e3ee82fb483031404131eba65fd66f9eb8c10083
Parents: a069edb
Author: \u9690\u98ce <cx...@apache.org>
Authored: Thu Apr 6 16:03:51 2017 +0800
Committer: \u9690\u98ce <cx...@apache.org>
Committed: Thu Apr 6 16:03:51 2017 +0800

----------------------------------------------------------------------
 ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/e3ee82fb/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m b/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
index a72e84d..9dbe63a 100644
--- a/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
+++ b/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
@@ -193,7 +193,9 @@
 
 - (void)triggerDisplay
 {
-    [self _willDisplayLayer:_layer];
+    WXPerformBlockOnMainThread(^{
+        [self _willDisplayLayer:_layer];
+    });
 }
 
 - (CGContextRef)beginDrawContext:(CGRect)bounds


[13/15] incubator-weex git commit: * [ios] remove unused if

Posted by cx...@apache.org.
* [ios] remove unused if


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

Branch: refs/heads/0.12-dev
Commit: 99b83db46fd46f6adf0c4d7ba36caa70749dfef2
Parents: 4a7a54b
Author: \u9690\u98ce <cx...@apache.org>
Authored: Mon Apr 10 11:13:58 2017 +0800
Committer: \u9690\u98ce <cx...@apache.org>
Committed: Mon Apr 10 11:13:58 2017 +0800

----------------------------------------------------------------------
 ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m | 3 ---
 1 file changed, 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/99b83db4/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m b/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
index a02f53a..937339e 100644
--- a/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
+++ b/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
@@ -277,9 +277,6 @@
     
     if (shouldDisplay) {
         dispatch_block_t displayBlockToPush = ^{
-            if (!context) {
-                
-            }
             CGContextSaveGState(context);
             CGContextTranslateCTM(context, frame.origin.x, frame.origin.y);
             


[06/15] incubator-weex git commit: * [ios] UIGraphicsPushContext to push context, fix invalid context 0x0 problem.

Posted by cx...@apache.org.
* [ios] UIGraphicsPushContext to push context, fix invalid context 0x0 problem.


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

Branch: refs/heads/0.12-dev
Commit: d81b656f146b5642faf7aa38b1d469b50c6e8051
Parents: 3a714ac
Author: \u9690\u98ce <cx...@apache.org>
Authored: Wed Apr 5 20:25:42 2017 +0800
Committer: \u9690\u98ce <cx...@apache.org>
Committed: Wed Apr 5 20:25:42 2017 +0800

----------------------------------------------------------------------
 ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m |  2 +-
 ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m  |  3 ++-
 .../WeexSDK/Sources/Display/WXComponent+Display.m    | 15 +++++++++------
 ios/sdk/WeexSDK/Sources/Model/WXComponent.h          |  2 +-
 4 files changed, 13 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d81b656f/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
index 2527adc..73696fd 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
@@ -167,7 +167,7 @@ static dispatch_queue_t WXImageUpdateQueue;
     }
 }
 
-- (UIImage *)drawRect:(CGRect)rect withContext:(CGContextRef)context;
+- (UIImage *)drawRect:(CGRect)rect;
 {
     if (!self.image) {
         [self updateImage];

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d81b656f/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 ff98d2d..42fccfb 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
@@ -201,8 +201,9 @@ do {\
     return YES;
 }
 
-- (UIImage *)drawRect:(CGRect)rect withContext:(CGContextRef)context;
+- (UIImage *)drawRect:(CGRect)rect;
 {
+    CGContextRef context = UIGraphicsGetCurrentContext();
     if (_isCompositingChild) {
         [self drawTextWithContext:context bounds:rect padding:_padding view:nil];
     } else {

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d81b656f/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m b/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
index b548663..6428ecb 100644
--- a/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
+++ b/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
@@ -58,7 +58,7 @@
     return YES;
 }
 
-- (UIImage *)drawRect:(CGRect)rect withContext:(CGContextRef)context
+- (UIImage *)drawRect:(CGRect)rect
 {
     CGSize size = rect.size;
     if (size.width <= 0 || size.height <= 0) {
@@ -66,6 +66,7 @@
         return nil;
     }
     
+    CGContextRef context = UIGraphicsGetCurrentContext();
     [self _drawBorderWithContext:context size:size];
 
     return nil;
@@ -79,8 +80,7 @@
         }
 
         UIGraphicsBeginImageContextWithOptions(bounds.size, [self _bitmapOpaqueWithSize:bounds.size] , 0.0);
-        CGContextRef context = UIGraphicsGetCurrentContext();
-        UIImage *image = [self drawRect:bounds withContext:context];
+        UIImage *image = [self drawRect:bounds];
         if (!image) {
             image = UIGraphicsGetImageFromCurrentImageContext();
         }
@@ -228,6 +228,8 @@
         
         [self _collectCompositingDisplayBlocks:displayBlocks context:context isCancelled:isCancelled];
         
+        UIGraphicsPushContext(context);
+        
         for (dispatch_block_t block in displayBlocks) {
             if (isCancelled()) {
                 UIGraphicsEndImageContext();
@@ -236,6 +238,8 @@
             block();
         }
         
+        UIGraphicsPopContext();
+        
         UIImage *image = [self endDrawContext:context];
         return image;
     };
@@ -273,10 +277,9 @@
                 [[UIBezierPath bezierPathWithRect:bounds] addClip];
             }
             
-            UIImage *image = [self drawRect:bounds withContext:context];
+            UIImage *image = [self drawRect:bounds];
             if (image) {
-                CGContextDrawImage(context, bounds, image.CGImage);
-//                [image drawInRect:bounds];
+                [image drawInRect:bounds];
             }
         };
         [displayBlocks addObject:[displayBlockToPush copy]];

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d81b656f/ios/sdk/WeexSDK/Sources/Model/WXComponent.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXComponent.h b/ios/sdk/WeexSDK/Sources/Model/WXComponent.h
index d9e7070..7da7bc6 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXComponent.h
+++ b/ios/sdk/WeexSDK/Sources/Model/WXComponent.h
@@ -350,7 +350,7 @@ NS_ASSUME_NONNULL_BEGIN
  * If you already have an image that represents the content of the component, then you should just return the image and do no drawing, otherwise you should draw your content in the current context and return nil.
  * You should never call this method directly yourself. To invalidate part of your component's content, and thus cause that portion to be redrawn, call the `setNeedsDisplay` method instead.
  */
-- (UIImage *)drawRect:(CGRect)rect withContext:(CGContextRef)context;
+- (UIImage *)drawRect:(CGRect)rect;
 
 /**
  * @abstract Called when a component finishes rendering its content.


[08/15] incubator-weex git commit: * [ios] Add public method to trigger display

Posted by cx...@apache.org.
* [ios] Add public method to trigger display


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

Branch: refs/heads/0.12-dev
Commit: a069edb7ad815893eb2e330307bca5c211ebacfd
Parents: 3844a25
Author: \u9690\u98ce <cx...@apache.org>
Authored: Thu Apr 6 15:59:20 2017 +0800
Committer: \u9690\u98ce <cx...@apache.org>
Committed: Thu Apr 6 15:59:20 2017 +0800

----------------------------------------------------------------------
 ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m | 5 +++++
 ios/sdk/WeexSDK/Sources/Model/WXComponent.h           | 5 +++++
 2 files changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/a069edb7/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m b/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
index 0d4bca1..a72e84d 100644
--- a/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
+++ b/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
@@ -191,6 +191,11 @@
     }
 }
 
+- (void)triggerDisplay
+{
+    [self _willDisplayLayer:_layer];
+}
+
 - (CGContextRef)beginDrawContext:(CGRect)bounds
 {
     UIGraphicsBeginImageContextWithOptions(bounds.size, [self _bitmapOpaqueWithSize:bounds.size], 0.0);

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/a069edb7/ios/sdk/WeexSDK/Sources/Model/WXComponent.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXComponent.h b/ios/sdk/WeexSDK/Sources/Model/WXComponent.h
index bec45d1..c2cc3b9 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXComponent.h
+++ b/ios/sdk/WeexSDK/Sources/Model/WXComponent.h
@@ -361,6 +361,11 @@ NS_ASSUME_NONNULL_BEGIN
 - (void)readyToRender;
 
 /**
+ * @abstract trigger display if you do not have a WXLayer
+ */
+- (void)triggerDisplay;
+
+/**
  * @abstract Creates a  graphics context with the specified bounds, the context will be used for `drawRect:` in compositing environment
  * @discussion You can override this method to use your own graphics context.
  */


[04/15] incubator-weex git commit: * [ios] support view compositing

Posted by cx...@apache.org.
* [ios] support view compositing


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

Branch: refs/heads/0.12-dev
Commit: c6d980d30001fa50c25b6c91434cbbb85b24021f
Parents: dbe2f32
Author: \u9690\u98ce <cx...@apache.org>
Authored: Wed Apr 5 19:48:08 2017 +0800
Committer: \u9690\u98ce <cx...@apache.org>
Committed: Wed Apr 5 19:48:08 2017 +0800

----------------------------------------------------------------------
 .../Sources/Component/WXComponent_internal.h    |   8 +-
 .../Sources/Component/WXImageComponent.m        |  50 ++---
 .../WeexSDK/Sources/Component/WXTextComponent.m |  89 ++++-----
 .../Sources/Display/WXComponent+Display.m       | 191 ++++++++++++-------
 ios/sdk/WeexSDK/Sources/Display/WXRoundedRect.h |   2 +
 .../WeexSDK/Sources/Display/WXRoundedRect.mm    |   5 +
 ios/sdk/WeexSDK/Sources/Model/WXComponent.h     |  55 +++++-
 ios/sdk/WeexSDK/Sources/Model/WXComponent.m     |   7 +-
 ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m   |   6 +-
 9 files changed, 248 insertions(+), 165 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/c6d980d3/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h b/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h
index 28f9d2e..00f0ef4 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h
+++ b/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h
@@ -81,8 +81,8 @@
      *  Display
      */
     CALayer *_layer;
-    BOOL _composite;
-    BOOL _compositingChild;
+    BOOL _useCompositing;
+    BOOL _isCompositingChild;
     WXThreadSafeCounter *_displayCounter;
     
     UIColor *_borderTopColor;
@@ -185,6 +185,10 @@
 
 - (void)_setupNavBarWithStyles:(NSMutableDictionary *)styles attributes:(NSMutableDictionary *)attributes;
 
+- (void)_initCompositingAttribute:(NSDictionary *)attributes;
+
+- (BOOL)_bitmapOpaqueWithSize:(CGSize)size;
+
 - (void)_updateNavBarAttributes:(NSDictionary *)attributes;
 
 - (void)_handleFirstScreenTime;

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/c6d980d3/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
index d5d9ca6..1e2594c 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
@@ -158,38 +158,21 @@ static dispatch_queue_t WXImageUpdateQueue;
     
 }
 
-- (WXDisplayBlock)displayBlock
+- (BOOL)needsDrawRect
 {
-    if ([self isViewLoaded]) {
-        // if has a image view, image is setted by image view, displayBlock is not needed
-        return nil;
+    if (_isCompositingChild) {
+        return YES;
+    } else {
+        return NO;
     }
-    
-    __weak typeof(self) weakSelf = self;
-    return ^UIImage *(CGRect bounds, BOOL(^isCancelled)(void)) {
-        if (isCancelled()) {
-            return nil;
-        }
-        
-        if (!weakSelf.image) {
-            [weakSelf updateImage];
-            return nil;
-        }
-        
-        if (isCancelled && isCancelled()) {
-            return nil;
-        }
-        
-        UIGraphicsBeginImageContextWithOptions(bounds.size, self.layer.opaque, 1.0);
-        
-        [weakSelf.image drawInRect:bounds];
-        
-        UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
-        
-        UIGraphicsEndImageContext();
-        
-        return image;
-    };
+}
+
+- (UIImage *)drawRect:(CGRect)rect
+{
+    if (!self.image) {
+        [self updateImage];
+    }
+    return self.image;
 }
 
 - (void)viewWillUnload
@@ -262,6 +245,9 @@ static dispatch_queue_t WXImageUpdateQueue;
                     ((UIImageView *)strongSelf.view).image = image;
                     weakSelf.imageDownloadFinish = YES;
                     [self readyToRender];
+                } else if (strongSelf->_isCompositingChild) {
+                    strongSelf->_image = image;
+                    weakSelf.imageDownloadFinish = YES;
                 }
             });
         }];
@@ -302,6 +288,10 @@ static dispatch_queue_t WXImageUpdateQueue;
                         strongSelf.imageDownloadFinish = YES;
                         ((UIImageView *)strongSelf.view).image = image;
                         [strongSelf readyToRender];
+                    } else if (strongSelf->_isCompositingChild) {
+                        strongSelf.imageDownloadFinish = YES;
+                        strongSelf->_image = image;
+                        [strongSelf setNeedsDisplay];
                     }
                 });
             }];

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/c6d980d3/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 77e7ce2..4ee3860 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
@@ -42,37 +42,6 @@
     return [WXLayer class];
 }
 
-- (UIImage *)drawTextWithBounds:(CGRect)bounds padding:(UIEdgeInsets)padding
-{
-    if (bounds.size.width <=0 || bounds.size.height <= 0) {
-        return nil;
-    }
-    UIGraphicsBeginImageContextWithOptions(bounds.size, self.layer.opaque, WXScreenScale());
-    CGContextRef context = UIGraphicsGetCurrentContext();
-    
-    if ([self.wx_component _needsDrawBorder]) {
-        [self.wx_component _drawBorderWithContext:context size:bounds.size];
-    } else {
-        WXPerformBlockOnMainThread(^{
-            [self.wx_component _resetNativeBorderRadius];
-        });
-    }
-    NSLayoutManager *layoutManager = _textStorage.layoutManagers.firstObject;
-    NSTextContainer *textContainer = layoutManager.textContainers.firstObject;
-    
-    CGRect textFrame = UIEdgeInsetsInsetRect(bounds, padding);
-    NSRange glyphRange = [layoutManager glyphRangeForTextContainer:textContainer];
-    
-    [layoutManager drawBackgroundForGlyphRange:glyphRange atPoint:textFrame.origin];
-    [layoutManager drawGlyphsForGlyphRange:glyphRange atPoint:textFrame.origin];
-    
-    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
-    
-    UIGraphicsEndImageContext();
-    
-    return image;
-}
-
 - (void)setTextStorage:(NSTextStorage *)textStorage
 {
     if (_textStorage != textStorage) {
@@ -227,25 +196,21 @@ do {\
     return [[WXText alloc] init];
 }
 
-- (WXDisplayBlock)displayBlock
+- (BOOL)needsDrawRect
 {
-    WXText *textView = ((WXText *)self.view);
-    return ^UIImage *(CGRect bounds, BOOL(^isCancelled)(void)) {
-        if (isCancelled()) {
-            return nil;
-        }
-        if (_isUsingTextStorageLock) {
-            pthread_mutex_lock(&_textStorageMutex);
-        }
-        
-        UIImage *image = [textView drawTextWithBounds:bounds padding:_padding];
-        
-        if (_isUsingTextStorageLock) {
-            pthread_mutex_unlock(&_textStorageMutex);
-        }
-        
-        return image;
-    };
+    return YES;
+}
+
+- (UIImage *)drawRect:(CGRect)rect
+{
+    if (_isCompositingChild) {
+        [self drawTextWithBounds:rect padding:_padding view:nil];
+    } else {
+        WXText *textView = ((WXText *)self.view);
+        [self drawTextWithBounds:rect padding:_padding view:textView];
+    }
+    
+    return nil;
 }
 
 - (CGSize (^)(CGSize))measureBlock
@@ -287,6 +252,7 @@ do {\
 }
 
 #pragma mark Text Building
+
 - (NSString *)text
 {
     return _text;
@@ -447,6 +413,31 @@ do {\
     [self syncTextStorageForView];
 }
 
+- (void)drawTextWithBounds:(CGRect)bounds padding:(UIEdgeInsets)padding view:(WXText *)view
+{
+    if (bounds.size.width <=0 || bounds.size.height <= 0) {
+        return;
+    }
+    
+    CGContextRef context = UIGraphicsGetCurrentContext();
+    
+    if ([self _needsDrawBorder]) {
+        [self _drawBorderWithContext:context size:bounds.size];
+    } else {
+        WXPerformBlockOnMainThread(^{
+            [self _resetNativeBorderRadius];
+        });
+    }
+    NSLayoutManager *layoutManager = (view ? view.textStorage : _textStorage).layoutManagers.firstObject;
+    NSTextContainer *textContainer = layoutManager.textContainers.firstObject;
+    
+    CGRect textFrame = UIEdgeInsetsInsetRect(bounds, padding);
+    NSRange glyphRange = [layoutManager glyphRangeForTextContainer:textContainer];
+    
+    [layoutManager drawBackgroundForGlyphRange:glyphRange atPoint:textFrame.origin];
+    [layoutManager drawGlyphsForGlyphRange:glyphRange atPoint:textFrame.origin];
+}
+
 #ifdef UITEST
 - (NSString *)description
 {

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/c6d980d3/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m b/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
index 2231d46..fdd02a1 100644
--- a/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
+++ b/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
@@ -28,10 +28,10 @@
 {
     WXAssertMainThread();
     
-    if (_compositingChild) {
+    if (_isCompositingChild) {
         WXComponent *supercomponent = self.supercomponent;
         while (supercomponent) {
-            if (supercomponent->_composite) {
+            if (supercomponent->_useCompositing) {
                 break;
             }
             supercomponent = supercomponent.supercomponent;
@@ -44,54 +44,82 @@
     }
 }
 
-- (WXDisplayBlock)displayBlock
+- (BOOL)needsDrawRect
+{
+    if (![self _needsDrawBorder]) {
+        WXLogDebug(@"No need to draw border for %@", self.ref);
+        WXPerformBlockOnMainThread(^{
+            [self _resetNativeBorderRadius];
+        });
+        
+        return NO;
+    }
+    
+    return YES;
+}
+
+- (UIImage *)drawRect:(CGRect)rect
+{
+    CGSize size = rect.size;
+    if (size.width <= 0 || size.height <= 0) {
+        WXLogDebug(@"No need to draw border for %@, because width or height is zero", self.ref);
+        return nil;
+    }
+    
+    CGContextRef context = UIGraphicsGetCurrentContext();
+    [self _drawBorderWithContext:context size:size];
+
+    return nil;
+}
+
+- (WXDisplayBlock)_displayBlock
 {
     WXDisplayBlock displayBlock = ^UIImage *(CGRect bounds, BOOL(^isCancelled)(void)) {
         if (isCancelled()) {
             return nil;
         }
-        
-        if (![self _needsDrawBorder]) {
-            WXLogDebug(@"No need to draw border for %@", self.ref);
-            WXPerformBlockOnMainThread(^{
-                [self _resetNativeBorderRadius];
-            });
-            return nil;
+
+        UIGraphicsBeginImageContextWithOptions(bounds.size, [self _bitmapOpaqueWithSize:bounds.size] , 0.0);
+        UIImage *image = [self drawRect:bounds];
+        if (!image) {
+            image = UIGraphicsGetImageFromCurrentImageContext();
         }
+        UIGraphicsEndImageContext();
         
-        return [self _borderImage];
+        return image;
     };
     
     return displayBlock;
 }
 
-- (WXDisplayCompletionBlock)displayCompletionBlock
+#pragma mark Private
+
+- (void)_initCompositingAttribute:(NSDictionary *)attributes
 {
-    return nil;
+    _useCompositing = attributes[@"compositing"] ? [WXConvert BOOL:attributes[@"compositing"]] : NO;
 }
 
-#pragma mark Private
-
 - (void)_willDisplayLayer:(CALayer *)layer
 {
     WXAssertMainThread();
     
-    if (_compositingChild) {
-        // compsiting children need not draw layer
+    if (_isCompositingChild) {
+        // compsiting children do not have own layers, so return here.
         return;
     }
     
     CGRect displayBounds = CGRectMake(0, 0, self.calculatedFrame.size.width, self.calculatedFrame.size.height);
     
+    BOOL needsDrawRect = [self needsDrawRect];
     WXDisplayBlock displayBlock;
-    if (_composite) {
+    if (_useCompositing) {
         displayBlock = [self _compositeDisplayBlock];
     } else {
-        displayBlock = [self displayBlock];
+        displayBlock = [self _displayBlock];
     }
     WXDisplayCompletionBlock completionBlock = [self displayCompletionBlock];
     
-    if (!displayBlock) {
+    if (!displayBlock || !needsDrawRect) {
         if (completionBlock) {
             completionBlock(layer, NO);
         }
@@ -146,6 +174,22 @@
     }
 }
 
+- (CGContextRef)beginDrawContext:(CGRect)bounds
+{
+    UIGraphicsBeginImageContextWithOptions(bounds.size, [self _bitmapOpaqueWithSize:bounds.size], 0.0);
+    CGContextRef context = UIGraphicsGetCurrentContext();
+    
+    return context;
+}
+
+- (UIImage *)endDrawContext
+{
+    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
+    UIGraphicsEndImageContext();
+    
+    return image;
+}
+
 - (WXDisplayBlock)_compositeDisplayBlock
 {
     return ^UIImage* (CGRect bounds, BOOL(^isCancelled)(void)) {
@@ -153,11 +197,20 @@
             return nil;
         }
         NSMutableArray *displayBlocks = [NSMutableArray array];
-        [self _collectDisplayBlocks:displayBlocks isCancelled:isCancelled];
         
-        BOOL opaque = _layer.opaque && CGColorGetAlpha(_backgroundColor.CGColor) == 1.0f;
+        CGContextRef context = [self beginDrawContext:bounds];
+        
+//        float scaleFactor = [[UIScreen mainScreen] scale];
+//        CGColorSpaceRef	colorSpace = CGColorSpaceCreateDeviceRGB();
+//        CGContextRef context = CGBitmapContextCreate(NULL, bounds.size.width * scaleFactor, bounds.size.height * scaleFactor, 8, 4 * bounds.size.width * scaleFactor, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
+//        CGContextScaleCTM(context, scaleFactor, scaleFactor);
+//        
+//        // Adjusts position and invert the image.
+//        // The OpenGL uses the image data upside-down compared commom image files.
+//        CGContextTranslateCTM(context, 0, bounds.size.height);
+//        CGContextScaleCTM(context, 1.0, -1.0);
         
-        UIGraphicsBeginImageContextWithOptions(bounds.size, opaque, 0.0);
+        [self _collectCompositingDisplayBlocks:displayBlocks context:context isCancelled:isCancelled];
         
         for (dispatch_block_t block in displayBlocks) {
             if (isCancelled()) {
@@ -167,36 +220,32 @@
             block();
         }
         
-        UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
-        UIGraphicsEndImageContext();
+//        CGImageRef imageRef= CGBitmapContextCreateImage(context);
+//        UIImage *image = [[UIImage alloc] initWithCGImage:imageRef];
         
+//        CGColorSpaceRelease(colorSpace);
+//        CGContextRelease(context);
+       
+        UIImage *image = [self endDrawContext];
         return image;
     };
 }
 
-- (void)_collectDisplayBlocks:(NSMutableArray *)displayBlocks isCancelled:(BOOL(^)(void))isCancelled
+- (void)_collectCompositingDisplayBlocks:(NSMutableArray *)displayBlocks context:(CGContextRef)context isCancelled:(BOOL(^)(void))isCancelled
 {
-    // compositingChild has no chance to applyPropertiesToView, so force updateNode
-    //    if (_compositingChild) {
-    //        if (_data) {
-    //            dispatch_async(dispatch_get_main_queue(), ^{
-    //                [self updateNode:_data];
-    //            });
-    //        }
-    //    }
-    
+    // TODO: compositingChild has no chance to applyPropertiesToView, need update here?
     UIColor *backgroundColor = _backgroundColor;
     BOOL clipsToBounds = _clipToBounds;
     CGRect frame = self.calculatedFrame;
     CGRect bounds = CGRectMake(0, 0, frame.size.width, frame.size.height);
     
-    if (_composite) {
+    if (_useCompositing) {
         frame.origin = CGPointMake(0, 0);
     }
     
-    WXDisplayBlock displayBlock = [self displayBlock];
+    BOOL needsDrawRect = [self needsDrawRect];
     
-    BOOL shouldDisplay = displayBlock || backgroundColor || CGPointEqualToPoint(CGPointZero, frame.origin) == NO || clipsToBounds;
+    BOOL shouldDisplay = needsDrawRect && (backgroundColor || CGPointEqualToPoint(CGPointZero, frame.origin) == NO || clipsToBounds);
     
     if (shouldDisplay) {
         dispatch_block_t displayBlockToPush = ^{
@@ -204,21 +253,17 @@
             CGContextSaveGState(context);
             CGContextTranslateCTM(context, frame.origin.x, frame.origin.y);
             
-            if (_compositingChild && clipsToBounds) {
-                [[UIBezierPath bezierPathWithRect:bounds] addClip];
+            if (isCancelled && isCancelled()) {
+                return ;
             }
             
-            CGColorRef backgroundCGColor = backgroundColor.CGColor;
-            if (backgroundColor && CGColorGetAlpha(backgroundCGColor) > 0.0) {
-                CGContextSetFillColorWithColor(context, backgroundCGColor);
-                CGContextFillRect(context, bounds);
+            if (_isCompositingChild && clipsToBounds) {
+                [[UIBezierPath bezierPathWithRect:bounds] addClip];
             }
             
-            if (displayBlock) {
-                UIImage *image = displayBlock(bounds, isCancelled);
-                if (image) {
-                    [image drawInRect:bounds];
-                }
+            UIImage *image = [self drawRect:bounds];
+            if (image) {
+                [image drawInRect:bounds];
             }
         };
         [displayBlocks addObject:[displayBlockToPush copy]];
@@ -226,13 +271,12 @@
     
     for (WXComponent *component in self.subcomponents) {
         if (!isCancelled()) {
-            [component _collectDisplayBlocks:displayBlocks isCancelled:isCancelled];
+            [component _collectCompositingDisplayBlocks:displayBlocks context:context isCancelled:isCancelled];
         }
     }
     
     if (shouldDisplay) {
         dispatch_block_t blockToPop = ^{
-            CGContextRef context = UIGraphicsGetCurrentContext();
             CGContextRestoreGState(context);
         };
         [displayBlocks addObject:[blockToPop copy]];
@@ -241,26 +285,6 @@
 
 #pragma mark Border Drawing
 
-- (UIImage *)_borderImage
-{
-    CGSize size = self.calculatedFrame.size;
-    if (size.width <= 0 || size.height <= 0) {
-        WXLogDebug(@"No need to draw border for %@, because width or height is zero", self.ref);
-        return nil;
-    }
-    
-    WXLogDebug(@"Begin to draw border for %@", self.ref);
-    UIGraphicsBeginImageContextWithOptions(size, NO, 0.0);
-    CGContextRef context = UIGraphicsGetCurrentContext();
-    
-    [self _drawBorderWithContext:context size:size];
-    
-    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
-    UIGraphicsEndImageContext();
-    
-    return image;
-}
-
 - (void)_drawBorderWithContext:(CGContextRef)context size:(CGSize)size
 {
     CGRect rect = CGRectMake(0, 0, size.width, size.height);
@@ -353,6 +377,10 @@
 
 - (BOOL)_needsDrawBorder
 {
+    if (_isCompositingChild) {
+        return YES;
+    }
+    
     if (![_layer isKindOfClass:[WXLayer class]]) {
         // Only support WXLayer
         return NO;
@@ -491,4 +519,25 @@ do {\
     }
 }
 
+- (BOOL)_bitmapOpaqueWithSize:(CGSize)size
+{
+    CGRect rect = CGRectMake(0, 0, size.width, size.height);
+    WXRoundedRect *borderRect = [[WXRoundedRect alloc] initWithRect:rect topLeft:_borderTopLeftRadius topRight:_borderTopRightRadius bottomLeft:_borderBottomLeftRadius bottomRight:_borderBottomRightRadius];
+    WXRadii *radii = borderRect.radii;
+    BOOL hasBorderRadius = [radii hasBorderRadius];
+    return (!hasBorderRadius) && CGColorGetAlpha(_backgroundColor.CGColor) == 1.0;
+}
+
+#pragma mark - Deprecated
+
+- (WXDisplayBlock)displayBlock
+{
+    return [self _displayBlock];
+}
+
+- (WXDisplayCompletionBlock)displayCompletionBlock
+{
+    return nil;
+}
+
 @end

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/c6d980d3/ios/sdk/WeexSDK/Sources/Display/WXRoundedRect.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Display/WXRoundedRect.h b/ios/sdk/WeexSDK/Sources/Display/WXRoundedRect.h
index 9cabf8e..4cde88a 100644
--- a/ios/sdk/WeexSDK/Sources/Display/WXRoundedRect.h
+++ b/ios/sdk/WeexSDK/Sources/Display/WXRoundedRect.h
@@ -17,6 +17,8 @@
 @property (nonatomic, assign) CGFloat bottomLeft;
 @property (nonatomic, assign) CGFloat bottomRight;
 
+- (BOOL)hasBorderRadius;
+
 @end
 
 @interface WXRoundedRect : NSObject

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/c6d980d3/ios/sdk/WeexSDK/Sources/Display/WXRoundedRect.mm
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Display/WXRoundedRect.mm b/ios/sdk/WeexSDK/Sources/Display/WXRoundedRect.mm
index ae535dd..fb62465 100644
--- a/ios/sdk/WeexSDK/Sources/Display/WXRoundedRect.mm
+++ b/ios/sdk/WeexSDK/Sources/Display/WXRoundedRect.mm
@@ -26,6 +26,11 @@
     return self;
 }
 
+- (BOOL)hasBorderRadius
+{
+    return _topLeft > 0.001 || _topRight > 0.001 || _bottomLeft > 0.001 || _bottomRight > 0.001;
+}
+
 - (void)scale:(float)factor
 {
     if (factor == 1) {

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/c6d980d3/ios/sdk/WeexSDK/Sources/Model/WXComponent.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXComponent.h b/ios/sdk/WeexSDK/Sources/Model/WXComponent.h
index a2f75d7..6bd7cd3 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXComponent.h
+++ b/ios/sdk/WeexSDK/Sources/Model/WXComponent.h
@@ -324,34 +324,69 @@ NS_ASSUME_NONNULL_BEGIN
 /// @name Display
 ///--------------------------------------
 
-typedef UIImage * _Nonnull(^WXDisplayBlock)(CGRect bounds, BOOL(^isCancelled)(void));
-typedef void(^WXDisplayCompletionBlock)(CALayer *layer, BOOL finished);
-
 /**
  * @abstract Marks the view as needing display. The method should be called on the main thread.
+ * @discussion You can use this method to notify the system that your component's contents need to be redrawn. This method makes a note of the request and returns immediately. The component is not actually redrawn until the next drawing cycle, at which point all invalidated components are updated.
+ *
  */
 - (void)setNeedsDisplay;
 
+- (CGContextRef)beginDrawContext:(CGRect)bounds;
+
+- (UIImage *)endDrawContext;
+
 /**
- * @abstract Return a block to be called to draw layer.
- *
- * @discussion The block returned will be called on any thread.
- *
+ * @abstract Returns a Boolean indicating whether the component needs to be drawn by `drawRect:`
+ */
+- (BOOL)needsDrawRect;
+
+/**
+ * @abstract Draws the component\u2019s image within the passed-in rectangle.
+ * @parameter rect The rectangle which is the entire visible bounds of your component. 
+ * @return A UIImage containing the contents of the current bitmap graphics context.
+ * @discussion 
+ * Subclasses that use technologies such as Core Graphics and UIKit to draw their own component\u2019s content should override this method and implement their drawing code there. You do not need to override this method if your component sets its content in superclass's way.
+ * By the time this method is called, UIKit has configured the drawing environment appropriately for your view and you can simply call whatever drawing methods and functions you need to render your content. Specifically, Weex creates and configures a graphics context for drawing and adjusts the transform of that context so that its origin matches the origin of your components\u2019s bounds rectangle. You can get a reference to the graphics context using the `UIGraphicsGetCurrentContext` function, but do not establish a strong reference to the graphics context because it can change between calls to the drawRect: method.
+ * If you already have an image that represents the content of the component, then you should just return the image and do no drawing, otherwise you should draw your content in the current context and return nil.
+ * You should never call this method directly yourself. To invalidate part of your component's content, and thus cause that portion to be redrawn, call the `setNeedsDisplay` method instead.
+ */
+- (UIImage *)drawRect:(CGRect)rect;
+
+/**
+ * @abstract Called when a component finishes rendering its content.
+ * @discussion Do not call this method directly. Weex calls this method at appropriate times to finish updating the component's content.
+ * Subclasses can override this method to perform additional work on components that were rendered.
  */
-- (WXDisplayBlock)displayBlock;
+- (void)displayDidFinished:(BOOL)success;
 
 /**
- * readyToRender
+ * readyToRender, do not use it, will be deprecated soon
  */
 - (void)readyToRender;
 
+@end
+
+@interface WXComponent (Deprecated)
+
+typedef UIImage * _Nonnull(^WXDisplayBlock)(CGRect bounds, BOOL(^isCancelled)(void));
+typedef void(^WXDisplayCompletionBlock)(CALayer *layer, BOOL finished);
+
+/**
+ * @abstract Return a block to be called to draw layer.
+ *
+ * @discussion The block returned will be called on any thread.
+ *
+ */
+- (WXDisplayBlock)displayBlock DEPRECATED_MSG_ATTRIBUTE("use drawRect method instead.");
+
 /**
  * @abstract Return a block to be called while drawing is finished.
  *
  * @discussion The block returned will be called on main thread.
  *
  */
-- (WXDisplayCompletionBlock)displayCompletionBlock;
+- (WXDisplayCompletionBlock)displayCompletionBlock DEPRECATED_MSG_ATTRIBUTE("use displayDidFinished method instead.");
+
 
 @end
 

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/c6d980d3/ios/sdk/WeexSDK/Sources/Model/WXComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXComponent.m b/ios/sdk/WeexSDK/Sources/Model/WXComponent.m
index cecc708..08a1bcc 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Model/WXComponent.m
@@ -95,6 +95,7 @@
         [self _setupNavBarWithStyles:_styles attributes:_attributes];
         [self _initCSSNodeWithStyles:_styles];
         [self _initViewPropertyWithStyles:_styles];
+        [self _initCompositingAttribute:_attributes];
         [self _handleBorders:styles isUpdating:NO];
     }
     
@@ -180,7 +181,7 @@
         WXAssertMainThread();
         
         // compositing child will be drew by its composited ancestor
-        if (_compositingChild) {
+        if (_isCompositingChild) {
             return nil;
         }
         
@@ -332,6 +333,10 @@
         subcomponent->_isNeedJoinLayoutSystem = NO;
     }
     
+    if (_useCompositing || _isCompositingChild) {
+        subcomponent->_isCompositingChild = YES;
+    }
+    
     [self _recomputeCSSNodeChildren];
     [self setNeedsLayout];
 }

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/c6d980d3/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 83bcd7d..66985a9 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
+++ b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
@@ -292,8 +292,10 @@ typedef enum : NSUInteger {
     }
     
     [[WXSDKManager bridgeMgr] destroyInstance:self.instanceId];
-
-    [self.componentManager invalidate];
+    
+    if (_componentManager) {
+        [_componentManager invalidate];
+    }
     __weak typeof(self) weakSelf = self;
     WXPerformBlockOnComponentThread(^{
         __strong typeof(self) strongSelf = weakSelf;


[07/15] incubator-weex git commit: * [ios] deprecate displayBlock and completionDisplayBlock method

Posted by cx...@apache.org.
* [ios] deprecate displayBlock and completionDisplayBlock method


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

Branch: refs/heads/0.12-dev
Commit: 3844a2532e1ec046abae2fe6132ff1bbf0a432ac
Parents: d81b656
Author: \u9690\u98ce <cx...@apache.org>
Authored: Thu Apr 6 12:14:27 2017 +0800
Committer: \u9690\u98ce <cx...@apache.org>
Committed: Thu Apr 6 12:14:27 2017 +0800

----------------------------------------------------------------------
 .../WeexSDK/Sources/Component/WXCellComponent.m | 10 +--
 .../Sources/Display/WXComponent+Display.m       | 73 +++++++++++---------
 ios/sdk/WeexSDK/Sources/Model/WXComponent.h     | 24 ++++---
 3 files changed, 58 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/3844a253/ios/sdk/WeexSDK/Sources/Component/WXCellComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXCellComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXCellComponent.m
index 24a5a1d..5e67ec7 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXCellComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXCellComponent.m
@@ -59,15 +59,9 @@
     }
 }
 
-- (WXDisplayCompletionBlock)displayCompletionBlock
+- (void)didFinishDrawingLayer:(BOOL)success
 {
-    return ^(CALayer *layer, BOOL finished) {
-        if ([super displayCompletionBlock]) {
-            [super displayCompletionBlock](layer, finished);
-        }
-        
-        [self.delegate cellDidRendered:self];
-    };
+    [self.delegate cellDidRendered:self];
 }
 
 - (void)updateAttributes:(NSDictionary *)attributes

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/3844a253/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m b/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
index 6428ecb..0d4bca1 100644
--- a/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
+++ b/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
@@ -46,6 +46,10 @@
 
 - (BOOL)needsDrawRect
 {
+    if (_useCompositing || _isCompositingChild) {
+        return YES;
+    }
+    
     if (![self _needsDrawBorder]) {
         WXLogDebug(@"No need to draw border for %@", self.ref);
         WXPerformBlockOnMainThread(^{
@@ -72,13 +76,20 @@
     return nil;
 }
 
+- (void)didFinishDrawingLayer:(BOOL)success
+{
+    WXAssertMainThread();
+}
+
+#pragma mark Private
+
 - (WXDisplayBlock)_displayBlock
 {
     WXDisplayBlock displayBlock = ^UIImage *(CGRect bounds, BOOL(^isCancelled)(void)) {
         if (isCancelled()) {
             return nil;
         }
-
+        
         UIGraphicsBeginImageContextWithOptions(bounds.size, [self _bitmapOpaqueWithSize:bounds.size] , 0.0);
         UIImage *image = [self drawRect:bounds];
         if (!image) {
@@ -92,7 +103,13 @@
     return displayBlock;
 }
 
-#pragma mark Private
+- (WXDisplayCompletionBlock)_displayCompletionBlock
+{
+    __weak typeof(self) weakSelf = self;
+    return ^(CALayer *layer, BOOL finished) {
+        [weakSelf didFinishDrawingLayer:finished];
+    };
+}
 
 - (void)_initCompositingAttribute:(NSDictionary *)attributes
 {
@@ -117,7 +134,7 @@
     } else {
         displayBlock = [self _displayBlock];
     }
-    WXDisplayCompletionBlock completionBlock = [self displayCompletionBlock];
+    WXDisplayCompletionBlock completionBlock = [self _displayCompletionBlock];
     
     if (!displayBlock || !needsDrawRect) {
         if (completionBlock) {
@@ -176,32 +193,32 @@
 
 - (CGContextRef)beginDrawContext:(CGRect)bounds
 {
-//    UIGraphicsBeginImageContextWithOptions(bounds.size, [self _bitmapOpaqueWithSize:bounds.size], 0.0);
-//    CGContextRef context = UIGraphicsGetCurrentContext();
-    
-    float scaleFactor = [[UIScreen mainScreen] scale];
-    CGColorSpaceRef	colorSpace = CGColorSpaceCreateDeviceRGB();
-    CGContextRef context = CGBitmapContextCreate(NULL, bounds.size.width * scaleFactor, bounds.size.height * scaleFactor, 8, 4 * bounds.size.width * scaleFactor, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
-    CGContextScaleCTM(context, scaleFactor, scaleFactor);
-
-    // Adjusts position and invert the image.
-    // The OpenGL uses the image data upside-down compared commom image files.
-    CGContextTranslateCTM(context, 0, bounds.size.height);
-    CGContextScaleCTM(context, 1.0, -1.0);
+    UIGraphicsBeginImageContextWithOptions(bounds.size, [self _bitmapOpaqueWithSize:bounds.size], 0.0);
+    CGContextRef context = UIGraphicsGetCurrentContext();
     
-    CGColorSpaceRelease(colorSpace);
+//    float scaleFactor = [[UIScreen mainScreen] scale];
+//    CGColorSpaceRef	colorSpace = CGColorSpaceCreateDeviceRGB();
+//    CGContextRef context = CGBitmapContextCreate(NULL, bounds.size.width * scaleFactor, bounds.size.height * scaleFactor, 8, 4 * bounds.size.width * scaleFactor, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
+//    CGContextScaleCTM(context, scaleFactor, scaleFactor);
+//
+//    // Adjusts position and invert the image.
+//    // The OpenGL uses the image data upside-down compared commom image files.
+//    CGContextTranslateCTM(context, 0, bounds.size.height);
+//    CGContextScaleCTM(context, 1.0, -1.0);
+//    
+//    CGColorSpaceRelease(colorSpace);
     
     return context;
 }
 
 - (UIImage *)endDrawContext:(CGContextRef)context
 {
-//    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
-//    UIGraphicsEndImageContext();
+    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
+    UIGraphicsEndImageContext();
     
-    CGImageRef imageRef= CGBitmapContextCreateImage(context);
-    UIImage *image = [[UIImage alloc] initWithCGImage:imageRef];
-    CGContextRelease(context);
+//    CGImageRef imageRef= CGBitmapContextCreateImage(context);
+//    UIImage *image = [[UIImage alloc] initWithCGImage:imageRef];
+//    CGContextRelease(context);
     
     return image;
 }
@@ -216,20 +233,10 @@
         
         CGContextRef context = [self beginDrawContext:bounds];
         
-//        float scaleFactor = [[UIScreen mainScreen] scale];
-//        CGColorSpaceRef	colorSpace = CGColorSpaceCreateDeviceRGB();
-//        CGContextRef context = CGBitmapContextCreate(NULL, bounds.size.width * scaleFactor, bounds.size.height * scaleFactor, 8, 4 * bounds.size.width * scaleFactor, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
-//        CGContextScaleCTM(context, scaleFactor, scaleFactor);
-//        
-//        // Adjusts position and invert the image.
-//        // The OpenGL uses the image data upside-down compared commom image files.
-//        CGContextTranslateCTM(context, 0, bounds.size.height);
-//        CGContextScaleCTM(context, 1.0, -1.0);
+        UIGraphicsPushContext(context);
         
         [self _collectCompositingDisplayBlocks:displayBlocks context:context isCancelled:isCancelled];
         
-        UIGraphicsPushContext(context);
-        
         for (dispatch_block_t block in displayBlocks) {
             if (isCancelled()) {
                 UIGraphicsEndImageContext();
@@ -553,7 +560,7 @@ do {\
 
 - (WXDisplayCompletionBlock)displayCompletionBlock
 {
-    return nil;
+    return [self _displayCompletionBlock];
 }
 
 @end

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/3844a253/ios/sdk/WeexSDK/Sources/Model/WXComponent.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXComponent.h b/ios/sdk/WeexSDK/Sources/Model/WXComponent.h
index 7da7bc6..bec45d1 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXComponent.h
+++ b/ios/sdk/WeexSDK/Sources/Model/WXComponent.h
@@ -331,10 +331,6 @@ NS_ASSUME_NONNULL_BEGIN
  */
 - (void)setNeedsDisplay;
 
-- (CGContextRef)beginDrawContext:(CGRect)bounds;
-
-- (UIImage *)endDrawContext:(CGContextRef)context;
-
 /**
  * @abstract Returns a Boolean indicating whether the component needs to be drawn by `drawRect:`
  */
@@ -353,17 +349,29 @@ NS_ASSUME_NONNULL_BEGIN
 - (UIImage *)drawRect:(CGRect)rect;
 
 /**
- * @abstract Called when a component finishes rendering its content.
+ * @abstract Called when a component finishes drawing its content.
  * @discussion Do not call this method directly. Weex calls this method at appropriate times to finish updating the component's content.
  * Subclasses can override this method to perform additional work on components that were rendered.
  */
-- (void)displayDidFinished:(BOOL)success;
+- (void)didFinishDrawingLayer:(BOOL)success;
 
 /**
  * readyToRender, do not use it, will be deprecated soon
  */
 - (void)readyToRender;
 
+/**
+ * @abstract Creates a  graphics context with the specified bounds, the context will be used for `drawRect:` in compositing environment
+ * @discussion You can override this method to use your own graphics context.
+ */
+- (CGContextRef)beginDrawContext:(CGRect)bounds;
+
+/**
+ * @abstract Removes the current graphics context and returns an image based on the contents of the current graphics context.
+ * @discussion You can override this method to use your own graphics context. The image will be set to layer,  if your drawing system do not have layer and do not need image, returning nil is fine.
+ */
+- (UIImage *)endDrawContext:(CGContextRef)context;
+
 @end
 
 @interface WXComponent (Deprecated)
@@ -377,7 +385,7 @@ typedef void(^WXDisplayCompletionBlock)(CALayer *layer, BOOL finished);
  * @discussion The block returned will be called on any thread.
  *
  */
-- (WXDisplayBlock)displayBlock DEPRECATED_MSG_ATTRIBUTE("use drawRect method instead.");
+- (WXDisplayBlock)displayBlock DEPRECATED_MSG_ATTRIBUTE("use drawRect: method instead.");
 
 /**
  * @abstract Return a block to be called while drawing is finished.
@@ -385,7 +393,7 @@ typedef void(^WXDisplayCompletionBlock)(CALayer *layer, BOOL finished);
  * @discussion The block returned will be called on main thread.
  *
  */
-- (WXDisplayCompletionBlock)displayCompletionBlock DEPRECATED_MSG_ATTRIBUTE("use displayDidFinished method instead.");
+- (WXDisplayCompletionBlock)displayCompletionBlock DEPRECATED_MSG_ATTRIBUTE("use didFinishDrawingLayer: method instead.");
 
 
 @end


[05/15] incubator-weex git commit: * [ios] use bitmap context to draw compositing

Posted by cx...@apache.org.
* [ios] use bitmap context to draw compositing


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

Branch: refs/heads/0.12-dev
Commit: 3a714ac333b2d230d11e6c8c2e94ab94988049da
Parents: c6d980d
Author: \u9690\u98ce <cx...@apache.org>
Authored: Wed Apr 5 20:17:20 2017 +0800
Committer: \u9690\u98ce <cx...@apache.org>
Committed: Wed Apr 5 20:17:20 2017 +0800

----------------------------------------------------------------------
 .../Sources/Component/WXImageComponent.m        |  2 +-
 .../WeexSDK/Sources/Component/WXTextComponent.m | 10 ++--
 .../Sources/Display/WXComponent+Display.m       | 49 +++++++++++++-------
 ios/sdk/WeexSDK/Sources/Model/WXComponent.h     |  4 +-
 4 files changed, 38 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/3a714ac3/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
index 1e2594c..2527adc 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
@@ -167,7 +167,7 @@ static dispatch_queue_t WXImageUpdateQueue;
     }
 }
 
-- (UIImage *)drawRect:(CGRect)rect
+- (UIImage *)drawRect:(CGRect)rect withContext:(CGContextRef)context;
 {
     if (!self.image) {
         [self updateImage];

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/3a714ac3/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 4ee3860..ff98d2d 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
@@ -201,13 +201,13 @@ do {\
     return YES;
 }
 
-- (UIImage *)drawRect:(CGRect)rect
+- (UIImage *)drawRect:(CGRect)rect withContext:(CGContextRef)context;
 {
     if (_isCompositingChild) {
-        [self drawTextWithBounds:rect padding:_padding view:nil];
+        [self drawTextWithContext:context bounds:rect padding:_padding view:nil];
     } else {
         WXText *textView = ((WXText *)self.view);
-        [self drawTextWithBounds:rect padding:_padding view:textView];
+        [self drawTextWithContext:context bounds:rect padding:_padding view:textView];
     }
     
     return nil;
@@ -413,14 +413,12 @@ do {\
     [self syncTextStorageForView];
 }
 
-- (void)drawTextWithBounds:(CGRect)bounds padding:(UIEdgeInsets)padding view:(WXText *)view
+- (void)drawTextWithContext:(CGContextRef)context bounds:(CGRect)bounds padding:(UIEdgeInsets)padding view:(WXText *)view
 {
     if (bounds.size.width <=0 || bounds.size.height <= 0) {
         return;
     }
     
-    CGContextRef context = UIGraphicsGetCurrentContext();
-    
     if ([self _needsDrawBorder]) {
         [self _drawBorderWithContext:context size:bounds.size];
     } else {

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/3a714ac3/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m b/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
index fdd02a1..b548663 100644
--- a/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
+++ b/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
@@ -58,7 +58,7 @@
     return YES;
 }
 
-- (UIImage *)drawRect:(CGRect)rect
+- (UIImage *)drawRect:(CGRect)rect withContext:(CGContextRef)context
 {
     CGSize size = rect.size;
     if (size.width <= 0 || size.height <= 0) {
@@ -66,7 +66,6 @@
         return nil;
     }
     
-    CGContextRef context = UIGraphicsGetCurrentContext();
     [self _drawBorderWithContext:context size:size];
 
     return nil;
@@ -80,7 +79,8 @@
         }
 
         UIGraphicsBeginImageContextWithOptions(bounds.size, [self _bitmapOpaqueWithSize:bounds.size] , 0.0);
-        UIImage *image = [self drawRect:bounds];
+        CGContextRef context = UIGraphicsGetCurrentContext();
+        UIImage *image = [self drawRect:bounds withContext:context];
         if (!image) {
             image = UIGraphicsGetImageFromCurrentImageContext();
         }
@@ -176,16 +176,32 @@
 
 - (CGContextRef)beginDrawContext:(CGRect)bounds
 {
-    UIGraphicsBeginImageContextWithOptions(bounds.size, [self _bitmapOpaqueWithSize:bounds.size], 0.0);
-    CGContextRef context = UIGraphicsGetCurrentContext();
+//    UIGraphicsBeginImageContextWithOptions(bounds.size, [self _bitmapOpaqueWithSize:bounds.size], 0.0);
+//    CGContextRef context = UIGraphicsGetCurrentContext();
+    
+    float scaleFactor = [[UIScreen mainScreen] scale];
+    CGColorSpaceRef	colorSpace = CGColorSpaceCreateDeviceRGB();
+    CGContextRef context = CGBitmapContextCreate(NULL, bounds.size.width * scaleFactor, bounds.size.height * scaleFactor, 8, 4 * bounds.size.width * scaleFactor, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
+    CGContextScaleCTM(context, scaleFactor, scaleFactor);
+
+    // Adjusts position and invert the image.
+    // The OpenGL uses the image data upside-down compared commom image files.
+    CGContextTranslateCTM(context, 0, bounds.size.height);
+    CGContextScaleCTM(context, 1.0, -1.0);
+    
+    CGColorSpaceRelease(colorSpace);
     
     return context;
 }
 
-- (UIImage *)endDrawContext
+- (UIImage *)endDrawContext:(CGContextRef)context
 {
-    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
-    UIGraphicsEndImageContext();
+//    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
+//    UIGraphicsEndImageContext();
+    
+    CGImageRef imageRef= CGBitmapContextCreateImage(context);
+    UIImage *image = [[UIImage alloc] initWithCGImage:imageRef];
+    CGContextRelease(context);
     
     return image;
 }
@@ -220,13 +236,7 @@
             block();
         }
         
-//        CGImageRef imageRef= CGBitmapContextCreateImage(context);
-//        UIImage *image = [[UIImage alloc] initWithCGImage:imageRef];
-        
-//        CGColorSpaceRelease(colorSpace);
-//        CGContextRelease(context);
-       
-        UIImage *image = [self endDrawContext];
+        UIImage *image = [self endDrawContext:context];
         return image;
     };
 }
@@ -249,7 +259,9 @@
     
     if (shouldDisplay) {
         dispatch_block_t displayBlockToPush = ^{
-            CGContextRef context = UIGraphicsGetCurrentContext();
+            if (!context) {
+                
+            }
             CGContextSaveGState(context);
             CGContextTranslateCTM(context, frame.origin.x, frame.origin.y);
             
@@ -261,9 +273,10 @@
                 [[UIBezierPath bezierPathWithRect:bounds] addClip];
             }
             
-            UIImage *image = [self drawRect:bounds];
+            UIImage *image = [self drawRect:bounds withContext:context];
             if (image) {
-                [image drawInRect:bounds];
+                CGContextDrawImage(context, bounds, image.CGImage);
+//                [image drawInRect:bounds];
             }
         };
         [displayBlocks addObject:[displayBlockToPush copy]];

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/3a714ac3/ios/sdk/WeexSDK/Sources/Model/WXComponent.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXComponent.h b/ios/sdk/WeexSDK/Sources/Model/WXComponent.h
index 6bd7cd3..d9e7070 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXComponent.h
+++ b/ios/sdk/WeexSDK/Sources/Model/WXComponent.h
@@ -333,7 +333,7 @@ NS_ASSUME_NONNULL_BEGIN
 
 - (CGContextRef)beginDrawContext:(CGRect)bounds;
 
-- (UIImage *)endDrawContext;
+- (UIImage *)endDrawContext:(CGContextRef)context;
 
 /**
  * @abstract Returns a Boolean indicating whether the component needs to be drawn by `drawRect:`
@@ -350,7 +350,7 @@ NS_ASSUME_NONNULL_BEGIN
  * If you already have an image that represents the content of the component, then you should just return the image and do no drawing, otherwise you should draw your content in the current context and return nil.
  * You should never call this method directly yourself. To invalidate part of your component's content, and thus cause that portion to be redrawn, call the `setNeedsDisplay` method instead.
  */
-- (UIImage *)drawRect:(CGRect)rect;
+- (UIImage *)drawRect:(CGRect)rect withContext:(CGContextRef)context;
 
 /**
  * @abstract Called when a component finishes rendering its content.


[11/15] incubator-weex git commit: * [ios] support border-x-x-radius in image.

Posted by cx...@apache.org.
* [ios] support border-x-x-radius in image.


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

Branch: refs/heads/0.12-dev
Commit: aab1eefbbce4dbe3b47c555afe834a85a5b16cd7
Parents: 29a47f8
Author: \u9690\u98ce <cx...@apache.org>
Authored: Sun Apr 9 21:43:23 2017 +0800
Committer: \u9690\u98ce <cx...@apache.org>
Committed: Sun Apr 9 21:43:23 2017 +0800

----------------------------------------------------------------------
 .../Sources/Component/WXImageComponent.m        | 44 +++++++++++++++++++-
 .../Sources/Display/WXComponent+Display.m       |  2 +-
 ios/sdk/WeexSDK/Sources/Display/WXRoundedRect.h |  2 +
 .../WeexSDK/Sources/Display/WXRoundedRect.mm    |  5 +++
 4 files changed, 50 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/aab1eefb/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
index 73696fd..974bd65 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
@@ -14,6 +14,8 @@
 #import "WXType.h"
 #import "WXConvert.h"
 #import "WXURLRewriteProtocol.h"
+#import "WXRoundedRect.h"
+#import "UIBezierPath+Weex.h"
 
 @interface WXImageView : UIImageView
 
@@ -154,6 +156,8 @@ static dispatch_queue_t WXImageUpdateQueue;
     imageView.clipsToBounds = YES;
     imageView.exclusiveTouch = YES;
     
+    [self _clipsToBounds];
+    
     [self updateImage];
     
 }
@@ -171,6 +175,16 @@ static dispatch_queue_t WXImageUpdateQueue;
 {
     if (!self.image) {
         [self updateImage];
+        return nil;
+    }
+    
+    WXRoundedRect *borderRect = [[WXRoundedRect alloc] initWithRect:rect topLeft:_borderTopLeftRadius topRight:_borderTopRightRadius bottomLeft:_borderBottomLeftRadius bottomRight:_borderBottomRightRadius];
+
+    WXRadii *radii = borderRect.radii;    
+    if ([radii hasBorderRadius]) {
+        CGFloat topLeft = radii.topLeft, topRight = radii.topRight, bottomLeft = radii.bottomLeft, bottomRight = radii.bottomRight;
+        UIBezierPath *bezierPath = [UIBezierPath wx_bezierPathWithRoundedRect:rect topLeft:topLeft topRight:topRight bottomLeft:bottomLeft bottomRight:bottomRight];
+        [bezierPath addClip];
     }
     return self.image;
 }
@@ -182,6 +196,13 @@ static dispatch_queue_t WXImageUpdateQueue;
     _image = nil;
 }
 
+- (void)_frameDidCalculated:(BOOL)isChanged
+{
+    if ([self isViewLoaded] && isChanged) {
+        [self _clipsToBounds];
+    }
+}
+
 - (void)setImageSrc:(NSString*)src
 {
     if (![src isEqualToString:_imageSrc]) {
@@ -325,9 +346,28 @@ static dispatch_queue_t WXImageUpdateQueue;
     return imageLoader;
 }
 
-- (BOOL)_needsDrawBorder
+- (void)_clipsToBounds
 {
-    return NO;
+    if (!_clipToBounds) {
+        return;
+    }
+    
+    WXRoundedRect *borderRect = [[WXRoundedRect alloc] initWithRect:self.view.bounds topLeft:_borderTopLeftRadius topRight:_borderTopRightRadius bottomLeft:_borderBottomLeftRadius bottomRight:_borderBottomRightRadius];
+    // here is computed radii, do not use original style
+    WXRadii *radii = borderRect.radii;
+    
+    if ([radii radiusesAreEqual]) {
+        return;
+    }
+    
+    CGFloat topLeft = radii.topLeft, topRight = radii.topRight, bottomLeft = radii.bottomLeft, bottomRight = radii.bottomRight;
+    
+    // clip to border radius
+    UIBezierPath *bezierPath = [UIBezierPath wx_bezierPathWithRoundedRect:self.view.bounds topLeft:topLeft topRight:topRight bottomLeft:bottomLeft bottomRight:bottomRight];
+    
+    CAShapeLayer *shapeLayer = [CAShapeLayer layer];
+    shapeLayer.path = bezierPath.CGPath;
+    self.layer.mask = shapeLayer;
 }
 
 #ifdef UITEST

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/aab1eefb/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m b/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
index 9dbe63a..a02f53a 100644
--- a/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
+++ b/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
@@ -555,7 +555,7 @@ do {\
     WXRoundedRect *borderRect = [[WXRoundedRect alloc] initWithRect:rect topLeft:_borderTopLeftRadius topRight:_borderTopRightRadius bottomLeft:_borderBottomLeftRadius bottomRight:_borderBottomRightRadius];
     WXRadii *radii = borderRect.radii;
     BOOL hasBorderRadius = [radii hasBorderRadius];
-    return (!hasBorderRadius) && CGColorGetAlpha(_backgroundColor.CGColor) == 1.0;
+    return (!hasBorderRadius) && _opacity == 1.0 && CGColorGetAlpha(_backgroundColor.CGColor) == 1.0;
 }
 
 #pragma mark - Deprecated

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/aab1eefb/ios/sdk/WeexSDK/Sources/Display/WXRoundedRect.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Display/WXRoundedRect.h b/ios/sdk/WeexSDK/Sources/Display/WXRoundedRect.h
index 4cde88a..a90099e 100644
--- a/ios/sdk/WeexSDK/Sources/Display/WXRoundedRect.h
+++ b/ios/sdk/WeexSDK/Sources/Display/WXRoundedRect.h
@@ -19,6 +19,8 @@
 
 - (BOOL)hasBorderRadius;
 
+- (BOOL)radiusesAreEqual;
+
 @end
 
 @interface WXRoundedRect : NSObject

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/aab1eefb/ios/sdk/WeexSDK/Sources/Display/WXRoundedRect.mm
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Display/WXRoundedRect.mm b/ios/sdk/WeexSDK/Sources/Display/WXRoundedRect.mm
index fb62465..e02c5e1 100644
--- a/ios/sdk/WeexSDK/Sources/Display/WXRoundedRect.mm
+++ b/ios/sdk/WeexSDK/Sources/Display/WXRoundedRect.mm
@@ -31,6 +31,11 @@
     return _topLeft > 0.001 || _topRight > 0.001 || _bottomLeft > 0.001 || _bottomRight > 0.001;
 }
 
+- (BOOL)radiusesAreEqual
+{
+    return _topLeft == _topRight && _topRight == _bottomRight && _bottomRight == _bottomLeft;
+}
+
 - (void)scale:(float)factor
 {
     if (factor == 1) {


[10/15] incubator-weex git commit: Merge remote-tracking branch 'upstream/0.12-dev' into ios-feature-composite

Posted by cx...@apache.org.
Merge remote-tracking branch 'upstream/0.12-dev' into ios-feature-composite


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

Branch: refs/heads/0.12-dev
Commit: 29a47f87f1b3c7522bf7ce4bdfdddcb2af320813
Parents: e3ee82f 6e4dcfb
Author: \u9690\u98ce <cx...@apache.org>
Authored: Sun Apr 9 19:54:53 2017 +0800
Committer: \u9690\u98ce <cx...@apache.org>
Committed: Sun Apr 9 19:54:53 2017 +0800

----------------------------------------------------------------------
 android/sdk/assets/main.js                      | 14 ++--
 .../java/com/taobao/weex/WXSDKInstance.java     | 15 ++--
 .../com/taobao/weex/ui/component/WXSlider.java  | 81 ++++++++++++++++++--
 .../taobao/weex/ui/view/WXCircleViewPager.java  | 21 +++--
 build/config.js                                 |  8 +-
 build/karma.vue.conf.js                         | 15 ++--
 build/webpack.examples.config.js                |  4 +-
 doc/source/cn/references/modules/dom.md         |  3 +-
 doc/source/references/modules/dom.md            |  3 +-
 examples/module/componentRect.we                |  4 +-
 html5/frameworks/legacy/app/ctrl/init.js        | 42 ++++++++--
 html5/frameworks/legacy/static/life.js          |  8 +-
 ios/sdk/WeexSDK/Resources/main.js               | 14 ++--
 .../WeexSDK/Sources/Bridge/WXBridgeContext.m    |  4 +
 ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m | 77 +++++++++++++++++++
 .../WeexSDK/Sources/Protocol/WXBridgeProtocol.h |  5 ++
 package.json                                    |  9 ++-
 test/pages/slider-infinite.vue                  | 49 ++++++++++++
 test/scripts/components/slider-infinite.test.js | 38 +++++++++
 19 files changed, 357 insertions(+), 57 deletions(-)
----------------------------------------------------------------------



[03/15] incubator-weex git commit: * [ios] remove NSTextStorage lock because it is not necessary for thread safety

Posted by cx...@apache.org.
* [ios] remove NSTextStorage lock because it is not necessary for thread safety


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

Branch: refs/heads/0.12-dev
Commit: dbe2f321bc37fc308c3b75ef8c48d77b7a4b17be
Parents: 82412d7
Author: \u9690\u98ce <cx...@apache.org>
Authored: Wed Apr 5 17:50:47 2017 +0800
Committer: \u9690\u98ce <cx...@apache.org>
Committed: Wed Apr 5 17:50:47 2017 +0800

----------------------------------------------------------------------
 .../WeexSDK/Sources/Component/WXTextComponent.m | 46 +-------------------
 1 file changed, 1 insertion(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/dbe2f321/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 f18ac94..77e7ce2 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
@@ -119,16 +119,6 @@
     WXTextDecoration _textDecoration;
     NSString *_textOverflow;
     CGFloat _lineHeight;
-    
-   
-    pthread_mutex_t _textStorageMutex;
-    pthread_mutexattr_t _textStorageMutexAttr;
-}
-
-static BOOL _isUsingTextStorageLock = NO;
-+ (void)useTextStorageLock:(BOOL)isUsingTextStorageLock
-{
-    _isUsingTextStorageLock = isUsingTextStorageLock;
 }
 
 - (instancetype)initWithRef:(NSString *)ref
@@ -140,12 +130,6 @@ static BOOL _isUsingTextStorageLock = NO;
 {
     self = [super initWithRef:ref type:type styles:styles attributes:attributes events:events weexInstance:weexInstance];
     if (self) {
-        if (_isUsingTextStorageLock) {
-            pthread_mutexattr_init(&_textStorageMutexAttr);
-            pthread_mutexattr_settype(&_textStorageMutexAttr, PTHREAD_MUTEX_RECURSIVE);
-            pthread_mutex_init(&_textStorageMutex, &_textStorageMutexAttr);
-        }
-        
         [self fillCSSStyles:styles];
         [self fillAttributes:attributes];
     }
@@ -155,10 +139,6 @@ static BOOL _isUsingTextStorageLock = NO;
 
 - (void)dealloc
 {
-    if (_isUsingTextStorageLock) {
-        pthread_mutex_destroy(&_textStorageMutex);
-        pthread_mutexattr_destroy(&_textStorageMutexAttr);
-    }
     [[NSNotificationCenter defaultCenter] removeObserver:self];
 }
 
@@ -226,13 +206,7 @@ do {\
 
 - (void)setNeedsRepaint
 {
-    if (_isUsingTextStorageLock) {
-        pthread_mutex_lock(&_textStorageMutex);
-    }
     _textStorage = nil;
-    if (_isUsingTextStorageLock) {
-        pthread_mutex_unlock(&_textStorageMutex);
-    }
 }
 
 #pragma mark - Subclass
@@ -244,13 +218,7 @@ do {\
 
 - (void)viewDidLoad
 {
-    if (_isUsingTextStorageLock) {
-        pthread_mutex_lock(&_textStorageMutex);
-    }
     ((WXText *)self.view).textStorage = _textStorage;
-    if (_isUsingTextStorageLock) {
-        pthread_mutex_unlock(&_textStorageMutex);
-    }
     [self setNeedsDisplay];
 }
 
@@ -435,14 +403,7 @@ do {\
     [layoutManager ensureLayoutForTextContainer:textContainer];
     
     _textStorageWidth = width;
-    
-    if (_isUsingTextStorageLock) {
-        pthread_mutex_lock(&_textStorageMutex);
-    }
     _textStorage = textStorage;
-    if (_isUsingTextStorageLock) {
-        pthread_mutex_unlock(&_textStorageMutex);
-    }
     
     return textStorage;
 }
@@ -454,13 +415,8 @@ do {\
     
     [self.weexInstance.componentManager  _addUITask:^{
         if ([self isViewLoaded]) {
-            if (_isUsingTextStorageLock) {
-                pthread_mutex_lock(&_textStorageMutex);
-            }
             ((WXText *)self.view).textStorage = textStorage;
-            if (_isUsingTextStorageLock) {
-                pthread_mutex_unlock(&_textStorageMutex);
-            }
+            
             [self readyToRender]; // notify super component
             [self setNeedsDisplay];
         }


[14/15] incubator-weex git commit: Merge branch '0.12-dev' into ios-feature-composite

Posted by cx...@apache.org.
Merge branch '0.12-dev' into ios-feature-composite

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

Branch: refs/heads/0.12-dev
Commit: c8c75a268433640d30ba23453398c3872bef298a
Parents: 99b83db 5b1126a
Author: \u9690\u5c0f\u98ce <cx...@gmail.com>
Authored: Mon Apr 10 11:53:06 2017 +0800
Committer: GitHub <no...@github.com>
Committed: Mon Apr 10 11:53:06 2017 +0800

----------------------------------------------------------------------
 .../taobao/weex/ui/component/WXComponent.java   |  23 ++-
 .../taobao/weex/ui/view/gesture/WXGesture.java  |  14 ++
 .../Component/Recycler/WXRecyclerComponent.m    |   1 +
 .../WeexSDK/Sources/Component/WXListComponent.m |   2 +
 .../Sources/Display/WXComponent+Display.m       |   1 +
 ios/sdk/WeexSDK/Sources/Model/WXComponent.h     |   6 +
 ios/sdk/WeexSDK/Sources/Model/WXComponent.m     |   5 +
 ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m   |   2 +-
 ios/sdk/WeexSDK/Sources/Utility/WXDefine.h      |  11 ++
 ios/sdk/WeexSDK/Sources/Utility/WXType.h        |   5 +
 .../Sources/View/WXComponent+ViewManagement.m   |   3 +
 test/pages/components/recycler.vue              |  29 ++--
 test/scripts/components/recycler.test.js        | 147 ++++++++++---------
 13 files changed, 160 insertions(+), 89 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/c8c75a26/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/c8c75a26/ios/sdk/WeexSDK/Sources/Model/WXComponent.h
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/c8c75a26/ios/sdk/WeexSDK/Sources/Model/WXComponent.m
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/c8c75a26/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
----------------------------------------------------------------------
diff --cc ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
index 66985a9,83bcd7d..f7ef622
--- a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
+++ b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
@@@ -292,10 -292,8 +292,10 @@@ typedef enum : NSUInteger 
      }
      
      [[WXSDKManager bridgeMgr] destroyInstance:self.instanceId];
-     
+ 
 -    [self.componentManager invalidate];
 +    if (_componentManager) {
 +        [_componentManager invalidate];
 +    }
      __weak typeof(self) weakSelf = self;
      WXPerformBlockOnComponentThread(^{
          __strong typeof(self) strongSelf = weakSelf;

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/c8c75a26/test/scripts/components/recycler.test.js
----------------------------------------------------------------------
diff --cc test/scripts/components/recycler.test.js
index bbf20a8,21e8f79..9850945
--- a/test/scripts/components/recycler.test.js
+++ b/test/scripts/components/recycler.test.js
@@@ -37,9 -37,11 +37,9 @@@ describe('recycler', function () 
    const driver = util.createDriver(wd)
  
    before(function () {
 -
 -    console.log(util.getPage('/components/recycler.js'))
      return util.init(driver)
        .get(util.getPage('/components/recycler.js'))
-       .waitForElementByXPath('//recycler[1]',util.getGETActionWaitTimeMills(),1000)
+       .waitForElementById('waterfall',util.getGETActionWaitTimeMills(),1000)
    });
  
    after(function () {


[12/15] incubator-weex git commit: + [example] Add compositing showcase

Posted by cx...@apache.org.
+ [example] Add compositing showcase


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

Branch: refs/heads/0.12-dev
Commit: 4a7a54b3aed794774fd0e242ca1c2bd33e00d439
Parents: aab1eef
Author: \u9690\u98ce <cx...@apache.org>
Authored: Sun Apr 9 22:05:10 2017 +0800
Committer: \u9690\u98ce <cx...@apache.org>
Committed: Sun Apr 9 22:05:10 2017 +0800

----------------------------------------------------------------------
 examples/vue/index.vue                | 10 +++-
 examples/vue/showcase/compositing.vue | 89 ++++++++++++++++++++++++++++++
 2 files changed, 98 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/4a7a54b3/examples/vue/index.vue
----------------------------------------------------------------------
diff --git a/examples/vue/index.vue b/examples/vue/index.vue
index e37931d..fb4693d 100644
--- a/examples/vue/index.vue
+++ b/examples/vue/index.vue
@@ -6,8 +6,9 @@
   module.exports = {
     data: function () {
       var root = typeof window === 'object' ? 'vue-web/vue' : 'vue'
+
       return {
-        items: [
+        items: [ 
           // common
           {name: root + '/syntax/hello-world', title: 'Hello World'},
           {name: root + '/style/index', title: 'Common Style'},
@@ -49,6 +50,13 @@
     },
     components: {
       exampleList: require('./include/example-list.vue')
+    },
+    created: function() {
+      let root = typeof window === 'object' ? 'vue-web/vue' : 'vue'
+      let platform = this.$getConfig().env.platform.toLowerCase()
+      if (platform === 'ios') {
+        this.items.push({name: root + '/showcase/compositing', title: 'Compositing'})
+      }
     }
   }
 </script>

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/4a7a54b3/examples/vue/showcase/compositing.vue
----------------------------------------------------------------------
diff --git a/examples/vue/showcase/compositing.vue b/examples/vue/showcase/compositing.vue
new file mode 100644
index 0000000..58e238f
--- /dev/null
+++ b/examples/vue/showcase/compositing.vue
@@ -0,0 +1,89 @@
+
+<template>
+  <div class="wrapper" @click="update" >
+    <div class="item" compositing=true>
+      <div class="itemWrapper">
+        <div class="nameWrapper">
+          <text class="itemName">Thomas Carlyle</text>
+        </div>
+        <image class="itemPhoto" src="https://gw.alicdn.com/tps/TB1Jl1CPFXXXXcJXXXXXXXXXXXX-370-370.jpg"></image>
+        <div class="descWrapper">
+          <text class="itemDesc">Genius only means hard-working all one\'s life</text>
+        </div>
+      </div>
+    </div>
+
+    <div class="item" compositing=false>
+      <div class="itemWrapper">
+        <div class="nameWrapper">
+          <text class="itemName">Thomas Carlyle</text>
+        </div>
+        <image class="itemPhoto" src="https://gw.alicdn.com/tps/TB1Jl1CPFXXXXcJXXXXXXXXXXXX-370-370.jpg"></image>
+        <div class="descWrapper">
+          <text class="itemDesc">Genius only means hard-working all one\'s life</text>
+        </div>
+      </div>
+    </div>
+  </div>
+</template>
+
+<style>
+  .wrapper {
+    align-items: center; 
+    opacity: 0.8;
+  }
+  .itemWrapper {
+    flex:1;
+    border-top-right-radius: 80;
+    border-bottom-right-radius: 80;
+    border-top-width: 10;
+    border-top-color: red;
+    border-style: dashed;
+    align-items: center;
+    background-color: white;
+  }
+  .nameWrapper {
+    background-color:rgba(255,0,0,0.5);
+    border-radius: 30;
+    overflow: visible;
+    border-color: black;
+    border-width: 10;
+  }
+  .item {
+    margin-top: 120px; 
+    background-color: #CCCCCC;
+    align-items: center;
+  }
+  .itemName {
+    font-size:28;
+    color:#333333;
+    line-height:42;
+    text-align:left;
+    margin-top: 24;
+  }
+  .itemPhoto {
+    margin-top: 18;
+    width: 220;
+    height: 220;
+    margin-bottom: 18;
+    border-radius: 30;
+    overflow: hidden;
+    background-color: blue;
+  }
+  .itemDesc {
+    font-size:24;
+    margin:12;
+    color:#999999;
+    line-height:36;
+    text-align:left;
+  }
+</style>
+
+<script>
+  module.exports = {
+    data: {
+    },
+    methods: {
+    }
+  }
+</script>


[15/15] incubator-weex git commit: Merge branch 'ios-feature-composite' of https://github.com/cxfeng1/incubator-weex into 0.12-dev

Posted by cx...@apache.org.
Merge branch 'ios-feature-composite' of https://github.com/cxfeng1/incubator-weex into 0.12-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/219cd30a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/219cd30a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/219cd30a

Branch: refs/heads/0.12-dev
Commit: 219cd30a5e92e645c66d3dbc8e0b91fb6b00614e
Parents: 68b2b57 c8c75a2
Author: cxfeng <cx...@apache.org>
Authored: Mon Apr 10 13:53:35 2017 +0800
Committer: cxfeng <cx...@apache.org>
Committed: Mon Apr 10 13:53:35 2017 +0800

----------------------------------------------------------------------
 examples/vue/index.vue                          |  10 +-
 examples/vue/showcase/compositing.vue           |  89 ++++++++
 .../WeexSDK/Sources/Component/WXCellComponent.m |  10 +-
 .../Sources/Component/WXComponent_internal.h    |   8 +-
 .../Sources/Component/WXImageComponent.m        |  90 +++++---
 .../WeexSDK/Sources/Component/WXTextComponent.m | 134 ++++--------
 .../Sources/Display/WXComponent+Display.m       | 218 +++++++++++++------
 ios/sdk/WeexSDK/Sources/Display/WXRoundedRect.h |   4 +
 .../WeexSDK/Sources/Display/WXRoundedRect.mm    |  10 +
 ios/sdk/WeexSDK/Sources/Model/WXComponent.h     |  68 +++++-
 ios/sdk/WeexSDK/Sources/Model/WXComponent.m     |   7 +-
 ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m   |   4 +-
 test/scripts/components/recycler.test.js        |   2 -
 13 files changed, 434 insertions(+), 220 deletions(-)
----------------------------------------------------------------------