mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2024-11-27 01:00:50 +00:00
merge conflict fix Signed-off-by: s30029175 <shiqiwei4@huawei.com>
Signed-off-by: sqwlly <shiqiwei4@huawei.com> Change-Id: Ie01c2bcecd032326a92ac85757c58fec8755c7c0
This commit is contained in:
commit
b17c6cc417
@ -22,7 +22,7 @@
|
||||
using namespace OHOS;
|
||||
#ifdef PLAYER_FRAMEWORK_ENABLE
|
||||
static const int CONTENT_TYPE_UNKNOWN = 0;
|
||||
static const int STREAM_USAGE_RINGTONE = 6;
|
||||
static const int STREAM_USAGE_ENFORCED_TONE = 15;
|
||||
#endif
|
||||
|
||||
void BootVideoPlayer::SetVideoPath(const std::string& path)
|
||||
@ -113,7 +113,7 @@ void BootVideoPlayer::SetVideoSound()
|
||||
LOGI("BootVideoPlayer SetVideoSound");
|
||||
Media::Format format;
|
||||
format.PutIntValue(Media::PlayerKeys::CONTENT_TYPE, CONTENT_TYPE_UNKNOWN);
|
||||
format.PutIntValue(Media::PlayerKeys::STREAM_USAGE, STREAM_USAGE_RINGTONE);
|
||||
format.PutIntValue(Media::PlayerKeys::STREAM_USAGE, STREAM_USAGE_ENFORCED_TONE);
|
||||
format.PutIntValue(Media::PlayerKeys::RENDERER_FLAG, 0);
|
||||
int ret = mediaPlayer_->SetParameter(format);
|
||||
if (ret != 0) {
|
||||
|
@ -427,6 +427,8 @@ void ReleaseSwapchainImage(VkDevice device, NativeWindow* window, int releaseFen
|
||||
}
|
||||
|
||||
if (image.image != VK_NULL_HANDLE) {
|
||||
NativeObjectUnreference(image.buffer);
|
||||
image.buffer = nullptr;
|
||||
pDisp->DestroyImage(device, image.image, nullptr);
|
||||
image.image = VK_NULL_HANDLE;
|
||||
}
|
||||
@ -583,6 +585,7 @@ VKAPI_ATTR VkResult CreateImages(uint32_t &numImages, Swapchain* swapchain, cons
|
||||
SWLOGD("vkCreateImage native buffer failed: %{public}u", result);
|
||||
break;
|
||||
}
|
||||
NativeObjectReference(buffer);
|
||||
}
|
||||
|
||||
SWLOGD("swapchain init shared %{public}d", swapchain->shared);
|
||||
|
@ -58,7 +58,8 @@ declare_args() {
|
||||
graphic_2d_feature_enable_stack_culling = false
|
||||
}
|
||||
|
||||
if (graphic_2d_feature_product == "phone") {
|
||||
if (graphic_2d_feature_product == "phone" ||
|
||||
graphic_2d_feature_product == "tablet") {
|
||||
graphic_2d_feature_enable_vulkan = true
|
||||
graphic_2d_feature_enable_ddgr = false
|
||||
graphic_2d_feature_enable_stack_culling = true
|
||||
|
@ -49,6 +49,11 @@ public:
|
||||
vsyncCallbacks_ = cb.callback_;
|
||||
userData_ = cb.userData_;
|
||||
}
|
||||
void SetName(std::string &name)
|
||||
{
|
||||
std::lock_guard<std::mutex> locker(mtx_);
|
||||
name_ = name;
|
||||
}
|
||||
int64_t period_;
|
||||
int64_t timeStamp_;
|
||||
thread_local static inline int64_t periodShared_ = 0;
|
||||
@ -59,6 +64,7 @@ private:
|
||||
VSyncCallback vsyncCallbacks_;
|
||||
void *userData_;
|
||||
std::mutex mtx_;
|
||||
std::string name_;
|
||||
};
|
||||
|
||||
#ifdef __OHOS__
|
||||
|
@ -49,8 +49,8 @@ ohos_shared_library("drawing_napi") {
|
||||
external_deps = [ "napi:ace_napi" ]
|
||||
|
||||
if (current_os == "ohos" || current_os == "ohos_ng") {
|
||||
cflags = [ "-fstack-protector-strong" ]
|
||||
cflags_cc = [ "-fstack-protector-strong" ]
|
||||
cflags = [ "-fstack-protector-all" ]
|
||||
cflags_cc = [ "-fstack-protector-all" ]
|
||||
}
|
||||
|
||||
relative_install_dir = "module/graphics"
|
||||
|
@ -44,6 +44,8 @@ private:
|
||||
static napi_value Blur(napi_env env, napi_callback_info info);
|
||||
static napi_value Brightness(napi_env env, napi_callback_info info);
|
||||
static napi_value Grayscale(napi_env env, napi_callback_info info);
|
||||
static napi_value Invert(napi_env env, napi_callback_info info);
|
||||
static napi_value SetColorMatrix(napi_env env, napi_callback_info info);
|
||||
void AddNextFilter(sk_sp<SkImageFilter> filter);
|
||||
void Render(bool forceCPU);
|
||||
std::vector<sk_sp<SkImageFilter> > skFilters_;
|
||||
|
@ -144,6 +144,8 @@ napi_value FilterNapi::Init(napi_env env, napi_value exports)
|
||||
DECLARE_NAPI_FUNCTION("blur", Blur),
|
||||
DECLARE_NAPI_FUNCTION("brightness", Brightness),
|
||||
DECLARE_NAPI_FUNCTION("grayscale", Grayscale),
|
||||
DECLARE_NAPI_FUNCTION("invert", Invert),
|
||||
DECLARE_NAPI_FUNCTION("setColorMatrix", SetColorMatrix),
|
||||
DECLARE_NAPI_FUNCTION("getPixelMap", GetPixelMap),
|
||||
DECLARE_NAPI_FUNCTION("getPixelMapAsync", GetPixelMapAsync),
|
||||
DECLARE_NAPI_FUNCTION("getEffectPixelMap", GetPixelMapAsync),
|
||||
@ -495,5 +497,84 @@ napi_value FilterNapi::Grayscale(napi_env env, napi_callback_info info)
|
||||
thisFilter->AddNextFilter(grayscale);
|
||||
return _this;
|
||||
}
|
||||
|
||||
napi_value FilterNapi::Invert(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value _this;
|
||||
napi_status status;
|
||||
IMG_JS_NO_ARGS(env, info, status, _this);
|
||||
FilterNapi* thisFilter = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, _this, reinterpret_cast<void**>(&thisFilter)));
|
||||
if (thisFilter == nullptr) {
|
||||
EFFECT_LOG_I("FilterNapi napi_unwrap is Faild");
|
||||
return nullptr;
|
||||
}
|
||||
auto invert = Rosen::SKImageFilterFactory::Invert();
|
||||
thisFilter->AddNextFilter(invert);
|
||||
return _this;
|
||||
}
|
||||
|
||||
static uint32_t ParseColorMatrix(napi_env env, napi_value val, PixelColorMatrix &colorMatrix)
|
||||
{
|
||||
bool isArray = false;
|
||||
napi_is_array(env, val, &isArray);
|
||||
if (!isArray) {
|
||||
EFFECT_LOG_E("Parse color matrix is not an array");
|
||||
return ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
uint32_t len = 0;
|
||||
if (napi_get_array_length(env, val, &len) != napi_ok ||
|
||||
len != PixelColorMatrix::MATRIX_SIZE) {
|
||||
EFFECT_LOG_E("Parse color matrix napi_get_array_length failed %{public}u", len);
|
||||
return ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
double itemVal;
|
||||
napi_value item;
|
||||
napi_get_element(env, val, i, &item);
|
||||
if (napi_get_value_double(env, item, &itemVal) != napi_ok) {
|
||||
EFFECT_LOG_E("Parse format in item failed %{public}zu", i);
|
||||
return ERR_INVALID_PARAM;
|
||||
}
|
||||
colorMatrix.val[i] = static_cast<float>(itemVal);
|
||||
EFFECT_LOG_D("FilterNapi color matrix [%{public}zu] = %{public}f.", i, colorMatrix.val[i]);
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
napi_value FilterNapi::SetColorMatrix(napi_env env, napi_callback_info info)
|
||||
{
|
||||
size_t argc = NUM_1;
|
||||
napi_value argv[NUM_1];
|
||||
napi_value _this;
|
||||
napi_status status;
|
||||
uint32_t res = 0;
|
||||
PixelColorMatrix colorMatrix;
|
||||
IMG_JS_ARGS(env, info, status, argc, argv, _this);
|
||||
if (!IMG_IS_OK(status) || argc != NUM_1) {
|
||||
EFFECT_LOG_E("FilterNapi parse input falid");
|
||||
napi_throw_error(env, std::to_string(ERR_INVALID_PARAM).c_str(),
|
||||
"FilterNapi parse input falid, Color matrix mismatch");
|
||||
return nullptr;
|
||||
}
|
||||
res = ParseColorMatrix(env, argv[NUM_0], colorMatrix);
|
||||
if (res != SUCCESS) {
|
||||
EFFECT_LOG_E("Color matrix mismatch");
|
||||
napi_throw_error(env, std::to_string(res).c_str(), "Color matrix mismatch");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FilterNapi* thisFilter = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, _this, reinterpret_cast<void**>(&thisFilter)));
|
||||
if (thisFilter == nullptr) {
|
||||
EFFECT_LOG_E("FilterNapi napi_unwrap is Faild");
|
||||
return nullptr;
|
||||
}
|
||||
auto applyColorMatrix = Rosen::SKImageFilterFactory::ApplyColorMatrix(colorMatrix);
|
||||
thisFilter->AddNextFilter(applyColorMatrix);
|
||||
return _this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
# 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.
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("//foundation/graphic/graphic_2d/graphic_config.gni")
|
||||
@ -52,6 +52,7 @@ ohos_shared_library("text_napi") {
|
||||
|
||||
ohos_shared_library("text_napi_impl") {
|
||||
sources = [
|
||||
"enum_napi/text_enum_napi.cpp",
|
||||
"fontcollection_napi/js_fontcollection.cpp",
|
||||
"js_text_init.cpp",
|
||||
"js_text_utils.cpp",
|
||||
|
155
interfaces/kits/napi/graphic/text/enum_napi/text_enum_napi.cpp
Normal file
155
interfaces/kits/napi/graphic/text/enum_napi/text_enum_napi.cpp
Normal file
@ -0,0 +1,155 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include "utils/log.h"
|
||||
#include "text_enum_napi.h"
|
||||
namespace OHOS::Rosen {
|
||||
struct JsEnumInt {
|
||||
std::string_view enumName;
|
||||
size_t enumInt;
|
||||
};
|
||||
|
||||
static const std::vector<struct JsEnumInt> g_textAlign = {
|
||||
{ "LEFT", static_cast<size_t>(TextAlign::LEFT) },
|
||||
{ "RIGHT", static_cast<size_t>(TextAlign::RIGHT) },
|
||||
{ "CENTER", static_cast<size_t>(TextAlign::CENTER) },
|
||||
{ "JUSTIFY", static_cast<size_t>(TextAlign::JUSTIFY) },
|
||||
{ "START", static_cast<size_t>(TextAlign::START) },
|
||||
{ "END", static_cast<size_t>(TextAlign::END) },
|
||||
};
|
||||
|
||||
static const std::vector<struct JsEnumInt> g_textDecorationStyle = {
|
||||
{ "SOLID", static_cast<size_t>(TextDecorationStyle::SOLID) },
|
||||
{ "DOUBLE", static_cast<size_t>(TextDecorationStyle::DOUBLE) },
|
||||
{ "DOTTED", static_cast<size_t>(TextDecorationStyle::DOTTED) },
|
||||
{ "DASHED", static_cast<size_t>(TextDecorationStyle::DASHED) },
|
||||
{ "WAVY", static_cast<size_t>(TextDecorationStyle::WAVY) },
|
||||
};
|
||||
|
||||
static const std::vector<struct JsEnumInt> g_fontWeight = {
|
||||
{ "W100", static_cast<size_t>(FontWeight::W100) },
|
||||
{ "W200", static_cast<size_t>(FontWeight::W200) },
|
||||
{ "W300", static_cast<size_t>(FontWeight::W300) },
|
||||
{ "W400", static_cast<size_t>(FontWeight::W400) },
|
||||
{ "W500", static_cast<size_t>(FontWeight::W500) },
|
||||
{ "W600", static_cast<size_t>(FontWeight::W600) },
|
||||
{ "W700", static_cast<size_t>(FontWeight::W700) },
|
||||
{ "W800", static_cast<size_t>(FontWeight::W800) },
|
||||
{ "W900", static_cast<size_t>(FontWeight::W900) },
|
||||
};
|
||||
|
||||
static const std::vector<struct JsEnumInt> g_fontStyle = {
|
||||
{ "NORMAL", static_cast<size_t>(FontStyle::NORMAL) },
|
||||
{ "ITALIC", static_cast<size_t>(FontStyle::ITALIC) },
|
||||
};
|
||||
|
||||
static const std::vector<struct JsEnumInt> g_textBaseline = {
|
||||
{ "ALPHABETIC", static_cast<size_t>(TextBaseline::ALPHABETIC) },
|
||||
{ "IDEOGRAPHIC", static_cast<size_t>(TextBaseline::IDEOGRAPHIC) },
|
||||
};
|
||||
|
||||
static const std::vector<struct JsEnumInt> g_textDirection = {
|
||||
{ "RTL", static_cast<size_t>(TextDirection::RTL) },
|
||||
{ "LTR", static_cast<size_t>(TextDirection::LTR) },
|
||||
};
|
||||
|
||||
static const std::vector<struct JsEnumInt> g_wordBreakType = {
|
||||
{ "NORMAL", static_cast<size_t>(WordBreakType::NORMAL) },
|
||||
{ "BREAK_ALL", static_cast<size_t>(WordBreakType::BREAK_ALL) },
|
||||
{ "BREAK_WORD", static_cast<size_t>(WordBreakType::BREAK_WORD) },
|
||||
};
|
||||
|
||||
static const std::vector<struct JsEnumInt> g_breakStrategy = {
|
||||
{ "GREEDY", static_cast<size_t>(BreakStrategy::GREEDY) },
|
||||
{ "HIGH_QUALITY", static_cast<size_t>(BreakStrategy::HIGH_QUALITY) },
|
||||
{ "BALANCED", static_cast<size_t>(BreakStrategy::BALANCED) },
|
||||
};
|
||||
|
||||
static const std::vector<struct JsEnumInt> g_ellipsisModal = {
|
||||
{ "HEAD", static_cast<size_t>(EllipsisModal::HEAD) },
|
||||
{ "MIDDLE", static_cast<size_t>(EllipsisModal::MIDDLE) },
|
||||
{ "TAIL", static_cast<size_t>(EllipsisModal::TAIL) },
|
||||
};
|
||||
|
||||
static const std::vector<struct JsEnumInt> g_textDecoration = {
|
||||
{ "NONE", static_cast<size_t>(TextDecoration::NONE) },
|
||||
{ "UNDERLINE", static_cast<size_t>(TextDecoration::UNDERLINE) },
|
||||
{ "OVERLINE", static_cast<size_t>(TextDecoration::OVERLINE) },
|
||||
{ "LINE_THROUGH", static_cast<size_t>(TextDecoration::LINE_THROUGH) },
|
||||
};
|
||||
|
||||
static const std::map<std::string_view, const std::vector<struct JsEnumInt>&> g_intEnumClassMap = {
|
||||
{ "TextAlign", g_textAlign },
|
||||
{ "TextDecorationStyle", g_textDecorationStyle },
|
||||
{ "FontWeight", g_fontWeight },
|
||||
{ "FontStyle", g_fontStyle },
|
||||
{ "TextBaseline", g_textBaseline },
|
||||
{ "TextDirection", g_textDirection },
|
||||
{ "WordBreakType", g_wordBreakType },
|
||||
{ "BreakStrategy", g_breakStrategy },
|
||||
{ "EllipsisModal", g_ellipsisModal },
|
||||
{ "TextDecoration", g_textDecoration },
|
||||
};
|
||||
|
||||
napi_value JsEnum::JsEnumIntInit(napi_env env, napi_value exports)
|
||||
{
|
||||
for (auto it = g_intEnumClassMap.begin(); it != g_intEnumClassMap.end(); it++) {
|
||||
auto &enumClassName = it->first;
|
||||
auto &enumItemVec = it->second;
|
||||
auto vecSize = enumItemVec.size();
|
||||
std::vector<napi_value> value;
|
||||
value.resize(vecSize);
|
||||
for (size_t index = 0; index < vecSize; ++index) {
|
||||
napi_create_uint32(env, enumItemVec[index].enumInt, &value[index]);
|
||||
}
|
||||
|
||||
std::vector<napi_property_descriptor> property;
|
||||
property.resize(vecSize);
|
||||
for (size_t index = 0; index < vecSize; ++index) {
|
||||
property[index] = napi_property_descriptor DECLARE_NAPI_STATIC_PROPERTY(
|
||||
enumItemVec[index].enumName.data(), value[index]);
|
||||
}
|
||||
|
||||
auto napiConstructor = [](napi_env env, napi_callback_info info) {
|
||||
napi_value jsThis = nullptr;
|
||||
napi_get_cb_info(env, info, nullptr, nullptr, &jsThis, nullptr);
|
||||
return jsThis;
|
||||
};
|
||||
|
||||
napi_value result = nullptr;
|
||||
napi_status napiStatus = napi_define_class(env, enumClassName.data(), NAPI_AUTO_LENGTH, napiConstructor,
|
||||
nullptr, property.size(), property.data(), &result);
|
||||
if (napiStatus != napi_ok) {
|
||||
LOGE("napi_define_class falied");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
napiStatus = napi_set_named_property(env, exports, enumClassName.data(), result);
|
||||
if (napiStatus != napi_ok) {
|
||||
LOGE("napi_set_named_property falied");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
return exports;
|
||||
}
|
||||
|
||||
napi_value JsEnum::Init(napi_env env, napi_value exports)
|
||||
{
|
||||
JsEnumIntInit(env, exports);
|
||||
return exports;
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
35
interfaces/kits/napi/graphic/text/enum_napi/text_enum_napi.h
Normal file
35
interfaces/kits/napi/graphic/text/enum_napi/text_enum_napi.h
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed 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 OHOS_ROSEN_TEXT_ENUM_NAPI_H
|
||||
#define OHOS_ROSEN_TEXT_ENUM_NAPI_H
|
||||
|
||||
#include <memory>
|
||||
#include <native_engine/native_engine.h>
|
||||
#include <native_engine/native_value.h>
|
||||
#include "typography_style.h"
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
class JsEnum {
|
||||
public:
|
||||
JsEnum() = default;
|
||||
~JsEnum() = default;
|
||||
static napi_value Init(napi_env env, napi_value exports);
|
||||
|
||||
private:
|
||||
static napi_value JsEnumIntInit(napi_env env, napi_value exports);
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
#endif // OHOS_ROSEN_JS_ENUM_NAPI_H
|
@ -14,6 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "js_text_init.h"
|
||||
#include "enum_napi/text_enum_napi.h"
|
||||
#include "fontcollection_napi/js_fontcollection.h"
|
||||
#include "paragraph_style_napi/js_paragraphstyle.h"
|
||||
#include "utils/log.h"
|
||||
@ -22,6 +23,7 @@ namespace OHOS::Rosen {
|
||||
napi_value TextInit(napi_env env, napi_value exportObj)
|
||||
{
|
||||
JsFontCollection::Init(env, exportObj);
|
||||
JsEnum::Init(env, exportObj);
|
||||
return exportObj;
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
|
@ -41,4 +41,148 @@ napi_value NapiThrowError(napi_env env, DrawingErrorCode err, const std::string&
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(err), message));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
bool OnMakeFontFamilies(napi_env& env, napi_value jsValue, std::vector<std::string> &fontFamilies)
|
||||
{
|
||||
if (jsValue == nullptr) {
|
||||
return false;
|
||||
}
|
||||
uint32_t size = 0;
|
||||
napi_get_array_length(env, jsValue, &size);
|
||||
if (size == 0) {
|
||||
return false;
|
||||
}
|
||||
for (uint32_t i = 0; i < size; i++) {
|
||||
napi_value tempStr = nullptr;
|
||||
napi_get_element(env, jsValue, i, &tempStr);
|
||||
std::string text = "";
|
||||
if (ConvertFromJsValue(env, tempStr, text)) {
|
||||
fontFamilies.push_back(text);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SetTextStyleColor(napi_env env, napi_value argValue, const std::string& str, Drawing::Color& colorSrc)
|
||||
{
|
||||
napi_value tempValue = nullptr;
|
||||
napi_value tempValueChild = nullptr;
|
||||
napi_get_named_property(env, argValue, str.c_str(), &tempValue);
|
||||
if (tempValue != nullptr) {
|
||||
return false;
|
||||
}
|
||||
int32_t alpha = 0;
|
||||
int32_t red = 0;
|
||||
int32_t green = 0;
|
||||
int32_t blue = 0;
|
||||
napi_get_named_property(env, tempValue, "alpha", &tempValueChild);
|
||||
bool isAlphaOk = ConvertClampFromJsValue(env, tempValueChild, alpha, 0, Drawing::Color::RGB_MAX);
|
||||
napi_get_named_property(env, tempValue, "red", &tempValueChild);
|
||||
bool isRedOk = ConvertClampFromJsValue(env, tempValueChild, red, 0, Drawing::Color::RGB_MAX);
|
||||
napi_get_named_property(env, tempValue, "green", &tempValueChild);
|
||||
bool isGreenOk = ConvertClampFromJsValue(env, tempValueChild, green, 0, Drawing::Color::RGB_MAX);
|
||||
napi_get_named_property(env, tempValue, "blue", &tempValueChild);
|
||||
bool isBlueOk = ConvertClampFromJsValue(env, tempValueChild, blue, 0, Drawing::Color::RGB_MAX);
|
||||
if (isAlphaOk && isRedOk && isGreenOk && isBlueOk) {
|
||||
Drawing::Color color(Drawing::Color::ColorQuadSetARGB(alpha, red, green, blue));
|
||||
colorSrc = color;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GetTextStyleFromJS(napi_env env, napi_value argValue, TextStyle& textStyle)
|
||||
{
|
||||
if (argValue == nullptr) {
|
||||
return false;
|
||||
}
|
||||
SetTextStyleColor(env, argValue, "color", textStyle.color);
|
||||
|
||||
napi_value tempValue = nullptr;
|
||||
napi_get_named_property(env, argValue, "fontWeight", &tempValue);
|
||||
uint32_t fontWeight = 0;
|
||||
if (napi_get_value_uint32(env, tempValue, &fontWeight)== napi_ok) {
|
||||
textStyle.fontWeight = FontWeight(fontWeight);
|
||||
}
|
||||
napi_get_named_property(env, argValue, "baseline", &tempValue);
|
||||
uint32_t baseline = 0;
|
||||
if (napi_get_value_uint32(env, tempValue, &baseline)== napi_ok) {
|
||||
textStyle.baseline = TextBaseline(baseline);
|
||||
}
|
||||
SetTextStyleDoubleValueFromJS(env, argValue, "fontSize", textStyle.fontSize);
|
||||
|
||||
std::vector<std::string> fontFamilies;
|
||||
napi_get_named_property(env, argValue, "fontFamilies", &tempValue);
|
||||
if (OnMakeFontFamilies(env, tempValue, fontFamilies)== napi_ok) {
|
||||
textStyle.fontFamilies = fontFamilies;
|
||||
}
|
||||
|
||||
SetTextStyleDoubleValueFromJS(env, argValue, "letterSpacing", textStyle.letterSpacing);
|
||||
SetTextStyleDoubleValueFromJS(env, argValue, "wordSpacing", textStyle.wordSpacing);
|
||||
SetTextStyleDoubleValueFromJS(env, argValue, "heightScale", textStyle.heightScale);
|
||||
SetTextStyleBooleValueFromJS(env, argValue, "halfLeading", textStyle.halfLeading);
|
||||
SetTextStyleBooleValueFromJS(env, argValue, "heightOnly", textStyle.heightOnly);
|
||||
napi_get_named_property(env, argValue, "ellipsis", &tempValue);
|
||||
|
||||
std::string text = "";
|
||||
if (ConvertFromJsValue(env, tempValue, text)) {
|
||||
textStyle.ellipsis = Str8ToStr16(text);
|
||||
}
|
||||
napi_get_named_property(env, argValue, "ellipsisModal", &tempValue);
|
||||
uint32_t ellipsisModal = 0;
|
||||
if (napi_get_value_uint32(env, tempValue, &ellipsisModal)== napi_ok) {
|
||||
textStyle.ellipsisModal = EllipsisModal(ellipsisModal);
|
||||
}
|
||||
napi_get_named_property(env, argValue, "locale", &tempValue);
|
||||
std::string textLocale = "";
|
||||
if (ConvertFromJsValue(env, tempValue, textLocale)) {
|
||||
textStyle.locale = textLocale;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GetParagraphStyleFromJS(napi_env env, napi_value argValue, TypographyStyle& pographyStyle)
|
||||
{
|
||||
if (argValue == nullptr) {
|
||||
return false;
|
||||
}
|
||||
napi_value tempValue = nullptr;
|
||||
napi_get_named_property(env, argValue, "textStyle", &tempValue);
|
||||
TextStyle textStyle;
|
||||
if (GetTextStyleFromJS(env, tempValue, textStyle)) {
|
||||
pographyStyle.insideTextStyle = textStyle;
|
||||
}
|
||||
|
||||
napi_get_named_property(env, argValue, "textDirection", &tempValue);
|
||||
uint32_t textDirection = 0;
|
||||
if (napi_get_value_uint32(env, tempValue, &textDirection)== napi_ok) {
|
||||
pographyStyle.textDirection = TextDirection(textDirection);
|
||||
}
|
||||
|
||||
napi_get_named_property(env, argValue, "align", &tempValue);
|
||||
uint32_t align = 0;
|
||||
if (napi_get_value_uint32(env, tempValue, &align)== napi_ok) {
|
||||
pographyStyle.textAlign = TextAlign(align);
|
||||
}
|
||||
|
||||
napi_get_named_property(env, argValue, "wordBreak", &tempValue);
|
||||
uint32_t wordBreak = 0;
|
||||
if (napi_get_value_uint32(env, tempValue, &wordBreak)== napi_ok) {
|
||||
pographyStyle.wordBreakType = WordBreakType(wordBreak);
|
||||
}
|
||||
|
||||
napi_get_named_property(env, argValue, "maxLines", &tempValue);
|
||||
uint32_t maxLines = 0;
|
||||
if (napi_get_value_uint32(env, tempValue, &maxLines)== napi_ok) {
|
||||
pographyStyle.maxLines = maxLines;
|
||||
}
|
||||
|
||||
napi_get_named_property(env, argValue, "breakStrategy", &tempValue);
|
||||
uint32_t breakStrategy = 0;
|
||||
if (napi_get_value_uint32(env, tempValue, &breakStrategy)== napi_ok) {
|
||||
pographyStyle.breakStrategy = BreakStrategy(breakStrategy);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace OHOS::Rosen
|
||||
|
@ -20,6 +20,12 @@
|
||||
#include "native_engine/native_engine.h"
|
||||
#include "native_engine/native_value.h"
|
||||
|
||||
#include "utils/log.h"
|
||||
#include "draw/color.h"
|
||||
#include "text_style.h"
|
||||
#include "typography_style.h"
|
||||
#include <codecvt>
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
constexpr size_t ARGC_ONE = 1;
|
||||
constexpr size_t ARGC_TWO = 2;
|
||||
@ -222,5 +228,39 @@ void BindNativeFunction(napi_env env, napi_value object, const char* name, const
|
||||
napi_value CreateJsError(napi_env env, int32_t errCode, const std::string& message);
|
||||
|
||||
napi_value NapiThrowError(napi_env env, DrawingErrorCode err, const std::string& message);
|
||||
|
||||
inline std::u16string Str8ToStr16(const std::string &str)
|
||||
{
|
||||
return std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> {}.from_bytes(str);
|
||||
}
|
||||
|
||||
inline void SetTextStyleDoubleValueFromJS(napi_env env, napi_value argValue, const std::string str, double& cValue)
|
||||
{
|
||||
napi_value tempValue = nullptr;
|
||||
napi_get_named_property(env, argValue, str.c_str(), &tempValue);
|
||||
if (tempValue == nullptr) {
|
||||
return;
|
||||
}
|
||||
ConvertFromJsValue(env, tempValue, cValue);
|
||||
}
|
||||
|
||||
inline void SetTextStyleBooleValueFromJS(napi_env env, napi_value argValue, const std::string str, bool& cValue)
|
||||
{
|
||||
napi_value tempValue = nullptr;
|
||||
napi_get_named_property(env, argValue, str.c_str(), &tempValue);
|
||||
if (tempValue == nullptr) {
|
||||
return;
|
||||
}
|
||||
ConvertFromJsValue(env, tempValue, cValue);
|
||||
}
|
||||
|
||||
bool OnMakeFontFamilies(napi_env& env, napi_value jsValue, std::vector<std::string> &fontFamilies);
|
||||
|
||||
bool SetTextStyleColor(napi_env env, napi_value argValue, const std::string& str, Drawing::Color& colorSrc);
|
||||
|
||||
bool GetTextStyleFromJS(napi_env env, napi_value argValue, TextStyle& textStyle);
|
||||
|
||||
bool GetParagraphStyleFromJS(napi_env env, napi_value argValue, TypographyStyle& pographyStyle);
|
||||
|
||||
} // namespace OHOS::Rosen
|
||||
#endif // OHOS_JS_TEXT_UTILS_H
|
@ -190,6 +190,15 @@ if (enable_text_gine) {
|
||||
]
|
||||
|
||||
external_deps = [ "hilog:libhilog" ]
|
||||
|
||||
is_cross_platform =
|
||||
current_os == "mac" || current_os == "mingw" || current_os == "linux" ||
|
||||
current_os == "android" || current_os == "ios"
|
||||
|
||||
if (!is_cross_platform) {
|
||||
external_deps += [ "hitrace:hitrace_meter" ]
|
||||
}
|
||||
|
||||
part_name = "graphic_2d"
|
||||
subsystem_name = "graphic"
|
||||
}
|
||||
|
@ -110,6 +110,19 @@ static std::string RemoveQuotes(const std::string& str)
|
||||
return str.substr(start, end); // Remove quotation marks from both ends.
|
||||
}
|
||||
|
||||
void CopyTextStyleSymbol(const TextStyle& style, SPText::TextStyle& textStyle)
|
||||
{
|
||||
textStyle.symbol.SetRenderColor(style.symbol.GetRenderColor());
|
||||
textStyle.symbol.SetRenderMode(style.symbol.GetRenderMode());
|
||||
textStyle.symbol.SetSymbolEffect(style.symbol.GetEffectStrategy());
|
||||
textStyle.symbol.SetAnimationMode(style.symbol.GetAnimationMode());
|
||||
textStyle.symbol.SetRepeatCount(style.symbol.GetRepeatCount());
|
||||
textStyle.symbol.SetAminationStart(style.symbol.GetAminationStart());
|
||||
for (auto [tag, value] : style.symbol.GetVisualMap()) {
|
||||
textStyle.fontFeatures.SetFeature(RemoveQuotes(tag), value);
|
||||
}
|
||||
}
|
||||
|
||||
SPText::TextStyle Convert(const TextStyle& style)
|
||||
{
|
||||
SPText::TextStyle textStyle;
|
||||
@ -141,12 +154,7 @@ SPText::TextStyle Convert(const TextStyle& style)
|
||||
textStyle.isPlaceholder = style.isPlaceholder;
|
||||
|
||||
if (style.isSymbolGlyph) {
|
||||
textStyle.symbol.SetRenderColor(style.symbol.GetRenderColor());
|
||||
textStyle.symbol.SetRenderMode(style.symbol.GetRenderMode());
|
||||
textStyle.symbol.SetSymbolEffect(style.symbol.GetEffectStrategy());
|
||||
textStyle.symbol.SetAnimationMode(style.symbol.GetAnimationMode());
|
||||
textStyle.symbol.SetRepeatCount(style.symbol.GetRepeatCount());
|
||||
textStyle.symbol.SetAminationStart(style.symbol.GetAminationStart());
|
||||
CopyTextStyleSymbol(style, textStyle);
|
||||
}
|
||||
if (style.backgroundBrush.has_value() || style.backgroundPen.has_value()) {
|
||||
textStyle.background = SPText::PaintRecord(style.backgroundBrush, style.backgroundPen);
|
||||
|
@ -222,7 +222,8 @@ Boundary Typography::GetActualTextRange(int lineNumber, bool includeSpaces)
|
||||
|
||||
double Typography::GetLineHeight(int lineNumber)
|
||||
{
|
||||
const auto &lines = paragraph_->GetLineMetrics();
|
||||
std::vector<size_t> startIndexs;
|
||||
const auto &lines = paragraph_->GetLineMetrics(startIndexs);
|
||||
if (lineNumber < static_cast<int>(lines.size())) {
|
||||
return lines[lineNumber].height;
|
||||
}
|
||||
@ -231,7 +232,8 @@ double Typography::GetLineHeight(int lineNumber)
|
||||
|
||||
double Typography::GetLineWidth(int lineNumber)
|
||||
{
|
||||
const auto &lines = paragraph_->GetLineMetrics();
|
||||
std::vector<size_t> startIndexs;
|
||||
const auto &lines = paragraph_->GetLineMetrics(startIndexs);
|
||||
if (lineNumber < static_cast<int>(lines.size())) {
|
||||
return lines[lineNumber].width;
|
||||
}
|
||||
@ -264,13 +266,13 @@ bool Typography::GetLineInfo(int lineNumber, bool oneLine, bool includeWhitespac
|
||||
}
|
||||
|
||||
skia::textlayout::LineMetrics sklineMetrics;
|
||||
if (!paragraph_->GetLineMetricsAt(lineNumber, &sklineMetrics)) {
|
||||
size_t startIndex;
|
||||
if (!paragraph_->GetLineMetricsAt(lineNumber, &sklineMetrics, startIndex)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!sklineMetrics.fLineMetrics.empty() &&
|
||||
sklineMetrics.fLineMetrics.find(sklineMetrics.fStartIndex) != sklineMetrics.fLineMetrics.end()) {
|
||||
const auto &skFontMetrics = sklineMetrics.fLineMetrics.at(sklineMetrics.fStartIndex).font_metrics;
|
||||
if (!sklineMetrics.fLineMetrics.empty()) {
|
||||
const auto &skFontMetrics = sklineMetrics.fLineMetrics.at(startIndex).font_metrics;
|
||||
lineMetrics->firstCharMetrics = skFontMetrics;
|
||||
if (oneLine) {
|
||||
lineMetrics->ascender = sklineMetrics.fAscent;
|
||||
@ -310,12 +312,13 @@ std::vector<LineMetrics> Typography::GetLineMetrics()
|
||||
{
|
||||
std::vector<LineMetrics> lineMetrics;
|
||||
if (paragraph_ != nullptr) {
|
||||
auto metrics = paragraph_->GetLineMetrics();
|
||||
std::vector<size_t> startIndexs;
|
||||
int index = 0;
|
||||
auto metrics = paragraph_->GetLineMetrics(startIndexs);
|
||||
for (SPText::LineMetrics& spLineMetrics : metrics) {
|
||||
LineMetrics& line = lineMetrics.emplace_back();
|
||||
if (!spLineMetrics.runMetrics.empty() &&
|
||||
spLineMetrics.runMetrics.find(spLineMetrics.startIndex) != spLineMetrics.runMetrics.end()) {
|
||||
auto &spFontMetrics = spLineMetrics.runMetrics.at(spLineMetrics.startIndex).fontMetrics;
|
||||
if (!spLineMetrics.runMetrics.empty()) {
|
||||
auto &spFontMetrics = spLineMetrics.runMetrics.at(startIndexs[index++]).fontMetrics;
|
||||
line.firstCharMetrics = spFontMetrics;
|
||||
line.capHeight = spFontMetrics.fCapHeight;
|
||||
line.xHeight = spFontMetrics.fXHeight;
|
||||
@ -345,13 +348,13 @@ bool Typography::GetLineMetricsAt(int lineNumber, LineMetrics* lineMetrics)
|
||||
return false;
|
||||
}
|
||||
skia::textlayout::LineMetrics skLineMetrics;
|
||||
if (!paragraph_->GetLineMetricsAt(lineNumber, &skLineMetrics)) {
|
||||
size_t startIndex;
|
||||
if (!paragraph_->GetLineMetricsAt(lineNumber, &skLineMetrics, startIndex)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!skLineMetrics.fLineMetrics.empty() &&
|
||||
skLineMetrics.fLineMetrics.find(skLineMetrics.fStartIndex) != skLineMetrics.fLineMetrics.end()) {
|
||||
const auto &skFontMetrics = skLineMetrics.fLineMetrics.at(skLineMetrics.fStartIndex).font_metrics;
|
||||
if (!skLineMetrics.fLineMetrics.empty()) {
|
||||
const auto &skFontMetrics = skLineMetrics.fLineMetrics.at(startIndex).font_metrics;
|
||||
lineMetrics->firstCharMetrics = skFontMetrics;
|
||||
lineMetrics->capHeight = skFontMetrics.fCapHeight;
|
||||
lineMetrics->xHeight = skFontMetrics.fXHeight;
|
||||
|
@ -37,6 +37,12 @@ static const std::map<uint32_t, Drawing::DrawingEffectStrategy> EFFECT_TYPES = {
|
||||
{4, Drawing::DrawingEffectStrategy::DISAPPEAR},
|
||||
{5, Drawing::DrawingEffectStrategy::BOUNCE}};
|
||||
|
||||
enum VisualMode {
|
||||
VISUAL_MEDIUM = 0,
|
||||
VISUAL_SMALL = 1,
|
||||
VISUAL_LARGER = 2
|
||||
};
|
||||
|
||||
class RS_EXPORT HMSymbolTxt {
|
||||
public:
|
||||
HMSymbolTxt() {}
|
||||
@ -109,7 +115,7 @@ public:
|
||||
|
||||
void SetAnimationMode(const uint16_t animationMode)
|
||||
{
|
||||
animationMode_ = animationMode > 0 ? 1: 0; // 1 is whole or add, 0 is hierarchical or iterate
|
||||
animationMode_ = animationMode > 0 ? 1 : 0; // 1 is whole or add, 0 is hierarchical or iterate
|
||||
}
|
||||
|
||||
void SetRepeatCount(const int repeatCount)
|
||||
@ -137,13 +143,35 @@ public:
|
||||
return aminationStart_;
|
||||
}
|
||||
|
||||
void SetVisualMode(const VisualMode visual)
|
||||
{
|
||||
visualMap_.clear();
|
||||
if (visual == VisualMode::VISUAL_SMALL) {
|
||||
visualMap_["ss01"] = 1;
|
||||
}
|
||||
|
||||
if (visual == VisualMode::VISUAL_LARGER) {
|
||||
visualMap_["ss02"] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
std::map<std::string, int> GetVisualMap() const
|
||||
{
|
||||
return visualMap_;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<Drawing::DrawingSColor> colorList_;
|
||||
Drawing::DrawingSymbolRenderingStrategy renderMode_ = Drawing::DrawingSymbolRenderingStrategy::SINGLE;
|
||||
Drawing::DrawingEffectStrategy effectStrategy_ = Drawing::DrawingEffectStrategy::NONE;
|
||||
|
||||
// animationMode_ is the implementation mode of the animation effect:
|
||||
// common_animations: the 0 is the wholeSymbol effect and 1 is the byLayer effect;
|
||||
// variable_color : the 0 is the cumulative effect and 1 is the iteratuve effect.
|
||||
uint16_t animationMode_ = 1;
|
||||
int repeatCount_ = 1;
|
||||
bool aminationStart_ = true;
|
||||
std::map<std::string, int> visualMap_;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -80,6 +80,14 @@ template("skia_libtxt") {
|
||||
defines += [ "HM_SYMBOL_TXT_ENABLE" ]
|
||||
}
|
||||
|
||||
is_cross_platform =
|
||||
current_os == "mac" || current_os == "mingw" || current_os == "linux" ||
|
||||
current_os == "android" || current_os == "ios"
|
||||
|
||||
if (is_cross_platform) {
|
||||
defines += [ "TXT_TRACE_DISABLE" ]
|
||||
}
|
||||
|
||||
if (defined(use_rosen_drawing) && use_rosen_drawing) {
|
||||
defines += [
|
||||
"USE_ROSEN_DRAWING",
|
||||
@ -99,6 +107,10 @@ template("skia_libtxt") {
|
||||
]
|
||||
|
||||
external_deps += [ "hilog:libhilog" ]
|
||||
|
||||
if (!is_cross_platform) {
|
||||
external_deps += [ "hitrace:hitrace_meter" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
47
rosen/modules/2d_engine/rosen_text/skia_txt/impl/common.h
Normal file
47
rosen/modules/2d_engine/rosen_text/skia_txt/impl/common.h
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.. All rights reserved.
|
||||
* Licensed 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 ROSEN_MODULES_SPTEXT_COMMON_H
|
||||
#define ROSEN_MODULES_SPTEXT_COMMON_H
|
||||
|
||||
#ifndef TXT_TRACE_DISABLE
|
||||
#include <hitrace_meter.h>
|
||||
#include <parameters.h>
|
||||
#endif
|
||||
|
||||
namespace OHOS {
|
||||
#ifdef TXT_TRACE_DISABLE
|
||||
#define DRAWING_TRACE_NAME_FMT_LEVEL(Level, fmt, ...) \
|
||||
do { \
|
||||
(void)Level; \
|
||||
} while (0)
|
||||
#else
|
||||
#define DRAWING_TRACE_NAME_FMT_LEVEL(Level, fmt, ...) \
|
||||
do { \
|
||||
if (GetDebugTraceLevel() >= Level) { \
|
||||
HITRACE_METER_FMT(HITRACE_TAG_GRAPHIC_AGP, fmt, ##__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
int GetDebugTraceLevel()
|
||||
{
|
||||
static int openDebugTraceLevel =
|
||||
std::atoi((OHOS::system::GetParameter("persist.sys.graphic.openDebugTrace", "0")).c_str());
|
||||
return openDebugTraceLevel;
|
||||
}
|
||||
#endif
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // ROSEN_MODULES_SPTEXT_COMMON_H
|
@ -16,6 +16,7 @@
|
||||
#include "drawing_painter_impl.h"
|
||||
|
||||
#include <array>
|
||||
#include "common.h"
|
||||
|
||||
#include "include/core/SkBlurTypes.h"
|
||||
#include "include/core/SkMaskFilter.h"
|
||||
@ -34,6 +35,10 @@ const bool G_IS_HM_SYMBOL_TXT_ENABLE =
|
||||
const bool G_IS_HM_SYMBOL_TXT_ENABLE = true;
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
constexpr int TRACE_LEVEL_TWO = 2;
|
||||
}
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
namespace SPText {
|
||||
@ -179,6 +184,11 @@ void RSCanvasParagraphPainter::SymbolAnimation(const PaintRecord &pr)
|
||||
void RSCanvasParagraphPainter::drawTextShadow(const std::shared_ptr<RSTextBlob>& blob, SkScalar x, SkScalar y,
|
||||
SkColor color, SkScalar blurSigma)
|
||||
{
|
||||
std::vector<uint16_t> glyphIds;
|
||||
RSTextBlob::GetDrawingGlyphIDforTextBlob(blob.get(), glyphIds);
|
||||
DRAWING_TRACE_NAME_FMT_LEVEL(TRACE_LEVEL_TWO,
|
||||
"drawTextShadow: glyphIds.Size = %d, x = %f, y = %f, color = 0x%08X, blurSigma = %f.",
|
||||
glyphIds.size(), x, y, color, blurSigma);
|
||||
Drawing::Filter filter;
|
||||
filter.SetMaskFilter(Drawing::MaskFilter::CreateBlurMaskFilter(Drawing::BlurType::NORMAL, blurSigma, false));
|
||||
|
||||
|
@ -32,13 +32,34 @@ int ConvertToSkFontWeight(FontWeight fontWeight)
|
||||
return static_cast<int>(fontWeight) * weightBase + weightBase;
|
||||
}
|
||||
|
||||
RSFontStyle::Slant ConvertToRSFontSlant(FontStyle fontStyle)
|
||||
{
|
||||
RSFontStyle::Slant slant;
|
||||
switch (fontStyle) {
|
||||
case FontStyle::NORMAL: {
|
||||
slant = RSFontStyle::Slant::UPRIGHT_SLANT;
|
||||
break;
|
||||
}
|
||||
case FontStyle::ITALIC: {
|
||||
slant = RSFontStyle::Slant::ITALIC_SLANT;
|
||||
break;
|
||||
}
|
||||
case FontStyle::OBLIQUE: {
|
||||
slant = RSFontStyle::Slant::OBLIQUE_SLANT;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
slant = RSFontStyle::Slant::UPRIGHT_SLANT;
|
||||
}
|
||||
}
|
||||
return slant;
|
||||
}
|
||||
|
||||
RSFontStyle MakeFontStyle(FontWeight fontWeight, FontWidth fontWidth, FontStyle fontStyle)
|
||||
{
|
||||
auto weight = ConvertToSkFontWeight(fontWeight);
|
||||
auto width = static_cast<RSFontStyle::Width>(fontWidth);
|
||||
auto slant = fontStyle == FontStyle::NORMAL ? RSFontStyle::Slant::UPRIGHT_SLANT :
|
||||
fontStyle == FontStyle::ITALIC ? RSFontStyle::Slant::ITALIC_SLANT :
|
||||
RSFontStyle::Slant::OBLIQUE_SLANT;
|
||||
auto slant = ConvertToRSFontSlant(fontStyle);
|
||||
return RSFontStyle(weight, width, slant);
|
||||
}
|
||||
|
||||
|
@ -220,11 +220,11 @@ Range<size_t> ParagraphImpl::GetActualTextRange(int lineNumber, bool includeSpac
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<LineMetrics>& ParagraphImpl::GetLineMetrics()
|
||||
std::vector<LineMetrics>& ParagraphImpl::GetLineMetrics(std::vector<size_t>& startIndexs)
|
||||
{
|
||||
if (!lineMetrics_) {
|
||||
std::vector<skt::LineMetrics> metrics;
|
||||
paragraph_->getLineMetrics(metrics);
|
||||
paragraph_->getLineMetrics(metrics, startIndexs);
|
||||
|
||||
lineMetrics_.emplace();
|
||||
lineMetricsStyles_.reserve(std::accumulate(metrics.begin(), metrics.end(), 0,
|
||||
@ -258,9 +258,9 @@ std::vector<LineMetrics>& ParagraphImpl::GetLineMetrics()
|
||||
return lineMetrics_.value();
|
||||
}
|
||||
|
||||
bool ParagraphImpl::GetLineMetricsAt(int lineNumber, skt::LineMetrics* lineMetrics) const
|
||||
bool ParagraphImpl::GetLineMetricsAt(int lineNumber, skt::LineMetrics* lineMetrics, size_t& startIndex) const
|
||||
{
|
||||
return paragraph_->getLineMetricsAt(lineNumber, lineMetrics);
|
||||
return paragraph_->getLineMetricsAt(lineNumber, lineMetrics, startIndex);
|
||||
}
|
||||
|
||||
TextStyle ParagraphImpl::SkStyleToTextStyle(const skt::TextStyle& skStyle)
|
||||
|
@ -85,9 +85,10 @@ public:
|
||||
|
||||
Range<size_t> GetActualTextRange(int lineNumber, bool includeSpaces) override;
|
||||
|
||||
std::vector<LineMetrics>& GetLineMetrics() override;
|
||||
std::vector<LineMetrics>& GetLineMetrics(std::vector<size_t>& startIndexs) override;
|
||||
|
||||
bool GetLineMetricsAt(int lineNumber, skia::textlayout::LineMetrics* lineMetrics) const override;
|
||||
bool GetLineMetricsAt(
|
||||
int lineNumber, skia::textlayout::LineMetrics* lineMetrics, size_t& startIndex) const override;
|
||||
|
||||
void SetAnimation(
|
||||
std::function<bool(const std::shared_ptr<TextEngine::SymbolAnimationConfig>&)>& animationFunc
|
||||
|
@ -58,7 +58,7 @@ public:
|
||||
|
||||
void SetAnimationMode(const uint16_t animationMode)
|
||||
{
|
||||
animationMode_ = animationMode > 0 ? 1: 0; // 1 is whole or add, 0 is hierarchical or iterate
|
||||
animationMode_ = animationMode > 0 ? 1 : 0; // 1 is whole or add, 0 is hierarchical or iterate
|
||||
}
|
||||
|
||||
void SetRepeatCount(const int repeatCount)
|
||||
|
@ -69,7 +69,7 @@ public:
|
||||
|
||||
void SetAnimationMode(const uint16_t animationMode)
|
||||
{
|
||||
animationMode_ = animationMode > 0 ? 1: 0; // 1 is whole or add, 0 is hierarchical or iterate
|
||||
animationMode_ = animationMode > 0 ? 1 : 0; // 1 is whole or add, 0 is hierarchical or iterate
|
||||
}
|
||||
|
||||
void SetRepeatCount(const int repeatCount)
|
||||
|
@ -185,9 +185,10 @@ public:
|
||||
|
||||
virtual Range<size_t> GetActualTextRange(int lineNumber, bool includeSpaces) = 0;
|
||||
|
||||
virtual std::vector<LineMetrics>& GetLineMetrics() = 0;
|
||||
virtual std::vector<LineMetrics>& GetLineMetrics(std::vector<size_t>& startIndexs) = 0;
|
||||
|
||||
virtual bool GetLineMetricsAt(int lineNumber, skia::textlayout::LineMetrics* lineMetrics) const = 0;
|
||||
virtual bool GetLineMetricsAt(
|
||||
int lineNumber, skia::textlayout::LineMetrics* lineMetrics, size_t& startIndex) const = 0;
|
||||
|
||||
virtual void SetAnimation(
|
||||
std::function<bool(const std::shared_ptr<TextEngine::SymbolAnimationConfig>&)>& animationFunc) = 0;
|
||||
|
@ -139,13 +139,13 @@ OH_Drawing_FontStyleSet* OH_Drawing_FontMgrMatchFamily(OH_Drawing_FontMgr*, cons
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
|
||||
* @param OH_Drawing_FontMgr Indicates the pointer to an <b>OH_Drawing_FontMgr</b> object.
|
||||
* @param familyName Indicates the family name of a font style set to be matched.
|
||||
* @param OH_Drawing_FontStyleStruct Indicates the pointer to an <b>OH_Drawing_FontStyleStruct</b> object.
|
||||
* @param OH_Drawing_FontStyleStruct Indicates an <b>OH_Drawing_FontStyleStruct</b> object.
|
||||
* @return Returns the pointer to the <b>OH_Drawing_Typeface</b> object matched.
|
||||
* @since 12
|
||||
* @version 1.0
|
||||
*/
|
||||
OH_Drawing_Typeface* OH_Drawing_FontMgrMatchFamilyStyle(OH_Drawing_FontMgr*,
|
||||
const char* familyName, OH_Drawing_FontStyleStruct*);
|
||||
const char* familyName, OH_Drawing_FontStyleStruct fontStyle);
|
||||
|
||||
/**
|
||||
* @brief Get the pointer to an <b>OH_Drawing_Typeface</b> object for the given character.
|
||||
@ -153,7 +153,7 @@ OH_Drawing_Typeface* OH_Drawing_FontMgrMatchFamilyStyle(OH_Drawing_FontMgr*,
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
|
||||
* @param OH_Drawing_FontMgr Indicates the pointer to an <b>OH_Drawing_FontMgr</b> object.
|
||||
* @param familyName Indicates the family name of a font style set to be matched.
|
||||
* @param OH_Drawing_FontStyleStruct Indicates the pointer to an <b>OH_Drawing_FontStyleStruct</b> object.
|
||||
* @param OH_Drawing_FontStyleStruct Indicates an <b>OH_Drawing_FontStyleStruct</b> object.
|
||||
* @param bcp47 Indicates an array of languages which indicate the language of character.
|
||||
* @param bcp47Count Indicates the array size of bcp47.
|
||||
* @param character Indicates a UTF8 value to be matched.
|
||||
@ -162,7 +162,7 @@ OH_Drawing_Typeface* OH_Drawing_FontMgrMatchFamilyStyle(OH_Drawing_FontMgr*,
|
||||
* @version 1.0
|
||||
*/
|
||||
OH_Drawing_Typeface* OH_Drawing_FontMgrMatchFamilyStyleCharacter(OH_Drawing_FontMgr*, const char* familyName,
|
||||
OH_Drawing_FontStyleStruct*, const char* bcp47[], int bcp47Count, int32_t character);
|
||||
OH_Drawing_FontStyleStruct fontStyle, const char* bcp47[], int bcp47Count, int32_t character);
|
||||
|
||||
/**
|
||||
* @brief Create a typeface for the given index.
|
||||
|
@ -464,15 +464,15 @@ typedef enum {
|
||||
*/
|
||||
enum OH_Drawing_FontConfigInfoErrorCode {
|
||||
/** The list of system font configuration information was successfully obtained */
|
||||
SUCCESS = 0,
|
||||
SUCCESS_FONT_CONFIG_INFO = 0,
|
||||
/** Unknown error */
|
||||
ERROR_UNKNOWN = 1,
|
||||
ERROR_FONT_CONFIG_INFO_UNKNOWN = 1,
|
||||
/** Parse system config file error */
|
||||
ERROR_PARSE_FILE = 2,
|
||||
ERROR_FONT_CONFIG_INFO_PARSE_FILE = 2,
|
||||
/** Alloc memory error */
|
||||
ERROR_ALLOC_MEMORY = 3,
|
||||
ERROR_FONT_CONFIG_INFO_ALLOC_MEMORY = 3,
|
||||
/** Copy string data error */
|
||||
ERROR_COPY_STRING_DATA = 4,
|
||||
ERROR_FONT_CONFIG_INFO_COPY_STRING_DATA = 4,
|
||||
};
|
||||
|
||||
/**
|
||||
@ -2539,12 +2539,11 @@ void OH_Drawing_SetTextStyleFontStyleStruct(OH_Drawing_TextStyle* drawingTextSty
|
||||
*
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
|
||||
* @param OH_Drawing_TextStyle Indicates the pointer to an <b>OH_Drawing_TextStyle</b> object.
|
||||
* @param OH_Drawing_FontStyleStruct Indicates the pointer to an <b>OH_Drawing_FontStyleStruct</b> object.
|
||||
* @return Returns the <b>OH_Drawing_FontStyleStruct</b> object getted.
|
||||
* @since 12
|
||||
* @version 1.0
|
||||
*/
|
||||
void OH_Drawing_TextStyleGetFontStyleStruct(OH_Drawing_TextStyle* drawingTextStyle,
|
||||
OH_Drawing_FontStyleStruct* fontStyle);
|
||||
OH_Drawing_FontStyleStruct OH_Drawing_TextStyleGetFontStyleStruct(OH_Drawing_TextStyle* drawingTextStyle);
|
||||
|
||||
/**
|
||||
* @brief Sets the typography style, including font weight, font width and font slant.
|
||||
@ -2563,12 +2562,11 @@ void OH_Drawing_SetTypographyStyleFontStyleStruct(OH_Drawing_TypographyStyle* dr
|
||||
*
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
|
||||
* @param OH_Drawing_TypographyStyle Indicates the pointer to an <b>OH_Drawing_TypographyStyle</b> object.
|
||||
* @param OH_Drawing_FontStyleStruct Indicates the pointer to an <b>OH_Drawing_FontStyleStruct</b> object.
|
||||
* @return Returns the <b>OH_Drawing_FontStyleStruct</b> object getted.
|
||||
* @since 12
|
||||
* @version 1.0
|
||||
*/
|
||||
void OH_Drawing_TypographyStyleGetFontStyleStruct(OH_Drawing_TypographyStyle* drawingStyle,
|
||||
OH_Drawing_FontStyleStruct* fontStyle);
|
||||
OH_Drawing_FontStyleStruct OH_Drawing_TypographyStyleGetFontStyleStruct(OH_Drawing_TypographyStyle* drawingStyle);
|
||||
|
||||
/**
|
||||
* @brief Gets whether the two TextStyle objects are equal.
|
||||
|
@ -151,17 +151,14 @@ OH_Drawing_FontStyleSet* OH_Drawing_FontMgrMatchFamily(OH_Drawing_FontMgr* drawi
|
||||
}
|
||||
|
||||
OH_Drawing_Typeface* OH_Drawing_FontMgrMatchFamilyStyle(OH_Drawing_FontMgr* drawingFontMgr, const char* familyName,
|
||||
OH_Drawing_FontStyleStruct* fontStyle)
|
||||
OH_Drawing_FontStyleStruct fontStyle)
|
||||
{
|
||||
if (drawingFontMgr == nullptr|| fontStyle == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
FontMgr* fontMgr = CastToFontMgr(drawingFontMgr);
|
||||
if (fontMgr == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
Typeface* typeface = fontMgr->MatchFamilyStyle(familyName,
|
||||
FontStyle(fontStyle->weight, fontStyle->width, static_cast<FontStyle::Slant>(fontStyle->slant)));
|
||||
FontStyle(fontStyle.weight, fontStyle.width, static_cast<FontStyle::Slant>(fontStyle.slant)));
|
||||
if (typeface == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -172,18 +169,15 @@ OH_Drawing_Typeface* OH_Drawing_FontMgrMatchFamilyStyle(OH_Drawing_FontMgr* draw
|
||||
}
|
||||
|
||||
OH_Drawing_Typeface* OH_Drawing_FontMgrMatchFamilyStyleCharacter(OH_Drawing_FontMgr* drawingFontMgr,
|
||||
const char* familyName, OH_Drawing_FontStyleStruct* fontStyle, const char* bcp47[],
|
||||
const char* familyName, OH_Drawing_FontStyleStruct fontStyle, const char* bcp47[],
|
||||
int bcp47Count, int32_t character)
|
||||
{
|
||||
if (drawingFontMgr == nullptr || fontStyle == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
FontMgr* fontMgr = CastToFontMgr(drawingFontMgr);
|
||||
if (fontMgr == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
Typeface* typeface = fontMgr->MatchFamilyStyleCharacter(familyName,
|
||||
FontStyle(fontStyle->weight, fontStyle->width, static_cast<FontStyle::Slant>(fontStyle->slant)),
|
||||
FontStyle(fontStyle.weight, fontStyle.width, static_cast<FontStyle::Slant>(fontStyle.slant)),
|
||||
bcp47, bcp47Count, character);
|
||||
if (typeface == nullptr) {
|
||||
return nullptr;
|
||||
|
@ -1260,23 +1260,23 @@ static bool CopyStrData(char** destination, const std::string& source,
|
||||
OH_Drawing_FontConfigInfoErrorCode* code = nullptr)
|
||||
{
|
||||
if (destination == nullptr || source.empty()) {
|
||||
SetFontConfigInfoErrorCode(OH_Drawing_FontConfigInfoErrorCode::ERROR_COPY_STRING_DATA, code);
|
||||
SetFontConfigInfoErrorCode(OH_Drawing_FontConfigInfoErrorCode::ERROR_FONT_CONFIG_INFO_COPY_STRING_DATA, code);
|
||||
return false;
|
||||
}
|
||||
size_t destinationSize = source.size() + 1;
|
||||
*destination = new char[destinationSize];
|
||||
if (!(*destination)) {
|
||||
SetFontConfigInfoErrorCode(OH_Drawing_FontConfigInfoErrorCode::ERROR_ALLOC_MEMORY, code);
|
||||
SetFontConfigInfoErrorCode(OH_Drawing_FontConfigInfoErrorCode::ERROR_FONT_CONFIG_INFO_ALLOC_MEMORY, code);
|
||||
return false;
|
||||
}
|
||||
auto retCopy = strcpy_s(*destination, destinationSize, source.c_str());
|
||||
if (retCopy != 0) {
|
||||
delete[] *destination;
|
||||
*destination = nullptr;
|
||||
SetFontConfigInfoErrorCode(OH_Drawing_FontConfigInfoErrorCode::ERROR_COPY_STRING_DATA, code);
|
||||
SetFontConfigInfoErrorCode(OH_Drawing_FontConfigInfoErrorCode::ERROR_FONT_CONFIG_INFO_COPY_STRING_DATA, code);
|
||||
return false;
|
||||
}
|
||||
SetFontConfigInfoErrorCode(OH_Drawing_FontConfigInfoErrorCode::SUCCESS, code);
|
||||
SetFontConfigInfoErrorCode(OH_Drawing_FontConfigInfoErrorCode::SUCCESS_FONT_CONFIG_INFO, code);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2366,16 +2366,16 @@ static OH_Drawing_FontAliasInfo* InitDrawingAliasInfoSet(const size_t aliasInfoS
|
||||
OH_Drawing_FontConfigInfoErrorCode& code)
|
||||
{
|
||||
if (!aliasInfoSize) {
|
||||
code = SUCCESS;
|
||||
code = SUCCESS_FONT_CONFIG_INFO;
|
||||
return nullptr;
|
||||
}
|
||||
if (aliasInfoSize >= std::numeric_limits<int16_t>::max()) {
|
||||
code = ERROR_ALLOC_MEMORY;
|
||||
code = ERROR_FONT_CONFIG_INFO_ALLOC_MEMORY;
|
||||
return nullptr;
|
||||
}
|
||||
OH_Drawing_FontAliasInfo* aliasInfoArray = new OH_Drawing_FontAliasInfo[aliasInfoSize];
|
||||
if (aliasInfoArray == nullptr) {
|
||||
code = ERROR_ALLOC_MEMORY;
|
||||
code = ERROR_FONT_CONFIG_INFO_ALLOC_MEMORY;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -2384,7 +2384,7 @@ static OH_Drawing_FontAliasInfo* InitDrawingAliasInfoSet(const size_t aliasInfoS
|
||||
aliasInfoArray[i].weight = 0;
|
||||
i++;
|
||||
}
|
||||
code = SUCCESS;
|
||||
code = SUCCESS_FONT_CONFIG_INFO;
|
||||
return aliasInfoArray;
|
||||
}
|
||||
|
||||
@ -2416,16 +2416,16 @@ static OH_Drawing_FontAdjustInfo* InitDrawingAdjustInfoSet(const size_t adjustIn
|
||||
OH_Drawing_FontConfigInfoErrorCode& code)
|
||||
{
|
||||
if (!adjustInfoSize) {
|
||||
code = SUCCESS;
|
||||
code = SUCCESS_FONT_CONFIG_INFO;
|
||||
return nullptr;
|
||||
}
|
||||
if (adjustInfoSize >= std::numeric_limits<int16_t>::max()) {
|
||||
code = ERROR_ALLOC_MEMORY;
|
||||
code = ERROR_FONT_CONFIG_INFO_ALLOC_MEMORY;
|
||||
return nullptr;
|
||||
}
|
||||
OH_Drawing_FontAdjustInfo* adjustInfoArray = new OH_Drawing_FontAdjustInfo[adjustInfoSize];
|
||||
if (adjustInfoArray == nullptr) {
|
||||
code = ERROR_ALLOC_MEMORY;
|
||||
code = ERROR_FONT_CONFIG_INFO_ALLOC_MEMORY;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -2434,7 +2434,7 @@ static OH_Drawing_FontAdjustInfo* InitDrawingAdjustInfoSet(const size_t adjustIn
|
||||
adjustInfoArray[i].to = 0;
|
||||
i++;
|
||||
}
|
||||
code = SUCCESS;
|
||||
code = SUCCESS_FONT_CONFIG_INFO;
|
||||
return adjustInfoArray;
|
||||
}
|
||||
|
||||
@ -2452,17 +2452,17 @@ static OH_Drawing_FontGenericInfo* InitDrawingFontGenericInfoSet(const size_t fo
|
||||
OH_Drawing_FontConfigInfoErrorCode& code)
|
||||
{
|
||||
if (!fontGenericInfoSize) {
|
||||
code = ERROR_PARSE_FILE;
|
||||
code = ERROR_FONT_CONFIG_INFO_PARSE_FILE;
|
||||
return nullptr;
|
||||
}
|
||||
if (fontGenericInfoSize >= std::numeric_limits<int16_t>::max()) {
|
||||
code = ERROR_ALLOC_MEMORY;
|
||||
code = ERROR_FONT_CONFIG_INFO_ALLOC_MEMORY;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
OH_Drawing_FontGenericInfo* fontGenericInfoArray = new OH_Drawing_FontGenericInfo[fontGenericInfoSize];
|
||||
if (fontGenericInfoArray == nullptr) {
|
||||
code = ERROR_ALLOC_MEMORY;
|
||||
code = ERROR_FONT_CONFIG_INFO_ALLOC_MEMORY;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -2474,7 +2474,7 @@ static OH_Drawing_FontGenericInfo* InitDrawingFontGenericInfoSet(const size_t fo
|
||||
fontGenericInfoArray[index].adjustInfoSet = nullptr;
|
||||
index++;
|
||||
}
|
||||
code = SUCCESS;
|
||||
code = SUCCESS_FONT_CONFIG_INFO;
|
||||
return fontGenericInfoArray;
|
||||
}
|
||||
|
||||
@ -2505,16 +2505,16 @@ static OH_Drawing_FontFallbackInfo* InitDrawingDrawingFallbackInfoSet(const size
|
||||
OH_Drawing_FontConfigInfoErrorCode& code)
|
||||
{
|
||||
if (!fallbackInfoSize) {
|
||||
code = SUCCESS;
|
||||
code = SUCCESS_FONT_CONFIG_INFO;
|
||||
return nullptr;
|
||||
}
|
||||
if (fallbackInfoSize >= std::numeric_limits<int16_t>::max()) {
|
||||
code = ERROR_ALLOC_MEMORY;
|
||||
code = ERROR_FONT_CONFIG_INFO_ALLOC_MEMORY;
|
||||
return nullptr;
|
||||
}
|
||||
OH_Drawing_FontFallbackInfo* fallbackInfoArray = new OH_Drawing_FontFallbackInfo[fallbackInfoSize];
|
||||
if (fallbackInfoArray == nullptr) {
|
||||
code = ERROR_ALLOC_MEMORY;
|
||||
code = ERROR_FONT_CONFIG_INFO_ALLOC_MEMORY;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -2523,7 +2523,7 @@ static OH_Drawing_FontFallbackInfo* InitDrawingDrawingFallbackInfoSet(const size
|
||||
fallbackInfoArray[i].familyName = nullptr;
|
||||
i++;
|
||||
}
|
||||
code = SUCCESS;
|
||||
code = SUCCESS_FONT_CONFIG_INFO;
|
||||
return fallbackInfoArray;
|
||||
}
|
||||
|
||||
@ -2551,16 +2551,16 @@ static OH_Drawing_FontFallbackGroup* InitDrawingFallbackGroupSet(const size_t fa
|
||||
OH_Drawing_FontConfigInfoErrorCode& code)
|
||||
{
|
||||
if (!fallbackGroupSize) {
|
||||
code = SUCCESS;
|
||||
code = SUCCESS_FONT_CONFIG_INFO;
|
||||
return nullptr;
|
||||
}
|
||||
if (fallbackGroupSize >= std::numeric_limits<int16_t>::max()) {
|
||||
code = ERROR_ALLOC_MEMORY;
|
||||
code = ERROR_FONT_CONFIG_INFO_ALLOC_MEMORY;
|
||||
return nullptr;
|
||||
}
|
||||
OH_Drawing_FontFallbackGroup* fallbackGroupArray = new OH_Drawing_FontFallbackGroup[fallbackGroupSize];
|
||||
if (fallbackGroupArray == nullptr) {
|
||||
code = ERROR_ALLOC_MEMORY;
|
||||
code = ERROR_FONT_CONFIG_INFO_ALLOC_MEMORY;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -2570,7 +2570,7 @@ static OH_Drawing_FontFallbackGroup* InitDrawingFallbackGroupSet(const size_t fa
|
||||
fallbackGroupArray[i].fallbackInfoSet = nullptr;
|
||||
i++;
|
||||
}
|
||||
code = SUCCESS;
|
||||
code = SUCCESS_FONT_CONFIG_INFO;
|
||||
return fallbackGroupArray;
|
||||
}
|
||||
|
||||
@ -2659,18 +2659,18 @@ static bool CopyDrawingFontDirSet(char*** drawFontDirSet, size_t& fontDirSize,
|
||||
const std::vector<std::string>& fontDirSet, OH_Drawing_FontConfigInfoErrorCode& code)
|
||||
{
|
||||
if (!drawFontDirSet) {
|
||||
code = ERROR_ALLOC_MEMORY;
|
||||
code = ERROR_FONT_CONFIG_INFO_ALLOC_MEMORY;
|
||||
return false;
|
||||
}
|
||||
if (fontDirSet.empty()) {
|
||||
code = ERROR_PARSE_FILE;
|
||||
code = ERROR_FONT_CONFIG_INFO_PARSE_FILE;
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t size = fontDirSet.size();
|
||||
(*drawFontDirSet) = InitStringArray(size);
|
||||
if (!(*drawFontDirSet)) {
|
||||
code = ERROR_ALLOC_MEMORY;
|
||||
code = ERROR_FONT_CONFIG_INFO_ALLOC_MEMORY;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2697,7 +2697,7 @@ static bool CopyDrawingAliasInfo(OH_Drawing_FontAliasInfo& drawAliasInfo, const
|
||||
return false;
|
||||
}
|
||||
drawAliasInfo.weight = aliasInfo.weight;
|
||||
code = SUCCESS;
|
||||
code = SUCCESS_FONT_CONFIG_INFO;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2705,7 +2705,7 @@ static bool CopyDrawingAliasInfoSet(OH_Drawing_FontAliasInfo** drawAliasInfoSet,
|
||||
const std::vector<TextEngine::AliasInfo>& aliasSet, OH_Drawing_FontConfigInfoErrorCode& code)
|
||||
{
|
||||
if (!drawAliasInfoSet) {
|
||||
code = ERROR_ALLOC_MEMORY;
|
||||
code = ERROR_FONT_CONFIG_INFO_ALLOC_MEMORY;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2741,7 +2741,7 @@ static bool CopyDrawingAdjustSet(OH_Drawing_FontAdjustInfo** drawAdjustInfoSet,
|
||||
const std::vector<TextEngine::AdjustInfo>& adjustSet, OH_Drawing_FontConfigInfoErrorCode& code)
|
||||
{
|
||||
if (!drawAdjustInfoSet) {
|
||||
code = ERROR_ALLOC_MEMORY;
|
||||
code = ERROR_FONT_CONFIG_INFO_ALLOC_MEMORY;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2760,7 +2760,7 @@ static bool CopyDrawingAdjustSet(OH_Drawing_FontAdjustInfo** drawAdjustInfoSet,
|
||||
return false;
|
||||
}
|
||||
}
|
||||
code = SUCCESS;
|
||||
code = SUCCESS_FONT_CONFIG_INFO;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2791,7 +2791,7 @@ static bool CopyDrawingFontGenericInfoSetInner(OH_Drawing_FontGenericInfo** font
|
||||
OH_Drawing_FontConfigInfoErrorCode& code)
|
||||
{
|
||||
if (!fontGenericInfoSet || !(*fontGenericInfoSet)) {
|
||||
code = ERROR_ALLOC_MEMORY;
|
||||
code = ERROR_FONT_CONFIG_INFO_ALLOC_MEMORY;
|
||||
return false;
|
||||
}
|
||||
size_t genericInfoNum = 0;
|
||||
@ -2810,7 +2810,7 @@ static bool CopyDrawingFontGenericInfoSetInner(OH_Drawing_FontGenericInfo** font
|
||||
ResetDrawingFontGenericInfoSet(fontGenericInfoSet, fontGenericInfoSize);
|
||||
return false;
|
||||
}
|
||||
code = SUCCESS;
|
||||
code = SUCCESS_FONT_CONFIG_INFO;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2836,7 +2836,7 @@ static bool CopyDrawingFallbackGroup(OH_Drawing_FontFallbackGroup& drawFallbackG
|
||||
}
|
||||
auto& fallbackInfoSet = fallbackGroup.fallbackInfoSet;
|
||||
if (fallbackInfoSet.empty()) {
|
||||
code = SUCCESS;
|
||||
code = SUCCESS_FONT_CONFIG_INFO;
|
||||
return true;
|
||||
}
|
||||
drawFallbackGroup.fallbackInfoSet = InitDrawingDrawingFallbackInfoSet(fallbackInfoSet.size(), code);
|
||||
@ -2866,7 +2866,7 @@ static bool CopyDrawingFallbackGroupSetInner(OH_Drawing_FontFallbackGroup** draw
|
||||
OH_Drawing_FontConfigInfoErrorCode& code)
|
||||
{
|
||||
if (!drawFallbackGroupSet) {
|
||||
code = ERROR_ALLOC_MEMORY;
|
||||
code = ERROR_FONT_CONFIG_INFO_ALLOC_MEMORY;
|
||||
return false;
|
||||
}
|
||||
(*drawFallbackGroupSet) = InitDrawingFallbackGroupSet(fallbackGroupSet.size(), code);
|
||||
@ -2896,7 +2896,7 @@ static bool CopyDrawingFontGenericInfoSet(OH_Drawing_FontConfigInfo** drawFontCf
|
||||
const std::vector<TextEngine::FontGenericInfo>& genericSet, OH_Drawing_FontConfigInfoErrorCode& code)
|
||||
{
|
||||
if (!drawFontCfgInfo || !(*drawFontCfgInfo)) {
|
||||
code = ERROR_ALLOC_MEMORY;
|
||||
code = ERROR_FONT_CONFIG_INFO_ALLOC_MEMORY;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2922,12 +2922,12 @@ static bool CopyDrawingFallbackGroupSet(OH_Drawing_FontConfigInfo** drawFontCfgI
|
||||
const std::vector<TextEngine::FallbackGroup>& fallbackGroupSet, OH_Drawing_FontConfigInfoErrorCode& code)
|
||||
{
|
||||
if (!drawFontCfgInfo || !(*drawFontCfgInfo)) {
|
||||
code = ERROR_ALLOC_MEMORY;
|
||||
code = ERROR_FONT_CONFIG_INFO_ALLOC_MEMORY;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fallbackGroupSet.empty()) {
|
||||
code = SUCCESS;
|
||||
code = SUCCESS_FONT_CONFIG_INFO;
|
||||
return true;
|
||||
}
|
||||
bool result = CopyDrawingFallbackGroupSetInner(&((*drawFontCfgInfo)->fallbackGroupSet),
|
||||
@ -2944,23 +2944,23 @@ static bool CopyDrawingFallbackGroupSet(OH_Drawing_FontConfigInfo** drawFontCfgI
|
||||
|
||||
OH_Drawing_FontConfigInfo* OH_Drawing_GetSystemFontConfigInfo(OH_Drawing_FontConfigInfoErrorCode* errorCode)
|
||||
{
|
||||
OH_Drawing_FontConfigInfoErrorCode code = ERROR_UNKNOWN;
|
||||
OH_Drawing_FontConfigInfoErrorCode code = ERROR_FONT_CONFIG_INFO_UNKNOWN;
|
||||
TextEngine::FontConfigJson fontConfigJson;
|
||||
int res = fontConfigJson.ParseFile();
|
||||
if (res) {
|
||||
code = ERROR_PARSE_FILE;
|
||||
code = ERROR_FONT_CONFIG_INFO_PARSE_FILE;
|
||||
SetFontConfigInfoErrorCode(code, errorCode);
|
||||
return nullptr;
|
||||
}
|
||||
auto fontCfgJsonInfo = fontConfigJson.GetFontConfigJsonInfo();
|
||||
if (!fontCfgJsonInfo) {
|
||||
SetFontConfigInfoErrorCode(OH_Drawing_FontConfigInfoErrorCode::ERROR_PARSE_FILE, errorCode);
|
||||
SetFontConfigInfoErrorCode(OH_Drawing_FontConfigInfoErrorCode::ERROR_FONT_CONFIG_INFO_PARSE_FILE, errorCode);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
OH_Drawing_FontConfigInfo* drawFontCfgInfo = InitDrawingFontConfigJsonInfo();
|
||||
if (!drawFontCfgInfo) {
|
||||
SetFontConfigInfoErrorCode(OH_Drawing_FontConfigInfoErrorCode::ERROR_ALLOC_MEMORY, errorCode);
|
||||
SetFontConfigInfoErrorCode(OH_Drawing_FontConfigInfoErrorCode::ERROR_FONT_CONFIG_INFO_ALLOC_MEMORY, errorCode);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -3266,13 +3266,9 @@ static FontWidth GetFontWidth(OH_Drawing_FontWidth width)
|
||||
}
|
||||
return fontWidth;
|
||||
}
|
||||
|
||||
void OH_Drawing_SetTextStyleFontStyleStruct(OH_Drawing_TextStyle* drawingTextStyle,
|
||||
OH_Drawing_FontStyleStruct fontStyle)
|
||||
{
|
||||
if (drawingTextStyle == nullptr) {
|
||||
return;
|
||||
}
|
||||
TextStyle* style = ConvertToOriginalText<TextStyle>(drawingTextStyle);
|
||||
if (style == nullptr) {
|
||||
return;
|
||||
@ -3282,27 +3278,25 @@ void OH_Drawing_SetTextStyleFontStyleStruct(OH_Drawing_TextStyle* drawingTextSty
|
||||
style->fontStyle = GetFontStyle(fontStyle.slant);
|
||||
}
|
||||
|
||||
void OH_Drawing_TextStyleGetFontStyleStruct(OH_Drawing_TextStyle* drawingTextStyle,
|
||||
OH_Drawing_FontStyleStruct* fontStyle)
|
||||
OH_Drawing_FontStyleStruct OH_Drawing_TextStyleGetFontStyleStruct(OH_Drawing_TextStyle* drawingTextStyle)
|
||||
{
|
||||
if (drawingTextStyle == nullptr || fontStyle == nullptr) {
|
||||
return;
|
||||
}
|
||||
OH_Drawing_FontStyleStruct fontStyle;
|
||||
TextStyle* style = ConvertToOriginalText<TextStyle>(drawingTextStyle);
|
||||
if (style == nullptr) {
|
||||
return;
|
||||
fontStyle.weight = FONT_WEIGHT_400;
|
||||
fontStyle.width = FONT_WIDTH_NORMAL;
|
||||
fontStyle.slant = FONT_STYLE_NORMAL;
|
||||
return fontStyle;
|
||||
}
|
||||
fontStyle->weight = static_cast<OH_Drawing_FontWeight>(style->fontWeight);
|
||||
fontStyle->width = static_cast<OH_Drawing_FontWidth>(style->fontWidth);
|
||||
fontStyle->slant = static_cast<OH_Drawing_FontStyle>(style->fontStyle);
|
||||
fontStyle.weight = static_cast<OH_Drawing_FontWeight>(style->fontWeight);
|
||||
fontStyle.width = static_cast<OH_Drawing_FontWidth>(style->fontWidth);
|
||||
fontStyle.slant = static_cast<OH_Drawing_FontStyle>(style->fontStyle);
|
||||
return fontStyle;
|
||||
}
|
||||
|
||||
void OH_Drawing_SetTypographyStyleFontStyleStruct(OH_Drawing_TypographyStyle* drawingStyle,
|
||||
OH_Drawing_FontStyleStruct fontStyle)
|
||||
{
|
||||
if (drawingStyle == nullptr) {
|
||||
return;
|
||||
}
|
||||
TypographyStyle* style = ConvertToOriginalText<TypographyStyle>(drawingStyle);
|
||||
if (style == nullptr) {
|
||||
return;
|
||||
@ -3312,19 +3306,20 @@ void OH_Drawing_SetTypographyStyleFontStyleStruct(OH_Drawing_TypographyStyle* dr
|
||||
style->fontStyle = GetFontStyle(fontStyle.slant);
|
||||
}
|
||||
|
||||
void OH_Drawing_TypographyStyleGetFontStyleStruct(OH_Drawing_TypographyStyle* drawingStyle,
|
||||
OH_Drawing_FontStyleStruct* fontStyle)
|
||||
OH_Drawing_FontStyleStruct OH_Drawing_TypographyStyleGetFontStyleStruct(OH_Drawing_TypographyStyle* drawingStyle)
|
||||
{
|
||||
if (drawingStyle == nullptr || fontStyle == nullptr) {
|
||||
return;
|
||||
}
|
||||
OH_Drawing_FontStyleStruct fontStyle;
|
||||
TypographyStyle* style = ConvertToOriginalText<TypographyStyle>(drawingStyle);
|
||||
if (style == nullptr) {
|
||||
return;
|
||||
fontStyle.weight = FONT_WEIGHT_400;
|
||||
fontStyle.width = FONT_WIDTH_NORMAL;
|
||||
fontStyle.slant = FONT_STYLE_NORMAL;
|
||||
return fontStyle;
|
||||
}
|
||||
fontStyle->weight = static_cast<OH_Drawing_FontWeight>(style->fontWeight);
|
||||
fontStyle->width = static_cast<OH_Drawing_FontWidth>(style->fontWidth);
|
||||
fontStyle->slant = static_cast<OH_Drawing_FontStyle>(style->fontStyle);
|
||||
fontStyle.weight = static_cast<OH_Drawing_FontWeight>(style->fontWeight);
|
||||
fontStyle.width = static_cast<OH_Drawing_FontWidth>(style->fontWidth);
|
||||
fontStyle.slant = static_cast<OH_Drawing_FontStyle>(style->fontStyle);
|
||||
return fontStyle;
|
||||
}
|
||||
|
||||
bool OH_Drawing_TextStyleIsEqual(const OH_Drawing_TextStyle* style, const OH_Drawing_TextStyle* comparedStyle)
|
||||
|
@ -166,7 +166,7 @@ bool SkiaImage::BuildFromTexture(GPUContext& gpuContext, const TextureInfo& info
|
||||
if (SystemProperties::IsUseVulkan()) {
|
||||
const auto& backendTexture = SkiaTextureInfo::ConvertToGrBackendTexture(info);
|
||||
if (!backendTexture.isValid()) {
|
||||
LOGD("SkiaImage BuildFromTexture backend texture is not valid!!!!");
|
||||
LOGE("SkiaImage BuildFromTexture backend texture is not valid!!!!");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -185,8 +185,13 @@ bool SkiaImage::BuildFromTexture(GPUContext& gpuContext, const TextureInfo& info
|
||||
SkiaTextureInfo::ConvertToGrSurfaceOrigin(origin), SkiaImageInfo::ConvertToSkColorType(bitmapFormat.colorType),
|
||||
SkiaImageInfo::ConvertToSkAlphaType(bitmapFormat.alphaType), skColorSpace);
|
||||
#endif
|
||||
|
||||
return (skiaImage_ != nullptr) ? true : false;
|
||||
if (skiaImage_ == nullptr) {
|
||||
LOGE("SkiaImage::MakeFromTexture skiaImage_ is nullptr!!!! "
|
||||
"TextureInfo format:%u, w:%d, h:%d , bitmapFormat.colorType is %d",
|
||||
info.GetFormat(), info.GetWidth(), info.GetHeight(), static_cast<int>(bitmapFormat.colorType));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SkiaImage::BuildFromSurface(GPUContext& gpuContext, Surface& surface, TextureOrigin origin,
|
||||
|
@ -992,10 +992,9 @@ void DrawTextBlobOpItem::Marshalling(DrawCmdList& cmdList)
|
||||
GenerateHandleFromPaint(cmdList, paint_, paintHandle);
|
||||
TextBlob::Context ctx {nullptr, false};
|
||||
auto textBlobHandle = CmdListHelper::AddTextBlobToCmdList(cmdList, textBlob_.get(), &ctx);
|
||||
uint32_t typefaceId = 0;
|
||||
uint64_t globalUniqueId = 0;
|
||||
if (ctx.GetTypeface() != nullptr) {
|
||||
typefaceId = ctx.GetTypeface()->GetUniqueID();
|
||||
uint32_t typefaceId = ctx.GetTypeface()->GetUniqueID();
|
||||
globalUniqueId = (shiftedPid | typefaceId);
|
||||
}
|
||||
|
||||
|
@ -210,14 +210,14 @@ void DrawCmdList::MarshallingDrawOps()
|
||||
}
|
||||
std::vector<uint32_t> opIndexForCache(replacedOpListForVector_.size());
|
||||
uint32_t opReplaceIndex = 0;
|
||||
for (size_t index = 0; index < drawOpItems_.size(); index++) {
|
||||
for (auto index = 0u; index < drawOpItems_.size(); ++index) {
|
||||
drawOpItems_[index]->Marshalling(*this);
|
||||
if (index == static_cast<size_t>(replacedOpListForVector_[opReplaceIndex].first)) {
|
||||
opIndexForCache[opReplaceIndex] = lastOpItemOffset_.value();
|
||||
++opReplaceIndex;
|
||||
}
|
||||
}
|
||||
for (auto index = 0u; index < replacedOpListForVector_.size(); index++) {
|
||||
for (auto index = 0u; index < replacedOpListForVector_.size(); ++index) {
|
||||
replacedOpListForVector_[index].second->Marshalling(*this);
|
||||
replacedOpListForBuffer_.emplace_back(opIndexForCache[index], lastOpItemOffset_.value());
|
||||
}
|
||||
@ -307,8 +307,7 @@ void DrawCmdList::Playback(Canvas& canvas, const Rect* rect)
|
||||
}
|
||||
if (mode_ == DrawCmdList::UnmarshalMode::IMMEDIATE) {
|
||||
PlaybackByBuffer(canvas, &tmpRect);
|
||||
}
|
||||
if (mode_ == DrawCmdList::UnmarshalMode::DEFERRED) {
|
||||
} else if (mode_ == DrawCmdList::UnmarshalMode::DEFERRED) {
|
||||
PlaybackByVector(canvas, &tmpRect);
|
||||
}
|
||||
}
|
||||
@ -324,8 +323,7 @@ void DrawCmdList::GenerateCache(Canvas* canvas, const Rect* rect)
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (mode_ == DrawCmdList::UnmarshalMode::IMMEDIATE) {
|
||||
GenerateCacheByBuffer(canvas, rect);
|
||||
}
|
||||
if (mode_ == DrawCmdList::UnmarshalMode::DEFERRED) {
|
||||
} else if (mode_ == DrawCmdList::UnmarshalMode::DEFERRED) {
|
||||
GenerateCacheByVector(canvas, rect);
|
||||
}
|
||||
#endif
|
||||
@ -395,7 +393,7 @@ void DrawCmdList::GenerateCacheByVector(Canvas* canvas, const Rect* rect)
|
||||
return;
|
||||
}
|
||||
uint32_t opSize = drawOpItems_.size();
|
||||
for (auto index = 0u; index < opSize; index++) {
|
||||
for (auto index = 0u; index < opSize; ++index) {
|
||||
std::shared_ptr<DrawOpItem> op = drawOpItems_[index];
|
||||
if (!op || op->GetType() != DrawOpItem::TEXT_BLOB_OPITEM) {
|
||||
continue;
|
||||
|
@ -331,10 +331,9 @@ void RecordingCanvas::DrawTextBlob(const TextBlob* blob, const scalar x, const s
|
||||
}
|
||||
TextBlob::Context ctx {nullptr, IsCustomTypeface()};
|
||||
auto textBlobHandle = CmdListHelper::AddTextBlobToCmdList(*cmdList_, blob, &ctx);
|
||||
uint32_t typefaceId = 0;
|
||||
uint64_t globalUniqueId = 0;
|
||||
if (ctx.GetTypeface() != nullptr) {
|
||||
typefaceId = ctx.GetTypeface()->GetUniqueID();
|
||||
uint32_t typefaceId = ctx.GetTypeface()->GetUniqueID();
|
||||
globalUniqueId = (shiftedPid | typefaceId);
|
||||
}
|
||||
AddDrawOpImmediate<DrawTextBlobOpItem::ConstructorHandle>(textBlobHandle, globalUniqueId, x, y);
|
||||
|
@ -87,7 +87,11 @@ std::shared_ptr<Drawing::Data> ShaderCache::Load(const Drawing::Data& key)
|
||||
{
|
||||
RS_TRACE_NAME("Load shader");
|
||||
size_t keySize = key.GetSize();
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
OptionalLockGuard lock(mutex_);
|
||||
if (!lock.status) {
|
||||
LOGD("load: locked_ failed");
|
||||
return nullptr;
|
||||
}
|
||||
if (!initialized_) {
|
||||
LOGD("load: failed because ShaderCache is not initialized");
|
||||
return nullptr;
|
||||
@ -113,7 +117,11 @@ std::shared_ptr<Drawing::Data> ShaderCache::Load(const Drawing::Data& key)
|
||||
if (errorCode == CacheData::ErrorCode::VALUE_SIZE_TOO_SAMLL) {
|
||||
free(valueBuffer);
|
||||
valueBuffer = nullptr;
|
||||
void* newValueBuffer = realloc(valueBuffer, valueSize);
|
||||
if (valueSize <= 0) {
|
||||
LOGD("valueSize size error");
|
||||
return nullptr;
|
||||
}
|
||||
void* newValueBuffer = malloc(valueSize);
|
||||
if (!newValueBuffer) {
|
||||
LOGD("load: failed to reallocate valueSize:%zu", valueSize);
|
||||
return nullptr;
|
||||
|
@ -28,6 +28,23 @@ class ShaderCache : public Drawing::GPUContextOptions::PersistentCache {
|
||||
public:
|
||||
static ShaderCache& Instance();
|
||||
|
||||
struct OptionalLockGuard {
|
||||
explicit OptionalLockGuard(std::mutex& m): mtx_(m), status(m.try_lock()) {}
|
||||
|
||||
~OptionalLockGuard()
|
||||
{
|
||||
if (status) {
|
||||
mtx_.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
OptionalLockGuard(const OptionalLockGuard&) = delete;
|
||||
OptionalLockGuard& operator=(const OptionalLockGuard&) = delete;
|
||||
|
||||
std::mutex& mtx_;
|
||||
bool status = false;
|
||||
};
|
||||
|
||||
virtual void InitShaderCache(const char *identity, const size_t size, bool isUni);
|
||||
virtual void InitShaderCache()
|
||||
{
|
||||
|
@ -41,6 +41,12 @@ config("composer_public_config") {
|
||||
}
|
||||
|
||||
ohos_shared_library("libcomposer") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
}
|
||||
|
||||
sources = [
|
||||
"hdi_backend/src/hdi_backend.cpp",
|
||||
"hdi_backend/src/hdi_device.cpp",
|
||||
|
@ -92,6 +92,7 @@ ohos_shared_library("libvsync") {
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"ipc:ipc_core",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
|
@ -48,9 +48,9 @@ struct ConnectionInfo {
|
||||
|
||||
class VSyncConnection : public VSyncConnectionStub {
|
||||
public:
|
||||
|
||||
// id for LTPO, windowNodeId for vsync rate control
|
||||
VSyncConnection(const sptr<VSyncDistributor>& distributor, std::string name,
|
||||
const sptr<IRemoteObject>& token = nullptr, uint64_t id = 0);
|
||||
const sptr<IRemoteObject>& token = nullptr, uint64_t id = 0, uint64_t windowNodeId = 0);
|
||||
~VSyncConnection();
|
||||
|
||||
virtual VsyncError RequestNextVSync() override;
|
||||
@ -68,6 +68,7 @@ public:
|
||||
int32_t proxyPid_;
|
||||
bool triggerThisTime_ = false; // used for LTPO
|
||||
uint64_t id_ = 0;
|
||||
uint64_t windowNodeId_ = 0;
|
||||
uint32_t vsyncPulseFreq_ = 1;
|
||||
int64_t referencePulseCount_ = 0;
|
||||
uint32_t refreshRate_ = 0;
|
||||
@ -101,7 +102,7 @@ public:
|
||||
VSyncDistributor(const VSyncDistributor &) = delete;
|
||||
VSyncDistributor &operator=(const VSyncDistributor &) = delete;
|
||||
|
||||
VsyncError AddConnection(const sptr<VSyncConnection>& connection);
|
||||
VsyncError AddConnection(const sptr<VSyncConnection>& connection, uint64_t windowNodeId = 0);
|
||||
VsyncError RemoveConnection(const sptr<VSyncConnection> &connection);
|
||||
|
||||
// fromWhom indicates whether the source is animate or non-animate
|
||||
@ -112,7 +113,7 @@ public:
|
||||
VsyncError SetHighPriorityVSyncRate(int32_t highPriorityRate, const sptr<VSyncConnection>& connection);
|
||||
VsyncError GetVSyncConnectionInfos(std::vector<ConnectionInfo>& infos);
|
||||
VsyncError GetQosVSyncRateInfos(std::vector<std::pair<uint32_t, int32_t>>& vsyncRateInfos);
|
||||
VsyncError SetQosVSyncRate(uint32_t pid, int32_t rate);
|
||||
VsyncError SetQosVSyncRate(uint64_t windowNodeId, int32_t rate);
|
||||
|
||||
// used by DVSync
|
||||
bool IsDVsyncOn();
|
||||
@ -139,6 +140,7 @@ private:
|
||||
void CollectConnections(bool &waitForVSync, int64_t timestamp,
|
||||
std::vector<sptr<VSyncConnection>> &conns, int64_t vsyncCount);
|
||||
VsyncError QosGetPidByName(const std::string& name, uint32_t& pid);
|
||||
constexpr pid_t ExtractPid(uint64_t id);
|
||||
void PostVSyncEvent(const std::vector<sptr<VSyncConnection>> &conns, int64_t timestamp);
|
||||
void ChangeConnsRateLocked();
|
||||
void CollectConnectionsLTPO(bool &waitForVSync, int64_t timestamp,
|
||||
@ -146,6 +148,7 @@ private:
|
||||
/* std::pair<id, refresh rate> */
|
||||
void OnConnsRefreshRateChanged(const std::vector<std::pair<uint64_t, uint32_t>> &refreshRates);
|
||||
void WaitForVsyncOrRequest(std::unique_lock<std::mutex> &locker);
|
||||
VsyncError SetQosVSyncRateByPid(uint32_t pid, int32_t rate);
|
||||
|
||||
#ifdef COMPOSER_SCHED_ENABLE
|
||||
void SubScribeSystemAbility(const std::string& threadName);
|
||||
@ -157,7 +160,7 @@ private:
|
||||
std::mutex mutex_;
|
||||
std::condition_variable con_;
|
||||
std::vector<sptr<VSyncConnection> > connections_;
|
||||
std::map<uint32_t, std::vector<sptr<VSyncConnection>>> connectionsMap_;
|
||||
std::map<uint64_t, std::vector<sptr<VSyncConnection>>> connectionsMap_;
|
||||
VSyncEvent event_;
|
||||
bool vsyncEnabled_;
|
||||
std::string name_;
|
||||
|
@ -80,10 +80,12 @@ VSyncConnection::VSyncConnection(
|
||||
const sptr<VSyncDistributor>& distributor,
|
||||
std::string name,
|
||||
const sptr<IRemoteObject>& token,
|
||||
uint64_t id)
|
||||
uint64_t id,
|
||||
uint64_t windowNodeId)
|
||||
: rate_(-1),
|
||||
info_(name),
|
||||
id_(id),
|
||||
windowNodeId_(windowNodeId),
|
||||
vsyncConnDeathRecipient_(new VSyncConnectionDeathRecipient(this)),
|
||||
token_(token),
|
||||
distributor_(distributor)
|
||||
@ -164,12 +166,8 @@ int32_t VSyncConnection::PostEvent(int64_t now, int64_t period, int64_t vsyncCou
|
||||
int64_t data[3];
|
||||
data[0] = now;
|
||||
// 1, 2: index of array data.
|
||||
data[1] = now + period;
|
||||
data[1] = period;
|
||||
data[2] = vsyncCount;
|
||||
if ((CreateVSyncGenerator()->GetVSyncMode() == VSYNC_MODE_LTPS) && info_.name_ == "rs") {
|
||||
// 5000000 is the vsync offset.
|
||||
data[1] += period - 5000000;
|
||||
}
|
||||
int32_t ret = socketPair->SendData(data, sizeof(data));
|
||||
if (ret > -1) {
|
||||
ScopedDebugTrace successful("successful");
|
||||
@ -249,7 +247,7 @@ VSyncDistributor::~VSyncDistributor()
|
||||
}
|
||||
}
|
||||
|
||||
VsyncError VSyncDistributor::AddConnection(const sptr<VSyncConnection>& connection)
|
||||
VsyncError VSyncDistributor::AddConnection(const sptr<VSyncConnection>& connection, uint64_t windowNodeId)
|
||||
{
|
||||
if (connection == nullptr) {
|
||||
return VSYNC_ERROR_NULLPTR;
|
||||
@ -269,10 +267,15 @@ VsyncError VSyncDistributor::AddConnection(const sptr<VSyncConnection>& connecti
|
||||
ScopedBytrace func("Add VSyncConnection: " + connection->info_.name_);
|
||||
connections_.push_back(connection);
|
||||
connectionCounter_[proxyPid]++;
|
||||
uint32_t tmpPid;
|
||||
if (QosGetPidByName(connection->info_.name_, tmpPid) == VSYNC_ERROR_OK) {
|
||||
connectionsMap_[tmpPid].push_back(connection);
|
||||
if (windowNodeId != 0) {
|
||||
connectionsMap_[windowNodeId].push_back(connection);
|
||||
} else {
|
||||
uint32_t tmpPid;
|
||||
if (QosGetPidByName(connection->info_.name_, tmpPid) == VSYNC_ERROR_OK) {
|
||||
connectionsMap_[tmpPid].push_back(connection);
|
||||
}
|
||||
}
|
||||
|
||||
return VSYNC_ERROR_OK;
|
||||
}
|
||||
|
||||
@ -293,6 +296,7 @@ VsyncError VSyncDistributor::RemoveConnection(const sptr<VSyncConnection>& conne
|
||||
if (connectionCounter_[proxyPid] == 0) {
|
||||
connectionCounter_.erase(proxyPid);
|
||||
}
|
||||
connectionsMap_.erase(connection->windowNodeId_);
|
||||
uint32_t tmpPid;
|
||||
if (QosGetPidByName(connection->info_.name_, tmpPid) == VSYNC_ERROR_OK) {
|
||||
auto iter = connectionsMap_.find(tmpPid);
|
||||
@ -300,7 +304,9 @@ VsyncError VSyncDistributor::RemoveConnection(const sptr<VSyncConnection>& conne
|
||||
return VSYNC_ERROR_OK;
|
||||
}
|
||||
auto connIter = find(iter->second.begin(), iter->second.end(), connection);
|
||||
iter->second.erase(connIter);
|
||||
if (connIter != iter->second.end()) {
|
||||
iter->second.erase(connIter);
|
||||
}
|
||||
if (iter->second.empty()) {
|
||||
connectionsMap_.erase(iter);
|
||||
}
|
||||
@ -736,9 +742,8 @@ VsyncError VSyncDistributor::QosGetPidByName(const std::string& name, uint32_t&
|
||||
return VSYNC_ERROR_OK;
|
||||
}
|
||||
|
||||
VsyncError VSyncDistributor::SetQosVSyncRate(uint32_t pid, int32_t rate)
|
||||
VsyncError VSyncDistributor::SetQosVSyncRateByPid(uint32_t pid, int32_t rate)
|
||||
{
|
||||
std::lock_guard<std::mutex> locker(mutex_);
|
||||
auto iter = connectionsMap_.find(pid);
|
||||
if (iter == connectionsMap_.end()) {
|
||||
VLOGD("%{public}s:%{public}d pid[%{public}u] can not found", __func__, __LINE__, pid);
|
||||
@ -764,6 +769,36 @@ VsyncError VSyncDistributor::SetQosVSyncRate(uint32_t pid, int32_t rate)
|
||||
return VSYNC_ERROR_OK;
|
||||
}
|
||||
|
||||
constexpr pid_t VSyncDistributor::ExtractPid(uint64_t id)
|
||||
{
|
||||
constexpr uint32_t bits = 32u;
|
||||
return static_cast<pid_t>(id >> bits);
|
||||
}
|
||||
|
||||
VsyncError VSyncDistributor::SetQosVSyncRate(uint64_t windowNodeId, int32_t rate)
|
||||
{
|
||||
std::lock_guard<std::mutex> locker(mutex_);
|
||||
VsyncError resCode = SetQosVSyncRateByPid(ExtractPid(windowNodeId), rate);
|
||||
auto iter = connectionsMap_.find(windowNodeId);
|
||||
if (iter == connectionsMap_.end()) {
|
||||
return resCode;
|
||||
}
|
||||
bool isNeedNotify = false;
|
||||
for (auto& connection : iter->second) {
|
||||
if (connection && connection->highPriorityRate_ != rate) {
|
||||
connection->highPriorityRate_ = rate;
|
||||
connection->highPriorityState_ = true;
|
||||
VLOGD("in, conn name:%{public}s, highPriorityRate:%{public}d", connection->info_.name_.c_str(),
|
||||
connection->highPriorityRate_);
|
||||
isNeedNotify = true;
|
||||
}
|
||||
}
|
||||
if (isNeedNotify) {
|
||||
con_.notify_all();
|
||||
}
|
||||
return VSYNC_ERROR_OK;
|
||||
}
|
||||
|
||||
VsyncError VSyncDistributor::GetQosVSyncRateInfos(std::vector<std::pair<uint32_t, int32_t>>& vsyncRateInfos)
|
||||
{
|
||||
vsyncRateInfos.clear();
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <unistd.h>
|
||||
#include <scoped_bytrace.h>
|
||||
#include <fcntl.h>
|
||||
#include <hitrace_meter.h>
|
||||
#include "event_handler.h"
|
||||
#include "graphic_common.h"
|
||||
#include "vsync_log.h"
|
||||
@ -30,6 +31,7 @@ constexpr int32_t INVALID_FD = -1;
|
||||
}
|
||||
void VSyncCallBackListener::OnReadable(int32_t fileDescriptor)
|
||||
{
|
||||
HitracePerfScoped perfTrace(ScopedDebugTrace::isEnabled(), HITRACE_TAG_GRAPHIC_AGP, "OnReadablePerfCount");
|
||||
if (fileDescriptor < 0) {
|
||||
return;
|
||||
}
|
||||
@ -60,15 +62,20 @@ void VSyncCallBackListener::OnReadable(int32_t fileDescriptor)
|
||||
cb = vsyncCallbacks_;
|
||||
}
|
||||
now = data[0];
|
||||
period_ = data[1] - data[0];
|
||||
periodShared_ = data[1] - data[0];
|
||||
period_ = data[1];
|
||||
periodShared_ = data[1];
|
||||
timeStamp_ = data[0];
|
||||
timeStampShared_ = data[0];
|
||||
|
||||
int64_t expectedEnd = now + period_;
|
||||
if (name_ == "rs") {
|
||||
expectedEnd += period_ - 5000000; // rs vsync offset is 5000000ns
|
||||
}
|
||||
|
||||
VLOGD("dataCount:%{public}d, cb == nullptr:%{public}d", dataCount, (cb == nullptr));
|
||||
// 1, 2: index of array data.
|
||||
ScopedBytrace func("ReceiveVsync dataCount:" + std::to_string(dataCount) + "bytes now:" + std::to_string(now) +
|
||||
" expectedEnd:" + std::to_string(data[1]) + " vsyncId:" + std::to_string(data[2]));
|
||||
" expectedEnd:" + std::to_string(expectedEnd) + " vsyncId:" + std::to_string(data[2])); // data[2] is vsyncId
|
||||
if (dataCount > 0 && cb != nullptr) {
|
||||
cb(now, userData_);
|
||||
}
|
||||
@ -106,6 +113,8 @@ VsyncError VSyncReceiver::Init()
|
||||
VLOGW("%{public}s fcntl set fd_ NonBlock failed", __func__);
|
||||
}
|
||||
|
||||
listener_->SetName(name_);
|
||||
|
||||
if (looper_ == nullptr) {
|
||||
std::shared_ptr<AppExecFwk::EventRunner> runner = AppExecFwk::EventRunner::Create(true);
|
||||
looper_ = std::make_shared<AppExecFwk::EventHandler>(runner);
|
||||
|
@ -22,9 +22,10 @@
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
/* Effect defined errors */
|
||||
const uint32_t ERR_EFFECT_INVALID_VALUE = 2; // Invalid value
|
||||
const uint32_t ERROR = 1; // Operation error
|
||||
const uint32_t SUCCESS = 0; // Operation success
|
||||
const uint32_t ERR_EFFECT_INVALID_VALUE = 2; // Invalid value
|
||||
const uint32_t ERROR = 1; // Operation error
|
||||
const uint32_t SUCCESS = 0; // Operation success
|
||||
const uint32_t ERR_INVALID_PARAM = 401; // the value do not change. It is defined on all system
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
#endif // EFFECT_ERRORS_H
|
||||
|
@ -27,6 +27,8 @@ namespace Rosen {
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "EffectNapi"
|
||||
|
||||
#define EFFECT_LOG_D(fmt, ...) HILOG_DEBUG(LOG_CORE, fmt, ##__VA_ARGS__)
|
||||
|
||||
#define EFFECT_LOG_I(fmt, ...) HILOG_INFO(LOG_CORE, fmt, ##__VA_ARGS__)
|
||||
|
||||
#define EFFECT_LOG_E(fmt, ...) HILOG_ERROR(LOG_CORE, fmt, ##__VA_ARGS__)
|
||||
|
@ -20,11 +20,21 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
|
||||
struct PixelColorMatrix {
|
||||
static constexpr uint8_t MATRIX_SIZE = 20;
|
||||
static constexpr uint8_t ROW_SIZE = 4;
|
||||
static constexpr uint8_t COL_SIZE = 5;
|
||||
float val[MATRIX_SIZE] = {0};
|
||||
};
|
||||
|
||||
class SKImageFilterFactory {
|
||||
public:
|
||||
static sk_sp<SkImageFilter> Blur(float radius);
|
||||
static sk_sp<SkImageFilter> Brightness(float degree);
|
||||
static sk_sp<SkImageFilter> Grayscale();
|
||||
static sk_sp<SkImageFilter> Invert();
|
||||
static sk_sp<SkImageFilter> ApplyColorMatrix(const PixelColorMatrix &matrix);
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -31,10 +31,11 @@ sk_sp<SkImageFilter> SKImageFilterFactory::Blur(float radius)
|
||||
sk_sp<SkImageFilter> SKImageFilterFactory::Brightness(float degree)
|
||||
{
|
||||
float matrix[20] = {
|
||||
1, 0, 0, 0, degree,
|
||||
0, 1, 0, 0, degree,
|
||||
0, 0, 1, 0, degree,
|
||||
0, 0, 0, 1, 0 };
|
||||
1, 0, 0, 0, degree,
|
||||
0, 1, 0, 0, degree,
|
||||
0, 0, 1, 0, degree,
|
||||
0, 0, 0, 1, 0
|
||||
};
|
||||
|
||||
return SkImageFilters::ColorFilter(SkColorFilters::Matrix(matrix), nullptr);
|
||||
}
|
||||
@ -42,12 +43,31 @@ sk_sp<SkImageFilter> SKImageFilterFactory::Brightness(float degree)
|
||||
sk_sp<SkImageFilter> SKImageFilterFactory::Grayscale()
|
||||
{
|
||||
float matrix[20] = {
|
||||
GRAYSCALE_PARAONE, GRAYSCALE_PARATWO, GRAYSCALE_PARATHREE, 0, 0,
|
||||
GRAYSCALE_PARAONE, GRAYSCALE_PARATWO, GRAYSCALE_PARATHREE, 0, 0,
|
||||
GRAYSCALE_PARAONE, GRAYSCALE_PARATWO, GRAYSCALE_PARATHREE, 0, 0,
|
||||
0, 0, 0, 1, 0 };
|
||||
GRAYSCALE_PARAONE, GRAYSCALE_PARATWO, GRAYSCALE_PARATHREE, 0, 0,
|
||||
GRAYSCALE_PARAONE, GRAYSCALE_PARATWO, GRAYSCALE_PARATHREE, 0, 0,
|
||||
GRAYSCALE_PARAONE, GRAYSCALE_PARATWO, GRAYSCALE_PARATHREE, 0, 0,
|
||||
0, 0, 0, 1, 0
|
||||
};
|
||||
|
||||
return SkImageFilters::ColorFilter(SkColorFilters::Matrix(matrix), nullptr);
|
||||
}
|
||||
|
||||
sk_sp<SkImageFilter> SKImageFilterFactory::Invert()
|
||||
{
|
||||
/* invert matrix */
|
||||
float matrix[20] = {
|
||||
-1.0, 0, 0, 0, 1,
|
||||
0, -1.0, 0, 0, 1,
|
||||
0, 0, -1.0, 0, 1,
|
||||
0, 0, 0, 1, 0
|
||||
};
|
||||
|
||||
return SkImageFilters::ColorFilter(SkColorFilters::Matrix(matrix), nullptr);
|
||||
}
|
||||
|
||||
sk_sp<SkImageFilter> SKImageFilterFactory::ApplyColorMatrix(const PixelColorMatrix &matrix)
|
||||
{
|
||||
return SkImageFilters::ColorFilter(SkColorFilters::Matrix(matrix.val), nullptr);
|
||||
}
|
||||
} // namespcae Rosen
|
||||
} // namespace OHOS
|
@ -58,24 +58,24 @@ struct FrameRateVoteInfo {
|
||||
std::string ltpoType = "";
|
||||
uint64_t timestamp = 0;
|
||||
|
||||
void SetTimestamp(uint64_t timestamp_)
|
||||
void SetTimestamp(uint64_t curTimestamp)
|
||||
{
|
||||
timestamp = timestamp_;
|
||||
timestamp = curTimestamp;
|
||||
}
|
||||
|
||||
void SetVoteInfo(std::string voterName_, uint32_t preferred_)
|
||||
void SetVoteInfo(const std::string& curVoterName, uint32_t curPreferred)
|
||||
{
|
||||
voterName = voterName_;
|
||||
preferred = preferred_;
|
||||
voterName = curVoterName;
|
||||
preferred = curPreferred;
|
||||
}
|
||||
|
||||
void SetLtpoInfo(FrameRateLinkerId pid_, std::string ltpoType_)
|
||||
void SetLtpoInfo(FrameRateLinkerId curPid, const std::string& curLtpoType)
|
||||
{
|
||||
pid = pid_;
|
||||
ltpoType = ltpoType_;
|
||||
pid = curPid;
|
||||
ltpoType = curLtpoType;
|
||||
}
|
||||
|
||||
std::string ToString()
|
||||
std::string ToString() const
|
||||
{
|
||||
std::stringstream str;
|
||||
str << "VOTER_NAME:" << voterName << ";";
|
||||
|
@ -272,6 +272,7 @@ ohos_shared_library("librender_service") {
|
||||
"hiview:libucollection_utility",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_core",
|
||||
"qos_manager:qos",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
"window_manager:libwsutils",
|
||||
@ -310,6 +311,7 @@ ohos_shared_library("librender_service") {
|
||||
|
||||
if (accessibility_enable) {
|
||||
external_deps += [ "accessibility:accessibilityconfig" ]
|
||||
external_deps += [ "accessibility:accessibility_common" ]
|
||||
defines += accessibility_defines
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,9 @@
|
||||
#include "memory/rs_tag_tracker.h"
|
||||
#include "rs_trace.h"
|
||||
#include "platform/common/rs_log.h"
|
||||
#ifdef RES_SCHED_ENABLE
|
||||
#include "qos.h"
|
||||
#endif
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
@ -36,6 +39,14 @@ void RSSubThreadRCD::Start(RenderContext* context)
|
||||
std::string name = "RoundCornerDisplaySubThread";
|
||||
runner_ = AppExecFwk::EventRunner::Create(name);
|
||||
handler_ = std::make_shared<AppExecFwk::EventHandler>(runner_);
|
||||
|
||||
#ifdef RES_SCHED_ENABLE
|
||||
PostTask([this]() {
|
||||
auto ret = OHOS::QOS::SetThreadQos(OHOS::QOS::QosLevel::QOS_USER_INTERACTIVE);
|
||||
RS_LOGI("RoundCornerDisplay: SetThreadQos retcode = %{public}d", ret);
|
||||
});
|
||||
#endif
|
||||
|
||||
renderContext_ = context;
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,7 @@ public:
|
||||
virtual void DrawLayers(RSPaintFilterCanvas& canvas, const std::vector<LayerInfoPtr>& layers, bool forceCPU = false,
|
||||
float mirrorAdaptiveCoefficient = 1.0f) = 0;
|
||||
|
||||
void DrawBuffer(RSPaintFilterCanvas& canvas, BufferDrawParam& params);
|
||||
static void DrawBuffer(RSPaintFilterCanvas& canvas, BufferDrawParam& params);
|
||||
|
||||
void ShrinkCachesIfNeeded(bool isForUniRedraw = false);
|
||||
static void SetColorFilterMode(ColorFilterMode mode);
|
||||
|
@ -400,7 +400,7 @@ void RSHardwareThread::Redraw(const sptr<Surface>& surface, const std::vector<La
|
||||
params.matrix.PostScale(screenInfo.GetRogWidthRatio(), screenInfo.GetRogHeightRatio());
|
||||
canvas->ConcatMatrix(params.matrix);
|
||||
#ifndef RS_ENABLE_EGLIMAGE
|
||||
uniRenderEngine_->DrawBuffer(*canvas, params);
|
||||
RSBaseRenderEngine::DrawBuffer(*canvas, params);
|
||||
#else
|
||||
if (!params.useCPU) {
|
||||
if (!RSBaseRenderUtil::IsBufferValid(params.buffer)) {
|
||||
@ -524,7 +524,7 @@ void RSHardwareThread::Redraw(const sptr<Surface>& surface, const std::vector<La
|
||||
#endif
|
||||
canvas->DetachBrush();
|
||||
} else {
|
||||
uniRenderEngine_->DrawBuffer(*canvas, params);
|
||||
RSBaseRenderEngine::DrawBuffer(*canvas, params);
|
||||
}
|
||||
#endif
|
||||
// Dfx for redraw region
|
||||
|
@ -147,7 +147,6 @@ constexpr int32_t SIMI_VISIBLE_RATE = 2;
|
||||
constexpr int32_t DEFAULT_RATE = 1;
|
||||
constexpr int32_t INVISBLE_WINDOW_RATE = 10;
|
||||
constexpr int32_t SYSTEM_ANIMATED_SECNES_RATE = 2;
|
||||
constexpr int32_t MAX_MULTI_INSTANCE_PID_COUNT = 1;
|
||||
constexpr uint32_t WAIT_FOR_MEM_MGR_SERVICE = 100;
|
||||
constexpr uint32_t CAL_NODE_PREFERRED_FPS_LIMIT = 50;
|
||||
constexpr uint32_t EVENT_SET_HARDWARE_UTIL = 100004;
|
||||
@ -382,7 +381,7 @@ void RSMainThread::Init()
|
||||
rsFrameRateLinker_ = std::make_shared<RSRenderFrameRateLinker>();
|
||||
conn->id_ = rsFrameRateLinker_->GetId();
|
||||
rsVSyncDistributor_->AddConnection(conn);
|
||||
receiver_ = std::make_shared<VSyncReceiver>(conn, token->AsObject(), handler_);
|
||||
receiver_ = std::make_shared<VSyncReceiver>(conn, token->AsObject(), handler_, "rs");
|
||||
receiver_->Init();
|
||||
if (isUniRender_) {
|
||||
uniRenderEngine_ = std::make_shared<RSUniRenderEngine>();
|
||||
@ -1770,12 +1769,12 @@ RSVisibleLevel RSMainThread::GetRegionVisibleLevel(const Occlusion::Region& curR
|
||||
}
|
||||
|
||||
void RSMainThread::CalcOcclusionImplementation(std::vector<RSBaseRenderNode::SharedPtr>& curAllSurfaces,
|
||||
VisibleData& dstCurVisVec, std::map<uint32_t, RSVisibleLevel>& dstPidVisMap)
|
||||
VisibleData& dstCurVisVec, std::map<NodeId, RSVisibleLevel>& dstVisMapForVsyncRate)
|
||||
{
|
||||
Occlusion::Region accumulatedRegion;
|
||||
VisibleData curVisVec;
|
||||
OcclusionRectISet occlusionSurfaces;
|
||||
std::map<uint32_t, RSVisibleLevel> pidVisMap;
|
||||
std::map<NodeId, RSVisibleLevel> visMapForVsyncRate;
|
||||
bool hasFilterCacheOcclusion = false;
|
||||
bool filterCacheOcclusionEnabled = RSSystemParameters::GetFilterCacheOcculusionEnabled();
|
||||
for (auto it = curAllSurfaces.rbegin(); it != curAllSurfaces.rend(); ++it) {
|
||||
@ -1792,12 +1791,12 @@ void RSMainThread::CalcOcclusionImplementation(std::vector<RSBaseRenderNode::Sha
|
||||
RSVisibleLevel visibleLevel = GetRegionVisibleLevel(curRegion, subResult);
|
||||
RS_LOGD("%{public}s nodeId[%{public}" PRIu64 "] visibleLevel[%{public}d]",
|
||||
__func__, curSurface->GetId(), visibleLevel);
|
||||
curSurface->SetVisibleRegionRecursive(subResult, curVisVec, pidVisMap, true, visibleLevel,
|
||||
curSurface->SetVisibleRegionRecursive(subResult, curVisVec, visMapForVsyncRate, true, visibleLevel,
|
||||
!systemAnimatedScenesList_.empty());
|
||||
curSurface->AccumulateOcclusionRegion(accumulatedRegion, curRegion, hasFilterCacheOcclusion, isUniRender_,
|
||||
filterCacheOcclusionEnabled);
|
||||
} else {
|
||||
curSurface->SetVisibleRegionRecursive({}, curVisVec, pidVisMap);
|
||||
curSurface->SetVisibleRegionRecursive({}, curVisVec, visMapForVsyncRate);
|
||||
RS_LOGD("%{public}s nodeId[%{public}" PRIu64 "] visibleLevel[%{public}d]",
|
||||
__func__, curSurface->GetId(), RSVisibleLevel::RS_INVISIBLE);
|
||||
}
|
||||
@ -1806,7 +1805,7 @@ void RSMainThread::CalcOcclusionImplementation(std::vector<RSBaseRenderNode::Sha
|
||||
// if there are valid filter cache occlusion, recalculate surfacenode visibleregionforcallback for WMS/QOS callback
|
||||
if (hasFilterCacheOcclusion && isUniRender_) {
|
||||
curVisVec.clear();
|
||||
pidVisMap.clear();
|
||||
visMapForVsyncRate.clear();
|
||||
occlusionSurfaces.clear();
|
||||
accumulatedRegion = {};
|
||||
for (auto it = curAllSurfaces.rbegin(); it != curAllSurfaces.rend(); ++it) {
|
||||
@ -1820,18 +1819,18 @@ void RSMainThread::CalcOcclusionImplementation(std::vector<RSBaseRenderNode::Sha
|
||||
Occlusion::Region curRegion { occlusionRect };
|
||||
Occlusion::Region subResult = curRegion.Sub(accumulatedRegion);
|
||||
RSVisibleLevel visibleLevel = GetRegionVisibleLevel(curRegion, subResult);
|
||||
curSurface->SetVisibleRegionRecursive(subResult, curVisVec, pidVisMap, false, visibleLevel,
|
||||
curSurface->SetVisibleRegionRecursive(subResult, curVisVec, visMapForVsyncRate, false, visibleLevel,
|
||||
!systemAnimatedScenesList_.empty());
|
||||
curSurface->AccumulateOcclusionRegion(accumulatedRegion, curRegion, hasFilterCacheOcclusion,
|
||||
isUniRender_, false);
|
||||
} else {
|
||||
curSurface->SetVisibleRegionRecursive({}, curVisVec, pidVisMap, false);
|
||||
curSurface->SetVisibleRegionRecursive({}, curVisVec, visMapForVsyncRate, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dstCurVisVec.insert(dstCurVisVec.end(), curVisVec.begin(), curVisVec.end());
|
||||
dstPidVisMap.insert(pidVisMap.begin(), pidVisMap.end());
|
||||
dstVisMapForVsyncRate.insert(visMapForVsyncRate.begin(), visMapForVsyncRate.end());
|
||||
}
|
||||
|
||||
void RSMainThread::CalcOcclusion()
|
||||
@ -1911,59 +1910,37 @@ void RSMainThread::CalcOcclusion()
|
||||
}
|
||||
isReduceVSyncBySystemAnimatedScenes_ = false;
|
||||
VisibleData dstCurVisVec;
|
||||
std::map<uint32_t, RSVisibleLevel> dstPidVisMap;
|
||||
std::map<NodeId, RSVisibleLevel> dstVisMapForVsyncRate;
|
||||
for (auto& surfaces : curAllSurfacesInDisplay) {
|
||||
CalcOcclusionImplementation(surfaces.second, dstCurVisVec, dstPidVisMap);
|
||||
CalcOcclusionImplementation(surfaces.second, dstCurVisVec, dstVisMapForVsyncRate);
|
||||
}
|
||||
|
||||
// Callback to WMS and QOS
|
||||
CallbackToWMS(dstCurVisVec);
|
||||
SetVSyncRateByVisibleLevel(dstPidVisMap, curAllSurfaces);
|
||||
SetVSyncRateByVisibleLevel(dstVisMapForVsyncRate, curAllSurfaces);
|
||||
// Callback for registered self drawing surfacenode
|
||||
SurfaceOcclusionCallback();
|
||||
}
|
||||
|
||||
void RSMainThread::SetMultiInstancePidVSyncRate(std::map<uint32_t, RSVisibleLevel>& pidVisMap,
|
||||
std::vector<RSBaseRenderNode::SharedPtr>& curAllSurfaces)
|
||||
{
|
||||
std::map<uint32_t, int> multiInstancePidMap;
|
||||
for (auto it = curAllSurfaces.rbegin(); it != curAllSurfaces.rend(); ++it) {
|
||||
auto curSurface = RSBaseRenderNode::ReinterpretCast<RSSurfaceRenderNode>(*it);
|
||||
if (curSurface == nullptr || curSurface->GetDstRect().IsEmpty() || curSurface->IsLeashWindow()) {
|
||||
continue;
|
||||
}
|
||||
uint32_t tmpPid = ExtractPid(curSurface->GetId());
|
||||
multiInstancePidMap[tmpPid]++;
|
||||
}
|
||||
for (auto& iter : multiInstancePidMap) {
|
||||
if (iter.second > MAX_MULTI_INSTANCE_PID_COUNT) {
|
||||
pidVisMap[iter.first] = RSVisibleLevel::RS_ALL_VISIBLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool RSMainThread::CheckSurfaceVisChanged(std::map<uint32_t, RSVisibleLevel>& pidVisMap,
|
||||
bool RSMainThread::CheckSurfaceVisChanged(std::map<NodeId, RSVisibleLevel>& visMapForVsyncRate,
|
||||
std::vector<RSBaseRenderNode::SharedPtr>& curAllSurfaces)
|
||||
{
|
||||
if (!systemAnimatedScenesList_.empty()) {
|
||||
pidVisMap.clear();
|
||||
visMapForVsyncRate.clear();
|
||||
for (auto it = curAllSurfaces.rbegin(); it != curAllSurfaces.rend(); ++it) {
|
||||
auto curSurface = RSBaseRenderNode::ReinterpretCast<RSSurfaceRenderNode>(*it);
|
||||
if (curSurface == nullptr || curSurface->GetDstRect().IsEmpty() || curSurface->IsLeashWindow()) {
|
||||
continue;
|
||||
}
|
||||
uint32_t tmpPid = ExtractPid(curSurface->GetId());
|
||||
pidVisMap[tmpPid] = RSVisibleLevel::RS_SYSTEM_ANIMATE_SCENE;
|
||||
visMapForVsyncRate[curSurface->GetId()] = RSVisibleLevel::RS_SYSTEM_ANIMATE_SCENE;
|
||||
}
|
||||
isReduceVSyncBySystemAnimatedScenes_ = true;
|
||||
} else {
|
||||
SetMultiInstancePidVSyncRate(pidVisMap, curAllSurfaces);
|
||||
}
|
||||
bool isVisibleChanged = pidVisMap.size() != lastPidVisMap_.size();
|
||||
bool isVisibleChanged = visMapForVsyncRate.size() != visMapForVsyncRate.size();
|
||||
if (!isVisibleChanged) {
|
||||
auto iterCur = pidVisMap.begin();
|
||||
auto iterLast = lastPidVisMap_.begin();
|
||||
for (; iterCur != pidVisMap.end(); iterCur++, iterLast++) {
|
||||
auto iterCur = visMapForVsyncRate.begin();
|
||||
auto iterLast = lastVisMapForVsyncRate_.begin();
|
||||
for (; iterCur != visMapForVsyncRate.end(); iterCur++, iterLast++) {
|
||||
if (iterCur->first != iterLast->first ||
|
||||
iterCur->second != iterLast->second) {
|
||||
isVisibleChanged = true;
|
||||
@ -1973,20 +1950,20 @@ bool RSMainThread::CheckSurfaceVisChanged(std::map<uint32_t, RSVisibleLevel>& pi
|
||||
}
|
||||
|
||||
if (isVisibleChanged) {
|
||||
lastPidVisMap_ = pidVisMap;
|
||||
lastVisMapForVsyncRate_ = visMapForVsyncRate;
|
||||
}
|
||||
return isVisibleChanged;
|
||||
}
|
||||
|
||||
void RSMainThread::SetVSyncRateByVisibleLevel(std::map<uint32_t, RSVisibleLevel>& pidVisMap,
|
||||
void RSMainThread::SetVSyncRateByVisibleLevel(std::map<NodeId, RSVisibleLevel>& visMapForVsyncRate,
|
||||
std::vector<RSBaseRenderNode::SharedPtr>& curAllSurfaces)
|
||||
{
|
||||
if (!vsyncControlEnabled_ || !CheckSurfaceVisChanged(pidVisMap, curAllSurfaces) ||
|
||||
if (!vsyncControlEnabled_ || !CheckSurfaceVisChanged(visMapForVsyncRate, curAllSurfaces) ||
|
||||
appVSyncDistributor_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
RS_TRACE_NAME_FMT("%s pidVisMapSize[%lu]", __func__, pidVisMap.size());
|
||||
for (auto iter:pidVisMap) {
|
||||
RS_TRACE_NAME_FMT("%s visMapForVsyncRateSize[%lu]", __func__, visMapForVsyncRate.size());
|
||||
for (auto iter:visMapForVsyncRate) {
|
||||
if (iter.second == RSVisibleLevel::RS_SEMI_DEFAULT_VISIBLE) {
|
||||
appVSyncDistributor_->SetQosVSyncRate(iter.first, SIMI_VISIBLE_RATE);
|
||||
} else if (iter.second == RSVisibleLevel::RS_SYSTEM_ANIMATE_SCENE) {
|
||||
@ -2227,7 +2204,7 @@ void RSMainThread::Animate(uint64_t timestamp)
|
||||
});
|
||||
if (needPrintAnimationDFX && needRequestNextVsync && animationPids.size() > 0) {
|
||||
std::string pidList;
|
||||
for (auto& pid : animationPids) {
|
||||
for (const auto& pid : animationPids) {
|
||||
pidList += "[" + std::to_string(pid) + "]";
|
||||
}
|
||||
RS_TRACE_NAME_FMT("Animate from pid %s", pidList.c_str());
|
||||
|
@ -192,8 +192,6 @@ public:
|
||||
void CountMem(int pid, MemoryGraphic& mem);
|
||||
void CountMem(std::vector<MemoryGraphic>& mems);
|
||||
void SetAppWindowNum(uint32_t num);
|
||||
void SetMultiInstancePidVSyncRate(std::map<uint32_t, RSVisibleLevel>& pidVisMap,
|
||||
std::vector<RSBaseRenderNode::SharedPtr>& curAllSurfaces);
|
||||
bool SetSystemAnimatedScenes(SystemAnimatedScenes systemAnimatedScenes);
|
||||
SystemAnimatedScenes GetSystemAnimatedScenes();
|
||||
void ShowWatermark(const std::shared_ptr<Media::PixelMap> &watermarkImg, bool isShow);
|
||||
@ -304,11 +302,11 @@ private:
|
||||
void UniRender(std::shared_ptr<RSBaseRenderNode> rootNode);
|
||||
bool CheckSurfaceNeedProcess(OcclusionRectISet& occlusionSurfaces, std::shared_ptr<RSSurfaceRenderNode> curSurface);
|
||||
void CalcOcclusionImplementation(std::vector<RSBaseRenderNode::SharedPtr>& curAllSurfaces,
|
||||
VisibleData& dstCurVisVec, std::map<uint32_t, RSVisibleLevel>& dstPidVisMap);
|
||||
VisibleData& dstCurVisVec, std::map<NodeId, RSVisibleLevel>& dstPidVisMap);
|
||||
void CalcOcclusion();
|
||||
bool CheckSurfaceVisChanged(std::map<uint32_t, RSVisibleLevel>& pidVisMap,
|
||||
bool CheckSurfaceVisChanged(std::map<NodeId, RSVisibleLevel>& pidVisMap,
|
||||
std::vector<RSBaseRenderNode::SharedPtr>& curAllSurfaces);
|
||||
void SetVSyncRateByVisibleLevel(std::map<uint32_t, RSVisibleLevel>& pidVisMap,
|
||||
void SetVSyncRateByVisibleLevel(std::map<NodeId, RSVisibleLevel>& pidVisMap,
|
||||
std::vector<RSBaseRenderNode::SharedPtr>& curAllSurfaces);
|
||||
void CallbackToWMS(VisibleData& curVisVec);
|
||||
void SendCommands();
|
||||
@ -449,7 +447,7 @@ private:
|
||||
mutable std::mutex hardwareThreadTaskMutex_;
|
||||
std::condition_variable hardwareThreadTaskCond_;
|
||||
|
||||
std::map<uint32_t, RSVisibleLevel> lastPidVisMap_;
|
||||
std::map<NodeId, RSVisibleLevel> lastVisMapForVsyncRate_;
|
||||
VisibleData lastVisVec_;
|
||||
std::map<NodeId, uint64_t> lastDrawStatusMap_;
|
||||
std::vector<NodeId> curDrawStatusVec_;
|
||||
|
@ -308,6 +308,8 @@ sptr<Surface> RSRenderServiceConnection::CreateNodeAndSurface(const RSSurfaceRen
|
||||
"id:%{public}" PRIu64 " name:%{public}s bundleName:%{public}s surface id:%{public}" PRIu64 " name:%{public}s",
|
||||
node->GetId(), node->GetName().c_str(), node->GetBundleName().c_str(),
|
||||
surface->GetUniqueId(), surfaceName.c_str());
|
||||
auto defaultUsage = surface->GetDefaultUsage();
|
||||
surface->SetDefaultUsage(defaultUsage | BUFFER_USAGE_MEM_DMA | BUFFER_USAGE_HW_COMPOSER);
|
||||
node->SetConsumer(surface);
|
||||
std::function<void()> registerNode = [node, this]() -> void {
|
||||
this->mainThread_->GetContext().GetMutableNodeMap().RegisterRenderNode(node);
|
||||
@ -332,9 +334,10 @@ sptr<Surface> RSRenderServiceConnection::CreateNodeAndSurface(const RSSurfaceRen
|
||||
|
||||
sptr<IVSyncConnection> RSRenderServiceConnection::CreateVSyncConnection(const std::string& name,
|
||||
const sptr<VSyncIConnectionToken>& token,
|
||||
uint64_t id)
|
||||
uint64_t id,
|
||||
NodeId windowNodeId)
|
||||
{
|
||||
sptr<VSyncConnection> conn = new VSyncConnection(appVSyncDistributor_, name, token->AsObject());
|
||||
sptr<VSyncConnection> conn = new VSyncConnection(appVSyncDistributor_, name, token->AsObject(), windowNodeId);
|
||||
if (ExtractPid(id) == remotePid_) {
|
||||
auto linker = std::make_shared<RSRenderFrameRateLinker>(id);
|
||||
auto& context = mainThread_->GetContext();
|
||||
@ -342,7 +345,7 @@ sptr<IVSyncConnection> RSRenderServiceConnection::CreateVSyncConnection(const st
|
||||
frameRateLikerMap.RegisterFrameRateLinker(linker);
|
||||
conn->id_ = id;
|
||||
}
|
||||
auto ret = appVSyncDistributor_->AddConnection(conn);
|
||||
auto ret = appVSyncDistributor_->AddConnection(conn, windowNodeId);
|
||||
if (ret != VSYNC_ERROR_OK) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -77,7 +77,8 @@ private:
|
||||
|
||||
sptr<IVSyncConnection> CreateVSyncConnection(const std::string& name,
|
||||
const sptr<VSyncIConnectionToken>& token,
|
||||
uint64_t id) override;
|
||||
uint64_t id,
|
||||
NodeId windowNodeId = 0) override;
|
||||
|
||||
int32_t SetFocusAppInfo(
|
||||
int32_t pid, int32_t uid, const std::string &bundleName, const std::string &abilityName,
|
||||
|
@ -141,6 +141,7 @@ void RSRenderServiceVisitor::ProcessDisplayRenderNode(RSDisplayRenderNode& node)
|
||||
RS_TRACE_NAME("ProcessDisplayRenderNode[" + std::to_string(node.GetScreenId()) + "]");
|
||||
// skip frame according to skipFrameInterval value of SetScreenSkipFrameInterval interface
|
||||
if (node.SkipFrame(curScreenInfo.skipFrameInterval)) {
|
||||
RS_TRACE_NAME("SkipFrame, screenId:" + std::to_string(node.GetScreenId()));
|
||||
return;
|
||||
}
|
||||
processor_ = RSProcessorFactory::CreateProcessor(node.GetCompositeType());
|
||||
|
@ -631,7 +631,7 @@ void RSSurfaceCaptureVisitor::CaptureSingleSurfaceNodeWithUni(RSSurfaceRenderNod
|
||||
canvas_->Save();
|
||||
}
|
||||
|
||||
if (node.IsAppWindow()) {
|
||||
if (node.IsAppWindow() || node.IsLeashWindow()) {
|
||||
// When CaptureSingleSurfaceNodeWithUni, we should consider scale factor of canvas_ and
|
||||
// child nodes (self-drawing surfaceNode) of AppWindow should use relative coordinates
|
||||
// which is the node relative to the upper-left corner of the window.
|
||||
|
@ -352,28 +352,30 @@ bool RSUniRenderUtil::HandleSubThreadNode(RSSurfaceRenderNode& node, RSPaintFilt
|
||||
bool RSUniRenderUtil::HandleCaptureNode(RSRenderNode& node, RSPaintFilterCanvas& canvas)
|
||||
{
|
||||
auto surfaceNodePtr = node.ReinterpretCastTo<RSSurfaceRenderNode>();
|
||||
if (surfaceNodePtr == nullptr) {
|
||||
if (surfaceNodePtr == nullptr ||
|
||||
(!surfaceNodePtr->IsAppWindow() && !surfaceNodePtr->IsLeashWindow())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto curNode = surfaceNodePtr;
|
||||
if (surfaceNodePtr->IsAppWindow()) {
|
||||
auto rsParent = RSBaseRenderNode::ReinterpretCast<RSSurfaceRenderNode>(surfaceNodePtr->GetParent().lock());
|
||||
auto curNode = surfaceNodePtr;
|
||||
if (rsParent && rsParent->IsLeashWindow()) {
|
||||
curNode = rsParent;
|
||||
}
|
||||
if (!curNode->ShouldPaint()) {
|
||||
return false;
|
||||
}
|
||||
if (curNode->IsOnTheTree()) {
|
||||
return HandleSubThreadNode(*curNode, canvas);
|
||||
} else {
|
||||
}
|
||||
if (!curNode->ShouldPaint()) {
|
||||
return false;
|
||||
}
|
||||
if (curNode->IsOnTheTree()) {
|
||||
return HandleSubThreadNode(*curNode, canvas);
|
||||
} else {
|
||||
#if defined(RS_ENABLE_GL) || defined(RS_ENABLE_VK)
|
||||
if (curNode->GetCacheSurfaceProcessedStatus() == CacheProcessStatus::DOING) {
|
||||
RSSubThreadManager::Instance()->WaitNodeTask(curNode->GetId());
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
if (curNode->GetCacheSurfaceProcessedStatus() == CacheProcessStatus::DOING) {
|
||||
RSSubThreadManager::Instance()->WaitNodeTask(curNode->GetId());
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ RSUniRenderVisitor::RSUniRenderVisitor()
|
||||
#endif
|
||||
RSTagTracker::UpdateReleaseResourceEnabled(RSSystemProperties::GetReleaseResourceEnabled());
|
||||
isScreenRotationAnimating_ = RSSystemProperties::GetCacheEnabledForRotation();
|
||||
isSubSurfaceEnabled_ = RSSystemProperties::GetSubSurfaceEnabled();
|
||||
isSubSurfaceEnabled_ = RSSystemProperties::GetSubSurfaceEnabled() && RSSystemProperties::IsPhoneType();
|
||||
isSkipCanvasNodeOutOfScreen_ = RSSystemParameters::GetSkipCanvasNodeOutofScreenEnabled();
|
||||
#if defined(RS_ENABLE_DRIVEN_RENDER)
|
||||
if (RSDrivenRenderManager::GetInstance().GetDrivenRenderEnabled()) {
|
||||
@ -2248,6 +2248,13 @@ void RSUniRenderVisitor::ProcessDisplayRenderNode(RSDisplayRenderNode& node)
|
||||
RS_LOGE("RSUniRenderVisitor::ProcessDisplayRenderNode ScreenManager is nullptr");
|
||||
return;
|
||||
}
|
||||
ScreenInfo curScreenInfo = screenManager->QueryScreenInfo(node.GetScreenId());
|
||||
// skip frame according to skipFrameInterval value of SetScreenSkipFrameInterval interface
|
||||
if (node.SkipFrame(curScreenInfo.skipFrameInterval)) {
|
||||
RS_TRACE_NAME("SkipFrame, screenId:" + std::to_string(node.GetScreenId()));
|
||||
return;
|
||||
}
|
||||
|
||||
constexpr int ROTATION_NUM = 4;
|
||||
auto screenRotation = node.GetScreenRotation();
|
||||
if (RSSystemProperties::IsFoldScreenFlag() && node.GetScreenId() == 0) {
|
||||
@ -2353,9 +2360,8 @@ void RSUniRenderVisitor::ProcessDisplayRenderNode(RSDisplayRenderNode& node)
|
||||
mirrorAutoRotate_ = true;
|
||||
}
|
||||
canvas_->Save();
|
||||
bool canvasRotation = screenManager->GetCanvasRotation(node.GetScreenId());
|
||||
ScaleMirrorIfNeed(node, canvasRotation);
|
||||
RotateMirrorCanvasIfNeed(node, canvasRotation);
|
||||
ScaleMirrorIfNeedForWiredScreen(node);
|
||||
RotateMirrorCanvasIfNeedForWiredScreen(node);
|
||||
bool forceCPU = false;
|
||||
auto params = RSUniRenderUtil::CreateBufferDrawParam(*mirrorNode, forceCPU);
|
||||
params.isMirror = true;
|
||||
@ -3884,13 +3890,9 @@ void RSUniRenderVisitor::ProcessSurfaceRenderNode(RSSurfaceRenderNode& node)
|
||||
}
|
||||
#endif
|
||||
if (isUIFirst_ && isSubThread_) {
|
||||
bool isFirstLevelSurface = !RSBaseRenderNode::ReinterpretCast<RSSurfaceRenderNode>(node.GetParent().lock());
|
||||
if (isSubSurfaceEnabled_) {
|
||||
isFirstLevelSurface = node.IsFirstLevelSurfaceNode();
|
||||
}
|
||||
if (auto parentNode = RSBaseRenderNode::ReinterpretCast<RSDisplayRenderNode>(node.GetParent().lock()) ||
|
||||
(SceneBoardJudgement::IsSceneBoardEnabled() && (node.IsLeashWindow() || (node.IsAppWindow() &&
|
||||
isFirstLevelSurface)))) {
|
||||
node.IsFirstLevelNode())))) {
|
||||
UpdateCacheSurface(node);
|
||||
return;
|
||||
}
|
||||
@ -5010,6 +5012,10 @@ void RSUniRenderVisitor::ScaleMirrorIfNeed(RSDisplayRenderNode& node, bool canva
|
||||
if (mainWidth != mirrorWidth || mainHeight != mirrorHeight) {
|
||||
canvas_->Clear(SK_ColorBLACK);
|
||||
auto processor = std::static_pointer_cast<RSUniRenderVirtualProcessor>(processor_);
|
||||
if (!processor) {
|
||||
RS_LOGE("RSUniRenderVisitor::ScaleMirrorIfNeed processor is nullptr!");
|
||||
return;
|
||||
}
|
||||
if (scaleMode == ScreenScaleMode::FILL_MODE) {
|
||||
processor->Fill(*canvas_, mainWidth, mainHeight, mirrorWidth, mirrorHeight);
|
||||
} else if (scaleMode == ScreenScaleMode::UNISCALE_MODE) {
|
||||
@ -5018,6 +5024,83 @@ void RSUniRenderVisitor::ScaleMirrorIfNeed(RSDisplayRenderNode& node, bool canva
|
||||
}
|
||||
}
|
||||
|
||||
void RSUniRenderVisitor::RotateMirrorCanvasIfNeedForWiredScreen(RSDisplayRenderNode& node)
|
||||
{
|
||||
auto mirrorNode = node.GetMirrorSource().lock();
|
||||
auto rotation = mirrorNode->GetScreenRotation();
|
||||
if (RSSystemProperties::IsFoldScreenFlag() && mirrorNode->GetScreenId() == 0) {
|
||||
if (rotation == ScreenRotation::ROTATION_270) {
|
||||
rotation = ScreenRotation::ROTATION_0;
|
||||
} else {
|
||||
rotation = static_cast<ScreenRotation>(static_cast<int>(rotation) + 1);
|
||||
}
|
||||
}
|
||||
if (rotation != ScreenRotation::ROTATION_0) {
|
||||
auto screenManager = CreateOrGetScreenManager();
|
||||
auto mainScreenInfo = screenManager->QueryScreenInfo(mirrorNode->GetScreenId());
|
||||
if (rotation == ScreenRotation::ROTATION_90) {
|
||||
canvas_->Rotate(ROTATION_90, 0, 0);
|
||||
canvas_->Translate(0, -(static_cast<float>(mainScreenInfo.height)));
|
||||
} else if (rotation == ScreenRotation::ROTATION_180) {
|
||||
float ratio = 0.5f;
|
||||
canvas_->Rotate(ROTATION_180, static_cast<float>(mainScreenInfo.width) * ratio,
|
||||
static_cast<float>(mainScreenInfo.height) * ratio);
|
||||
} else if (rotation == ScreenRotation::ROTATION_270) {
|
||||
canvas_->Rotate(ROTATION_270, 0, 0);
|
||||
canvas_->Translate(-(static_cast<float>(mainScreenInfo.width)), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RSUniRenderVisitor::ScaleMirrorIfNeedForWiredScreen(RSDisplayRenderNode& node, bool canvasRotation)
|
||||
{
|
||||
auto screenManager = CreateOrGetScreenManager();
|
||||
auto mirrorNode = node.GetMirrorSource().lock();
|
||||
auto mainScreenInfo = screenManager->QueryScreenInfo(mirrorNode->GetScreenId());
|
||||
float mainWidth = static_cast<float>(mainScreenInfo.width);
|
||||
float mainHeight = static_cast<float>(mainScreenInfo.height);
|
||||
if (canvasRotation) {
|
||||
if ((RSSystemProperties::IsFoldScreenFlag() && mirrorNode->GetScreenId() == 0) ||
|
||||
mirrorNode->GetScreenRotation() == ScreenRotation::ROTATION_90 ||
|
||||
mirrorNode->GetScreenRotation() == ScreenRotation::ROTATION_270) {
|
||||
std::swap(mainWidth, mainHeight);
|
||||
}
|
||||
} else {
|
||||
if ((RSSystemProperties::IsFoldScreenFlag() && mirrorNode->GetScreenId() == 0) ||
|
||||
node.GetOriginScreenRotation() == ScreenRotation::ROTATION_90 ||
|
||||
node.GetOriginScreenRotation() == ScreenRotation::ROTATION_270) {
|
||||
std::swap(mainWidth, mainHeight);
|
||||
}
|
||||
if ((RSSystemProperties::IsFoldScreenFlag() && mirrorNode->GetScreenId() == 0 &&
|
||||
(mirrorNode->GetScreenRotation() == ScreenRotation::ROTATION_90 ||
|
||||
mirrorNode->GetScreenRotation() == ScreenRotation::ROTATION_270)) || mirrorAutoRotate_) {
|
||||
std::swap(mainWidth, mainHeight);
|
||||
}
|
||||
}
|
||||
float boundsWidth = node.GetRenderProperties().GetBoundsWidth();
|
||||
float boundsHeight = node.GetRenderProperties().GetBoundsHeight();
|
||||
// If the width and height not match the main screen, calculate the dstRect.
|
||||
if ((mainWidth != boundsWidth || mainHeight != boundsHeight) &&
|
||||
(mainWidth > 0 && mainHeight > 0)) {
|
||||
canvas_->Clear(SK_ColorBLACK);
|
||||
float mirrorScale = 1.0f; // 1 for init scale
|
||||
float startX = 0.0f;
|
||||
float startY = 0.0f;
|
||||
float mirrorScaleX = boundsWidth / mainWidth;
|
||||
float mirrorScaleY = boundsHeight / mainHeight;
|
||||
float ratio = 0.5f;
|
||||
if (mirrorScaleX < mirrorScaleY) {
|
||||
mirrorScale = mirrorScaleY;
|
||||
startX = (boundsWidth - (mirrorScale * mainWidth)) * ratio;
|
||||
} else {
|
||||
mirrorScale = mirrorScaleX;
|
||||
startY = (boundsHeight - (mirrorScale * mainHeight)) * ratio;
|
||||
}
|
||||
canvas_->Translate(startX, startY);
|
||||
canvas_->Scale(mirrorScale, mirrorScale);
|
||||
}
|
||||
}
|
||||
|
||||
void RSUniRenderVisitor::SetHasSharedTransitionNode(RSSurfaceRenderNode& surfaceNode, bool hasSharedTransitionNode)
|
||||
{
|
||||
// only allow change hasSharedTransitionNode in leash window's child
|
||||
|
@ -131,7 +131,10 @@ public:
|
||||
|
||||
void SetHardwareEnabledNodes(const std::vector<std::shared_ptr<RSSurfaceRenderNode>>& hardwareEnabledNodes);
|
||||
void AssignGlobalZOrderAndCreateLayer(std::vector<std::shared_ptr<RSSurfaceRenderNode>>& nodesInZOrder);
|
||||
void RotateMirrorCanvasIfNeed(RSDisplayRenderNode& node, bool canvasRotation = false);
|
||||
void ScaleMirrorIfNeed(RSDisplayRenderNode& node, bool canvasRotation = false);
|
||||
void RotateMirrorCanvasIfNeedForWiredScreen(RSDisplayRenderNode& node);
|
||||
void ScaleMirrorIfNeedForWiredScreen(RSDisplayRenderNode& node, bool canvasRotation = false);
|
||||
|
||||
bool GetIsPartialRenderEnabled() const
|
||||
{
|
||||
@ -260,7 +263,6 @@ private:
|
||||
void DrawChildRenderNode(RSRenderNode& node);
|
||||
void DrawChildCanvasRenderNode(RSRenderNode& node);
|
||||
|
||||
void RotateMirrorCanvasIfNeed(RSDisplayRenderNode& node, bool canvasRotation = false);
|
||||
void CheckColorSpace(RSSurfaceRenderNode& node);
|
||||
void HandleColorGamuts(RSDisplayRenderNode& node, const sptr<RSScreenManager>& screenManager);
|
||||
void CheckPixelFormat(RSSurfaceRenderNode& node);
|
||||
|
@ -22,6 +22,10 @@
|
||||
#include "transaction/rs_transaction_data.h"
|
||||
#include "rs_profiler.h"
|
||||
|
||||
#ifdef RES_SCHED_ENABLE
|
||||
#include "qos.h"
|
||||
#endif
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
namespace {
|
||||
constexpr int REQUEST_FRAME_AWARE_ID = 100001;
|
||||
@ -39,6 +43,12 @@ void RSUnmarshalThread::Start()
|
||||
{
|
||||
runner_ = AppExecFwk::EventRunner::Create("RSUnmarshalThread");
|
||||
handler_ = std::make_shared<AppExecFwk::EventHandler>(runner_);
|
||||
#ifdef RES_SCHED_ENABLE
|
||||
PostTask([this]() {
|
||||
auto ret = OHOS::QOS::SetThreadQos(OHOS::QOS::QosLevel::QOS_USER_INTERACTIVE);
|
||||
RS_LOGI("RSUnmarshalThread: SetThreadQos retcode = %{public}d", ret);
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
void RSUnmarshalThread::PostTask(const std::function<void()>& task)
|
||||
|
@ -539,7 +539,8 @@ void RSScreen::DisplayDump(int32_t screenIndex, std::string& dumpString)
|
||||
dumpString += "mirrorId=";
|
||||
dumpString += (mirrorId_ == INVALID_SCREEN_ID) ? "INVALID_SCREEN_ID" : std::to_string(mirrorId_);
|
||||
dumpString += ", ";
|
||||
AppendFormat(dumpString, ", render size: %dx%d, isvirtual=true\n", width_, height_);
|
||||
AppendFormat(dumpString, ", render size: %dx%d, isvirtual=true, skipFrameInterval_:%d\n",
|
||||
width_, height_, skipFrameInterval_);
|
||||
} else {
|
||||
dumpString += "screen[" + std::to_string(screenIndex) + "]: ";
|
||||
dumpString += "id=";
|
||||
@ -550,8 +551,9 @@ void RSScreen::DisplayDump(int32_t screenIndex, std::string& dumpString)
|
||||
dumpString += "backlight=" + std::to_string(GetScreenBacklight());
|
||||
dumpString += ", ";
|
||||
ScreenTypeDump(dumpString);
|
||||
AppendFormat(dumpString, ", render size: %dx%d, physical screen resolution: %dx%d, isvirtual=false\n",
|
||||
width_, height_, phyWidth_, phyHeight_);
|
||||
AppendFormat(dumpString,
|
||||
", render size: %dx%d, physical screen resolution: %dx%d, isvirtual=false, skipFrameInterval_:%d\n",
|
||||
width_, height_, phyWidth_, phyHeight_, skipFrameInterval_);
|
||||
dumpString += "\n";
|
||||
ModeInfoDump(dumpString);
|
||||
CapabilityDump(dumpString);
|
||||
|
@ -769,7 +769,7 @@ ScreenId RSScreenManager::CreateVirtualScreen(
|
||||
if (surface != nullptr) {
|
||||
uint64_t surfaceId = surface->GetUniqueId();
|
||||
for (auto &[_, screen] : screens_) {
|
||||
if (screen != nullptr && !screen->IsVirtual()) {
|
||||
if (screen == nullptr || !screen->IsVirtual()) {
|
||||
continue;
|
||||
}
|
||||
auto screenSurface = screen->GetProducerSurface();
|
||||
@ -1190,6 +1190,9 @@ void RSScreenManager::DisplayDump(std::string& dumpString)
|
||||
{
|
||||
int32_t index = 0;
|
||||
for (const auto &[id, screen] : screens_) {
|
||||
if (screen == nullptr) {
|
||||
return;
|
||||
}
|
||||
screen->DisplayDump(index, dumpString);
|
||||
index++;
|
||||
}
|
||||
|
@ -794,6 +794,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest(
|
||||
std::string name = data.ReadString();
|
||||
auto remoteObj = data.ReadRemoteObject();
|
||||
uint64_t id = data.ReadUint64();
|
||||
NodeId windowNodeID = data.ReadUint64();
|
||||
if (remoteObj == nullptr) {
|
||||
ret = ERR_NULL_OBJECT;
|
||||
break;
|
||||
@ -807,7 +808,7 @@ int RSRenderServiceConnectionStub::OnRemoteRequest(
|
||||
ret = ERR_UNKNOWN_OBJECT;
|
||||
break;
|
||||
}
|
||||
sptr<IVSyncConnection> conn = CreateVSyncConnection(name, token, id);
|
||||
sptr<IVSyncConnection> conn = CreateVSyncConnection(name, token, id, windowNodeID);
|
||||
if (conn == nullptr) {
|
||||
ret = ERR_NULL_OBJECT;
|
||||
break;
|
||||
|
@ -473,6 +473,13 @@ ohos_source_set("render_service_base_src") {
|
||||
sources += graphic_2d_ext_configs.librender_service_base_ext_sources
|
||||
}
|
||||
|
||||
if (defined(global_parts_info) &&
|
||||
defined(global_parts_info.resourceschedule_resource_schedule_service)) {
|
||||
external_deps += [ "resource_schedule_service:ressched_client" ]
|
||||
defines += [ "RES_BASE_SCHED_ENABLE" ]
|
||||
external_deps += [ "qos_manager:qos" ]
|
||||
}
|
||||
|
||||
part_name = "graphic_2d"
|
||||
subsystem_name = "graphic"
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ using FrameRateLinkerId = uint64_t;
|
||||
using SurfaceId = uint64_t;
|
||||
constexpr uint32_t UNI_MAIN_THREAD_INDEX = UINT32_MAX;
|
||||
constexpr uint64_t INVALID_NODEID = 0;
|
||||
constexpr int32_t INSTANCE_ID_UNDEFINED = -1;
|
||||
|
||||
// types in the same layer should be 0/1/2/4/8
|
||||
// types for UINode
|
||||
|
@ -47,78 +47,79 @@ enum class RSModifierType : int16_t {
|
||||
BACKGROUND_COLOR, // 20
|
||||
BACKGROUND_SHADER, // 21
|
||||
BG_IMAGE, // 22
|
||||
BG_IMAGE_WIDTH, // 23
|
||||
BG_IMAGE_HEIGHT, // 24
|
||||
BG_IMAGE_POSITION_X, // 25
|
||||
BG_IMAGE_POSITION_Y, // 26
|
||||
SURFACE_BG_COLOR, // 27
|
||||
BORDER_COLOR, // 28
|
||||
BORDER_WIDTH, // 29
|
||||
BORDER_STYLE, // 30
|
||||
FILTER, // 31
|
||||
BACKGROUND_FILTER, // 32
|
||||
LINEAR_GRADIENT_BLUR_PARA, // 33
|
||||
DYNAMIC_LIGHT_UP_RATE, // 34
|
||||
DYNAMIC_LIGHT_UP_DEGREE, // 35
|
||||
FRAME_GRAVITY, // 36
|
||||
CLIP_RRECT, // 37
|
||||
CLIP_BOUNDS, // 38
|
||||
CLIP_TO_BOUNDS, // 39
|
||||
CLIP_TO_FRAME, // 40
|
||||
VISIBLE, // 41
|
||||
SHADOW_COLOR, // 42
|
||||
SHADOW_OFFSET_X, // 43
|
||||
SHADOW_OFFSET_Y, // 44
|
||||
SHADOW_ALPHA, // 45
|
||||
SHADOW_ELEVATION, // 46
|
||||
SHADOW_RADIUS, // 47
|
||||
SHADOW_PATH, // 48
|
||||
SHADOW_MASK, // 49
|
||||
SHADOW_COLOR_STRATEGY, // 50
|
||||
MASK, // 51
|
||||
SPHERIZE, // 52
|
||||
LIGHT_UP_EFFECT, // 53
|
||||
PIXEL_STRETCH, // 54
|
||||
PIXEL_STRETCH_PERCENT, // 55
|
||||
USE_EFFECT, // 56
|
||||
COLOR_BLEND_MODE, // 57
|
||||
COLOR_BLEND_APPLY_TYPE, // 58
|
||||
SANDBOX, // 59
|
||||
GRAY_SCALE, // 60
|
||||
BRIGHTNESS, // 61
|
||||
CONTRAST, // 62
|
||||
SATURATE, // 63
|
||||
SEPIA, // 64
|
||||
INVERT, // 65
|
||||
AIINVERT, // 66
|
||||
SYSTEMBAREFFECT, // 67
|
||||
HUE_ROTATE, // 68
|
||||
COLOR_BLEND, // 69
|
||||
PARTICLE, // 70
|
||||
SHADOW_IS_FILLED, // 71
|
||||
OUTLINE_COLOR, // 72
|
||||
OUTLINE_WIDTH, // 73
|
||||
OUTLINE_STYLE, // 74
|
||||
OUTLINE_RADIUS, // 75
|
||||
USE_SHADOW_BATCHING, // 76
|
||||
GREY_COEF, // 77
|
||||
LIGHT_INTENSITY, // 78
|
||||
LIGHT_POSITION, // 79
|
||||
ILLUMINATED_BORDER_WIDTH, // 80
|
||||
ILLUMINATED_TYPE, // 81
|
||||
BLOOM, // 82
|
||||
DYNAMIC_DIM_DEGREE, // 83
|
||||
CUSTOM, // 84
|
||||
EXTENDED, // 85
|
||||
TRANSITION, // 86
|
||||
BACKGROUND_STYLE, // 87
|
||||
CONTENT_STYLE, // 88
|
||||
FOREGROUND_STYLE, // 89
|
||||
OVERLAY_STYLE, // 90
|
||||
NODE_MODIFIER, // 91
|
||||
ENV_FOREGROUND_COLOR, // 92
|
||||
ENV_FOREGROUND_COLOR_STRATEGY, // 93
|
||||
GEOMETRYTRANS, // 94
|
||||
BG_IMAGE_INNER_RECT, // 23
|
||||
BG_IMAGE_WIDTH, // 24
|
||||
BG_IMAGE_HEIGHT, // 25
|
||||
BG_IMAGE_POSITION_X, // 26
|
||||
BG_IMAGE_POSITION_Y, // 27
|
||||
SURFACE_BG_COLOR, // 28
|
||||
BORDER_COLOR, // 29
|
||||
BORDER_WIDTH, // 30
|
||||
BORDER_STYLE, // 31
|
||||
FILTER, // 32
|
||||
BACKGROUND_FILTER, // 33
|
||||
LINEAR_GRADIENT_BLUR_PARA, // 34
|
||||
DYNAMIC_LIGHT_UP_RATE, // 35
|
||||
DYNAMIC_LIGHT_UP_DEGREE, // 36
|
||||
FRAME_GRAVITY, // 37
|
||||
CLIP_RRECT, // 38
|
||||
CLIP_BOUNDS, // 39
|
||||
CLIP_TO_BOUNDS, // 40
|
||||
CLIP_TO_FRAME, // 41
|
||||
VISIBLE, // 42
|
||||
SHADOW_COLOR, // 43
|
||||
SHADOW_OFFSET_X, // 44
|
||||
SHADOW_OFFSET_Y, // 45
|
||||
SHADOW_ALPHA, // 46
|
||||
SHADOW_ELEVATION, // 47
|
||||
SHADOW_RADIUS, // 48
|
||||
SHADOW_PATH, // 49
|
||||
SHADOW_MASK, // 50
|
||||
SHADOW_COLOR_STRATEGY, // 51
|
||||
MASK, // 52
|
||||
SPHERIZE, // 53
|
||||
LIGHT_UP_EFFECT, // 54
|
||||
PIXEL_STRETCH, // 55
|
||||
PIXEL_STRETCH_PERCENT, // 56
|
||||
USE_EFFECT, // 57
|
||||
COLOR_BLEND_MODE, // 58
|
||||
COLOR_BLEND_APPLY_TYPE, // 59
|
||||
SANDBOX, // 60
|
||||
GRAY_SCALE, // 61
|
||||
BRIGHTNESS, // 62
|
||||
CONTRAST, // 63
|
||||
SATURATE, // 64
|
||||
SEPIA, // 65
|
||||
INVERT, // 66
|
||||
AIINVERT, // 67
|
||||
SYSTEMBAREFFECT, // 68
|
||||
HUE_ROTATE, // 69
|
||||
COLOR_BLEND, // 70
|
||||
PARTICLE, // 71
|
||||
SHADOW_IS_FILLED, // 72
|
||||
OUTLINE_COLOR, // 73
|
||||
OUTLINE_WIDTH, // 74
|
||||
OUTLINE_STYLE, // 75
|
||||
OUTLINE_RADIUS, // 76
|
||||
USE_SHADOW_BATCHING, // 77
|
||||
GREY_COEF, // 78
|
||||
LIGHT_INTENSITY, // 79
|
||||
LIGHT_POSITION, // 80
|
||||
ILLUMINATED_BORDER_WIDTH, // 81
|
||||
ILLUMINATED_TYPE, // 82
|
||||
BLOOM, // 83
|
||||
DYNAMIC_DIM_DEGREE, // 84
|
||||
CUSTOM, // 85
|
||||
EXTENDED, // 86
|
||||
TRANSITION, // 87
|
||||
BACKGROUND_STYLE, // 88
|
||||
CONTENT_STYLE, // 89
|
||||
FOREGROUND_STYLE, // 90
|
||||
OVERLAY_STYLE, // 91
|
||||
NODE_MODIFIER, // 92
|
||||
ENV_FOREGROUND_COLOR, // 93
|
||||
ENV_FOREGROUND_COLOR_STRATEGY, // 94
|
||||
GEOMETRYTRANS, // 95
|
||||
MAX_RS_MODIFIER_TYPE,
|
||||
};
|
||||
|
||||
|
@ -64,6 +64,8 @@ DECLARE_NOANIMATABLE_MODIFIER(BackgroundShader, std::shared_ptr<RSShader>, BACKG
|
||||
|
||||
DECLARE_NOANIMATABLE_MODIFIER(BgImage, std::shared_ptr<RSImage>, BG_IMAGE, Background)
|
||||
|
||||
DECLARE_ANIMATABLE_MODIFIER(BgImageInnerRect, Vector4f, BG_IMAGE_INNER_RECT, Add, Background, LAYOUT)
|
||||
|
||||
DECLARE_ANIMATABLE_MODIFIER(BgImageWidth, float, BG_IMAGE_WIDTH, Add, Background, LAYOUT)
|
||||
|
||||
DECLARE_ANIMATABLE_MODIFIER(BgImageHeight, float, BG_IMAGE_HEIGHT, Add, Background, LAYOUT)
|
||||
|
@ -129,11 +129,13 @@ public:
|
||||
return subSurfaceNodes_;
|
||||
}
|
||||
|
||||
bool IsFirstLevelSurfaceNode();
|
||||
bool IsFirstLevelNode();
|
||||
bool IsSubSurfaceNode();
|
||||
bool SubSurfaceNodeNeedDraw(PartialRenderType opDropType);
|
||||
void AddSubSurfaceNode(SharedPtr child, SharedPtr parent);
|
||||
void RemoveSubSurfaceNode(SharedPtr child, SharedPtr parent);
|
||||
inline static const bool isSubSurfaceEnabled_ = RSSystemProperties::GetSubSurfaceEnabled();
|
||||
void AddSubSurfaceNode(SharedPtr parent);
|
||||
void RemoveSubSurfaceNode(SharedPtr parent);
|
||||
inline static const bool isSubSurfaceEnabled_ =
|
||||
RSSystemProperties::GetSubSurfaceEnabled() && RSSystemProperties::IsPhoneType();
|
||||
|
||||
// flag: isOnTheTree; instanceRootNodeId: displaynode or leash/appnode attached to
|
||||
// firstLevelNodeId: surfacenode for uiFirst to assign task; cacheNodeId: drawing cache rootnode attached to
|
||||
|
@ -60,6 +60,7 @@ public:
|
||||
void TraverseCanvasDrawingNodes(std::function<void (const std::shared_ptr<RSCanvasDrawingRenderNode>&)> func) const;
|
||||
std::unordered_map<NodeId, std::shared_ptr<RSSurfaceRenderNode>> GetResidentSurfaceNodeMap() const;
|
||||
bool IsResidentProcessNode(NodeId id) const;
|
||||
void CalCulateAbilityComponentNumsInProcess(NodeId id);
|
||||
|
||||
NodeId GetEntryViewNodeId() const;
|
||||
NodeId GetWallPaperViewNodeId() const;
|
||||
@ -68,6 +69,7 @@ public:
|
||||
void ObtainLauncherNodeId(const std::shared_ptr<RSSurfaceRenderNode> surfaceNode);
|
||||
private:
|
||||
explicit RSRenderNodeMap();
|
||||
void EraseAbilityComponentNumsInProcess(NodeId id);
|
||||
~RSRenderNodeMap() = default;
|
||||
RSRenderNodeMap(const RSRenderNodeMap&) = delete;
|
||||
RSRenderNodeMap(const RSRenderNodeMap&&) = delete;
|
||||
@ -81,6 +83,7 @@ private:
|
||||
std::unordered_map<NodeId, std::shared_ptr<RSSurfaceRenderNode>> residentSurfaceNodeMap_;
|
||||
std::unordered_map<NodeId, std::shared_ptr<RSDisplayRenderNode>> displayNodeMap_;
|
||||
std::unordered_map<NodeId, std::shared_ptr<RSCanvasDrawingRenderNode>> canvasDrawingNodeMap_;
|
||||
std::unordered_map<pid_t, int> abilityComponentNumsInProcess_;
|
||||
|
||||
NodeId entryViewNodeId_ = 0;
|
||||
NodeId wallpaperViewNodeId_ = 0;
|
||||
|
@ -465,7 +465,7 @@ public:
|
||||
void SetVisibleRegionRecursive(
|
||||
const Occlusion::Region& region,
|
||||
VisibleData& visibleVec,
|
||||
std::map<uint32_t, RSVisibleLevel>& pidVisMap,
|
||||
std::map<NodeId, RSVisibleLevel>& pidVisMap,
|
||||
bool needSetVisibleRegion = true,
|
||||
RSVisibleLevel visibleLevel = RSVisibleLevel::RS_UNKNOW_VISIBLE_LEVEL,
|
||||
bool isSystemAnimatedScenes = false);
|
||||
|
@ -62,7 +62,8 @@ public:
|
||||
|
||||
virtual sptr<IVSyncConnection> CreateVSyncConnection(const std::string& name,
|
||||
const sptr<VSyncIConnectionToken>& token = nullptr,
|
||||
uint64_t id = 0) = 0;
|
||||
uint64_t id = 0,
|
||||
NodeId windowNodeId = 0) = 0;
|
||||
|
||||
virtual int32_t SetFocusAppInfo(
|
||||
int32_t pid, int32_t uid, const std::string &bundleName, const std::string &abilityName,
|
||||
|
@ -180,6 +180,8 @@ public:
|
||||
std::shared_ptr<RSShader> GetBackgroundShader() const;
|
||||
void SetBgImage(const std::shared_ptr<RSImage>& image);
|
||||
std::shared_ptr<RSImage> GetBgImage() const;
|
||||
void SetBgImageInnerRect(const Vector4f& rect);
|
||||
Vector4f GetBgImageInnerRect() const;
|
||||
void SetBgImageWidth(float width);
|
||||
void SetBgImageHeight(float height);
|
||||
void SetBgImagePositionX(float positionX);
|
||||
|
@ -120,6 +120,7 @@ public:
|
||||
std::shared_ptr<RSShader> bgShader_ = nullptr;
|
||||
std::shared_ptr<RSImage> bgImage_ = nullptr;
|
||||
RectF bgImageRect_ = RectF();
|
||||
Vector4f bgImageInnerRect_ = Vector4f();
|
||||
Color backgroundColor_ = RgbPalette::Transparent();
|
||||
Color foregroundColor_ = RgbPalette::Transparent();
|
||||
};
|
||||
|
@ -71,6 +71,7 @@ public:
|
||||
void SetImageRepeat(int repeatNum);
|
||||
void SetRadius(const std::vector<Drawing::Point>& radius);
|
||||
void SetScale(double scale);
|
||||
void SetInnerRect(const std::optional<Drawing::RectI>& innerRect) { innerRect_ = innerRect;}
|
||||
|
||||
void SetCompressData(const std::shared_ptr<Drawing::Data> data, uint32_t id, int width, int height);
|
||||
void SetCompressData(const std::shared_ptr<Drawing::Data> compressData);
|
||||
@ -109,6 +110,7 @@ private:
|
||||
ImageFit imageFit_ = ImageFit::COVER;
|
||||
ImageRepeat imageRepeat_ = ImageRepeat::NO_REPEAT;
|
||||
std::vector<Drawing::Point> radius_ = std::vector<Drawing::Point>(4);
|
||||
std::optional<Drawing::RectI> innerRect_ = std::nullopt;
|
||||
bool hasRadius_ = false;
|
||||
RectF frameRect_;
|
||||
double scale_ = 1.0;
|
||||
|
@ -118,7 +118,8 @@ public:
|
||||
std::shared_ptr<VSyncReceiver> CreateVSyncReceiver(
|
||||
const std::string& name,
|
||||
const std::shared_ptr<OHOS::AppExecFwk::EventHandler> &looper = nullptr,
|
||||
uint64_t id = 0);
|
||||
uint64_t id = 0,
|
||||
NodeId windowNodeId = 0);
|
||||
|
||||
bool TakeSurfaceCapture(
|
||||
NodeId id, std::shared_ptr<SurfaceCaptureCallback> callback, float scaleX, float scaleY,
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
: payload_(std::move(other.payload_)), timestamp_(std::move(other.timestamp_)),
|
||||
abilityName_(std::move(other.abilityName_)), pid_(other.pid_), index_(other.index_)
|
||||
{}
|
||||
~RSTransactionData() noexcept override;
|
||||
~RSTransactionData() override;
|
||||
|
||||
[[nodiscard]] static RSTransactionData* Unmarshalling(Parcel& parcel);
|
||||
bool Marshalling(Parcel& parcel) const override;
|
||||
|
@ -80,13 +80,15 @@ std::shared_ptr<RSInterpolator> RSInterpolator::Unmarshalling(Parcel& parcel)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (ret == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
if (ret == nullptr) { return nullptr; }
|
||||
|
||||
static std::mutex cachedInterpolatorsMutex_;
|
||||
static std::unordered_map<uint32_t, std::weak_ptr<RSInterpolator>> cachedInterpolators_;
|
||||
static const auto Destructor = [](RSInterpolator* ptr) {
|
||||
if (ptr == nullptr) {
|
||||
ROSEN_LOGE("RSInterpolator::Unmarshalling, sharePtr is nullptr.");
|
||||
return;
|
||||
}
|
||||
std::unique_lock<std::mutex> lock(cachedInterpolatorsMutex_);
|
||||
cachedInterpolators_.erase(ptr->id_); // Unregister interpolator from cache before destruction.
|
||||
delete ptr;
|
||||
|
@ -62,9 +62,8 @@ float RSRenderParticleEffector::UpdateCurveValue(
|
||||
#ifdef ENABLE_RUST
|
||||
value = generate_value(startValue, endValue, startTime, endTime, activeTime);
|
||||
#else
|
||||
float t = 0.f;
|
||||
if (endTime - startTime != 0) {
|
||||
t = static_cast<float>(activeTime - startTime) / static_cast<float>(endTime - startTime);
|
||||
float t = static_cast<float>(activeTime - startTime) / static_cast<float>(endTime - startTime);
|
||||
auto& interpolator = valChangeOverLife[i]->interpolator_;
|
||||
t = (interpolator != nullptr) ? interpolator->Interpolate(t) : t;
|
||||
value = startValue * (1.0f - t) + endValue * t;
|
||||
@ -88,10 +87,9 @@ Color RSRenderParticleEffector::UpdateColorCurveValue(
|
||||
continue;
|
||||
}
|
||||
Color startValue = valChangeOverLife[i]->fromValue_;
|
||||
float t = 0.f;
|
||||
if (endTime - startTime != 0) {
|
||||
Color endValue = valChangeOverLife[i]->toValue_;
|
||||
t = static_cast<float>(activeTime - startTime) / static_cast<float>(endTime - startTime);
|
||||
float t = static_cast<float>(activeTime - startTime) / static_cast<float>(endTime - startTime);
|
||||
auto& interpolator = valChangeOverLife[i]->interpolator_;
|
||||
t = (interpolator != nullptr) ? interpolator->Interpolate(t) : t;
|
||||
startValue *= (1.0f - t);
|
||||
|
@ -255,7 +255,8 @@ void RSRenderSpringAnimation::OnDetach()
|
||||
void RSRenderSpringAnimation::OnInitialize(int64_t time)
|
||||
{
|
||||
if (springValueEstimator_ == nullptr) {
|
||||
ROSEN_LOGE("RSRenderSpringAnimation::OnInitialize failed, springValueEstimator is null");
|
||||
ROSEN_LOGD("RSRenderSpringAnimation::OnInitialize failed, springValueEstimator is null");
|
||||
RSRenderPropertyAnimation::OnInitialize(time);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -160,6 +160,10 @@ void SurfaceNodeCommandHelper::SetSurfaceNodeType(RSContext& context, NodeId nod
|
||||
{
|
||||
auto type = static_cast<RSSurfaceNodeType>(surfaceNodeType);
|
||||
if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(nodeId)) {
|
||||
if (type == RSSurfaceNodeType::ABILITY_COMPONENT_NODE) {
|
||||
auto& nodeMap = context.GetMutableNodeMap();
|
||||
nodeMap.CalCulateAbilityComponentNumsInProcess(nodeId);
|
||||
}
|
||||
node->SetSurfaceNodeType(type);
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,10 @@
|
||||
#endif
|
||||
#include "rs_trace.h"
|
||||
|
||||
#ifdef RES_BASE_SCHED_ENABLE
|
||||
#include "qos.h"
|
||||
#endif
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
RSBackgroundThread& RSBackgroundThread::Instance()
|
||||
{
|
||||
@ -37,6 +41,12 @@ RSBackgroundThread::RSBackgroundThread()
|
||||
{
|
||||
runner_ = AppExecFwk::EventRunner::Create("RSBackgroundThread");
|
||||
handler_ = std::make_shared<AppExecFwk::EventHandler>(runner_);
|
||||
#ifdef RES_BASE_SCHED_ENABLE
|
||||
PostTask([this]() {
|
||||
auto ret = OHOS::QOS::SetThreadQos(OHOS::QOS::QosLevel::QOS_USER_INTERACTIVE);
|
||||
RS_LOGI("RSBackgroundThread: SetThreadQos retcode = %{public}d", ret);
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
void RSBackgroundThread::PostTask(const std::function<void()>& task)
|
||||
|
@ -20,29 +20,14 @@
|
||||
#include "render_context/render_context.h"
|
||||
#endif
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
#ifndef ROSEN_CROSS_PLATFORM
|
||||
namespace {
|
||||
constexpr int32_t SCHED_PRIORITY = 2;
|
||||
void SetThreadPriority()
|
||||
{
|
||||
struct sched_param param = {0};
|
||||
param.sched_priority = SCHED_PRIORITY;
|
||||
if (sched_setscheduler(0, SCHED_FIFO, ¶m) != 0) {
|
||||
RS_LOGE("RSOffscreenRender Couldn't set SCHED_FIFO.");
|
||||
} else {
|
||||
RS_LOGI("RSOffscreenRender set SCHED_FIFO succeed.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
#ifdef RES_BASE_SCHED_ENABLE
|
||||
#include "qos.h"
|
||||
#endif
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
|
||||
RSOffscreenRenderThread& RSOffscreenRenderThread::Instance()
|
||||
{
|
||||
#ifndef ROSEN_CROSS_PLATFORM
|
||||
SetThreadPriority();
|
||||
#endif
|
||||
static RSOffscreenRenderThread instance;
|
||||
return instance;
|
||||
}
|
||||
@ -66,6 +51,13 @@ RSOffscreenRenderThread::RSOffscreenRenderThread()
|
||||
renderContext_->SetUpGpuContext(nullptr);
|
||||
});
|
||||
#endif
|
||||
|
||||
#ifdef RES_BASE_SCHED_ENABLE
|
||||
PostTask([this]() {
|
||||
auto ret = OHOS::QOS::SetThreadQos(OHOS::QOS::QosLevel::QOS_USER_INTERACTIVE);
|
||||
RS_LOGI("RSOffscreenRenderThread: SetThreadQos retcode = %{public}d", ret);
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
void RSOffscreenRenderThread::PostTask(const std::function<void()>& task)
|
||||
|
@ -71,7 +71,6 @@ bool RSCanvasDrawingRenderNode::ResetSurfaceWithTexture(int width, int height, R
|
||||
return false;
|
||||
}
|
||||
|
||||
SKResourceManager::Instance().HoldResource(image);
|
||||
Drawing::BitmapFormat bitmapFormat = { image->GetColorType(), image->GetAlphaType() };
|
||||
auto sharedTexture = std::make_shared<Drawing::Image>();
|
||||
if (!sharedTexture->BuildFromTexture(*canvas.GetGPUContext(), sharedBackendTexture.GetTextureInfo(),
|
||||
|
@ -469,7 +469,7 @@ void RSRenderNode::SetParent(WeakPtr parent)
|
||||
UpdateSubSurfaceCnt(parent.lock(), parent_.lock());
|
||||
parent_ = parent;
|
||||
if (isSubSurfaceEnabled_) {
|
||||
AddSubSurfaceNode(shared_from_this(), parent.lock());
|
||||
AddSubSurfaceNode(parent.lock());
|
||||
}
|
||||
}
|
||||
|
||||
@ -480,7 +480,7 @@ void RSRenderNode::ResetParent()
|
||||
auto it = std::find_if(parentNode->disappearingChildren_.begin(), parentNode->disappearingChildren_.end(),
|
||||
[childPtr = shared_from_this()](const auto& pair) -> bool { return pair.first == childPtr; });
|
||||
if (it == parentNode->disappearingChildren_.end()) {
|
||||
RemoveSubSurfaceNode(shared_from_this(), parentNode);
|
||||
RemoveSubSurfaceNode(parentNode);
|
||||
}
|
||||
}
|
||||
parentNode->hasRemovedChild_ = true;
|
||||
@ -492,20 +492,16 @@ void RSRenderNode::ResetParent()
|
||||
OnResetParent();
|
||||
}
|
||||
|
||||
bool RSRenderNode::IsFirstLevelSurfaceNode()
|
||||
bool RSRenderNode::IsFirstLevelNode()
|
||||
{
|
||||
if (!this->IsInstanceOf<RSSurfaceRenderNode>()) {
|
||||
return false;
|
||||
}
|
||||
auto parentNode = parent_.lock();
|
||||
while (parentNode && !parentNode->IsInstanceOf<RSDisplayRenderNode>()) {
|
||||
auto node = RSBaseRenderNode::ReinterpretCast<RSSurfaceRenderNode>(parentNode);
|
||||
if (node != nullptr && (node->IsLeashOrMainWindow())) {
|
||||
return false;
|
||||
}
|
||||
parentNode = parentNode->GetParent().lock();
|
||||
}
|
||||
return true;
|
||||
return id_ == firstLevelNodeId_;
|
||||
}
|
||||
|
||||
bool RSRenderNode::IsSubSurfaceNode()
|
||||
{
|
||||
return IsInstanceOf<RSSurfaceRenderNode>() &&
|
||||
(RSBaseRenderNode::ReinterpretCast<RSSurfaceRenderNode>(shared_from_this())->IsMainWindowType() ||
|
||||
RSBaseRenderNode::ReinterpretCast<RSSurfaceRenderNode>(shared_from_this())->IsLeashWindow());
|
||||
}
|
||||
|
||||
bool RSRenderNode::SubSurfaceNodeNeedDraw(PartialRenderType opDropType)
|
||||
@ -523,26 +519,24 @@ bool RSRenderNode::SubSurfaceNodeNeedDraw(PartialRenderType opDropType)
|
||||
return false;
|
||||
}
|
||||
|
||||
void RSRenderNode::AddSubSurfaceNode(SharedPtr child, SharedPtr parent)
|
||||
void RSRenderNode::AddSubSurfaceNode(SharedPtr parent)
|
||||
{
|
||||
if (parent->subSurfaceNodes_.find(child->GetId()) != parent->subSurfaceNodes_.end()) {
|
||||
if (parent && parent->subSurfaceNodes_.find(GetId()) != parent->subSurfaceNodes_.end()) {
|
||||
return;
|
||||
}
|
||||
std::vector<WeakPtr> subSurfaceNodes;
|
||||
if (child->IsInstanceOf<RSSurfaceRenderNode>() &&
|
||||
(RSBaseRenderNode::ReinterpretCast<RSSurfaceRenderNode>(child)->IsMainWindowType() ||
|
||||
RSBaseRenderNode::ReinterpretCast<RSSurfaceRenderNode>(child)->IsLeashWindow())) {
|
||||
subSurfaceNodes.push_back(child);
|
||||
if (IsSubSurfaceNode()) {
|
||||
subSurfaceNodes.push_back(weak_from_this());
|
||||
} else {
|
||||
for (auto &nodes : child->subSurfaceNodes_) {
|
||||
subSurfaceNodes.insert(subSurfaceNodes.end(), nodes.second.begin(), nodes.second.end());
|
||||
for (auto &node : subSurfaceNodes_) {
|
||||
subSurfaceNodes.insert(subSurfaceNodes.end(), node.second.begin(), node.second.end());
|
||||
}
|
||||
}
|
||||
if (subSurfaceNodes.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto childNode = child;
|
||||
auto childNode = shared_from_this();
|
||||
auto parentNode = parent;
|
||||
while (parentNode && !parentNode->IsInstanceOf<RSDisplayRenderNode>()) {
|
||||
auto id = childNode->GetId();
|
||||
@ -558,7 +552,7 @@ void RSRenderNode::AddSubSurfaceNode(SharedPtr child, SharedPtr parent)
|
||||
first.lock()->GetRenderProperties().GetPositionZ() <
|
||||
second.lock()->GetRenderProperties().GetPositionZ();
|
||||
});
|
||||
if (parentNode->IsInstanceOf<RSSurfaceRenderNode>()) {
|
||||
if (parentNode->IsSubSurfaceNode()) {
|
||||
break;
|
||||
}
|
||||
childNode = parentNode;
|
||||
@ -566,34 +560,38 @@ void RSRenderNode::AddSubSurfaceNode(SharedPtr child, SharedPtr parent)
|
||||
}
|
||||
}
|
||||
|
||||
void RSRenderNode::RemoveSubSurfaceNode(SharedPtr child, SharedPtr parent)
|
||||
void RSRenderNode::RemoveSubSurfaceNode(SharedPtr parent)
|
||||
{
|
||||
if (parent->subSurfaceNodes_.find(child->GetId()) == parent->subSurfaceNodes_.end()) {
|
||||
if (parent && parent->subSurfaceNodes_.find(GetId()) == parent->subSurfaceNodes_.end()) {
|
||||
return;
|
||||
}
|
||||
auto subSurfaceNodes = parent->subSurfaceNodes_[child->GetId()];
|
||||
parent->subSurfaceNodes_.erase(child->GetId());
|
||||
auto childNode = parent;
|
||||
auto parentNode = parent->GetParent().lock();
|
||||
auto subSurfaceNodes = parent->subSurfaceNodes_[GetId()];
|
||||
parent->subSurfaceNodes_.erase(GetId());
|
||||
SharedPtr childNode;
|
||||
SharedPtr parentNode = parent;
|
||||
while (parentNode && !parentNode->IsInstanceOf<RSDisplayRenderNode>()) {
|
||||
auto id = childNode->GetId();
|
||||
for (auto iter : subSurfaceNodes) {
|
||||
parentNode->subSurfaceNodes_[id].erase(
|
||||
remove_if(parentNode->subSurfaceNodes_[id].begin(), parentNode->subSurfaceNodes_[id].end(),
|
||||
[iter](WeakPtr it) {
|
||||
return iter.lock() && it.lock() && iter.lock()->GetId() == it.lock()->GetId();
|
||||
}),
|
||||
parentNode->subSurfaceNodes_[id].end()
|
||||
);
|
||||
}
|
||||
if (parentNode->subSurfaceNodes_[id].size() == 0) {
|
||||
parentNode->subSurfaceNodes_.erase(id);
|
||||
}
|
||||
if (parentNode->IsInstanceOf<RSSurfaceRenderNode>()) {
|
||||
if (parentNode->IsSubSurfaceNode()) {
|
||||
break;
|
||||
}
|
||||
childNode = parentNode;
|
||||
parentNode = parentNode->GetParent().lock();
|
||||
if (!parentNode) {
|
||||
break;
|
||||
}
|
||||
auto id = childNode->GetId();
|
||||
// If sizes are equal means that parentNode having no other subSurface nodes.
|
||||
if (parentNode->subSurfaceNodes_[id].size() == subSurfaceNodes.size()) {
|
||||
parentNode->subSurfaceNodes_.erase(id);
|
||||
}
|
||||
for (auto &node : subSurfaceNodes) {
|
||||
parentNode->subSurfaceNodes_[id].erase(
|
||||
remove_if(parentNode->subSurfaceNodes_[id].begin(), parentNode->subSurfaceNodes_[id].end(),
|
||||
[node](WeakPtr iter) {
|
||||
return node.lock() && iter.lock() && node.lock()->GetId() == iter.lock()->GetId();
|
||||
}),
|
||||
parentNode->subSurfaceNodes_[id].end()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1566,8 +1564,8 @@ void RSRenderNode::InitCacheSurface(Drawing::GPUContext* gpuContext, ClearCacheS
|
||||
height = boundsHeight_;
|
||||
}
|
||||
#else
|
||||
width = boundsWidth_;
|
||||
height = boundsHeight_;
|
||||
width = std::ceil(boundsWidth_);
|
||||
height = std::ceil(boundsHeight_);
|
||||
#endif
|
||||
}
|
||||
#if (defined (RS_ENABLE_GL) || defined (RS_ENABLE_VK)) && (defined RS_ENABLE_EGLIMAGE)
|
||||
@ -1787,7 +1785,6 @@ std::shared_ptr<Drawing::Image> RSRenderNode::GetCompletedImage(
|
||||
RS_LOGE("get backendTexture failed");
|
||||
return nullptr;
|
||||
}
|
||||
SKResourceManager::Instance().HoldResource(completeImage);
|
||||
auto cacheImage = std::make_shared<Drawing::Image>();
|
||||
Drawing::BitmapFormat info =
|
||||
Drawing::BitmapFormat{ completeImage->GetColorType(), completeImage->GetAlphaType() };
|
||||
|
@ -28,6 +28,7 @@ constexpr const char* ENTRY_VIEW = "SCBDesktop";
|
||||
constexpr const char* WALLPAPER_VIEW = "SCBWallpaper";
|
||||
constexpr const char* SCREENLOCK_WINDOW = "SCBScreenLock";
|
||||
constexpr const char* SYSUI_DROPDOWN = "SCBDropdownPanel";
|
||||
constexpr const int ABILITY_COMPONENT_LIMIT = 100;
|
||||
};
|
||||
RSRenderNodeMap::RSRenderNodeMap()
|
||||
{
|
||||
@ -86,6 +87,16 @@ static bool IsResidentProcess(const std::shared_ptr<RSSurfaceRenderNode> surface
|
||||
surfaceNode->GetName().find(WALLPAPER_VIEW) != std::string::npos;
|
||||
}
|
||||
|
||||
void RSRenderNodeMap::CalCulateAbilityComponentNumsInProcess(NodeId id)
|
||||
{
|
||||
if (abilityComponentNumsInProcess_[ExtractPid(id)] > ABILITY_COMPONENT_LIMIT) {
|
||||
renderNodeMap_.erase(id);
|
||||
surfaceNodeMap_.erase(id);
|
||||
return;
|
||||
}
|
||||
abilityComponentNumsInProcess_[ExtractPid(id)]++;
|
||||
}
|
||||
|
||||
bool RSRenderNodeMap::IsResidentProcessNode(NodeId id) const
|
||||
{
|
||||
auto nodePid = ExtractPid(id);
|
||||
@ -128,8 +139,26 @@ bool RSRenderNodeMap::RegisterDisplayRenderNode(const std::shared_ptr<RSDisplayR
|
||||
return true;
|
||||
}
|
||||
|
||||
void RSRenderNodeMap::EraseAbilityComponentNumsInProcess(NodeId id)
|
||||
{
|
||||
auto surfaceNodeIter = surfaceNodeMap_.find(id);
|
||||
if (surfaceNodeIter != surfaceNodeMap_.end()) {
|
||||
auto surfaceNode = GetRenderNode<RSSurfaceRenderNode>(id);
|
||||
if (surfaceNode->IsAbilityComponent()) {
|
||||
auto pid = ExtractPid(id);
|
||||
auto iter = abilityComponentNumsInProcess_.find(pid);
|
||||
if (iter != abilityComponentNumsInProcess_.end()) {
|
||||
if (--abilityComponentNumsInProcess_[pid] == 0) {
|
||||
abilityComponentNumsInProcess_.erase(pid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RSRenderNodeMap::UnregisterRenderNode(NodeId id)
|
||||
{
|
||||
EraseAbilityComponentNumsInProcess(id);
|
||||
renderNodeMap_.erase(id);
|
||||
surfaceNodeMap_.erase(id);
|
||||
drivenRenderNodeMap_.erase(id);
|
||||
@ -192,6 +221,10 @@ void RSRenderNodeMap::FilterNodeByPid(pid_t pid)
|
||||
return ExtractPid(pair.first) == pid;
|
||||
});
|
||||
|
||||
EraseIf(abilityComponentNumsInProcess_, [pid](const auto& pair) -> bool {
|
||||
return pair.first == pid;
|
||||
});
|
||||
|
||||
EraseIf(displayNodeMap_, [pid](const auto& pair) -> bool {
|
||||
if (ExtractPid(pair.first) != pid && pair.second) {
|
||||
ROSEN_LOGD("RSRenderNodeMap::FilterNodeByPid removing all nodes belong to pid %{public}llu",
|
||||
|
@ -941,7 +941,7 @@ bool RSSurfaceRenderNode::IsNeedSetVSync()
|
||||
|
||||
void RSSurfaceRenderNode::SetVisibleRegionRecursive(const Occlusion::Region& region,
|
||||
VisibleData& visibleVec,
|
||||
std::map<uint32_t, RSVisibleLevel>& pidVisMap,
|
||||
std::map<NodeId, RSVisibleLevel>& visMapForVsyncRate,
|
||||
bool needSetVisibleRegion,
|
||||
RSVisibleLevel visibleLevel,
|
||||
bool isSystemAnimatedScenes)
|
||||
@ -959,8 +959,7 @@ void RSSurfaceRenderNode::SetVisibleRegionRecursive(const Occlusion::Region& reg
|
||||
|
||||
// collect visible changed pid
|
||||
if (qosPidCal_ && GetType() == RSRenderNodeType::SURFACE_NODE && !isSystemAnimatedScenes) {
|
||||
uint32_t tmpPid = ExtractPid(GetId());
|
||||
pidVisMap[tmpPid] = !IsNeedSetVSync() ? RSVisibleLevel::RS_ALL_VISIBLE : visibleLevel;
|
||||
visMapForVsyncRate[GetId()] = !IsNeedSetVSync() ? RSVisibleLevel::RS_ALL_VISIBLE : visibleLevel;
|
||||
}
|
||||
|
||||
visibleRegionForCallBack_ = region;
|
||||
@ -973,7 +972,7 @@ void RSSurfaceRenderNode::SetVisibleRegionRecursive(const Occlusion::Region& reg
|
||||
|
||||
for (auto& child : *GetChildren()) {
|
||||
if (auto surfaceChild = RSBaseRenderNode::ReinterpretCast<RSSurfaceRenderNode>(child)) {
|
||||
surfaceChild->SetVisibleRegionRecursive(region, visibleVec, pidVisMap, needSetVisibleRegion,
|
||||
surfaceChild->SetVisibleRegionRecursive(region, visibleVec, visMapForVsyncRate, needSetVisibleRegion,
|
||||
visibleLevel, isSystemAnimatedScenes);
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +104,8 @@ public:
|
||||
std::shared_ptr<VSyncReceiver> RSRenderServiceClient::CreateVSyncReceiver(
|
||||
const std::string& name,
|
||||
const std::shared_ptr<OHOS::AppExecFwk::EventHandler> &looper,
|
||||
uint64_t id)
|
||||
uint64_t id,
|
||||
NodeId windowNodeId)
|
||||
{
|
||||
return std::make_shared<VSyncReceiverDarwin>();
|
||||
}
|
||||
|
@ -175,6 +175,7 @@ ohos_source_set("rosen_ohos_sources") {
|
||||
|
||||
if (accessibility_enable) {
|
||||
external_deps += [ "accessibility:accessibilityconfig" ]
|
||||
external_deps += [ "accessibility:accessibility_common" ]
|
||||
defines += accessibility_defines
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ void RSJankStats::SetRSJankStats()
|
||||
return;
|
||||
}
|
||||
if (missedVsync >= VSYNC_JANK_LOG_THRESHOLED) {
|
||||
ROSEN_LOGI("RSJankStats::SetJankStats jank frames %{public}lld", missedVsync);
|
||||
ROSEN_LOGI("RSJankStats::SetJankStats jank frames %{public} " PRId64 "", missedVsync);
|
||||
}
|
||||
size_t type = JANK_FRAME_INVALID;
|
||||
if (missedVsync < 6) { // JANK_FRAME_6_FREQ : (0,6)
|
||||
|
@ -154,7 +154,8 @@ std::shared_ptr<RSSurface> RSRenderServiceClient::CreateRSSurface(const sptr<Sur
|
||||
std::shared_ptr<VSyncReceiver> RSRenderServiceClient::CreateVSyncReceiver(
|
||||
const std::string& name,
|
||||
const std::shared_ptr<OHOS::AppExecFwk::EventHandler> &looper,
|
||||
uint64_t id)
|
||||
uint64_t id,
|
||||
NodeId windowNodeId)
|
||||
{
|
||||
ROSEN_LOGD("RSRenderServiceClient::CreateVSyncReceiver Start");
|
||||
auto renderService = RSRenderServiceConnectHub::GetRenderService();
|
||||
@ -162,7 +163,7 @@ std::shared_ptr<VSyncReceiver> RSRenderServiceClient::CreateVSyncReceiver(
|
||||
return nullptr;
|
||||
}
|
||||
sptr<VSyncIConnectionToken> token = new IRemoteStub<VSyncIConnectionToken>();
|
||||
sptr<IVSyncConnection> conn = renderService->CreateVSyncConnection(name, token, id);
|
||||
sptr<IVSyncConnection> conn = renderService->CreateVSyncConnection(name, token, id, windowNodeId);
|
||||
if (conn == nullptr) {
|
||||
ROSEN_LOGE("RSRenderServiceClient::CreateVSyncReceiver Failed");
|
||||
return nullptr;
|
||||
|
@ -211,7 +211,8 @@ sptr<Surface> RSRenderServiceConnectionProxy::CreateNodeAndSurface(const RSSurfa
|
||||
|
||||
sptr<IVSyncConnection> RSRenderServiceConnectionProxy::CreateVSyncConnection(const std::string& name,
|
||||
const sptr<VSyncIConnectionToken>& token,
|
||||
uint64_t id)
|
||||
uint64_t id,
|
||||
NodeId windowNodeId)
|
||||
{
|
||||
if (token == nullptr) {
|
||||
ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateVSyncConnection: token is nullptr.");
|
||||
@ -224,6 +225,7 @@ sptr<IVSyncConnection> RSRenderServiceConnectionProxy::CreateVSyncConnection(con
|
||||
data.WriteString(name);
|
||||
data.WriteRemoteObject(token->AsObject());
|
||||
data.WriteUint64(id);
|
||||
data.WriteUint64(windowNodeId);
|
||||
option.SetFlags(MessageOption::TF_SYNC);
|
||||
uint32_t code = static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::CREATE_VSYNC_CONNECTION);
|
||||
int32_t err = Remote()->SendRequest(code, data, reply, option);
|
||||
|
@ -44,7 +44,8 @@ public:
|
||||
|
||||
virtual sptr<IVSyncConnection> CreateVSyncConnection(const std::string& name,
|
||||
const sptr<VSyncIConnectionToken>& token,
|
||||
uint64_t id = 0) override;
|
||||
uint64_t id = 0,
|
||||
NodeId windowNodeId = 0) override;
|
||||
|
||||
int32_t SetFocusAppInfo(
|
||||
int32_t pid, int32_t uid, const std::string &bundleName, const std::string &abilityName,
|
||||
|
@ -756,7 +756,7 @@ bool RSSystemProperties::GetViewOcclusionCullingEnabled()
|
||||
bool RSSystemProperties::GetSubSurfaceEnabled()
|
||||
{
|
||||
static bool subSurfaceEnabled =
|
||||
std::atoi((system::GetParameter("persist.sys.graphic.subSurface", "0")).c_str());
|
||||
std::atoi((system::GetParameter("persist.sys.graphic.subSurface", "1")).c_str());
|
||||
return subSurfaceEnabled;
|
||||
}
|
||||
bool RSSystemProperties::GetSecurityPermissionCheckEnabled()
|
||||
|
@ -104,7 +104,8 @@ public:
|
||||
std::shared_ptr<VSyncReceiver> RSRenderServiceClient::CreateVSyncReceiver(
|
||||
const std::string& name,
|
||||
const std::shared_ptr<OHOS::AppExecFwk::EventHandler> &looper,
|
||||
uint64_t id)
|
||||
uint64_t id,
|
||||
NodeId windowNodeId)
|
||||
{
|
||||
return std::make_shared<VSyncReceiverWindows>();
|
||||
}
|
||||
|
@ -76,6 +76,7 @@ const std::array<ResetPropertyFunc, static_cast<int>(RSModifierType::CUSTOM)> g_
|
||||
[](RSProperties* prop) { prop->SetBackgroundColor({}); }, // BACKGROUND_COLOR
|
||||
[](RSProperties* prop) { prop->SetBackgroundShader({}); }, // BACKGROUND_SHADER
|
||||
[](RSProperties* prop) { prop->SetBgImage({}); }, // BG_IMAGE
|
||||
[](RSProperties* prop) { prop->SetBgImageInnerRect({}); }, // Bg_Image_Inner_Rect
|
||||
[](RSProperties* prop) { prop->SetBgImageWidth(0.f); }, // BG_IMAGE_WIDTH
|
||||
[](RSProperties* prop) { prop->SetBgImageHeight(0.f); }, // BG_IMAGE_HEIGHT
|
||||
[](RSProperties* prop) { prop->SetBgImagePositionX(0.f); }, // BG_IMAGE_POSITION_X
|
||||
@ -843,6 +844,21 @@ std::shared_ptr<RSImage> RSProperties::GetBgImage() const
|
||||
return decoration_ ? decoration_->bgImage_ : nullptr;
|
||||
}
|
||||
|
||||
void RSProperties::SetBgImageInnerRect(const Vector4f& rect)
|
||||
{
|
||||
if (!decoration_) {
|
||||
decoration_ = std::make_optional<Decoration>();
|
||||
}
|
||||
decoration_->bgImageInnerRect_ = rect;
|
||||
SetDirty();
|
||||
contentDirty_ = true;
|
||||
}
|
||||
|
||||
Vector4f RSProperties::GetBgImageInnerRect() const
|
||||
{
|
||||
return decoration_ ? decoration_->bgImageInnerRect_ : Vector4f();
|
||||
}
|
||||
|
||||
void RSProperties::SetBgImageWidth(float width)
|
||||
{
|
||||
if (!decoration_) {
|
||||
|
@ -880,14 +880,18 @@ void RSBackgroundDrawable::Draw(const RSRenderContent& content, RSPaintFilterCan
|
||||
brush.SetAntiAlias(antiAlias);
|
||||
canvas.AttachBrush(brush);
|
||||
// use drawrrect to avoid texture update in phone screen rotation scene
|
||||
if (RSSystemProperties::IsPhoneType()) {
|
||||
if (RSSystemProperties::IsPhoneType() && RSSystemProperties::GetCacheEnabledForRotation()) {
|
||||
if (borderColorAlpha < BORDER_TRANSPARENT) {
|
||||
canvas.DrawRoundRect(RSPropertiesPainter::RRect2DrawingRRect(properties.GetRRect()));
|
||||
} else {
|
||||
canvas.DrawRoundRect(RSPropertiesPainter::RRect2DrawingRRect(properties.GetInnerRRect()));
|
||||
}
|
||||
} else {
|
||||
canvas.DrawRect(RSPropertiesPainter::Rect2DrawingRect(properties.GetBoundsRect()));
|
||||
if (borderColorAlpha < BORDER_TRANSPARENT) {
|
||||
canvas.DrawRect(RSPropertiesPainter::Rect2DrawingRect(properties.GetBoundsRect()));
|
||||
} else {
|
||||
canvas.DrawRect(RSPropertiesPainter::RRect2DrawingRRect(properties.GetInnerRRect()).GetRect());
|
||||
}
|
||||
}
|
||||
canvas.DetachBrush();
|
||||
}
|
||||
@ -963,7 +967,10 @@ void RSBackgroundImageDrawable::Draw(const RSRenderContent& content, RSPaintFilt
|
||||
const auto& image = properties.GetBgImage();
|
||||
|
||||
auto boundsRect = RSPropertiesPainter::Rect2DrawingRect(properties.GetBoundsRect());
|
||||
auto innerRect = properties.GetBgImageInnerRect();
|
||||
canvas.AttachBrush(brush_);
|
||||
image->SetInnerRect(std::make_optional<Drawing::RectI>(
|
||||
innerRect.x_, innerRect.y_, innerRect.x_ + innerRect.z_, innerRect.y_ + innerRect.w_));
|
||||
image->CanvasDrawImage(canvas, boundsRect, Drawing::SamplingOptions(), true);
|
||||
canvas.DetachBrush();
|
||||
}
|
||||
|
@ -72,8 +72,12 @@ void RSImage::CanvasDrawImage(Drawing::Canvas& canvas, const Drawing::Rect& rect
|
||||
if (!isBackground) {
|
||||
ApplyCanvasClip(canvas);
|
||||
}
|
||||
canvas.DrawImageRect(*image_, src_, dst_, samplingOptions,
|
||||
Drawing::SrcRectConstraint::FAST_SRC_RECT_CONSTRAINT);
|
||||
if (innerRect_.has_value()) {
|
||||
canvas.DrawImageNine(image_.get(), innerRect_.value(), dst_, Drawing::FilterMode::LINEAR);
|
||||
} else {
|
||||
canvas.DrawImageRect(*image_, src_, dst_, samplingOptions,
|
||||
Drawing::SrcRectConstraint::FAST_SRC_RECT_CONSTRAINT);
|
||||
}
|
||||
}
|
||||
if (pixelMap_ != nullptr && pixelMap_->IsAstc()) {
|
||||
canvas.Restore();
|
||||
@ -282,8 +286,12 @@ void RSImage::DrawImageRepeatRect(const Drawing::SamplingOptions& samplingOption
|
||||
// In case of perspective transformation, make dstRect 1px outset to anti-alias
|
||||
dst_.MakeOutset(1, 1);
|
||||
}
|
||||
canvas.DrawImageRect(*image_, src_, dst_, samplingOptions,
|
||||
Drawing::SrcRectConstraint::FAST_SRC_RECT_CONSTRAINT);
|
||||
if (innerRect_.has_value()) {
|
||||
canvas.DrawImageNine(image_.get(), innerRect_.value(), dst_, Drawing::FilterMode::LINEAR);
|
||||
} else {
|
||||
canvas.DrawImageRect(*image_, src_, dst_, samplingOptions,
|
||||
Drawing::SrcRectConstraint::FAST_SRC_RECT_CONSTRAINT);
|
||||
}
|
||||
}
|
||||
if (isAstc) {
|
||||
canvas.Restore();
|
||||
|
@ -191,7 +191,8 @@ void RSPixelMapUtil::DrawPixelMap(Drawing::Canvas& canvas, Media::PixelMap& pixe
|
||||
ColorSpaceToDrawingColorSpace(pixelMap.InnerGetGrColorSpace().GetColorSpaceName()) };
|
||||
Drawing::Bitmap pixelBitmap;
|
||||
pixelBitmap.InstallPixels(
|
||||
drawingImageInfo, (void*)pixelMap.GetWritablePixels(), static_cast<uint32_t>(pixelMap.GetRowBytes()));
|
||||
drawingImageInfo, reinterpret_cast<void*>(pixelMap.GetWritablePixels()),
|
||||
static_cast<uint32_t>(pixelMap.GetRowBytes()));
|
||||
canvas.DrawBitmap(pixelBitmap, px, py);
|
||||
}
|
||||
} // namespace Rosen
|
||||
|
@ -184,6 +184,7 @@ template("render_service_client_source_set") {
|
||||
|
||||
if (accessibility_enable) {
|
||||
external_deps += [ "accessibility:accessibilityconfig" ]
|
||||
external_deps += [ "accessibility:accessibility_common" ]
|
||||
defines += accessibility_defines
|
||||
}
|
||||
} else if (rosen_preview) {
|
||||
|
@ -15,22 +15,22 @@
|
||||
|
||||
#include "animation/rs_symbol_animation.h"
|
||||
#include "animation/rs_keyframe_animation.h"
|
||||
#include "platform/common/rs_log.h"
|
||||
#include "draw/paint.h"
|
||||
#include "platform/common/rs_log.h"
|
||||
#include "utils/point.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
static const Vector2f CENTER_NODE_COORDINATE = {0.5f, 0.5f}; // scale center node
|
||||
static const unsigned int UNIT_GROUP = 0; // AnimationSubType is UNIT
|
||||
static const unsigned int UNIT_PERIOD = 0; // AnimationSubType is UNIT
|
||||
static const unsigned int UNIT_NODE = 0; // AnimationSubType is UNIT
|
||||
static const Vector2f CENTER_NODE_COORDINATE = { 0.5f, 0.5f }; // scale center node
|
||||
static const unsigned int UNIT_GROUP = 0; // AnimationSubType is UNIT
|
||||
static const unsigned int UNIT_PERIOD = 0; // AnimationSubType is UNIT
|
||||
static const unsigned int UNIT_NODE = 0; // AnimationSubType is UNIT
|
||||
static const std::string SCALE_PROP_X = "sx";
|
||||
static const std::string SCALE_PROP_Y = "sy";
|
||||
static const std::string ALPHA_PROP = "alpha";
|
||||
static const unsigned int PROPERTIES = 2; // symbol animation property contains two values, change from one to the other
|
||||
static const unsigned int PROP_START = 0; // symbol animation property contains two values, change from START to the END
|
||||
static const unsigned int PROP_END = 1; // symbol animation property contains two values, change from START to the END
|
||||
static const unsigned int PROP_END = 1; // symbol animation property contains two values, change from START to the END
|
||||
static const unsigned int WIDTH = 2;
|
||||
static const unsigned int HEIGHT = 3;
|
||||
|
||||
@ -39,6 +39,52 @@ bool IsEqual(const Vector2f& val1, const Vector2f& val2)
|
||||
return (val1.x_ == val2.x_ && val1.y_ == val2.y_);
|
||||
}
|
||||
|
||||
void CreateAnimationTimingCurve(OHOS::Rosen::Drawing::DrawingCurveType type, std::map<std::string, double>& curveArgs,
|
||||
RSAnimationTimingCurve& curve)
|
||||
{
|
||||
curve = RSAnimationTimingCurve();
|
||||
if (type == OHOS::Rosen::Drawing::DrawingCurveType::LINEAR) {
|
||||
curve = RSAnimationTimingCurve::LINEAR;
|
||||
} else if (type == OHOS::Rosen::Drawing::DrawingCurveType::SPRING) {
|
||||
double scaleVelocity = curveArgs.count("velocity") > 0 ? curveArgs["velocity"] : 0;
|
||||
double scaleMass = curveArgs.count("mass") > 0 ? curveArgs["mass"] : 0;
|
||||
double scaleStiffness = curveArgs.count("stiffness") > 0 ? curveArgs["stiffness"] : 0;
|
||||
double scaleDamping = curveArgs.count("damping") > 0 ? curveArgs["damping"] : 0;
|
||||
curve = RSAnimationTimingCurve::CreateInterpolatingSpring(static_cast<float>(scaleMass),
|
||||
static_cast<float>(scaleStiffness), static_cast<float>(scaleDamping), static_cast<float>(scaleVelocity));
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool GetAnimationGroupParameters(const std::shared_ptr<TextEngine::SymbolAnimationConfig>& symbolAnimationConfig,
|
||||
std::shared_ptr<std::vector<std::vector<Drawing::DrawingPiecewiseParameter>>>& parameters)
|
||||
{
|
||||
// count animation levels
|
||||
int animationLevelNum = -1;
|
||||
auto nodeNum = symbolAnimationConfig->numNodes;
|
||||
for (uint32_t n = 0; n < nodeNum; n++) {
|
||||
auto& symbolNode = symbolAnimationConfig->SymbolNodes[n];
|
||||
animationLevelNum =
|
||||
animationLevelNum < symbolNode.animationIndex ? symbolNode.animationIndex : animationLevelNum;
|
||||
}
|
||||
|
||||
if (animationLevelNum < 0) {
|
||||
return false;
|
||||
}
|
||||
animationLevelNum = animationLevelNum + 1;
|
||||
// unit animation : 1, multiple animation : 0
|
||||
int animationMode = animationLevelNum > 1 ? 0 : 1;
|
||||
// get animation group paramaters
|
||||
parameters = Drawing::HmSymbolConfigOhos::GetGroupParameters(
|
||||
Drawing::DrawingAnimationType(symbolAnimationConfig->effectStrategy), uint16_t(animationLevelNum),
|
||||
uint16_t(animationMode));
|
||||
if (parameters == nullptr) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool CreateOrSetModifierValue(std::shared_ptr<RSAnimatableProperty<T>>& property, const T& value)
|
||||
{
|
||||
@ -74,19 +120,15 @@ bool ElementInMap(const std::string curElement, const std::map<std::string, T>&
|
||||
return true;
|
||||
}
|
||||
|
||||
RSSymbolAnimation::RSSymbolAnimation()
|
||||
{
|
||||
}
|
||||
RSSymbolAnimation::RSSymbolAnimation() {}
|
||||
|
||||
RSSymbolAnimation::~RSSymbolAnimation()
|
||||
{
|
||||
}
|
||||
RSSymbolAnimation::~RSSymbolAnimation() {}
|
||||
|
||||
bool RSSymbolAnimation::SetSymbolAnimation(
|
||||
const std::shared_ptr<TextEngine::SymbolAnimationConfig>& symbolAnimationConfig)
|
||||
{
|
||||
if (rsNode_ == nullptr || symbolAnimationConfig == nullptr) {
|
||||
ROSEN_LOGE("HmSymbol RSSymbolAnimation::getNode or get symbolAnimationConfig:failed");
|
||||
ROSEN_LOGD("HmSymbol RSSymbolAnimation::getNode or get symbolAnimationConfig:failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -97,14 +139,160 @@ bool RSSymbolAnimation::SetSymbolAnimation(
|
||||
if (symbolAnimationConfig->effectStrategy == TextEngine::SymbolAnimationEffectStrategy::SYMBOL_NONE) {
|
||||
return true; // pre code already clear nodes.
|
||||
}
|
||||
InitSupportAnimationTable();
|
||||
return ChooseAnimation(symbolAnimationConfig);
|
||||
}
|
||||
|
||||
if (symbolAnimationConfig->effectStrategy == TextEngine::SymbolAnimationEffectStrategy::SYMBOL_SCALE) {
|
||||
return SetScaleUnitAnimation(symbolAnimationConfig);
|
||||
} else if (symbolAnimationConfig->effectStrategy ==
|
||||
TextEngine::SymbolAnimationEffectStrategy::SYMBOL_VARIABLE_COLOR) {
|
||||
return SetVariableColorAnimation(symbolAnimationConfig);
|
||||
void RSSymbolAnimation::InitSupportAnimationTable()
|
||||
{
|
||||
// Init public animation list
|
||||
publicSupportAnimations_ = { TextEngine::SymbolAnimationEffectStrategy::SYMBOL_BOUNCE,
|
||||
TextEngine::SymbolAnimationEffectStrategy::SYMBOL_APPEAR,
|
||||
TextEngine::SymbolAnimationEffectStrategy::SYMBOL_DISAPPEAR };
|
||||
}
|
||||
|
||||
bool RSSymbolAnimation::ChooseAnimation(const std::shared_ptr<TextEngine::SymbolAnimationConfig>& symbolAnimationConfig)
|
||||
{
|
||||
if (std::count(publicSupportAnimations_.begin(),
|
||||
publicSupportAnimations_.end(), symbolAnimationConfig->effectStrategy)) {
|
||||
return SetPublicAnimation(symbolAnimationConfig);
|
||||
}
|
||||
return false;
|
||||
|
||||
switch (symbolAnimationConfig->effectStrategy) {
|
||||
case TextEngine::SymbolAnimationEffectStrategy::SYMBOL_SCALE:
|
||||
return SetScaleUnitAnimation(symbolAnimationConfig);
|
||||
case TextEngine::SymbolAnimationEffectStrategy::SYMBOL_VARIABLE_COLOR:
|
||||
return SetVariableColorAnimation(symbolAnimationConfig);
|
||||
default:
|
||||
ROSEN_LOGD("[%{public}s] not support input animation type \n", __func__);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool RSSymbolAnimation::SetPublicAnimation(
|
||||
const std::shared_ptr<TextEngine::SymbolAnimationConfig>& symbolAnimationConfig)
|
||||
{
|
||||
auto nodeNum = symbolAnimationConfig->numNodes;
|
||||
if (nodeNum <= 0) {
|
||||
ROSEN_LOGD("HmSymbol SetDisappearAnimation::getNode or get symbolAnimationConfig:failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
auto symbolSpanId = symbolAnimationConfig->symbolSpanId;
|
||||
auto& symbolFirstNode = symbolAnimationConfig->SymbolNodes[0]; // calculate offset by the first node
|
||||
|
||||
Vector4f offsets = CalculateOffset(symbolFirstNode.symbolData.path_, symbolFirstNode.nodeBoundary[0],
|
||||
symbolFirstNode.nodeBoundary[1]); // index 0 offsetX and 1 offsetY of layout
|
||||
|
||||
std::shared_ptr<std::vector<std::vector<Drawing::DrawingPiecewiseParameter>>> parameters = nullptr;
|
||||
bool res = GetAnimationGroupParameters(symbolAnimationConfig, parameters);
|
||||
|
||||
for (uint32_t n = 0; n < nodeNum; n++) {
|
||||
auto& symbolNode = symbolAnimationConfig->SymbolNodes[n];
|
||||
auto canvasNode = RSCanvasNode::Create();
|
||||
|
||||
if (!rsNode_->canvasNodesListMap.count(symbolSpanId)) {
|
||||
rsNode_->canvasNodesListMap[symbolSpanId] = {};
|
||||
}
|
||||
rsNode_->canvasNodesListMap[symbolSpanId].emplace_back(canvasNode);
|
||||
|
||||
Vector4f offsets =
|
||||
CalculateOffset(symbolNode.symbolData.path_, symbolNode.nodeBoundary[0], symbolNode.nodeBoundary[1]);
|
||||
if (!SetSymbolGeometry(canvasNode, Vector4f(offsets[0], offsets[1], // 0: offsetX of newNode 1: offsetY
|
||||
symbolNode.nodeBoundary[WIDTH], symbolNode.nodeBoundary[HEIGHT]))) {
|
||||
return false;
|
||||
}
|
||||
rsNode_->AddChild(canvasNode, -1);
|
||||
GroupDrawing(canvasNode, symbolNode, offsets, nodeNum > 1);
|
||||
|
||||
if (!res || (symbolNode.animationIndex < 0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (parameters->size() <= symbolNode.animationIndex || parameters->at(symbolNode.animationIndex).empty()) {
|
||||
ROSEN_LOGD("[%{public}s] invalid parameter \n", __func__);
|
||||
continue;
|
||||
}
|
||||
auto oneGroupParas = (*parameters)[int(symbolNode.animationIndex)];
|
||||
if (oneGroupParas.empty()) {
|
||||
ROSEN_LOGD("[%{public}s] invalid parameter \n", __func__);
|
||||
continue;
|
||||
}
|
||||
SpliceAnimation(canvasNode, oneGroupParas, symbolAnimationConfig->effectStrategy);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void RSSymbolAnimation::GroupAnimationStart(
|
||||
const std::shared_ptr<RSNode>& rsNode, std::vector<std::shared_ptr<RSAnimation>>& animations)
|
||||
{
|
||||
if (rsNode == nullptr || animations.empty()) {
|
||||
ROSEN_LOGD("[%{public}s] : invalid input \n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < static_cast<int>(animations.size()); i++) {
|
||||
if (animations[i]) {
|
||||
animations[i]->Start(rsNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RSSymbolAnimation::SetNodePivot(const std::shared_ptr<RSNode>& rsNode)
|
||||
{
|
||||
// Set Node Center Offset
|
||||
Vector2f curNodePivot = rsNode->GetStagingProperties().GetPivot();
|
||||
if (!IsEqual(curNodePivot, CENTER_NODE_COORDINATE)) {
|
||||
bool isCreate = CreateOrSetModifierValue(pivotProperty_, CENTER_NODE_COORDINATE);
|
||||
if (isCreate) {
|
||||
auto pivotModifier = std::make_shared<RSPivotModifier>(pivotProperty_);
|
||||
rsNode->AddModifier(pivotModifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RSSymbolAnimation::SpliceAnimation(const std::shared_ptr<RSNode>& rsNode,
|
||||
std::vector<Drawing::DrawingPiecewiseParameter>& parameters,
|
||||
const TextEngine::SymbolAnimationEffectStrategy& effectStrategy)
|
||||
{
|
||||
if (effectStrategy == TextEngine::SymbolAnimationEffectStrategy::SYMBOL_DISAPPEAR ||
|
||||
effectStrategy == TextEngine::SymbolAnimationEffectStrategy::SYMBOL_APPEAR) {
|
||||
AppearAnimation(rsNode, parameters);
|
||||
} else if (effectStrategy == TextEngine::SymbolAnimationEffectStrategy::SYMBOL_BOUNCE) {
|
||||
BounceAnimation(rsNode, parameters);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void RSSymbolAnimation::BounceAnimation(
|
||||
const std::shared_ptr<RSNode>& rsNode, std::vector<Drawing::DrawingPiecewiseParameter>& parameters)
|
||||
{
|
||||
int animationStageNum = 2; // the count of atomizated animations
|
||||
if (rsNode == nullptr && parameters.empty() && parameters.size() < animationStageNum) {
|
||||
ROSEN_LOGD("[%{public}s] : invalid input\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<RSAnimation>> groupAnimation = {};
|
||||
ScaleAnimationBase(rsNode, parameters[0], groupAnimation);
|
||||
ScaleAnimationBase(rsNode, parameters[1], groupAnimation);
|
||||
GroupAnimationStart(rsNode, groupAnimation);
|
||||
}
|
||||
|
||||
void RSSymbolAnimation::AppearAnimation(
|
||||
const std::shared_ptr<RSNode>& rsNode, std::vector<Drawing::DrawingPiecewiseParameter>& parameters)
|
||||
{
|
||||
int animationStageNum = 2; // the count of atomizated animations
|
||||
if (rsNode == nullptr && parameters.empty() && parameters.size() < animationStageNum) {
|
||||
ROSEN_LOGD("[%{public}s] : invalid input\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<RSAnimation>> groupAnimation = {};
|
||||
ScaleAnimationBase(rsNode, parameters[0], groupAnimation);
|
||||
AlphaAnimationBase(rsNode, parameters[1], groupAnimation);
|
||||
GroupAnimationStart(rsNode, groupAnimation);
|
||||
}
|
||||
|
||||
Vector4f RSSymbolAnimation::CalculateOffset(const Drawing::Path& path, const float& offsetX, const float& offsetY)
|
||||
@ -114,13 +302,26 @@ Vector4f RSSymbolAnimation::CalculateOffset(const Drawing::Path& path, const flo
|
||||
float top = rect.GetTop();
|
||||
// the nodeTranslation is offset of new node to the father node;
|
||||
// the newOffset is offset of path on new node;
|
||||
Vector2f nodeTranslation = {offsetX + left, offsetY + top};
|
||||
Vector2f newOffset = {-left, -top};
|
||||
Vector2f nodeTranslation = { offsetX + left, offsetY + top };
|
||||
Vector2f newOffset = { -left, -top };
|
||||
return Vector4f(nodeTranslation[0], nodeTranslation[1], newOffset[0], newOffset[1]);
|
||||
}
|
||||
|
||||
void RSSymbolAnimation::DrawSymbolOnCanvas(ExtendRecordingCanvas* recordingCanvas,
|
||||
TextEngine::SymbolNode& symbolNode, const Vector4f& offsets)
|
||||
void RSSymbolAnimation::GroupDrawing(const std::shared_ptr<RSCanvasNode>& canvasNode,
|
||||
TextEngine::SymbolNode& symbolNode, const Vector4f& offsets, bool isMultiLayer)
|
||||
{
|
||||
// drawing a symbol or a path group
|
||||
auto recordingCanvas = canvasNode->BeginRecording(symbolNode.nodeBoundary[WIDTH], symbolNode.nodeBoundary[HEIGHT]);
|
||||
if (isMultiLayer) {
|
||||
DrawPathOnCanvas(recordingCanvas, symbolNode, offsets);
|
||||
} else {
|
||||
DrawSymbolOnCanvas(recordingCanvas, symbolNode, offsets);
|
||||
}
|
||||
canvasNode->FinishRecording();
|
||||
}
|
||||
|
||||
void RSSymbolAnimation::DrawSymbolOnCanvas(
|
||||
ExtendRecordingCanvas* recordingCanvas, TextEngine::SymbolNode& symbolNode, const Vector4f& offsets)
|
||||
{
|
||||
if (recordingCanvas == nullptr) {
|
||||
return;
|
||||
@ -128,7 +329,7 @@ void RSSymbolAnimation::DrawSymbolOnCanvas(ExtendRecordingCanvas* recordingCanva
|
||||
Drawing::Brush brush;
|
||||
Drawing::Pen pen;
|
||||
SetIconProperty(brush, pen, symbolNode);
|
||||
Drawing::Point offsetLocal = Drawing::Point{offsets[2], offsets[3]}; // index 2 offsetX 3 offsetY
|
||||
Drawing::Point offsetLocal = Drawing::Point { offsets[2], offsets[3] }; // index 2 offsetX 3 offsetY
|
||||
recordingCanvas->AttachBrush(brush);
|
||||
recordingCanvas->DrawSymbol(symbolNode.symbolData, offsetLocal);
|
||||
recordingCanvas->DetachBrush();
|
||||
@ -137,8 +338,8 @@ void RSSymbolAnimation::DrawSymbolOnCanvas(ExtendRecordingCanvas* recordingCanva
|
||||
recordingCanvas->DetachPen();
|
||||
}
|
||||
|
||||
void RSSymbolAnimation::DrawPathOnCanvas(ExtendRecordingCanvas* recordingCanvas,
|
||||
TextEngine::SymbolNode& symbolNode, const Vector4f& offsets)
|
||||
void RSSymbolAnimation::DrawPathOnCanvas(
|
||||
ExtendRecordingCanvas* recordingCanvas, TextEngine::SymbolNode& symbolNode, const Vector4f& offsets)
|
||||
{
|
||||
if (recordingCanvas == nullptr) {
|
||||
return;
|
||||
@ -154,8 +355,8 @@ void RSSymbolAnimation::DrawPathOnCanvas(ExtendRecordingCanvas* recordingCanvas,
|
||||
recordingCanvas->DetachPen();
|
||||
}
|
||||
|
||||
bool RSSymbolAnimation::GetScaleUnitAnimationParas(Drawing::DrawingPiecewiseParameter& scaleUnitParas,
|
||||
Vector2f& scaleValueBegin, Vector2f& scaleValue)
|
||||
bool RSSymbolAnimation::GetScaleUnitAnimationParas(
|
||||
Drawing::DrawingPiecewiseParameter& scaleUnitParas, Vector2f& scaleValueBegin, Vector2f& scaleValue)
|
||||
{
|
||||
// AnimationType, Animation groups, animation_mode; animation_mode is 1 when Animation groups is 1
|
||||
auto scaleParas = Drawing::HmSymbolConfigOhos::GetGroupParameters(Drawing::SCALE_TYPE, 1, 1);
|
||||
@ -176,13 +377,13 @@ bool RSSymbolAnimation::GetScaleUnitAnimationParas(Drawing::DrawingPiecewisePara
|
||||
return false;
|
||||
}
|
||||
|
||||
scaleValueBegin = {scaleProperties[SCALE_PROP_X][PROP_START], scaleProperties[SCALE_PROP_Y][PROP_START]};
|
||||
scaleValue = {scaleProperties[SCALE_PROP_X][PROP_END], scaleProperties[SCALE_PROP_Y][PROP_END]};
|
||||
scaleValueBegin = { scaleProperties[SCALE_PROP_X][PROP_START], scaleProperties[SCALE_PROP_Y][PROP_START] };
|
||||
scaleValue = { scaleProperties[SCALE_PROP_X][PROP_END], scaleProperties[SCALE_PROP_Y][PROP_END] };
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RSSymbolAnimation::SetScaleUnitAnimation(const std::shared_ptr<TextEngine::SymbolAnimationConfig>&
|
||||
symbolAnimationConfig)
|
||||
bool RSSymbolAnimation::SetScaleUnitAnimation(
|
||||
const std::shared_ptr<TextEngine::SymbolAnimationConfig>& symbolAnimationConfig)
|
||||
{
|
||||
if (rsNode_ == nullptr || symbolAnimationConfig == nullptr) {
|
||||
ROSEN_LOGD("HmSymbol SetScaleUnitAnimation::getNode or get symbolAnimationConfig:failed");
|
||||
@ -197,13 +398,12 @@ bool RSSymbolAnimation::SetScaleUnitAnimation(const std::shared_ptr<TextEngine::
|
||||
if (rsNode_->canvasNodesListMap.count(symbolSpanId) > 0) {
|
||||
rsNode_->canvasNodesListMap[symbolSpanId].emplace_back(canvasNode);
|
||||
} else {
|
||||
rsNode_->canvasNodesListMap[symbolSpanId] = {canvasNode};
|
||||
rsNode_->canvasNodesListMap[symbolSpanId] = { canvasNode };
|
||||
}
|
||||
|
||||
auto& symbolNode = symbolAnimationConfig->SymbolNodes[UNIT_NODE];
|
||||
Vector4f offsets = CalculateOffset(symbolNode.symbolData.path_,
|
||||
symbolNode.nodeBoundary[0], symbolNode.nodeBoundary[1]); // index 0 offsetX of layout, 1 offsetY of layout
|
||||
|
||||
Vector4f offsets = CalculateOffset(symbolNode.symbolData.path_, symbolNode.nodeBoundary[0],
|
||||
symbolNode.nodeBoundary[1]); // index 0 offsetX of layout, 1 offsetY of layout
|
||||
if (!SetSymbolGeometry(canvasNode, Vector4f(offsets[0], offsets[1], // 0: offsetX of newNode; 1: offsetY
|
||||
symbolNode.nodeBoundary[WIDTH], symbolNode.nodeBoundary[HEIGHT]))) {
|
||||
return false;
|
||||
@ -250,9 +450,9 @@ bool RSSymbolAnimation::SetSymbolGeometry(const std::shared_ptr<RSNode>& rsNode,
|
||||
return true;
|
||||
}
|
||||
|
||||
std::shared_ptr<RSAnimation> RSSymbolAnimation::ScaleSymbolAnimation(
|
||||
const std::shared_ptr<RSNode>& rsNode, const Drawing::DrawingPiecewiseParameter& scaleUnitParas,
|
||||
const Vector2f& scaleValueBegin, const Vector2f& scaleValue, const Vector2f& scaleValueEnd)
|
||||
std::shared_ptr<RSAnimation> RSSymbolAnimation::ScaleSymbolAnimation(const std::shared_ptr<RSNode>& rsNode,
|
||||
const Drawing::DrawingPiecewiseParameter& scaleUnitParas, const Vector2f& scaleValueBegin,
|
||||
const Vector2f& scaleValue, const Vector2f& scaleValueEnd)
|
||||
{
|
||||
if (rsNode == nullptr) {
|
||||
return nullptr;
|
||||
@ -303,8 +503,8 @@ RSAnimationTimingCurve RSSymbolAnimation::SetScaleSpringTimingCurve(const std::m
|
||||
return scaleCurve;
|
||||
}
|
||||
|
||||
bool RSSymbolAnimation::SetVariableColorAnimation(const std::shared_ptr<TextEngine::SymbolAnimationConfig>&
|
||||
symbolAnimationConfig)
|
||||
bool RSSymbolAnimation::SetVariableColorAnimation(
|
||||
const std::shared_ptr<TextEngine::SymbolAnimationConfig>& symbolAnimationConfig)
|
||||
{
|
||||
if (rsNode_ == nullptr || symbolAnimationConfig == nullptr) {
|
||||
ROSEN_LOGD("HmSymbol SetVariableColorAnimation::getNode or get symbolAnimationConfig:failed");
|
||||
@ -317,22 +517,22 @@ bool RSSymbolAnimation::SetVariableColorAnimation(const std::shared_ptr<TextEngi
|
||||
|
||||
auto symbolSpanId = symbolAnimationConfig->symbolSpanId;
|
||||
auto& symbolFirstNode = symbolAnimationConfig->SymbolNodes[0]; // calculate offset by the first node
|
||||
Vector4f offsets = CalculateOffset(symbolFirstNode.symbolData.path_,
|
||||
symbolFirstNode.nodeBoundary[0], symbolFirstNode.nodeBoundary[1]); // index 0 offsetX and 1 offsetY of layout
|
||||
Vector4f offsets = CalculateOffset(symbolFirstNode.symbolData.path_, symbolFirstNode.nodeBoundary[0],
|
||||
symbolFirstNode.nodeBoundary[1]); // index 0 offsetX and 1 offsetY of layout
|
||||
for (uint32_t n = 0; n < nodeNum; n++) {
|
||||
auto& symbolNode = symbolAnimationConfig->SymbolNodes[n];
|
||||
auto canvasNode = RSCanvasNode::Create();
|
||||
if (rsNode_->canvasNodesListMap.count(symbolSpanId) > 0) {
|
||||
rsNode_->canvasNodesListMap[symbolSpanId].emplace_back(canvasNode);
|
||||
} else {
|
||||
rsNode_->canvasNodesListMap[symbolSpanId] = {canvasNode};
|
||||
rsNode_->canvasNodesListMap[symbolSpanId] = { canvasNode };
|
||||
}
|
||||
if (!SetSymbolGeometry(canvasNode, Vector4f(offsets[0], offsets[1], // 0: offsetX of newNode 1: offsetY
|
||||
symbolNode.nodeBoundary[WIDTH], symbolNode.nodeBoundary[HEIGHT]))) {
|
||||
return false;
|
||||
}
|
||||
auto recordingCanvas = canvasNode->BeginRecording(symbolNode.nodeBoundary[WIDTH],
|
||||
symbolNode.nodeBoundary[HEIGHT]);
|
||||
auto recordingCanvas =
|
||||
canvasNode->BeginRecording(symbolNode.nodeBoundary[WIDTH], symbolNode.nodeBoundary[HEIGHT]);
|
||||
DrawPathOnCanvas(recordingCanvas, symbolNode, offsets);
|
||||
canvasNode->FinishRecording();
|
||||
rsNode_->AddChild(canvasNode, -1);
|
||||
@ -358,8 +558,8 @@ bool RSSymbolAnimation::SetVariableColorAnimation(const std::shared_ptr<TextEngi
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RSSymbolAnimation::GetVariableColorAnimationParas(const uint32_t index, uint32_t& totalDuration, int& delay,
|
||||
std::vector<float>& timePercents)
|
||||
bool RSSymbolAnimation::GetVariableColorAnimationParas(
|
||||
const uint32_t index, uint32_t& totalDuration, int& delay, std::vector<float>& timePercents)
|
||||
{
|
||||
// AnimationType, Animation groups, animation_mode; the variable color groups is 3 , animation_mode is 1
|
||||
auto multiGroupParas = Drawing::HmSymbolConfigOhos::GetGroupParameters(Drawing::VARIABLE_COLOR_TYPE, 3, 1);
|
||||
@ -415,16 +615,13 @@ bool RSSymbolAnimation::CalcTimePercents(std::vector<float>& timePercents, const
|
||||
return true;
|
||||
}
|
||||
|
||||
void RSSymbolAnimation::SetIconProperty(Drawing::Brush& brush, Drawing::Pen& pen,
|
||||
TextEngine::SymbolNode& symbolNode)
|
||||
void RSSymbolAnimation::SetIconProperty(Drawing::Brush& brush, Drawing::Pen& pen, TextEngine::SymbolNode& symbolNode)
|
||||
{
|
||||
brush.SetColor(Drawing::Color::ColorQuadSetARGB(0xFF, symbolNode.color.r,
|
||||
symbolNode.color.g, symbolNode.color.b));
|
||||
brush.SetColor(Drawing::Color::ColorQuadSetARGB(0xFF, symbolNode.color.r, symbolNode.color.g, symbolNode.color.b));
|
||||
brush.SetAlphaF(symbolNode.color.a);
|
||||
brush.SetAntiAlias(true);
|
||||
|
||||
pen.SetColor(Drawing::Color::ColorQuadSetARGB(0xFF, symbolNode.color.r,
|
||||
symbolNode.color.g, symbolNode.color.b));
|
||||
pen.SetColor(Drawing::Color::ColorQuadSetARGB(0xFF, symbolNode.color.r, symbolNode.color.g, symbolNode.color.b));
|
||||
pen.SetAlphaF(symbolNode.color.a);
|
||||
pen.SetAntiAlias(true);
|
||||
return;
|
||||
@ -449,5 +646,96 @@ std::shared_ptr<RSAnimation> RSSymbolAnimation::VariableColorSymbolAnimation(con
|
||||
keyframeAnimation->AddKeyFrames(keyframes);
|
||||
return keyframeAnimation;
|
||||
}
|
||||
|
||||
// base atomizated animation
|
||||
void RSSymbolAnimation::ScaleAnimationBase(const std::shared_ptr<RSNode>& rsNode,
|
||||
Drawing::DrawingPiecewiseParameter& scaleParameter, std::vector<std::shared_ptr<RSAnimation>>& animations)
|
||||
{
|
||||
// validation input
|
||||
if (rsNode == nullptr) {
|
||||
ROSEN_LOGD("[%{public}s] : invalid input \n", __func__);
|
||||
return;
|
||||
}
|
||||
int validSize = 2;
|
||||
if (scaleParameter.properties.count("sx") <= 0 || scaleParameter.properties.count("sy") <= 0 ||
|
||||
scaleParameter.properties["sx"].size() < validSize || scaleParameter.properties["sx"].size() < validSize) {
|
||||
ROSEN_LOGD("[%{public}s] : invalid input \n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
SetNodePivot(rsNode);
|
||||
|
||||
const Vector2f scaleValueBegin = { scaleParameter.properties["sx"][0], scaleParameter.properties["sy"][0] };
|
||||
const Vector2f scaleValueEnd = { scaleParameter.properties["sx"][1], scaleParameter.properties["sy"][1] };
|
||||
|
||||
std::shared_ptr<RSAnimatableProperty<Vector2f>> scaleProperty;
|
||||
bool isCreate = CreateOrSetModifierValue(scaleProperty, scaleValueBegin);
|
||||
if (!isCreate) {
|
||||
ROSEN_LOGD("[%{public}s] : invalid parameter \n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
std::shared_ptr<RSAnimatableProperty<Vector2f>> pivotProperty;
|
||||
auto scaleModifier = std::make_shared<Rosen::RSScaleModifier>(scaleProperty);
|
||||
rsNode->AddModifier(scaleModifier);
|
||||
|
||||
// set animation curve and protocol
|
||||
RSAnimationTimingCurve scaleCurve;
|
||||
CreateAnimationTimingCurve(scaleParameter.curveType, scaleParameter.curveArgs, scaleCurve);
|
||||
|
||||
RSAnimationTimingProtocol scaleprotocol;
|
||||
int startDelay = int(scaleParameter.delay);
|
||||
scaleprotocol.SetStartDelay(startDelay);
|
||||
int duration = int(scaleParameter.duration);
|
||||
scaleprotocol.SetDuration(duration);
|
||||
|
||||
// set animation
|
||||
std::vector<std::shared_ptr<RSAnimation>> animations1 = RSNode::Animate(
|
||||
scaleprotocol, scaleCurve, [&scaleProperty, &scaleValueEnd]() { scaleProperty->Set(scaleValueEnd); });
|
||||
|
||||
if (animations1.size() > 0 && animations1[0] != nullptr) {
|
||||
animations.emplace_back(animations1[0]);
|
||||
}
|
||||
}
|
||||
|
||||
void RSSymbolAnimation::AlphaAnimationBase(const std::shared_ptr<RSNode>& rsNode,
|
||||
Drawing::DrawingPiecewiseParameter& alphaParameter, std::vector<std::shared_ptr<RSAnimation>>& animations)
|
||||
{
|
||||
// validation input
|
||||
if (rsNode == nullptr) {
|
||||
ROSEN_LOGD("[%{public}s] : invalid input \n", __func__);
|
||||
return;
|
||||
}
|
||||
int validSize = 2;
|
||||
if (alphaParameter.properties.count("alpha") <= 0 || alphaParameter.properties["alpha"].size() < validSize) {
|
||||
ROSEN_LOGD("[%{public}s] : invalid input \n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
float alphaBegin = float(alphaParameter.properties["alpha"][0]);
|
||||
float alphaValueEnd = float(alphaParameter.properties["alpha"][1]);
|
||||
|
||||
std::shared_ptr<RSAnimatableProperty<float>> alphaProperty;
|
||||
|
||||
if (!CreateOrSetModifierValue(alphaProperty, alphaBegin)) {
|
||||
return;
|
||||
}
|
||||
auto alphaModifier = std::make_shared<Rosen::RSAlphaModifier>(alphaProperty);
|
||||
|
||||
rsNode->AddModifier(alphaModifier);
|
||||
|
||||
RSAnimationTimingProtocol alphaProtocol;
|
||||
alphaProtocol.SetStartDelay(alphaParameter.delay);
|
||||
alphaProtocol.SetDuration(alphaParameter.duration);
|
||||
RSAnimationTimingCurve alphaCurve;
|
||||
CreateAnimationTimingCurve(alphaParameter.curveType, alphaParameter.curveArgs, alphaCurve);
|
||||
|
||||
std::vector<std::shared_ptr<RSAnimation>> animations1 = RSNode::Animate(
|
||||
alphaProtocol, alphaCurve, [&alphaProperty, &alphaValueEnd]() { alphaProperty->Set(alphaValueEnd); });
|
||||
|
||||
if (animations1.size() > 0 && animations1[0] != nullptr) {
|
||||
animations.emplace_back(animations1[0]);
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user