Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
* [core] use interface replacce android_bridge_impl
Browse files Browse the repository at this point in the history
  • Loading branch information
lucky-chen authored and YorkShen committed Jun 1, 2018
1 parent 3e002a4 commit 6ba2553
Show file tree
Hide file tree
Showing 17 changed files with 158 additions and 27 deletions.
31 changes: 24 additions & 7 deletions weex_core/Source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ set(COMMON_SRCS
./core/config/core_environment.cpp

./core/moniter/render_performance.cpp
./core/manager/weex_core_manager.cpp )

SET(FINAL_ADD_LIBRARY
${COMMON_SRCS}
)
SET(FINAL_TARGET_LINK_LIBRARIES )

if (ANDROID)
## add_subdirectory for subdirectory has a CMakeLists.txt
Expand Down Expand Up @@ -77,13 +82,25 @@ if (ANDROID)


)
SET(FINAL_ADD_LIBRARY
${FINAL_ADD_LIBRARY}
${ANDROID_SRCS}
)

SET(FINAL_TARGET_LINK_LIBRARIES
${FINAL_TARGET_LINK_LIBRARIES}
wson
android
weexipc
log
z
)

add_library(${WEEXCORE_LIBRARY_NAME} SHARED
${COMMON_SRCS}
${ANDROID_SRCS}
)
endif (ANDROID)

target_include_directories(${WEEXCORE_LIBRARY_NAME} PUBLIC .)
add_library(${WEEXCORE_LIBRARY_NAME} SHARED
${FINAL_ADD_LIBRARY}
)

target_link_libraries(${WEEXCORE_LIBRARY_NAME} wson android weexipc log z)
endif (ANDROID)
target_include_directories(${WEEXCORE_LIBRARY_NAME} PUBLIC .)
target_link_libraries(${WEEXCORE_LIBRARY_NAME} ${FINAL_TARGET_LINK_LIBRARIES})
2 changes: 2 additions & 0 deletions weex_core/Source/android/jsengine/multiprocess/WeexProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <dlfcn.h>
#include <errno.h>
#include <core/layout/measure_func_adapter_impl_android.h>
#include <core/manager/weex_core_manager.h>

const char *s_cacheDir;
bool s_start_pie = true;
Expand Down Expand Up @@ -265,6 +266,7 @@ namespace WeexCore {
jobject params) {

Bridge_Impl_Android::getInstance()->setGlobalRef(jThis);
WeexCoreManager::getInstance()->setPlatformBridge(Bridge_Impl_Android::getInstance());
RenderManager::GetInstance()->SetMeasureFunctionAdapter(new MeasureFunctionAdapterImplAndroid());
std::unique_ptr<IPCSerializer> serializer(createIPCSerializer());
const std::vector<INIT_FRAMEWORK_PARAMS *> &initFrameworkParams = initFromParam(env,
Expand Down
3 changes: 3 additions & 0 deletions weex_core/Source/core/bridge/bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ namespace WeexCore {
virtual int callMoveElement(const char* pageId, const char* ref, const char* parentRef, int index) = 0;

virtual int callAppendTreeCreateFinish(const char* pageId, const char* ref) = 0;

virtual int callHasTransitionPros(const char* pageId, const char* ref,
std::vector<std::pair<std::string, std::string>> *style)=0;
};
} //end WeexCore
#endif //Bridge_h
36 changes: 36 additions & 0 deletions weex_core/Source/core/manager/weex_core_manager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//
// Created by 陈佩翰 on 2018/5/31.
//

#include "weex_core_manager.h"

namespace WeexCore {

WeexCoreManager *WeexCoreManager::m_pInstance = nullptr;

WeexCoreManager *WeexCoreManager::setPlatformBridge(Bridge *pBridge) {
this->platformBridge = pBridge;
}

Bridge *WeexCoreManager::getPlatformBridge() {
return this->platformBridge;
}
}
62 changes: 62 additions & 0 deletions weex_core/Source/core/manager/weex_core_manager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#ifndef WEEXCORE_WEEX_CORE_MANAGER_H
#define WEEXCORE_WEEX_CORE_MANAGER_H

#include <core/bridge/bridge.h>

namespace WeexCore {
class WeexCoreManager {
private:
Bridge *platformBridge = nullptr;
static WeexCoreManager *m_pInstance;

private:
WeexCoreManager() {};

~WeexCoreManager() {};

//just to release singleton object
class Garbo {
public:
~Garbo() {
if (WeexCoreManager::m_pInstance) {
delete WeexCoreManager::m_pInstance;
}
}
};

static Garbo garbo;

public:
static WeexCoreManager *getInstance() {
if (nullptr == m_pInstance) {
m_pInstance = new WeexCoreManager();
}
return m_pInstance;
};

Bridge *getPlatformBridge();

WeexCoreManager *setPlatformBridge(Bridge *pBridge);
};
}

#endif //WEEXCORE_WEEX_CORE_MANAGER_H
1 change: 0 additions & 1 deletion weex_core/Source/core/render/action/render_action.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <core/render/node/render_object.h>
#include <core/render/manager/render_manager.h>
#include <core/render/page/render_page.h>
#include <android/bridge/impl/bridge_impl_android.h>
#include <string>
#include <base/TimeUtils.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
#include <core/manager/weex_core_manager.h>
#include "render_action_add_element.h"

namespace WeexCore {
Expand All @@ -37,8 +38,8 @@ namespace WeexCore {
}

void RenderActionAddElement::ExecuteAction() {
Bridge_Impl_Android::getInstance()->callAddElement(mPageId.c_str(), mComponentType.c_str(), mRef.c_str(),
mIndex, mParentRef.c_str(), mStyles, mAttributes,
mEvents, mMargins, mPaddings, mBorders, mWillLayout);
WeexCoreManager::getInstance()->getPlatformBridge()->callAddElement(mPageId.c_str(), mComponentType.c_str(), mRef.c_str(),
mIndex, mParentRef.c_str(), mStyles, mAttributes,
mEvents, mMargins, mPaddings, mBorders, mWillLayout);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
#include <core/manager/weex_core_manager.h>
#include "render_action_add_event.h"

namespace WeexCore {
Expand All @@ -27,7 +28,7 @@ namespace WeexCore {
}

void RenderActionAddEvent::ExecuteAction() {
Bridge_Impl_Android::getInstance()->callAddEvent(mPageId.c_str(), mRef.c_str(), mEvent.c_str());
WeexCoreManager::getInstance()->getPlatformBridge()->callAddEvent(mPageId.c_str(), mRef.c_str(), mEvent.c_str());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
#include <core/manager/weex_core_manager.h>
#include "render_action_createbody.h"

namespace WeexCore {
Expand All @@ -33,8 +34,8 @@ namespace WeexCore {
}

void RenderActionCreateBody::ExecuteAction() {
Bridge_Impl_Android::getInstance()->callCreateBody(mPageId.c_str(), mComponentType.c_str(), mRef.c_str(),
mStyles, mAttributes, mEvents,
mMargins, mPaddings, mBorders);
WeexCoreManager::getInstance()->getPlatformBridge()->callCreateBody(mPageId.c_str(), mComponentType.c_str(), mRef.c_str(),
mStyles, mAttributes, mEvents,
mMargins, mPaddings, mBorders);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
#include <core/manager/weex_core_manager.h>
#include "render_action_createfinish.h"

namespace WeexCore {
Expand All @@ -25,6 +26,6 @@ namespace WeexCore {
}

void RenderActionCreateFinish::ExecuteAction() {
Bridge_Impl_Android::getInstance()->callCreateFinish(mPageId.c_str());
WeexCoreManager::getInstance()->getPlatformBridge()->callCreateFinish(mPageId.c_str());
}
}
7 changes: 4 additions & 3 deletions weex_core/Source/core/render/action/render_action_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
#include <core/manager/weex_core_manager.h>
#include "render_action_layout.h"

namespace WeexCore {
Expand All @@ -28,9 +29,9 @@ namespace WeexCore {
}

void RenderActionLayout::ExecuteAction() {
Bridge_Impl_Android::getInstance()->callLayout(mPageId.c_str(), mRef.c_str(),
mTop, mBottom, mLeft, mRight,
mHeight, mWidth, index);
WeexCoreManager::getInstance()->getPlatformBridge()->callLayout(mPageId.c_str(), mRef.c_str(),
mTop, mBottom, mLeft, mRight,
mHeight, mWidth, index);
}

void RenderActionLayout::GetLayoutInfo(const WXCoreLayoutNode *node) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
#include <core/manager/weex_core_manager.h>
#include "render_action_move_element.h"

namespace WeexCore {
Expand All @@ -29,6 +30,6 @@ namespace WeexCore {
}

void RenderActionMoveElement::ExecuteAction() {
Bridge_Impl_Android::getInstance()->callMoveElement(mPageId.c_str(), mRef.c_str(), mParentRef.c_str(), mIndex);
WeexCoreManager::getInstance()->getPlatformBridge()->callMoveElement(mPageId.c_str(), mRef.c_str(), mParentRef.c_str(), mIndex);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
#include <core/manager/weex_core_manager.h>
#include "render_action_remove_element.h"

namespace WeexCore {
Expand All @@ -26,6 +27,6 @@ namespace WeexCore {
}

void RenderActionRemoveElement::ExecuteAction() {
Bridge_Impl_Android::getInstance()->callRemoveElement(mPageId.c_str(), mRef.c_str());
WeexCoreManager::getInstance()->getPlatformBridge()->callRemoveElement(mPageId.c_str(), mRef.c_str());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License.
*/
#include "render_action_remove_event.h"
#include <core/manager/weex_core_manager.h>

namespace WeexCore {

Expand All @@ -27,7 +28,8 @@ namespace WeexCore {
}

void RenderActionRemoveEvent::ExecuteAction() {
Bridge_Impl_Android::getInstance()->callRemoveEvent(mPageId.c_str(), mRef.c_str(), mEvent.c_str());
WeexCoreManager::getInstance()->getPlatformBridge()->callRemoveEvent(mPageId.c_str(), mRef.c_str(), mEvent.c_str());
//Bridge_Impl_Android::getInstance()->callRemoveEvent(mPageId.c_str(), mRef.c_str(), mEvent.c_str());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
#include <core/manager/weex_core_manager.h>
#include "render_action_update_attr.h"

namespace WeexCore {
Expand All @@ -28,6 +29,6 @@ namespace WeexCore {
}

void RenderActionUpdateAttr::ExecuteAction() {
Bridge_Impl_Android::getInstance()->callUpdateAttr(mPageId.c_str(), mRef.c_str(), mAttrs);
WeexCoreManager::getInstance()->getPlatformBridge()->callUpdateAttr(mPageId.c_str(), mRef.c_str(), mAttrs);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
#include <core/manager/weex_core_manager.h>
#include "render_action_update_style.h"

namespace WeexCore {
Expand All @@ -34,7 +35,7 @@ namespace WeexCore {
}

void RenderActionUpdateStyle::ExecuteAction() {
Bridge_Impl_Android::getInstance()->callUpdateStyle(mPageId.c_str(), mRef.c_str(), mStyle, mMargin,
mPadding, mBorder);
WeexCoreManager::getInstance()->getPlatformBridge()->callUpdateStyle(mPageId.c_str(), mRef.c_str(), mStyle, mMargin,
mPadding, mBorder);
}
}
5 changes: 3 additions & 2 deletions weex_core/Source/core/render/page/render_page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <core/css/constants_value.h>
#include <core/render/node/factory/render_type.h>
#include <core/render/node/render_list.h>
#include <core/manager/weex_core_manager.h>
#include "render_page.h"
#include "core/render/manager/render_manager.h"
#include "core/render/node/render_object.h"
Expand Down Expand Up @@ -240,8 +241,8 @@ namespace WeexCore {
std::vector<std::pair<std::string, std::string>> *border = nullptr;

bool flag = false;

int result = Bridge_Impl_Android::getInstance()->callHasTransitionPros(mPageId.c_str(), ref.c_str(), src);
int result = WeexCoreManager::getInstance()->getPlatformBridge()->callHasTransitionPros(mPageId.c_str(), ref.c_str(), src);
//int result = Bridge_Impl_Android::getInstance()->callHasTransitionPros(mPageId.c_str(), ref.c_str(), src);

if (result == 1) {
SendUpdateStyleAction(render, src, margin, padding, border);
Expand Down

0 comments on commit 6ba2553

Please sign in to comment.