Merge branch 'master' of gitee.com:openharmony/graphic_graphic_2d into master

Signed-off-by: qxk <14165546+qinxikui@user.noreply.gitee.com>
This commit is contained in:
qxk 2024-11-01 06:58:42 +00:00 committed by Gitee
commit 38ae879ed3
498 changed files with 41492 additions and 3351 deletions

View File

@ -48,6 +48,7 @@ group("graphic_common_test") {
"rosen/test/texgine:test",
"utils/color_manager:test",
"utils/rs_frame_report_ext:test",
"utils/scoped_bytrace:test",
"utils/socketpair:test",
]
}

View File

@ -189,7 +189,7 @@ std::vector<std::string> EglSystemLayersManager::GetSystemLayersFromConfig(Json:
return std::vector<std::string>{};
}
return GetStringVectorFromJson(defaultArray);
return EglSystemLayersManager::GetStringVectorFromJson(defaultArray);
}
const Json::Value layersArray = appModeSection[processName];
@ -198,7 +198,7 @@ std::vector<std::string> EglSystemLayersManager::GetSystemLayersFromConfig(Json:
return std::vector<std::string>{};
}
return GetStringVectorFromJson(layersArray);
return EglSystemLayersManager::GetStringVectorFromJson(layersArray);
}
std::vector<std::string> EglSystemLayersManager::GetSystemLayers()
@ -232,7 +232,7 @@ std::vector<std::string> EglSystemLayersManager::GetSystemLayers()
constexpr int pnameLen = 512;
char pname[pnameLen + 1] = {0};
bool res = GetProcessName(getpid(), pname, pnameLen);
bool res = EglSystemLayersManager::GetProcessName(getpid(), pname, pnameLen);
if (!res) {
WLOGE("Failed to get process name");
return std::vector<std::string>{};

View File

@ -48,12 +48,12 @@ public:
std::vector<std::string> GetSystemLayers();
private:
bool GetProcessName(pid_t pid, char *pname, int len);
static bool GetProcessName(pid_t pid, char *pname, int len);
bool GetJsonConfig(Json::Value &configData);
bool GetDefaultJsonConfig(Json::Value &configData);
std::vector<std::string> GetSystemLayersFromConfig(Json::Value &appModeSection,
const std::string &processName);
std::vector<std::string> GetStringVectorFromJson(const Json::Value &jsonVector);
static std::vector<std::string> GetStringVectorFromJson(const Json::Value &jsonVector);
};
} //namespace OHOS

View File

@ -32,7 +32,7 @@ public:
~EglWrapperLayer();
bool Init(EglWrapperDispatchTable *table);
#if USE_IGRAPHICS_EXTENDS_HOOKS
bool GetIGraphicsLogicStatus() { return iGraphicsLogic; }
bool GetIGraphicsLogicStatus() const { return iGraphicsLogic; }
#endif
bool InitBundleInfo();

View File

@ -15,6 +15,7 @@ group("fuzztest") {
deps = [
"eglwrappercontext_fuzzer:fuzztest",
"eglwrapperdatactl_fuzzer:fuzztest",
"eglwrapperdisplay_fuzzer:fuzztest",
"eglwrapperentry_fuzzer:fuzztest",
"eglwrapperlayer_fuzzer:fuzztest",

View File

@ -0,0 +1,49 @@
# 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.
#####################hydra-fuzz###################
import("//build/config/features.gni")
import("//build/test.gni")
import("//foundation/graphic/graphic_2d/graphic_config.gni")
module_output_path = "graphic_2d/graphic_2d"
##############################fuzztest##########################################
ohos_fuzztest("EGLWrapperDataCtlFuzzTest") {
fuzz_config_file = "$graphic_2d_root/frameworks/opengl_wrapper/test/fuzztest/eglwrapperdatactl_fuzzer"
module_out_path = module_output_path
include_dirs = [ "$graphic_2d_root/frameworks/opengl_wrapper/src/EGL" ]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "eglwrapperdatactl_fuzzer.cpp" ]
deps = [
"$graphic_2d_root/frameworks/opengl_wrapper:EGL",
"$graphic_2d_root/frameworks/opengl_wrapper:GLESv3",
]
external_deps = [ "c_utils:utils" ]
}
###############################################################################
group("fuzztest") {
testonly = true
deps = []
deps += [
# deps file
":EGLWrapperDataCtlFuzzTest",
]
}
###############################################################################

View File

@ -0,0 +1,14 @@
# 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.
FUZZ

View File

@ -0,0 +1,88 @@
/*
* 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 "eglwrapperdatactl_fuzzer.h"
#include <EGL/egl.h>
#include <GLES3/gl3.h>
#include <securec.h>
#include <unistd.h>
#include "thread_private_data_ctl.h"
namespace OHOS {
namespace {
const uint8_t* g_data = nullptr;
size_t g_size = 0;
size_t g_pos;
}
/*
* describe: get data from outside untrusted data(g_data) which size is according to sizeof(T)
* tips: only support basic type
*/
template<class T>
T GetData()
{
T object {};
size_t objectSize = sizeof(object);
if (g_data == nullptr || objectSize > g_size - g_pos) {
return object;
}
errno_t ret = memcpy_s(&object, objectSize, g_data + g_pos, objectSize);
if (ret != EOK) {
return {};
}
g_pos += objectSize;
return object;
}
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
{
if (data == nullptr || size < 0) {
return false;
}
// initialize
g_data = data;
g_size = size;
g_pos = 0;
EGLint error = GetData<EGLint>();
EGLContext ctx = GetData<EGLContext>();
GlHookTable table = GetData<GlHookTable>();
GLenum texture = GetData<GLenum>();
// test
ThreadPrivateDataCtl::SetError(error);
ThreadPrivateDataCtl::SetContext(ctx);
ThreadPrivateDataCtl::SetGlHookTable(&table);
(void)ThreadPrivateDataCtl::GetPrivateData();
(void)ThreadPrivateDataCtl::GetError();
(void)ThreadPrivateDataCtl::GetContext();
(void)ThreadPrivateDataCtl::GetGlHookTable();
ThreadPrivateDataCtl::ClearError();
ThreadPrivateDataCtl::ClearPrivateData();
glActiveTexture(texture);
return true;
}
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
OHOS::DoSomethingInterestingWithMyAPI(data, size);
return 0;
}

View File

@ -0,0 +1,21 @@
/*
* 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 TEST_FUZZTEST_EGL_WRAPPER_DATA_CTL_FUZZER_H
#define TEST_FUZZTEST_EGL_WRAPPER_DATA_CTL_FUZZER_H
#define FUZZ_PROJECT_NAME "eglwrapperdatactl_fuzzer"
#endif // TEST_FUZZTEST_EGL_WRAPPER_DATA_CTL_FUZZER_H

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->
<fuzz_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -125,7 +125,7 @@ if (graphic_2d_feature_ace_enable_gpu) {
libvulkan += [ "//third_party/vulkan-loader:vulkan_loader" ]
}
} else {
gpu_defines = [ "ACE_DISABLE_GL" ]
gpu_defines += [ "ACE_DISABLE_GL" ]
ace_enable_gpu = false
rs_enable_gpu = false
surface_enable_gpu = false

View File

@ -13,6 +13,7 @@
* limitations under the License.
*/
#include "parameters_defination.h"
#include "rs_graphic_test.h"
#include "rs_graphic_test_img.h"
@ -41,17 +42,18 @@ GRAPHIC_TEST(ForegroundTest, CONTENT_DISPLAY_TEST, FgBrightnessParams_Fraction_T
float rateList[] = { -0.05, 0.0, 1.0, 20.0 };
float saturationList[] = { 0.0, 5.0, 10.0, 20.0 };
std::array<float, 3> RGB[] = { { 2.3, 4.5, 2 }, { 0.5, 2, 0.5 } };
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
for (int k = 0; k < 2; k++) {
for (int i = 0; i < FOUR_; i++) {
for (int j = 0; j < FOUR_; j++) {
for (int k = 0; k < TWO_; k++) {
RSDynamicBrightnessPara params = RSDynamicBrightnessPara(rateList[i], rateList[(i + 3) % 4],
saturationList[j], saturationList[(j + 1) % 4], saturationList[j], RGB[k], RGB[(k + 1) % 2]);
params.fraction_ = 0.5;
int x = i * 310;
int y = (k + j * 2) * 310;
auto testFaNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, 300, 300 });
params.fraction_ = ZERO_POINT_FIVE_;
int x = i * THREE_HUNDRED_TEN_;
int y = (k + j * 2) * THREE_HUNDRED_TEN_;
auto testFaNode =
SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, THREE_HUNDRED_, THREE_HUNDRED_ });
auto testNode = RSCanvasNode::Create();
testNode->SetBounds({ 0, 0, 300, 300 });
testNode->SetBounds({ 0, 0, THREE_HUNDRED_, THREE_HUNDRED_ });
testNode->SetForegroundColor(0xff7d112c);
testNode->SetFgBrightnessParams(params);
testNode->SetFgBrightnessFract(params.fraction_);
@ -69,17 +71,18 @@ GRAPHIC_TEST(ForegroundTest, CONTENT_DISPLAY_TEST, FgBrightnessParams_Fraction_T
float rateList[] = { -0.05, 0.0, 1.0, 20.0 };
float saturationList[] = { 0.0, 5.0, 10.0, 20.0 };
std::array<float, 3> RGB[] = { { 2.3, 4.5, 2 }, { 0.5, 2, 0.5 } };
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
for (int k = 0; k < 2; k++) {
for (int i = 0; i < FOUR_; i++) {
for (int j = 0; j < FOUR_; j++) {
for (int k = 0; k < TWO_; k++) {
RSDynamicBrightnessPara params = RSDynamicBrightnessPara(rateList[i], rateList[(i + 3) % 4],
saturationList[j], saturationList[(j + 1) % 4], saturationList[j], RGB[k], RGB[(k + 1) % 2]);
params.fraction_ = 1.0;
int x = i * 310;
int y = (k + j * 2) * 310;
auto testFaNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, 300, 300 });
params.fraction_ = ONE_;
int x = i * THREE_HUNDRED_TEN_;
int y = (k + j * 2) * THREE_HUNDRED_TEN_;
auto testFaNode =
SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, THREE_HUNDRED_, THREE_HUNDRED_ });
auto testNode = RSCanvasNode::Create();
testNode->SetBounds({ 0, 0, 300, 300 });
testNode->SetBounds({ 0, 0, THREE_HUNDRED_, THREE_HUNDRED_ });
testNode->SetForegroundColor(0xff7d112c);
testNode->SetFgBrightnessParams(params);
testNode->SetFgBrightnessFract(params.fraction_);
@ -97,17 +100,18 @@ GRAPHIC_TEST(ForegroundTest, CONTENT_DISPLAY_TEST, FgBrightnessParams_Fraction_T
float rateList[] = { -0.05, 0.0, 1.0, 20.0 };
float saturationList[] = { 0.0, 5.0, 10.0, 20.0 };
std::array<float, 3> RGB[] = { { 2.3, 4.5, 2 }, { 0.5, 2, 0.5 } };
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
for (int k = 0; k < 2; k++) {
for (int i = 0; i < FOUR_; i++) {
for (int j = 0; j < FOUR_; j++) {
for (int k = 0; k < TWO_; k++) {
RSDynamicBrightnessPara params = RSDynamicBrightnessPara(rateList[i], rateList[(i + 3) % 4],
saturationList[j], saturationList[(j + 1) % 4], saturationList[j], RGB[k], RGB[(k + 1) % 2]);
params.fraction_ = 0.0;
int x = i * 310;
int y = (k + j * 2) * 310;
auto testFaNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, 300, 300 });
params.fraction_ = ZERO_;
int x = i * THREE_HUNDRED_TEN_;
int y = (k + j * 2) * THREE_HUNDRED_TEN_;
auto testFaNode =
SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, THREE_HUNDRED_, THREE_HUNDRED_ });
auto testNode = RSCanvasNode::Create();
testNode->SetBounds({ 0, 0, 300, 300 });
testNode->SetBounds({ 0, 0, THREE_HUNDRED_, THREE_HUNDRED_ });
testNode->SetForegroundColor(0xff7d112c);
testNode->SetFgBrightnessParams(params);
testNode->SetFgBrightnessFract(params.fraction_);
@ -126,9 +130,9 @@ GRAPHIC_TEST(ForegroundTest, CONTENT_DISPLAY_TEST, Foreground_SetBlender_Test_1)
float saturationList[] = { 0.0, 5.0, 10.0, 20.0 };
float fractionVal = 0.5;
Vector3f RGB[] = { { 2.3, 4.5, 2 }, { 0.5, 2, 0.5 } };
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
for (int k = 0; k < 2; k++) {
for (int i = 0; i < FOUR_; i++) {
for (int j = 0; j < FOUR_; j++) {
for (int k = 0; k < TWO_; k++) {
auto blenderPara = std::make_shared<BrightnessBlender>();
blenderPara->SetFraction(fractionVal);
blenderPara->SetLinearRate(rateList[i]);
@ -138,11 +142,12 @@ GRAPHIC_TEST(ForegroundTest, CONTENT_DISPLAY_TEST, Foreground_SetBlender_Test_1)
blenderPara->SetSaturation(saturationList[j]);
blenderPara->SetPositiveCoeff(RGB[k]);
blenderPara->SetNegativeCoeff(RGB[(k + 1) % 2]);
int x = i * 310;
int y = (k + j * 2) * 310;
auto testFaNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, 300, 300 });
int x = i * THREE_HUNDRED_TEN_;
int y = (k + j * 2) * THREE_HUNDRED_TEN_;
auto testFaNode =
SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, THREE_HUNDRED_, THREE_HUNDRED_ });
auto testNode = RSCanvasNode::Create();
testNode->SetBounds({ 0, 0, 300, 300 });
testNode->SetBounds({ 0, 0, THREE_HUNDRED_, THREE_HUNDRED_ });
testNode->SetForegroundColor(0xff7d112c);
testNode->SetBlender(blenderPara.get());
GetRootNode()->AddChild(testFaNode);
@ -160,9 +165,9 @@ GRAPHIC_TEST(ForegroundTest, CONTENT_DISPLAY_TEST, Foreground_SetBlender_Test_2)
float saturationList[] = { 0.0, 5.0, 10.0, 20.0 };
float fractionVal = 1.0;
Vector3f RGB[] = { { 2.3, 4.5, 2 }, { 0.5, 2, 0.5 } };
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
for (int k = 0; k < 2; k++) {
for (int i = 0; i < FOUR_; i++) {
for (int j = 0; j < FOUR_; j++) {
for (int k = 0; k < TWO_; k++) {
auto blenderPara = std::make_shared<BrightnessBlender>();
blenderPara->SetFraction(fractionVal);
blenderPara->SetLinearRate(rateList[i]);
@ -172,11 +177,12 @@ GRAPHIC_TEST(ForegroundTest, CONTENT_DISPLAY_TEST, Foreground_SetBlender_Test_2)
blenderPara->SetSaturation(saturationList[j]);
blenderPara->SetPositiveCoeff(RGB[k]);
blenderPara->SetNegativeCoeff(RGB[(k + 1) % 2]);
int x = i * 310;
int y = (k + j * 2) * 310;
auto testFaNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, 300, 300 });
int x = i * THREE_HUNDRED_TEN_;
int y = (k + j * 2) * THREE_HUNDRED_TEN_;
auto testFaNode =
SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, THREE_HUNDRED_, THREE_HUNDRED_ });
auto testNode = RSCanvasNode::Create();
testNode->SetBounds({ 0, 0, 300, 300 });
testNode->SetBounds({ 0, 0, THREE_HUNDRED_, THREE_HUNDRED_ });
testNode->SetForegroundColor(0xff7d112c);
testNode->SetBlender(blenderPara.get());
GetRootNode()->AddChild(testFaNode);
@ -194,9 +200,9 @@ GRAPHIC_TEST(ForegroundTest, CONTENT_DISPLAY_TEST, Foreground_SetBlender_Test_3)
float saturationList[] = { 0.0, 5.0, 10.0, 20.0 };
float fractionVal = 0.0;
Vector3f RGB[] = { { 2.3, 4.5, 2 }, { 0.5, 2, 0.5 } };
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
for (int k = 0; k < 2; k++) {
for (int i = 0; i < FOUR_; i++) {
for (int j = 0; j < FOUR_; j++) {
for (int k = 0; k < TWO_; k++) {
auto blenderPara = std::make_shared<BrightnessBlender>();
blenderPara->SetFraction(fractionVal);
blenderPara->SetLinearRate(rateList[i]);
@ -206,11 +212,12 @@ GRAPHIC_TEST(ForegroundTest, CONTENT_DISPLAY_TEST, Foreground_SetBlender_Test_3)
blenderPara->SetSaturation(saturationList[j]);
blenderPara->SetPositiveCoeff(RGB[k]);
blenderPara->SetNegativeCoeff(RGB[(k + 1) % 2]);
int x = i * 310;
int y = (k + j * 2) * 310;
auto testFaNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, 300, 300 });
int x = i * THREE_HUNDRED_TEN_;
int y = (k + j * 2) * THREE_HUNDRED_TEN_;
auto testFaNode =
SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, THREE_HUNDRED_, THREE_HUNDRED_ });
auto testNode = RSCanvasNode::Create();
testNode->SetBounds({ 0, 0, 300, 300 });
testNode->SetBounds({ 0, 0, THREE_HUNDRED_, THREE_HUNDRED_ });
testNode->SetForegroundColor(0xff7d112c);
testNode->SetBlender(blenderPara.get());
GetRootNode()->AddChild(testFaNode);

View File

@ -13,6 +13,7 @@
* limitations under the License.
*/
#include "parameters_defination.h"
#include "rs_graphic_test.h"
#include "rs_graphic_test_img.h"
@ -38,10 +39,10 @@ public:
GRAPHIC_TEST(ForegroundTest01, CONTENT_DISPLAY_TEST, GrayScale_Test_1)
{
float grayScaleList[] = { 0.0, 0.5, 1.0, 2.0 };
for (int i = 0; i < 4; i++) {
int x = (i % 2) * 510;
int y = (i / 2) * 510;
auto testNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, 500, 500 });
for (int i = 0; i < FOUR_; i++) {
int x = (i % TWO_) * FIVE_HUNDRED_TEN_;
int y = (i / TWO_) * FIVE_HUNDRED_TEN_;
auto testNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNode->SetGrayScale(grayScaleList[i]);
GetRootNode()->AddChild(testNode);
RegisterNode(testNode);
@ -51,10 +52,10 @@ GRAPHIC_TEST(ForegroundTest01, CONTENT_DISPLAY_TEST, GrayScale_Test_1)
GRAPHIC_TEST(ForegroundTest01, CONTENT_DISPLAY_TEST, Brightness_Test_1)
{
float brightnessList[] = { 0.0, 0.5, 1.0, 2.0, 5.0 };
for (int i = 0; i < 5; i++) {
int x = (i % 2) * 510;
int y = (i / 2) * 510;
auto testNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, 500, 500 });
for (int i = 0; i < FIVE_; i++) {
int x = (i % TWO_) * FIVE_HUNDRED_TEN_;
int y = (i / TWO_) * FIVE_HUNDRED_TEN_;
auto testNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNode->SetBrightness(brightnessList[i]);
GetRootNode()->AddChild(testNode);
RegisterNode(testNode);
@ -64,10 +65,10 @@ GRAPHIC_TEST(ForegroundTest01, CONTENT_DISPLAY_TEST, Brightness_Test_1)
GRAPHIC_TEST(ForegroundTest01, CONTENT_DISPLAY_TEST, Contrast_Test_1)
{
float contrastList[] = { 0.0, 0.5, 1.0, 5.0, 20.0 };
for (int i = 0; i < 5; i++) {
int x = (i % 2) * 510;
int y = (i / 2) * 510;
auto testNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, 500, 500 });
for (int i = 0; i < FIVE_; i++) {
int x = (i % TWO_) * FIVE_HUNDRED_TEN_;
int y = (i / TWO_) * FIVE_HUNDRED_TEN_;
auto testNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNode->SetContrast(contrastList[i]);
GetRootNode()->AddChild(testNode);
RegisterNode(testNode);
@ -77,10 +78,10 @@ GRAPHIC_TEST(ForegroundTest01, CONTENT_DISPLAY_TEST, Contrast_Test_1)
GRAPHIC_TEST(ForegroundTest01, CONTENT_DISPLAY_TEST, Saturate_Test_1)
{
float saturateList[] = { 0.0, 0.5, 1.0, 10.0, 100.0 };
for (int i = 0; i < 5; i++) {
int x = (i % 2) * 510;
int y = (i / 2) * 510;
auto testNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, 500, 500 });
for (int i = 0; i < FIVE_; i++) {
int x = (i % TWO_) * FIVE_HUNDRED_TEN_;
int y = (i / TWO_) * FIVE_HUNDRED_TEN_;
auto testNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNode->SetSaturate(saturateList[i]);
GetRootNode()->AddChild(testNode);
RegisterNode(testNode);
@ -90,10 +91,10 @@ GRAPHIC_TEST(ForegroundTest01, CONTENT_DISPLAY_TEST, Saturate_Test_1)
GRAPHIC_TEST(ForegroundTest01, CONTENT_DISPLAY_TEST, Sepia_Test_1)
{
float sepiaList[] = { 0.0, 0.5, 1.0, 2.0 };
for (int i = 0; i < 4; i++) {
int x = (i % 2) * 510;
int y = (i / 2) * 510;
auto testNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, 500, 500 });
for (int i = 0; i < FOUR_; i++) {
int x = (i % TWO_) * FIVE_HUNDRED_TEN_;
int y = (i / TWO_) * FIVE_HUNDRED_TEN_;
auto testNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNode->SetSepia(sepiaList[i]);
GetRootNode()->AddChild(testNode);
RegisterNode(testNode);
@ -103,10 +104,10 @@ GRAPHIC_TEST(ForegroundTest01, CONTENT_DISPLAY_TEST, Sepia_Test_1)
GRAPHIC_TEST(ForegroundTest01, CONTENT_DISPLAY_TEST, Color_Invert_Test_1)
{
float invertList[] = { 0.0, 0.5, 1.0, 2.0 };
for (int i = 0; i < 4; i++) {
int x = (i % 2) * 510;
int y = (i / 2) * 510;
auto testNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, 500, 500 });
for (int i = 0; i < FOUR_; i++) {
int x = (i % TWO_) * FIVE_HUNDRED_TEN_;
int y = (i / TWO_) * FIVE_HUNDRED_TEN_;
auto testNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNode->SetInvert(invertList[i]);
GetRootNode()->AddChild(testNode);
RegisterNode(testNode);
@ -116,10 +117,10 @@ GRAPHIC_TEST(ForegroundTest01, CONTENT_DISPLAY_TEST, Color_Invert_Test_1)
GRAPHIC_TEST(ForegroundTest01, CONTENT_DISPLAY_TEST, HueRotate_Test_1)
{
float hueRotateList[] = { 0.0, 90.0, 180.0, 270.0, 360.0 };
for (int i = 0; i < 5; i++) {
int x = (i % 2) * 510;
int y = (i / 2) * 510;
auto testNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, 500, 500 });
for (int i = 0; i < FIVE_; i++) {
int x = (i % TWO_) * FIVE_HUNDRED_TEN_;
int y = (i / TWO_) * FIVE_HUNDRED_TEN_;
auto testNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNode->SetHueRotate(hueRotateList[i]);
GetRootNode()->AddChild(testNode);
RegisterNode(testNode);
@ -129,10 +130,10 @@ GRAPHIC_TEST(ForegroundTest01, CONTENT_DISPLAY_TEST, HueRotate_Test_1)
GRAPHIC_TEST(ForegroundTest01, CONTENT_DISPLAY_TEST, ColorBlend_Test_1)
{
uint32_t colorList[] = { 0xffffffff, 0xff000000, 0xffff0000, 0xff00ff00, 0xff0000ff, 0x00000000 };
for (int i = 0; i < 6; i++) {
int x = (i % 2) * 510;
int y = (i / 2) * 510;
auto testNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, 500, 500 });
for (int i = 0; i < SIX_; i++) {
int x = (i % TWO_) * FIVE_HUNDRED_TEN_;
int y = (i / TWO_) * FIVE_HUNDRED_TEN_;
auto testNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNode->SetColorBlend(colorList[i]);
GetRootNode()->AddChild(testNode);
RegisterNode(testNode);
@ -145,10 +146,10 @@ GRAPHIC_TEST(ForegroundTest01, CONTENT_DISPLAY_TEST, Color_AiInvert_Test_1)
GetRootNode()->AddChild(testFaNode);
RegisterNode(testFaNode);
Vector4f param_list[] = { { 0.0, 1.0, 0.5, 0.2 }, { 0.2, 0.5, 0.2, 0.2 }, { 0.0, 1.0, 0.5, 0.0 } };
for (int i = 0; i < 3; i++) {
int y = i * 310;
for (int i = 0; i < THREE_; i++) {
int y = i * THREE_HUNDRED_TEN_;
auto testNode = RSCanvasNode::Create();
testNode->SetBounds({ 0.0, y, 1000.0, 310.0 });
testNode->SetBounds({ 0.0, y, ONE_THOUSAND_, THREE_HUNDRED_TEN_ });
testNode->SetAiInvert(param_list[i]);
testFaNode->AddChild(testNode);
RegisterNode(testNode);

View File

@ -17,6 +17,7 @@
#define PARAMETERS_DEFINATION_H
#define ZERO_ 0
#define ZERO_POINT_FIVE_ 0.5
#define ONE_ 1
#define TWO_ 2
#define THREE_ 3
@ -39,6 +40,7 @@
#define TWO_HUNDRED_ 200
#define TWO_HUNDRED_FIFTY_ 250
#define THREE_HUNDRED_ 300
#define THREE_HUNDRED_TEN_ 310
#define FOUR_HUNDRED_ 400
#define FIVE_HUNDRED_ 500
#define FIVE_HUNDRED_TEN_ 510
@ -47,4 +49,6 @@
#define SIX_HUNDRED_ 600
#define SIX_HUNDRED_TEN_ 610
#define ONE_THOUSAND_ 1000
#endif // PARAMETERS_DEFINATION_H

View File

@ -16,6 +16,8 @@
#include "rs_graphic_test.h"
#include "rs_graphic_test_img.h"
#include "ui/rs_effect_node.h"
using namespace testing;
using namespace testing::ext;
@ -52,30 +54,39 @@ GRAPHIC_TEST(BackgroundTest01, CONTENT_DISPLAY_TEST, Use_Effect_Test)
int rowCount = 2;
auto sizeX = screenWidth / columnCount;
auto sizeY = screenHeight / rowCount;
const bool useEffectList[] = { false, true, false };
for (int i = 0; i < 2; i++) {
int x = (i % columnCount) * sizeX;
int y = (i / columnCount) * sizeY;
auto testNodeBackGround =
SetUpNodeBgImage("/data/local/tmp/Images/backGroundImage.jpg", { x, y, sizeX - 10, sizeY - 10 });
auto effectNode = RSEffectNode::Create();
effectNode->SetBounds({ x, y, sizeX - 10, sizeY - 10 });
effectNode->SetFrame({ x, y, sizeX - 10, sizeY - 10 });
effectNode->SetBackgroundColor(0xffff0000);
effectNode->SetBackgroundFilter(RSFilter::CreateBlurFilter(10, 10));
GetRootNode()->AddChild(effectNode);
RegisterNode(effectNode);
auto childNode1 =
SetUpNodeBgImage("/data/local/tmp/Images/475x327.jpg", { sizeX / 4, sizeY / 4, sizeX / 3, sizeY / 3 });
setNode(childNode1, 0.3);
childNode1->SetFrame({ sizeX / 4, sizeY / 4, sizeX / 3, sizeY / 3 });
childNode1->SetUseEffect(useEffectList[i]);
childNode1->SetBorderStyle(0, 0, 0, 0);
childNode1->SetBorderWidth(5, 5, 5, 5);
childNode1->SetBorderColor(Vector4<Color>(RgbPalette::Green()));
RegisterNode(childNode1);
auto childNode2 = RSCanvasNode::Create();
childNode2->SetBounds({ sizeX / 2, sizeY / 2, sizeX / 3, sizeY / 3 });
effectNode->AddChild(childNode1);
auto childNode2 =
SetUpNodeBgImage("/data/local/tmp/appearance_test.jpg", { sizeX / 2, sizeY / 2, sizeX / 3, sizeY / 3 });
childNode2->SetFrame({ sizeX / 2, sizeY / 2, sizeX / 3, sizeY / 3 });
childNode2->SetBackgroundColor(0xff00ff00);
setNode(childNode2, 0.5);
childNode2->SetUseEffect(useEffectList[i + 1]);
childNode2->SetBorderStyle(0, 0, 0, 0);
childNode2->SetBorderWidth(5, 5, 5, 5);
childNode2->SetBorderColor(Vector4<Color>(RgbPalette::Red()));
RegisterNode(childNode2);
testNodeBackGround->SetBounds({ x, y, sizeX - 10, sizeY - 10 });
testNodeBackGround->AddChild(childNode1);
testNodeBackGround->AddChild(childNode2);
testNodeBackGround->SetUseEffect(i);
testNodeBackGround->SetBorderStyle(0, 0, 0, 0);
testNodeBackGround->SetBorderWidth(5, 5, 5, 5);
testNodeBackGround->SetBorderColor(Vector4<Color>(RgbPalette::Green()));
GetRootNode()->AddChild(testNodeBackGround);
RegisterNode(testNodeBackGround);
effectNode->AddChild(childNode2);
}
}

View File

@ -66,16 +66,16 @@ void TextCustomModifier::SetText(std::string text)
void TextCustomModifier::Draw(RSDrawingContext& context) const
{
if (!text_)
if (text_ == nullptr)
return;
uint32_t colorInt = 0xff000000;
Vector2f position = { 0.0, 0.0 };
float fontSize = 16;
if (!color_)
if (color_ != nullptr)
colorInt = color_->Get();
if (!position_)
if (position_ != nullptr)
position = position_->Get();
if (!size_)
if (size_ != nullptr)
fontSize = size_->Get();
auto brushColor = OHOS::Rosen::Drawing::Color(colorInt);
Drawing::Brush brush;

View File

@ -114,25 +114,25 @@ int OH_NativeVSync_RequestFrameWithMultiCallback(
int OH_NativeVSync_GetPeriod(OH_NativeVSync* nativeVsync, long long* period);
/**
* @brief Enable DVSync to improve the smoothness of self-drawn animation scenes.
* DVSync stands for Decoupled VSync, a frame timing management strategy decoupled from hardware VSync.
* DVSync drives the early rendering of subsequent animation frames by sending VSync signals with future timestamps
* in advance, which are then cached in the frame buffer queue. DVSync reduces the possibility of future frame drops
* by caching pre-rendered frames for display, thereby improving the smoothness of animation scenes.
* Because DVSync requires the use of free self-drawn frame buffers to cache pre-rendered animation frames, users need
* to ensure that there is at least one free frame buffer, otherwise it is not recommended to enable this feature.
* After enabling DVSync, users need to respond correctly to the VSync signal sent in advance, and request
* the next VSync after the animation frame corresponding to the previous VSync has completed, and the self-drawn
* frame needs to carry a timestamp consistent with its VSync event.
* After the animation ends, the user needs to disable DVSync.
* On platforms that do not support DVSync or if another application has already enabled DVSync, the current
* enable operation will not take effect and the application will still receive normal VSync signals.
* @brief Enables DVSync to improve the smoothness of self-drawing animations.
* DVSync, short for Decoupled VSync, is a frame timing management policy that is decoupled from the hardware's VSync.
* DVSync drives the early rendering of upcoming animation frames by sending VSync signals with future timestamps.
* These frames are stored in a frame buffer queue. This helps DVSync reduce potential frame drop and therefore
* enhances the smoothness of animations.
* DVSync requires free self-drawing frame buffers to store these pre-rendered animation frames.
* Therefore, you must ensure that at least one free frame buffer is available. Otherwise, do not enable DVSync.
* After DVSync is enabled, you must correctly respond to the early VSync signals and request the subsequent VSync
* after the animation frame associated with the previous VSync is complete. In addition, the self-drawing frames must
* carry timestamps that align with VSync.
* After the animation ends, disable DVSync.
* On a platform that does not support DVSync or if another application has enabled DVSync, the attempt to enable it
* will not take effect, and the application still receives normal VSync signals.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeVsync
* @param nativeVsync Indicates the pointer to a NativeVsync.
* @param enable Indicates enable or disable DVSync, true indicates enable, false indicates disable.
* @param enable Whether to enable DVSync.The value true means to enable DVSync, and false means the opposite.
* @return {@link NATIVE_ERROR_OK} 0 - Success.
* {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - the parameter nativeVsync is NULL or callback is NULL.
* {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - the parameter nativeVsync is NULL.
* {@link NATIVE_ERROR_BINDER_ERROR} 50401000 - ipc send failed.
* @since 14
* @version 1.0

View File

@ -11,6 +11,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import("//foundation/graphic/graphic_2d/graphic_config.gni")
group("napi_packages") {
deps = [
"graphic/animation/window_animation_manager:windowanimationmanager_napi",
@ -22,6 +24,9 @@ group("napi_packages") {
"graphic/hyper_graphic_manager:libhgmnapi",
"graphic/text:textnapi",
"graphic/ui_effect:uieffect_napi",
"graphic/webgl:libwebglnapi",
]
if (rs_enable_gpu) {
deps += [ "graphic/webgl:libwebglnapi" ]
}
}

View File

@ -210,7 +210,7 @@ T* CheckSendableParamsAndGetThis(const napi_env env, napi_callback_info info, co
}
napi_value& resObject = propertyNameValue ? propertyNameValue : object;
if (resObject) {
return napi_unwrap(env, resObject, (void **)(&pointerValue)) == napi_ok ?
return napi_unwrap_sendable(env, resObject, (void **)(&pointerValue)) == napi_ok ?
reinterpret_cast<T*>(pointerValue) : nullptr;
}
return nullptr;

View File

@ -36,4 +36,4 @@ private:
} // namespace ColorManager
} // namespace OHOS
#endif // OHOS_JS_COLOR_SPACE_MANAGER_H
#endif // OHOS_JS_SENDABLE_COLOR_SPACE_MANAGER_H

View File

@ -148,6 +148,7 @@ if (is_arkui_x) {
external_deps += [
"hilog:libhilog",
"image_framework:image_native",
"image_framework:image_utils",
"init:libbegetutil",
]
deps += [ "../../../../../utils:libgraphic_utils" ]

View File

@ -20,7 +20,7 @@
#include "src/utils/SkUTF.h"
#ifdef ROSEN_OHOS
#include "pixel_map.h"
#include "image_utils.h"
#include "pixel_map_napi.h"
#endif
#include "native_value.h"
@ -114,6 +114,7 @@ struct PixelMapReleaseContext {
~PixelMapReleaseContext()
{
ImageUtils::FlushSurfaceBuffer(pixelMap_.get());
pixelMap_ = nullptr;
}
@ -347,6 +348,7 @@ napi_value JsCanvas::Constructor(napi_env env, napi_callback_info info)
Canvas* canvas = new Canvas();
canvas->Bind(bitmap);
JsCanvas *jsCanvas = new JsCanvas(canvas, true);
jsCanvas->mPixelMap_ = pixelMapNapi->GetPixelNapiInner();
status = napi_wrap(env, jsThis, jsCanvas, JsCanvas::Destructor, nullptr, nullptr);
if (status != napi_ok) {
delete jsCanvas;
@ -503,6 +505,9 @@ napi_value JsCanvas::OnClear(napi_env env, napi_callback_info info)
}
JS_CALL_DRAWING_FUNC(m_canvas->Clear(color));
#ifdef ROSEN_OHOS
ImageUtils::FlushSurfaceBuffer(mPixelMap_.get());
#endif
return nullptr;
}
@ -518,10 +523,8 @@ napi_value JsCanvas::OnDrawShadow(napi_env env, napi_callback_info info)
ROSEN_LOGE("JsCanvas::OnDrawShadow canvas is null.");
return NapiThrowError(env, DrawingErrorCode::ERROR_INVALID_PARAM, "Invalid params.");
}
napi_value argv[ARGC_SEVEN] = { nullptr };
CHECK_PARAM_NUMBER_WITHOUT_OPTIONAL_PARAMS(argv, ARGC_SEVEN);
JsPath* jsPath = nullptr;
GET_UNWRAP_PARAM(ARGC_ZERO, jsPath);
@ -569,6 +572,9 @@ napi_value JsCanvas::OnDrawShadow(napi_env env, napi_callback_info info)
spotColor[ARGC_TWO], spotColor[ARGC_THREE]);
m_canvas->DrawShadow(*jsPath->GetPath(), offset, lightPos, lightRadius, ambientColorPara, spotColorPara,
static_cast<ShadowFlags>(shadowFlag));
#ifdef ROSEN_OHOS
ImageUtils::FlushSurfaceBuffer(mPixelMap_.get());
#endif
return nullptr;
}
@ -601,6 +607,9 @@ napi_value JsCanvas::OnDrawArc(napi_env env, napi_callback_info info)
GET_DOUBLE_PARAM(ARGC_TWO, sweepAngle);
JS_CALL_DRAWING_FUNC(m_canvas->DrawArc(drawingRect, startAngle, sweepAngle));
#ifdef ROSEN_OHOS
ImageUtils::FlushSurfaceBuffer(mPixelMap_.get());
#endif
return nullptr;
}
@ -646,6 +655,9 @@ napi_value JsCanvas::OnDrawRect(napi_env env, napi_callback_info info)
DRAWING_PERFORMANCE_TEST_NAP_RETURN(nullptr);
m_canvas->DrawRect(drawingRect);
#ifdef ROSEN_OHOS
ImageUtils::FlushSurfaceBuffer(mPixelMap_.get());
#endif
return nullptr;
}
@ -676,6 +688,9 @@ napi_value JsCanvas::OnDrawCircle(napi_env env, napi_callback_info info)
Drawing::Point centerPt = Drawing::Point(x, y);
DRAWING_PERFORMANCE_TEST_NAP_RETURN(nullptr);
m_canvas->DrawCircle(centerPt, radius);
#ifdef ROSEN_OHOS
ImageUtils::FlushSurfaceBuffer(mPixelMap_.get());
#endif
return nullptr;
}
@ -746,6 +761,7 @@ napi_value JsCanvas::OnDrawImage(napi_env env, napi_callback_info info)
m_canvas->DrawImage(*image, px, py, *samplingOptions.get());
}
ImageUtils::FlushSurfaceBuffer(mPixelMap_.get());
#endif
return nullptr;
}
@ -821,6 +837,9 @@ napi_value JsCanvas::OnDrawColor(napi_env env, napi_callback_info info)
return NapiThrowError(env, DrawingErrorCode::ERROR_INVALID_PARAM, "Invalid params.");
}
#ifdef ROSEN_OHOS
ImageUtils::FlushSurfaceBuffer(mPixelMap_.get());
#endif
return nullptr;
}
@ -847,6 +866,9 @@ napi_value JsCanvas::OnDrawOval(napi_env env, napi_callback_info info)
Drawing::Rect drawingRect = Drawing::Rect(ltrb[ARGC_ZERO], ltrb[ARGC_ONE], ltrb[ARGC_TWO], ltrb[ARGC_THREE]);
JS_CALL_DRAWING_FUNC(m_canvas->DrawOval(drawingRect));
#ifdef ROSEN_OHOS
ImageUtils::FlushSurfaceBuffer(mPixelMap_.get());
#endif
return nullptr;
}
@ -874,6 +896,9 @@ napi_value JsCanvas::OnDrawPoint(napi_env env, napi_callback_info info)
DRAWING_PERFORMANCE_TEST_NAP_RETURN(nullptr);
m_canvas->DrawPoint(Point(px, py));
#ifdef ROSEN_OHOS
ImageUtils::FlushSurfaceBuffer(mPixelMap_.get());
#endif
return nullptr;
}
@ -930,6 +955,9 @@ napi_value JsCanvas::OnDrawPoints(napi_env env, napi_callback_info info)
return nullptr;
}
JS_CALL_DRAWING_FUNC(m_canvas->DrawPoints(PointMode::POINTS_POINTMODE, size, points));
#ifdef ROSEN_OHOS
ImageUtils::FlushSurfaceBuffer(mPixelMap_.get());
#endif
delete [] points;
return nullptr;
}
@ -947,6 +975,9 @@ napi_value JsCanvas::OnDrawPoints(napi_env env, napi_callback_info info)
return nullptr;
}
JS_CALL_DRAWING_FUNC(m_canvas->DrawPoints(static_cast<PointMode>(pointMode), size, points));
#ifdef ROSEN_OHOS
ImageUtils::FlushSurfaceBuffer(mPixelMap_.get());
#endif
delete [] points;
return nullptr;
}
@ -978,6 +1009,9 @@ napi_value JsCanvas::OnDrawPath(napi_env env, napi_callback_info info)
DRAWING_PERFORMANCE_TEST_NAP_RETURN(nullptr);
m_canvas->DrawPath(*jsPath->GetPath());
#ifdef ROSEN_OHOS
ImageUtils::FlushSurfaceBuffer(mPixelMap_.get());
#endif
return nullptr;
}
@ -1009,6 +1043,9 @@ napi_value JsCanvas::OnDrawLine(napi_env env, napi_callback_info info)
DRAWING_PERFORMANCE_TEST_NAP_RETURN(nullptr);
m_canvas->DrawLine(Point(startPx, startPy), Point(endPx, endPy));
#ifdef ROSEN_OHOS
ImageUtils::FlushSurfaceBuffer(mPixelMap_.get());
#endif
return nullptr;
}
@ -1038,6 +1075,9 @@ napi_value JsCanvas::OnDrawText(napi_env env, napi_callback_info info)
DRAWING_PERFORMANCE_TEST_NAP_RETURN(nullptr);
m_canvas->DrawTextBlob(jsTextBlob->GetTextBlob().get(), x, y);
#ifdef ROSEN_OHOS
ImageUtils::FlushSurfaceBuffer(mPixelMap_.get());
#endif
return nullptr;
}
@ -1092,6 +1132,9 @@ napi_value JsCanvas::OnDrawSingleCharacter(napi_env env, napi_callback_info info
"Parameter verification failed. Input parameter0 should be single character.");
}
m_canvas->DrawSingleCharacter(unicode, *font, x, y);
#ifdef ROSEN_OHOS
ImageUtils::FlushSurfaceBuffer(mPixelMap_.get());
#endif
return nullptr;
}
@ -1177,6 +1220,7 @@ napi_value JsCanvas::OnDrawPixelMapMesh(napi_env env, napi_callback_info info)
if (colorsSize == 0) {
DrawingPixelMapMesh(pixelMap, column, row, verticesMesh, nullptr, m_canvas);
ImageUtils::FlushSurfaceBuffer(mPixelMap_.get());
delete []vertices;
return nullptr;
}
@ -1203,6 +1247,7 @@ napi_value JsCanvas::OnDrawPixelMapMesh(napi_env env, napi_callback_info info)
uint32_t* colorsMesh = colors + colorOffset;
DrawingPixelMapMesh(pixelMap, column, row, verticesMesh, colorsMesh, m_canvas);
ImageUtils::FlushSurfaceBuffer(mPixelMap_.get());
delete []vertices;
delete []colors;
return nullptr;
@ -1233,6 +1278,9 @@ napi_value JsCanvas::OnDrawRegion(napi_env env, napi_callback_info info)
return nullptr;
}
JS_CALL_DRAWING_FUNC(m_canvas->DrawRegion(*jsRegion->GetRegion()));
#ifdef ROSEN_OHOS
ImageUtils::FlushSurfaceBuffer(mPixelMap_.get());
#endif
return nullptr;
}
@ -1260,6 +1308,9 @@ napi_value JsCanvas::OnDrawBackground(napi_env env, napi_callback_info info)
}
m_canvas->DrawBackground(*jsBrush->GetBrush());
#ifdef ROSEN_OHOS
ImageUtils::FlushSurfaceBuffer(mPixelMap_.get());
#endif
return nullptr;
}
@ -1283,6 +1334,9 @@ napi_value JsCanvas::OnDrawRoundRect(napi_env env, napi_callback_info info)
GET_UNWRAP_PARAM(ARGC_ZERO, jsRoundRect);
m_canvas->DrawRoundRect(jsRoundRect->GetRoundRect());
#ifdef ROSEN_OHOS
ImageUtils::FlushSurfaceBuffer(mPixelMap_.get());
#endif
return nullptr;
}
@ -1309,6 +1363,9 @@ napi_value JsCanvas::OnDrawNestedRoundRect(napi_env env, napi_callback_info info
GET_UNWRAP_PARAM(ARGC_ONE, jsInner);
m_canvas->DrawNestedRoundRect(jsOuter->GetRoundRect(), jsInner->GetRoundRect());
#ifdef ROSEN_OHOS
ImageUtils::FlushSurfaceBuffer(mPixelMap_.get());
#endif
return nullptr;
}
@ -2040,6 +2097,7 @@ napi_value JsCanvas::OnDrawImageRect(napi_env env, napi_callback_info info)
DRAWING_PERFORMANCE_TEST_NAP_RETURN(nullptr);
m_canvas->DrawImageRect(*image, dstRect, *samplingOptions.get());
}
ImageUtils::FlushSurfaceBuffer(mPixelMap_.get());
#endif
return nullptr;
}
@ -2125,7 +2183,9 @@ napi_value JsCanvas::OnDrawImageRectWithSrc(napi_env env, napi_callback_info inf
}
Drawing::Rect dstRect = Drawing::Rect(ltrb[ARGC_ZERO], ltrb[ARGC_ONE], ltrb[ARGC_TWO], ltrb[ARGC_THREE]);
return OnDrawingImageRectWithSrc(env, argv, argc, *m_canvas, *image, srcRect, dstRect);
napi_value result = OnDrawingImageRectWithSrc(env, argv, argc, *m_canvas, *image, srcRect, dstRect);
ImageUtils::FlushSurfaceBuffer(mPixelMap_.get());
return result;
#else
return nullptr;
#endif

View File

@ -18,6 +18,9 @@
#include <native_engine/native_engine.h>
#include <native_engine/native_value.h>
#ifdef ROSEN_OHOS
#include "pixel_map.h"
#endif
namespace OHOS::Rosen {
namespace Drawing {
@ -150,6 +153,9 @@ private:
static thread_local napi_ref constructor_;
Canvas* m_canvas = nullptr;
bool owned_ = false;
#ifdef ROSEN_OHOS
std::shared_ptr<Media::PixelMap> mPixelMap_ = nullptr;
#endif
};
} // namespace Drawing
} // namespace OHOS::Rosen

View File

@ -18,7 +18,6 @@
#include "ability.h"
#include "napi_async_work.h"
#include "utils/text_log.h"
namespace OHOS::Rosen {
namespace {
@ -440,6 +439,7 @@ napi_value JsFontCollection::LoadFontAsync(napi_env env, napi_callback_info info
napi_value JsFontCollection::OnLoadFontAsync(napi_env env, napi_callback_info info)
{
sptr<FontArgumentsConcreteContext> context = sptr<FontArgumentsConcreteContext>::MakeSptr();
NAPI_CHECK_AND_THROW_ERROR(context != nullptr, TextErrorCode::ERROR_NO_MEMORY, "Failed to make context");
auto inputParser = [env, context](size_t argc, napi_value* argv) {
TEXT_ERROR_CHECK(argv != nullptr, return, "Argv is null");
NAPI_CHECK_ARGS(context, context->status == napi_ok, napi_invalid_arg,

View File

@ -96,6 +96,7 @@ napi_value JsFontDescriptor::MatchFontDescriptorsAsync(napi_env env, napi_callba
std::set<FontDescSharedPtr> matchResult;
};
sptr<MatchFontDescriptorsContext> cb = sptr<MatchFontDescriptorsContext>::MakeSptr();
NAPI_CHECK_AND_THROW_ERROR(cb != nullptr, TextErrorCode::ERROR_NO_MEMORY, "Failed to make context");
auto inputParser = [env, cb](size_t argc, napi_value *argv) {
cb->status = napi_invalid_arg;
cb->errCode = static_cast<int32_t>(TextErrorCode::ERROR_INVALID_PARAM);

View File

@ -148,7 +148,7 @@ napi_value JsLineTypeset::OnGetLineBreak(napi_env env, napi_callback_info info)
return NapiThrowError(env, TextErrorCode::ERROR_INVALID_PARAM, "Argv convert failed.");
}
size_t limitSize = lineTypography_->GetUnicodeSize();
if (index < 0 || index >= limitSize || width <= 0) {
if (index < 0 || limitSize <= static_cast<size_t>(index) || width <= 0) {
return NapiThrowError(env, TextErrorCode::ERROR_INVALID_PARAM, "Params exceeds reasonable range.");
}
size_t count = static_cast<size_t>(lineTypography_->GetLineBreak(static_cast<size_t>(index), width));
@ -178,7 +178,7 @@ napi_value JsLineTypeset::OnCreateLine(napi_env env, napi_callback_info info)
return NapiThrowError(env, TextErrorCode::ERROR_INVALID_PARAM, "Argv convert failed");
}
size_t limitSize = lineTypography_->GetUnicodeSize();
if (index < 0 || index >= limitSize || count < 0 || count + index > limitSize) {
if (index < 0 || limitSize <= static_cast<size_t>(index) || count < 0 || count + index > limitSize) {
return NapiThrowError(env, TextErrorCode::ERROR_INVALID_PARAM, "Params exceeds reasonable range.");
}
auto textLineBase = lineTypography_->CreateLine(static_cast<size_t>(index), static_cast<size_t>(count));

View File

@ -17,6 +17,7 @@
#include "line_typeset_napi/js_line_typeset.h"
#include "napi_common.h"
#include "paragraph_napi/js_paragraph.h"
#include "utils/string_util.h"
#include "utils/text_log.h"
namespace OHOS::Rosen {
@ -168,6 +169,10 @@ napi_value JsParagraphBuilder::OnAddText(napi_env env, napi_callback_info info)
}
std::string text = "";
if (ConvertFromJsValue(env, argv[0], text)) {
if (!IsUtf8(text.c_str(), text.size())) {
TEXT_LOGE("Invalid utf-8 text");
return NapiThrowError(env, TextErrorCode::ERROR_INVALID_PARAM, "Invalid params.");
}
typographyCreate_->AppendText(Str8ToStr16(text));
}
return NapiGetUndefined(env);

View File

@ -806,6 +806,7 @@ napi_value JsParagraph::OnLayoutAsync(napi_env env, napi_callback_info info)
double width = 0.0;
};
sptr<ConcreteContext> context = sptr<ConcreteContext>::MakeSptr();
NAPI_CHECK_AND_THROW_ERROR(context != nullptr, TextErrorCode::ERROR_NO_MEMORY, "Failed to make context");
auto inputParser = [env, context](size_t argc, napi_value* argv) {
TEXT_ERROR_CHECK(argv, return, "Argv is null");
NAPI_CHECK_ARGS(context, context->status == napi_ok, napi_invalid_arg,

View File

@ -15,12 +15,11 @@
#include "napi_async_work.h"
#include "napi_common.h"
#include "utils/text_log.h"
namespace OHOS::Rosen {
ContextBase::~ContextBase()
{
TEXT_LOGI("No memory leak after callback or promise[resolved/rejected]");
TEXT_LOGD("Entry");
TEXT_CHECK(env != nullptr, return);
TEXT_CHECK(work == nullptr, status = napi_delete_async_work(env, work));
TEXT_ERROR_CHECK(status == napi_ok, return, "Failed to delete async work, status:%{public}d",

View File

@ -24,6 +24,7 @@
#include "napi/native_api.h"
#include "napi/native_common.h"
#include "napi/native_node_api.h"
#include "utils/text_log.h"
namespace OHOS::Rosen {
#define MAX_LOG_SIZE 1024

View File

@ -30,9 +30,40 @@ ohos_source_set("webgl_src") {
"common/napi/n_class.cpp",
"common/napi/n_func_arg.cpp",
"common/napi/n_val.cpp",
"src/egl_manager.cpp",
"src/module.cpp",
"src/util.cpp",
"src/webgl2_rendering_context.cpp",
"src/webgl2_rendering_context_base.cpp",
"src/webgl2_rendering_context_impl.cpp",
"src/webgl2_rendering_context_override.cpp",
"src/webgl_active_info.cpp",
"src/webgl_arg.cpp",
"src/webgl_buffer.cpp",
"src/webgl_framebuffer.cpp",
"src/webgl_program.cpp",
"src/webgl_query.cpp",
"src/webgl_renderbuffer.cpp",
"src/webgl_rendering_context.cpp",
"src/webgl_rendering_context_base.cpp",
"src/webgl_rendering_context_base_impl.cpp",
"src/webgl_rendering_context_basic_base.cpp",
"src/webgl_rendering_context_common.cpp",
"src/webgl_rendering_context_draw.cpp",
"src/webgl_rendering_context_ext.cpp",
"src/webgl_rendering_context_overloads.cpp",
"src/webgl_sampler.cpp",
"src/webgl_shader.cpp",
"src/webgl_shader_precision_format.cpp",
"src/webgl_sync.cpp",
"src/webgl_texture.cpp",
"src/webgl_transform_feedback.cpp",
"src/webgl_uniform_location.cpp",
"src/webgl_vertex_array_object.cpp",
]
external_deps = [
"bounds_checking_function:libsec_shared",
"c_utils:utils",
"egl:libEGL",
"graphic_surface:surface_headers",
@ -41,46 +72,10 @@ ohos_source_set("webgl_src") {
"napi:ace_napi",
]
if (rs_enable_gpu) {
sources += [
"src/egl_manager.cpp",
"src/module.cpp",
"src/util.cpp",
"src/webgl2_rendering_context.cpp",
"src/webgl2_rendering_context_base.cpp",
"src/webgl2_rendering_context_impl.cpp",
"src/webgl2_rendering_context_override.cpp",
"src/webgl_active_info.cpp",
"src/webgl_arg.cpp",
"src/webgl_buffer.cpp",
"src/webgl_framebuffer.cpp",
"src/webgl_program.cpp",
"src/webgl_query.cpp",
"src/webgl_renderbuffer.cpp",
"src/webgl_rendering_context.cpp",
"src/webgl_rendering_context_base.cpp",
"src/webgl_rendering_context_base_impl.cpp",
"src/webgl_rendering_context_basic_base.cpp",
"src/webgl_rendering_context_common.cpp",
"src/webgl_rendering_context_draw.cpp",
"src/webgl_rendering_context_ext.cpp",
"src/webgl_rendering_context_overloads.cpp",
"src/webgl_sampler.cpp",
"src/webgl_shader.cpp",
"src/webgl_shader_precision_format.cpp",
"src/webgl_sync.cpp",
"src/webgl_texture.cpp",
"src/webgl_transform_feedback.cpp",
"src/webgl_uniform_location.cpp",
"src/webgl_vertex_array_object.cpp",
]
deps = [
"$graphic_2d_root/frameworks/opengl_wrapper:EGL",
"$graphic_2d_root/frameworks/opengl_wrapper:GLESv3",
]
external_deps += [ "bounds_checking_function:libsec_shared" ]
}
deps = [
"$graphic_2d_root/frameworks/opengl_wrapper:EGL",
"$graphic_2d_root/frameworks/opengl_wrapper:GLESv3",
]
cflags = [
"-Wall",
@ -101,12 +96,8 @@ ohos_source_set("webgl_src") {
ohos_shared_library("libwebglnapi") {
external_deps = [ "hilog:libhilog" ]
deps = [ ":webgl_src" ]
if (rs_enable_gpu) {
install_enable = true
relative_install_dir = "module"
} else {
install_enable = false
}
install_enable = true
relative_install_dir = "module"
part_name = "graphic_2d"
subsystem_name = "graphic"
}

View File

@ -2804,7 +2804,7 @@ GLenum WebGLRenderingContextBaseImpl::GetBoundFrameBufferColorFormat(napi_env en
VertexAttribInfo* WebGLRenderingContextBaseImpl::GetVertexAttribInfo(GLint index)
{
if (index >= static_cast<GLint>(arrayVertexAttribs_.size())) {
if (index < 0 || index >= static_cast<GLint>(arrayVertexAttribs_.size())) {
LOGE("Invalid index for VertexAttrib %{public}d, max %{public}zu",
index, arrayVertexAttribs_.size());
return nullptr;

View File

@ -93,7 +93,7 @@ void RunImpl::GetStringRange(uint64_t* location, uint64_t* length) const
if (location == nullptr || length == nullptr) {
return;
} else if (run_ == nullptr) {
*location= 0;
*location = 0;
*length = 0;
return;
}

View File

@ -462,6 +462,18 @@ void Typography::UpdateColor(size_t from, size_t to, const Drawing::Color& color
}
paragraph_->UpdateColor(from, to, color);
}
Drawing::RectI Typography::GeneratePaintRegion(double x, double y) const
{
std::unique_lock<std::shared_mutex> writeLock(mutex_);
if (!paragraph_) {
double left = std::floor(x);
double top = std::floor(y);
return Drawing::RectI(left, top, left, top);
}
return paragraph_->GeneratePaintRegion(x, y);
}
} // namespace AdapterTxt
} // namespace Rosen
} // namespace OHOS

View File

@ -76,6 +76,7 @@ public:
std::unique_ptr<OHOS::Rosen::Typography> CloneSelf() override;
void UpdateColor(size_t from, size_t to, const Drawing::Color& color) override;
void* GetParagraph() override { return reinterpret_cast<void*>(paragraph_.get()); }
Drawing::RectI GeneratePaintRegion(double x, double y) const override;
private:
std::unique_ptr<SPText::Paragraph> paragraph_ = nullptr;
std::vector<TextStyle> lineMetricsStyles_;

View File

@ -163,6 +163,7 @@ public:
virtual void UpdateColor(size_t from, size_t to, const Drawing::Color& color) = 0;
virtual double GetLongestLineWithIndent() const = 0;
virtual void* GetParagraph() = 0;
virtual Drawing::RectI GeneratePaintRegion(double x, double y) const = 0;
};
} // namespace Rosen
} // namespace OHOS

View File

@ -28,6 +28,7 @@ namespace Rosen {
struct TextTab {
TextTab() = default;
TextTab(TextAlign alignment, float location) : alignment(alignment), location(location) {};
TextTab(const TextTab& other) : alignment(other.alignment), location(other.location) {};
TextTab& operator=(const TextTab&) = default;
bool operator==(const TextTab& rhs) const

View File

@ -244,7 +244,7 @@ ohos_source_set("skia_unicode") {
public_configs = [ ":skia_libtxt_config" ]
include_dirs = []
defines = []
defines = [ "OHOS_SUPPORT" ]
sources = []
public = [ "$skunicode_root/include/SkUnicode.h" ]

View File

@ -416,6 +416,19 @@ void ParagraphImpl::RecordDifferentPthreadCall(const char* caller) const
threadId_ = currenetThreadId;
}
}
Drawing::RectI ParagraphImpl::GeneratePaintRegion(double x, double y)
{
RecordDifferentPthreadCall("GeneratePaintRegion");
if (!paragraph_) {
double left = std::floor(x);
double top = std::floor(y);
return Drawing::RectI(left, top, left, top);
}
SkIRect skIRect = paragraph_->generatePaintRegion(SkDoubleToScalar(x), SkDoubleToScalar(y));
return Drawing::RectI(skIRect.left(), skIRect.top(), skIRect.right(), skIRect.bottom());
}
} // namespace SPText
} // namespace Rosen
} // namespace OHOS

View File

@ -120,6 +120,7 @@ public:
std::unique_ptr<Paragraph> CloneSelf() override;
TextStyle SkStyleToTextStyle(const skia::textlayout::TextStyle& skStyle) override;
void UpdateColor(size_t from, size_t to, const RSColor& color) override;
Drawing::RectI GeneratePaintRegion(double x, double y) override;
private:
void RecordDifferentPthreadCall(const char* caller) const;

View File

@ -96,7 +96,7 @@ void RunImpl::GetStringRange(uint64_t* location, uint64_t* length) const
if (location == nullptr || length == nullptr) {
return;
} else if (runBase_ == nullptr) {
*location= 0;
*location = 0;
*length = 0;
return;
}

View File

@ -197,6 +197,7 @@ public:
virtual TextStyle SkStyleToTextStyle(const skia::textlayout::TextStyle& skStyle) = 0;
virtual void UpdateColor(size_t from, size_t to, const RSColor& color) = 0;
virtual Range<size_t> GetEllipsisTextRange() = 0;
virtual OHOS::Rosen::Drawing::RectI GeneratePaintRegion(double x, double y) = 0;
};
} // namespace SPText
} // namespace Rosen

View File

@ -40,6 +40,7 @@ enum class BreakStrategy {
struct TextTab {
TextTab() = default;
TextTab(TextAlign alignment, float location) : alignment(alignment), location(location) {};
TextTab(const TextTab& other) : alignment(other.alignment), location(other.location) {};
TextTab& operator=(const TextTab&) = default;
TextAlign alignment = TextAlign::LEFT;
static constexpr float INVALID_LOCATION = -1.0f;

View File

@ -27,7 +27,7 @@ namespace OHOS {
namespace Rosen {
namespace SPText {
#ifdef OHOS_TEXT_ENABLE
bool TextBundleConfigParser::IsMetaDataExistInEntryModule(const std::string& metaData)
bool TextBundleConfigParser::IsMetaDataExistInModule(const std::string& metaData)
{
auto bundleMgr = GetSystemAbilityManager();
if (bundleMgr == nullptr) {
@ -45,20 +45,15 @@ bool TextBundleConfigParser::IsMetaDataExistInEntryModule(const std::string& met
return false;
}
auto infoIter = std::find_if(bundleInfo.hapModuleInfos.begin(), bundleInfo.hapModuleInfos.end(),
[](const AppExecFwk::HapModuleInfo info) {
return info.moduleType == AppExecFwk::ModuleType::ENTRY;
});
if (infoIter == bundleInfo.hapModuleInfos.end()) {
TEXT_LOGD("Entry module not found");
return false;
for (const auto& info : bundleInfo.hapModuleInfos) {
for (const auto& data : info.metadata) {
if (data.name == metaData) {
return true;
}
}
}
auto& dataList = infoIter->metadata;
return std::find_if(dataList.begin(), dataList.end(),
[&metaData](const AppExecFwk::Metadata& data) {
return data.name == metaData;
}) != dataList.end();
return false;
}
sptr<AppExecFwk::IBundleMgr> TextBundleConfigParser::GetSystemAbilityManager()
@ -84,7 +79,7 @@ bool TextBundleConfigParser::IsAdapterTextHeightEnabled()
#ifdef OHOS_TEXT_ENABLE
static bool adapterTextHeight = []() {
const std::string ADAPTER_TEXT_HEIGHT_META_DATA = "ohos.graphics2d.text.adapter_text_height";
auto enabled = IsMetaDataExistInEntryModule(ADAPTER_TEXT_HEIGHT_META_DATA);
auto enabled = IsMetaDataExistInModule(ADAPTER_TEXT_HEIGHT_META_DATA);
TEXT_LOGI("Adapter text height enabled: %{public}d", enabled);
return enabled;
}();

View File

@ -28,7 +28,7 @@ public:
static bool IsAdapterTextHeightEnabled();
private:
#ifdef OHOS_TEXT_ENABLE
static bool IsMetaDataExistInEntryModule(const std::string& metaData);
static bool IsMetaDataExistInModule(const std::string& metaData);
static sptr<AppExecFwk::IBundleMgr> GetSystemAbilityManager();
#endif
};

View File

@ -131,7 +131,6 @@ template("graphics2d_source_set") {
"$drawing_core_src_dir/engine_adapter/skia_adapter/skia_surface.cpp",
"$drawing_core_src_dir/engine_adapter/skia_adapter/skia_text_blob.cpp",
"$drawing_core_src_dir/engine_adapter/skia_adapter/skia_text_blob_builder.cpp",
"$drawing_core_src_dir/engine_adapter/skia_adapter/skia_texture_info.cpp",
"$drawing_core_src_dir/engine_adapter/skia_adapter/skia_trace_memory_dump.cpp",
"$drawing_core_src_dir/engine_adapter/skia_adapter/skia_typeface.cpp",
"$drawing_core_src_dir/engine_adapter/skia_adapter/skia_utils.cpp",
@ -141,7 +140,6 @@ template("graphics2d_source_set") {
"$drawing_core_src_dir/image/image.cpp",
"$drawing_core_src_dir/image/picture.cpp",
"$drawing_core_src_dir/image/pixmap.cpp",
"$drawing_core_src_dir/image/trace_memory_dump.cpp",
"$drawing_core_src_dir/recording/cmd_list.cpp",
"$drawing_core_src_dir/recording/cmd_list_helper.cpp",
"$drawing_core_src_dir/recording/draw_cmd.cpp",
@ -169,6 +167,7 @@ template("graphics2d_source_set") {
"$drawing_core_src_dir/utils/region.cpp",
"$drawing_core_src_dir/utils/resource_holder.cpp",
"$drawing_core_src_dir/utils/round_rect.cpp",
"$drawing_core_src_dir/utils/string_util.cpp",
"$drawing_core_src_dir/utils/vertices.cpp",
]
@ -207,7 +206,9 @@ template("graphics2d_source_set") {
sources += [
"$drawing_core_src_dir/engine_adapter/skia_adapter/skia_gpu_context.cpp",
"$drawing_core_src_dir/engine_adapter/skia_adapter/skia_task_executor.cpp",
"$drawing_core_src_dir/engine_adapter/skia_adapter/skia_texture_info.cpp",
"$drawing_core_src_dir/image/gpu_context.cpp",
"$drawing_core_src_dir/image/trace_memory_dump.cpp",
]
defines += [ "RS_ENABLE_GPU" ]

View File

@ -68,7 +68,6 @@ template("drawing_ndk_source_set") {
"$drawing_ndk_src_dir/drawing_font.cpp",
"$drawing_ndk_src_dir/drawing_font_collection.cpp",
"$drawing_ndk_src_dir/drawing_font_mgr.cpp",
"$drawing_ndk_src_dir/drawing_gpu_context.cpp",
"$drawing_ndk_src_dir/drawing_image.cpp",
"$drawing_ndk_src_dir/drawing_image_filter.cpp",
"$drawing_ndk_src_dir/drawing_mask_filter.cpp",
@ -95,6 +94,7 @@ template("drawing_ndk_source_set") {
"$drawing_ndk_src_dir/drawing_text_run.cpp",
"$drawing_ndk_src_dir/drawing_text_typography.cpp",
"$drawing_ndk_src_dir/drawing_typeface.cpp",
"$drawing_ndk_src_dir/font_utils.cpp",
"$drawing_utils_root/drawing_canvas_utils.cpp",
"$drawing_utils_root/native_pixel_map_manager.cpp",
]
@ -104,6 +104,7 @@ template("drawing_ndk_source_set") {
}
if (rs_enable_gpu) {
defines += [ "RS_ENABLE_GPU" ]
sources += [ "$drawing_ndk_src_dir/drawing_gpu_context.cpp" ]
}
if (is_emulator) {
defines += [ "ROSEN_EMULATOR" ]

View File

@ -34,11 +34,6 @@ static const Brush& CastToBrush(const OH_Drawing_Brush& cBrush)
return reinterpret_cast<const Brush&>(cBrush);
}
static ShaderEffect* CastToShaderEffect(OH_Drawing_ShaderEffect* cShaderEffect)
{
return reinterpret_cast<ShaderEffect*>(cShaderEffect);
}
static const Filter& CastToFilter(const OH_Drawing_Filter& cFilter)
{
return reinterpret_cast<const Filter&>(cFilter);
@ -140,7 +135,8 @@ void OH_Drawing_BrushSetShaderEffect(OH_Drawing_Brush* cBrush, OH_Drawing_Shader
brush->SetShaderEffect(nullptr);
return;
}
brush->SetShaderEffect(std::shared_ptr<ShaderEffect>{CastToShaderEffect(cShaderEffect), [](auto p) {}});
auto shaderEffectHandle = Helper::CastTo<OH_Drawing_ShaderEffect*, NativeHandle<ShaderEffect>*>(cShaderEffect);
brush->SetShaderEffect(shaderEffectHandle->value);
}
void OH_Drawing_BrushSetShadowLayer(OH_Drawing_Brush* cBrush, OH_Drawing_ShadowLayer* cShadowLayer)

View File

@ -402,7 +402,7 @@ float OH_Drawing_FontGetMetrics(OH_Drawing_Font* cFont, OH_Drawing_Font_Metrics*
OH_Drawing_ErrorCode OH_Drawing_FontGetBounds(const OH_Drawing_Font* cFont, const uint16_t* glyphs, uint32_t count,
OH_Drawing_Array* bounds)
{
if (cFont == nullptr || glyphs == nullptr || bounds == nullptr || count <= 0) {
if (cFont == nullptr || glyphs == nullptr || bounds == nullptr || count == 0) {
return OH_DRAWING_ERROR_INVALID_PARAMETER;
}
size_t size = 0;

View File

@ -54,11 +54,6 @@ static const Rect* CastToRect(const OH_Drawing_Rect* cRect)
return reinterpret_cast<const Rect*>(cRect);
}
static ShaderEffect* CastToShaderEffect(OH_Drawing_ShaderEffect* cShaderEffect)
{
return reinterpret_cast<ShaderEffect*>(cShaderEffect);
}
static const Filter& CastToFilter(const OH_Drawing_Filter& cFilter)
{
return reinterpret_cast<const Filter&>(cFilter);
@ -288,7 +283,8 @@ void OH_Drawing_PenSetShaderEffect(OH_Drawing_Pen* cPen, OH_Drawing_ShaderEffect
pen->SetShaderEffect(nullptr);
return;
}
pen->SetShaderEffect(std::shared_ptr<ShaderEffect>{CastToShaderEffect(cShaderEffect), [](auto p) {}});
auto shaderEffectHandle = Helper::CastTo<OH_Drawing_ShaderEffect*, NativeHandle<ShaderEffect>*>(cShaderEffect);
pen->SetShaderEffect(shaderEffectHandle->value);
}
void OH_Drawing_PenSetPathEffect(OH_Drawing_Pen* cPen, OH_Drawing_PathEffect* cPathEffect)

View File

@ -193,7 +193,7 @@ OH_Drawing_Array* OH_Drawing_RectCreateArray(size_t size)
return nullptr;
}
obj->num = size;
obj->addr = (OH_Drawing_Rect*)new Rect[size];
obj->addr = reinterpret_cast<OH_Drawing_Rect*>(new Rect[size]);
if (obj->addr == nullptr) {
return nullptr;
}

View File

@ -16,6 +16,7 @@
#include "drawing_shader_effect.h"
#include "drawing_canvas_utils.h"
#include "drawing_helper.h"
#include "effect/shader_effect.h"
@ -48,14 +49,16 @@ static const Matrix* CastToMatrix(const OH_Drawing_Matrix* cMatrix)
return reinterpret_cast<const Matrix*>(cMatrix);
}
static ShaderEffect* CastToShaderEffect(OH_Drawing_ShaderEffect* cShaderEffect)
static OH_Drawing_ShaderEffect* CastShaderEffect(std::shared_ptr<ShaderEffect> shaderEffect)
{
return reinterpret_cast<ShaderEffect*>(cShaderEffect);
NativeHandle<ShaderEffect>* shaderEffectHandle = new NativeHandle<ShaderEffect>;
shaderEffectHandle->value = shaderEffect;
return Helper::CastTo<NativeHandle<ShaderEffect>*, OH_Drawing_ShaderEffect*>(shaderEffectHandle);
}
OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateColorShader(const uint32_t color)
{
return (OH_Drawing_ShaderEffect*)new ShaderEffect(ShaderEffect::ShaderEffectType::COLOR_SHADER, color);
return CastShaderEffect(ShaderEffect::CreateColorShader(color));
}
OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateLinearGradient(const OH_Drawing_Point* cStartPt,
@ -80,8 +83,8 @@ OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateLinearGradient(const OH_Dr
posVector.emplace_back(pos[i]);
}
}
return (OH_Drawing_ShaderEffect*)new ShaderEffect(ShaderEffect::ShaderEffectType::LINEAR_GRADIENT,
*CastToPoint(cStartPt), *CastToPoint(cEndPt), colorsVector, posVector, static_cast<TileMode>(cTileMode));
return CastShaderEffect(ShaderEffect::CreateLinearGradient(
*CastToPoint(cStartPt), *CastToPoint(cEndPt), colorsVector, posVector, static_cast<TileMode>(cTileMode)));
}
OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix(
@ -106,9 +109,9 @@ OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMat
posVector.emplace_back(pos[i]);
}
}
return (OH_Drawing_ShaderEffect*)new ShaderEffect(
ShaderEffect::ShaderEffectType::LINEAR_GRADIENT, *CastToPoint(startPt), *CastToPoint(endPt), colorsVector,
posVector, static_cast<TileMode>(cTileMode), cMatrix ? CastToMatrix(cMatrix) : nullptr);
return CastShaderEffect(ShaderEffect::CreateLinearGradient(
*CastToPoint(startPt), *CastToPoint(endPt), colorsVector,
posVector, static_cast<TileMode>(cTileMode), cMatrix ? CastToMatrix(cMatrix) : nullptr));
}
OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateRadialGradient(const OH_Drawing_Point* cCenterPt, float radius,
@ -130,8 +133,8 @@ OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateRadialGradient(const OH_Dr
posVector.emplace_back(pos[i]);
}
}
return (OH_Drawing_ShaderEffect*)new ShaderEffect(ShaderEffect::ShaderEffectType::RADIAL_GRADIENT,
*CastToPoint(cCenterPt), radius, colorsVector, posVector, static_cast<TileMode>(cTileMode));
return CastShaderEffect(ShaderEffect::CreateRadialGradient(
*CastToPoint(cCenterPt), radius, colorsVector, posVector, static_cast<TileMode>(cTileMode)));
}
OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix(
@ -154,9 +157,9 @@ OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMat
posVector.emplace_back(pos[i]);
}
}
return (OH_Drawing_ShaderEffect*)new ShaderEffect(
ShaderEffect::ShaderEffectType::RADIAL_GRADIENT, *CastToPoint(centerPt), radius, colorsVector, posVector,
static_cast<TileMode>(cTileMode), cMatrix ? CastToMatrix(cMatrix) : nullptr);
return CastShaderEffect(ShaderEffect::CreateRadialGradient(
*CastToPoint(centerPt), radius, colorsVector, posVector,
static_cast<TileMode>(cTileMode), cMatrix ? CastToMatrix(cMatrix) : nullptr));
}
OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateSweepGradient(const OH_Drawing_Point* cCenterPt,
@ -178,9 +181,9 @@ OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateSweepGradient(const OH_Dra
posVector.emplace_back(pos[i]);
}
}
return (OH_Drawing_ShaderEffect*)new ShaderEffect(ShaderEffect::ShaderEffectType::SWEEP_GRADIENT,
return CastShaderEffect(ShaderEffect::CreateSweepGradient(
*CastToPoint(cCenterPt), colorsVector, posVector, static_cast<TileMode>(cTileMode), 0,
360, nullptr); // 360: endAngle
360, nullptr)); // 360: endAngle
}
OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateImageShader(OH_Drawing_Image* cImage, OH_Drawing_TileMode tileX,
@ -196,12 +199,13 @@ OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateImageShader(OH_Drawing_Ima
}
if (cMatrix == nullptr) {
Matrix matrix;
return (OH_Drawing_ShaderEffect*)new ShaderEffect(ShaderEffect::ShaderEffectType::IMAGE, CastToImage(*cImage),
static_cast<TileMode>(tileX), static_cast<TileMode>(tileY), CastToSamplingOptions(*cSampling), matrix);
return CastShaderEffect(ShaderEffect::CreateImageShader(
CastToImage(*cImage), static_cast<TileMode>(tileX), static_cast<TileMode>(tileY),
CastToSamplingOptions(*cSampling), matrix));
}
return (OH_Drawing_ShaderEffect*)new ShaderEffect(ShaderEffect::ShaderEffectType::IMAGE, CastToImage(*cImage),
static_cast<TileMode>(tileX), static_cast<TileMode>(tileY), CastToSamplingOptions(*cSampling),
*CastToMatrix(cMatrix));
return CastShaderEffect(ShaderEffect::CreateImageShader(
CastToImage(*cImage), static_cast<TileMode>(tileX), static_cast<TileMode>(tileY),
CastToSamplingOptions(*cSampling), *CastToMatrix(cMatrix)));
}
OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateTwoPointConicalGradient(const OH_Drawing_Point2D* startPt,
@ -224,9 +228,9 @@ OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateTwoPointConicalGradient(co
posVector.emplace_back(pos[i]);
}
}
return (OH_Drawing_ShaderEffect*)new ShaderEffect(ShaderEffect::ShaderEffectType::CONICAL_GRADIENT,
return CastShaderEffect(ShaderEffect::CreateTwoPointConical(
*CastToPoint(startPt), startRadius, *CastToPoint(endPt), endRadius, colorsVector, posVector,
static_cast<TileMode>(cTileMode), cMatrix ? CastToMatrix(cMatrix) : nullptr);
static_cast<TileMode>(cTileMode), cMatrix ? CastToMatrix(cMatrix) : nullptr));
}
void OH_Drawing_ShaderEffectDestroy(OH_Drawing_ShaderEffect* cShaderEffect)
@ -234,5 +238,5 @@ void OH_Drawing_ShaderEffectDestroy(OH_Drawing_ShaderEffect* cShaderEffect)
if (!cShaderEffect) {
return;
}
delete CastToShaderEffect(cShaderEffect);
delete Helper::CastTo<OH_Drawing_ShaderEffect*, NativeHandle<ShaderEffect>*>(cShaderEffect);
}

View File

@ -17,9 +17,41 @@
#include "array_mgr.h"
#include "font_descriptor_mgr.h"
#include "font_utils.h"
#include "text/common_utils.h"
using namespace OHOS::Rosen;
namespace {
size_t CalculateDrawingStringSize(const std::string& fullName, std::u16string& utf16String)
{
if (fullName.empty()) {
return 0;
}
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> converter;
utf16String = converter.from_bytes(fullName);
return utf16String.size() * sizeof(char16_t);
}
bool ConvertToDrawingString(std::u16string& utf16String, OH_Drawing_String& fullNameString)
{
if (utf16String.empty() || fullNameString.strData == nullptr || fullNameString.strLen == 0) {
return false;
}
char16_t* u16Data = const_cast<char16_t*>(utf16String.c_str());
if (!Drawing::IsBigEndian()) {
for (uint32_t i = 0; i < fullNameString.strLen / sizeof(char16_t); i++) {
uint16_t temp = static_cast<uint16_t>(u16Data[i]);
u16Data[i] = static_cast<char16_t>((temp & Drawing::LOW_BYTE_MASK) << Drawing::BYTE_SHIFT |
(temp & Drawing::HIGH_BYTE_MASK) >> Drawing::BYTE_SHIFT);
}
}
if (memcpy_s(fullNameString.strData, fullNameString.strLen, u16Data, fullNameString.strLen) == EOK) {
return true;
}
return false;
}
}
template<typename T1, typename T2>
inline T1* ConvertToOriginalText(T2* ptr)
@ -57,20 +89,19 @@ OH_Drawing_FontDescriptor* OH_Drawing_MatchFontDescriptors(OH_Drawing_FontDescri
*num = 0;
return nullptr;
}
int i = 0;
size_t i = 0;
for (const auto& item : result) {
descriptors[i].path = strdup(item->path.c_str());
descriptors[i].postScriptName = strdup(item->postScriptName.c_str());
descriptors[i].fullName = strdup(item->fullName.c_str());
descriptors[i].fontFamily = strdup(item->fontFamily.c_str());
descriptors[i].fontSubfamily = strdup(item->fontSubfamily.c_str());
descriptors[i].weight = item->weight;
descriptors[i].width = item->width;
descriptors[i].italic = item->italic;
descriptors[i].monoSpace = item->monoSpace;
descriptors[i].symbolic = item->symbolic;
if (!OHOS::Rosen::Drawing::CopyFontDescriptor(&descriptors[i], *item)) {
break;
}
++i;
}
if (i != result.size()) {
OH_Drawing_DestroyFontDescriptors(descriptors, i);
*num = 0;
return nullptr;
}
return descriptors;
}
@ -89,45 +120,6 @@ void OH_Drawing_DestroyFontDescriptors(OH_Drawing_FontDescriptor* descriptors, s
delete[] descriptors;
}
bool ConvertToDrawingString(const std::string& fullName, OH_Drawing_String& fullNameString)
{
if (fullName.empty()) {
fullNameString.strData = nullptr;
fullNameString.strLen = 0;
return false;
}
std::u16string utf16String;
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> converter;
utf16String = converter.from_bytes(fullName);
char16_t* u16Data = const_cast<char16_t*>(utf16String.c_str());
size_t strByteLen = utf16String.size() * sizeof(char16_t);
if (strByteLen == 0) {
fullNameString.strData = nullptr;
fullNameString.strLen = 0;
return false;
}
using namespace OHOS::Rosen::Drawing;
if (!IsBigEndian()) {
for (uint32_t i = 0; i < strByteLen / sizeof(char16_t); i++) {
uint16_t temp = static_cast<uint16_t>(u16Data[i]);
u16Data[i] = static_cast<char16_t>((temp & LOW_BYTE_MASK) << BYTE_SHIFT |
(temp & HIGH_BYTE_MASK) >> BYTE_SHIFT);
}
}
uint8_t* strData = new (std::nothrow)uint8_t[strByteLen];
if (strData == nullptr) {
return false;
}
if (memcpy_s(strData, strByteLen, u16Data, strByteLen) == EOK) {
fullNameString.strData = strData;
fullNameString.strLen = static_cast<uint32_t>(strByteLen);
return true;
}
delete[] strData;
strData = nullptr;
return false;
}
OH_Drawing_FontDescriptor* OH_Drawing_GetFontDescriptorByFullName(const OH_Drawing_String* fullName,
OH_Drawing_SystemFontType fontType)
{
@ -145,20 +137,14 @@ OH_Drawing_FontDescriptor* OH_Drawing_GetFontDescriptorByFullName(const OH_Drawi
if (result == nullptr) {
return nullptr;
}
OH_Drawing_FontDescriptor* descriptor = new (std::nothrow)OH_Drawing_FontDescriptor();
OH_Drawing_FontDescriptor* descriptor = OH_Drawing_CreateFontDescriptor();
if (descriptor == nullptr) {
return nullptr;
}
descriptor->path = strdup(result->path.c_str());
descriptor->postScriptName = strdup(result->postScriptName.c_str());
descriptor->fullName = strdup(result->fullName.c_str());
descriptor->fontFamily = strdup(result->fontFamily.c_str());
descriptor->fontSubfamily = strdup(result->fontSubfamily.c_str());
descriptor->weight = result->weight;
descriptor->width = result->width;
descriptor->italic = result->italic;
descriptor->monoSpace = result->monoSpace;
descriptor->symbolic = result->symbolic;
if (!OHOS::Rosen::Drawing::CopyFontDescriptor(descriptor, *result)) {
OH_Drawing_DestroyFontDescriptor(descriptor);
return nullptr;
}
return descriptor;
}
@ -181,8 +167,16 @@ OH_Drawing_Array* OH_Drawing_GetSystemFontFullNamesByType(OH_Drawing_SystemFontT
}
size_t index = 0;
for (const auto& fullName : fullNameList) {
if (!ConvertToDrawingString(fullName, drawingStringArray[index])) {
for (size_t i = 0; i < index; ++i) {
std::u16string utf16String;
size_t strByteLen = CalculateDrawingStringSize(fullName, utf16String);
if (strByteLen > 0) {
drawingStringArray[index].strData = new (std::nothrow) uint8_t[strByteLen];
drawingStringArray[index].strLen = static_cast<uint32_t>(strByteLen);
}
if (strByteLen == 0 || drawingStringArray[index].strData == nullptr ||
!ConvertToDrawingString(utf16String, drawingStringArray[index])) {
for (size_t i = 0; i <= index; ++i) {
delete[] drawingStringArray[i].strData;
}
delete[] drawingStringArray;

View File

@ -26,6 +26,7 @@
#include "array_mgr.h"
#include "font_config.h"
#include "font_parser.h"
#include "font_utils.h"
#include "rosen_text/font_collection.h"
#include "rosen_text/typography.h"
#include "rosen_text/typography_create.h"
@ -33,6 +34,7 @@
#include "utils/log.h"
#include "utils/object_mgr.h"
#include "utils/string_util.h"
using namespace OHOS::Rosen;
@ -302,25 +304,33 @@ void OH_Drawing_SetTextStyleDecoration(OH_Drawing_TextStyle* style, int decorati
void OH_Drawing_AddTextStyleDecoration(OH_Drawing_TextStyle* style, int decoration)
{
if (style == nullptr || (decoration & ~(TextDecoration::UNDERLINE | TextDecoration::OVERLINE |
TextDecoration::LINE_THROUGH))) {
if (decoration < 0) {
return;
}
unsigned int uintDecoration = static_cast<unsigned int>(decoration);
if (style == nullptr || (uintDecoration & (~(TextDecoration::UNDERLINE | TextDecoration::OVERLINE |
TextDecoration::LINE_THROUGH)))) {
return;
}
TextStyle* rosenTextStyle = ConvertToOriginalText<TextStyle>(style);
if (rosenTextStyle) {
rosenTextStyle->decoration = static_cast<TextDecoration>(rosenTextStyle->decoration | decoration);
rosenTextStyle->decoration = static_cast<TextDecoration>(rosenTextStyle->decoration | uintDecoration);
}
}
void OH_Drawing_RemoveTextStyleDecoration(OH_Drawing_TextStyle* style, int decoration)
{
if (style == nullptr || (decoration & ~(TextDecoration::UNDERLINE | TextDecoration::OVERLINE |
TextDecoration::LINE_THROUGH))) {
if (decoration < 0) {
return;
}
unsigned int uintDecoration = static_cast<unsigned int>(decoration);
if (style == nullptr || (uintDecoration & (~(TextDecoration::UNDERLINE | TextDecoration::OVERLINE |
TextDecoration::LINE_THROUGH)))) {
return;
}
TextStyle* rosenTextStyle = ConvertToOriginalText<TextStyle>(style);
if (rosenTextStyle) {
rosenTextStyle->decoration = static_cast<TextDecoration>(rosenTextStyle->decoration & ~decoration);
rosenTextStyle->decoration = static_cast<TextDecoration>(rosenTextStyle->decoration & ~uintDecoration);
}
}
@ -426,42 +436,12 @@ void OH_Drawing_TypographyHandlerPushTextStyle(OH_Drawing_TypographyCreate* hand
ConvertToOriginalText<TypographyCreate>(handler)->PushStyle(*rosenTextStyle);
}
static bool IsUtf8(const char* text)
{
int len = strlen(text);
int n;
for (int i = 0; i < len; i++) {
uint32_t c = text[i];
if (c <= 0x7F) { // 0x00 and 0x7F is the range of utf-8
n = 0;
} else if ((c & 0xE0) == 0xC0) { // 0xE0 and 0xC0 is the range of utf-8
n = 1;
} else if (c == 0xED && i < (len - 1) && (text[i + 1] & 0xA0) == 0xA0) { // 0xA0 and 0xED is the range of utf-8
return false;
} else if ((c & 0xF0) == 0xE0) { // 0xE0 and 0xF0 is the range of utf-8
n = 2; // 2 means the size of range
} else if ((c & 0xF8) == 0xF0) { // 0xF0 and 0xF8 is the range of utf-8
n = 3; // 3 means the size of range
} else {
return false;
}
for (int j = 0; j < n && i < len; j++) {
// 0x80 and 0xC0 is the range of utf-8
if ((++i == len) || ((text[i] & 0xC0) != 0x80)) {
return false;
}
}
}
return true;
}
void OH_Drawing_TypographyHandlerAddText(OH_Drawing_TypographyCreate* handler, const char* text)
{
if (!text || !handler) {
LOGE("null text");
return;
} else if (!IsUtf8(text)) {
} else if (!IsUtf8(text, strlen(text))) {
LOGE("text is not utf-8");
return;
}
@ -1292,21 +1272,14 @@ OH_Drawing_FontDescriptor* OH_Drawing_FontParserGetFontByName(OH_Drawing_FontPar
if (strcmp(name, systemFontList[i].fullName.c_str()) != 0) {
continue;
}
OH_Drawing_FontDescriptor* descriptor = new (std::nothrow) OH_Drawing_FontDescriptor();
OH_Drawing_FontDescriptor* descriptor = OH_Drawing_CreateFontDescriptor();
if (descriptor == nullptr) {
return nullptr;
}
descriptor->path = strdup(systemFontList[i].path.c_str());
descriptor->postScriptName = strdup(systemFontList[i].postScriptName.c_str());
descriptor->fullName = strdup(systemFontList[i].fullName.c_str());
descriptor->fontFamily = strdup(systemFontList[i].fontFamily.c_str());
descriptor->fontSubfamily = strdup(systemFontList[i].fontSubfamily.c_str());
descriptor->weight = systemFontList[i].weight;
descriptor->width = systemFontList[i].width;
descriptor->italic = systemFontList[i].italic;
descriptor->monoSpace = systemFontList[i].monoSpace;
descriptor->symbolic = systemFontList[i].symbolic;
if (!OHOS::Rosen::Drawing::CopyFontDescriptor(descriptor, systemFontList[i])) {
OH_Drawing_DestroyFontDescriptor(descriptor);
return nullptr;
}
return descriptor;
}
return nullptr;

View File

@ -0,0 +1,47 @@
/*
* 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 "font_utils.h"
#include "drawing_text_font_descriptor.h"
namespace OHOS::Rosen::Drawing {
bool CopyFontDescriptor(OH_Drawing_FontDescriptor* dst, const FontParser::FontDescriptor& src)
{
if (dst == nullptr) {
return false;
}
dst->path = strdup(src.path.c_str());
dst->postScriptName = strdup(src.postScriptName.c_str());
dst->fullName = strdup(src.fullName.c_str());
dst->fontFamily = strdup(src.fontFamily.c_str());
dst->fontSubfamily = strdup(src.fontSubfamily.c_str());
if (dst->path == NULL || dst->postScriptName == NULL || dst->fullName == NULL || dst->fontFamily == NULL ||
dst->fontSubfamily == NULL) {
free(dst->path);
free(dst->postScriptName);
free(dst->fullName);
free(dst->fontFamily);
free(dst->fontSubfamily);
return false;
}
dst->weight = src.weight;
dst->width = src.width;
dst->italic = src.italic;
dst->monoSpace = src.monoSpace;
dst->symbolic = src.symbolic;
return true;
}
} // namespace OHOS::Rosen::Drawing

View File

@ -0,0 +1,27 @@
/*
* 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 DRAWING_COMMON_H
#define DRAWING_COMMON_H
#include "drawing_text_typography.h"
#include "font_parser.h"
namespace OHOS::Rosen::Drawing {
using OHOS::Rosen::TextEngine::FontParser;
bool CopyFontDescriptor(OH_Drawing_FontDescriptor* dst, const FontParser::FontDescriptor& src);
} // namespace OHOS::Rosen::Drawing
#endif // DRAWING_COMMON_H

View File

@ -104,12 +104,14 @@ public:
return;
}
uint32_t offset = opAllocator_.AddrToOffset(op);
size_t offset = opAllocator_.AddrToOffset(op);
if (lastOpItemOffset_.has_value()) {
#ifdef CROSS_PLATFORM
auto* lastOpItem = static_cast<OpItem*>(opAllocator_.OffsetToAddr(lastOpItemOffset_.__get()));
auto* lastOpItem = static_cast<OpItem*>(
opAllocator_.OffsetToAddr(lastOpItemOffset_.__get(), sizeof(OpItem)));
#else
auto* lastOpItem = static_cast<OpItem*>(opAllocator_.OffsetToAddr(lastOpItemOffset_.value()));
auto* lastOpItem = static_cast<OpItem*>(
opAllocator_.OffsetToAddr(lastOpItemOffset_.value(), sizeof(OpItem)));
#endif
if (lastOpItem != nullptr) {
lastOpItem->SetNextOpItemOffset(offset);
@ -124,9 +126,9 @@ public:
* @param data A contiguous buffers.
* @return Returns the offset of the contiguous buffers and CmdList head point.
*/
uint32_t AddCmdListData(const CmdListData& data);
size_t AddCmdListData(const CmdListData& data);
const void* GetCmdListData(uint32_t offset) const;
const void* GetCmdListData(size_t offset, size_t size) const;
/**
* @brief Gets the contiguous buffers of CmdList.
@ -135,15 +137,15 @@ public:
// using for recording, should to remove after using shared memory
bool SetUpImageData(const void* data, size_t size);
uint32_t AddImageData(const void* data, size_t size);
const void* GetImageData(uint32_t offset) const;
size_t AddImageData(const void* data, size_t size);
const void* GetImageData(size_t offset, size_t size) const;
CmdListData GetAllImageData() const;
OpDataHandle AddImage(const Image& image);
std::shared_ptr<Image> GetImage(const OpDataHandle& imageHandle);
uint32_t AddBitmapData(const void* data, size_t size);
const void* GetBitmapData(uint32_t offset) const;
size_t AddBitmapData(const void* data, size_t size);
const void* GetBitmapData(size_t offset, size_t size) const;
bool SetUpBitmapData(const void* data, size_t size);
CmdListData GetAllBitmapData() const;
@ -281,10 +283,10 @@ protected:
MemAllocator opAllocator_;
MemAllocator imageAllocator_;
MemAllocator bitmapAllocator_;
std::optional<uint32_t> lastOpItemOffset_ = std::nullopt;
std::optional<size_t> lastOpItemOffset_ = std::nullopt;
std::recursive_mutex mutex_;
std::map<uint32_t, std::shared_ptr<Image>> imageMap_;
std::vector<std::pair<uint32_t, OpDataHandle>> imageHandleVec_;
std::map<size_t, std::shared_ptr<Image>> imageMap_;
std::vector<std::pair<size_t, OpDataHandle>> imageHandleVec_;
uint32_t opCnt_ = 0;
std::vector<std::shared_ptr<RecordCmd>> recordCmdVec_;

View File

@ -129,9 +129,9 @@ public:
}
template<typename Type>
static std::pair<uint32_t, size_t> AddVectorToCmdList(CmdList& cmdList, const std::vector<Type>& vec)
static std::pair<size_t, size_t> AddVectorToCmdList(CmdList& cmdList, const std::vector<Type>& vec)
{
std::pair<uint32_t, size_t> ret(0, 0);
std::pair<size_t, size_t> ret(0, 0);
if (!vec.empty()) {
const void* data = static_cast<const void*>(vec.data());
size_t size = vec.size() * sizeof(Type);
@ -143,10 +143,10 @@ public:
}
template<typename Type>
static std::vector<Type> GetVectorFromCmdList(const CmdList& cmdList, std::pair<uint32_t, size_t> info)
static std::vector<Type> GetVectorFromCmdList(const CmdList& cmdList, std::pair<size_t, size_t> info)
{
std::vector<Type> ret;
const auto* values = static_cast<const Type*>(cmdList.GetCmdListData(info.first));
const auto* values = static_cast<const Type*>(cmdList.GetCmdListData(info.first, info.second));
auto size = info.second / sizeof(Type);
if (values != nullptr && size > 0) {
for (size_t i = 0; i < size; i++) {
@ -166,7 +166,7 @@ public:
return std::make_shared<CmdListType>();
}
const void* childData = cmdList.GetCmdListData(childHandle.offset);
const void* childData = cmdList.GetCmdListData(childHandle.offset, childHandle.size);
if (childData == nullptr) {
return nullptr;
}
@ -176,8 +176,9 @@ public:
return nullptr;
}
if (childHandle.imageSize > 0 && cmdList.GetImageData(childHandle.imageOffset) != nullptr) {
if (!childCmdList->SetUpImageData(cmdList.GetImageData(childHandle.imageOffset), childHandle.imageSize)) {
const void* childImageData = cmdList.GetImageData(childHandle.imageOffset, childHandle.imageSize);
if (childHandle.imageSize > 0 && childImageData != nullptr) {
if (!childCmdList->SetUpImageData(childImageData, childHandle.imageSize)) {
LOGD("set up child image data failed!");
}
}

View File

@ -29,8 +29,8 @@
#include "draw/paint.h"
#include "recording/cmd_list.h"
#define REGISTER_UNMARSHALLING_FUNC(name, type, func) \
static bool isRegistered##name = OHOS::Rosen::Drawing::UnmarshallingHelper::Instance().RegisterFunc(type, func)
#define UNMARSHALLING_REGISTER(name, type, func, size) \
static bool isRegistered##name = OHOS::Rosen::Drawing::UnmarshallingHelper::Instance().Register(type, func, size)
namespace OHOS {
namespace Rosen {
@ -128,8 +128,8 @@ class DRAWING_API UnmarshallingHelper {
public:
static UnmarshallingHelper& Instance();
bool RegisterFunc(uint32_t type, UnmarshallingFunc func);
UnmarshallingFunc GetFunc(uint32_t type);
bool Register(uint32_t type, UnmarshallingFunc func, size_t unmarshallingSize);
std::pair<UnmarshallingFunc, size_t> GetFuncAndSize(uint32_t type);
private:
UnmarshallingHelper() = default;
@ -141,6 +141,7 @@ private:
std::shared_mutex mtx_;
std::unordered_map<uint32_t, UnmarshallingFunc> opUnmarshallingFuncLUT_;
std::unordered_map<uint32_t, size_t> opUnmarshallingSize_;
};
class UnmarshallingPlayer {
@ -148,7 +149,7 @@ public:
UnmarshallingPlayer(const DrawCmdList& cmdList);
~UnmarshallingPlayer() = default;
std::shared_ptr<DrawOpItem> Unmarshalling(uint32_t type, void* handle);
std::shared_ptr<DrawOpItem> Unmarshalling(uint32_t type, void* handle, size_t avaliableSize);
private:
const DrawCmdList& cmdList_;
};
@ -158,7 +159,7 @@ public:
GenerateCachedOpItemPlayer(DrawCmdList &cmdList, Canvas* canvas = nullptr, const Rect* rect = nullptr);
~GenerateCachedOpItemPlayer() = default;
bool GenerateCachedOpItem(uint32_t type, void* handle);
bool GenerateCachedOpItem(uint32_t type, void* handle, size_t avaliableSize);
Canvas* canvas_ = nullptr;
const Rect* rect_;
@ -258,11 +259,11 @@ private:
class DrawPointsOpItem : public DrawWithPaintOpItem {
public:
struct ConstructorHandle : public OpItem {
ConstructorHandle(PointMode mode, const std::pair<uint32_t, size_t>& pts, const PaintHandle& paintHandle)
ConstructorHandle(PointMode mode, const std::pair<size_t, size_t>& pts, const PaintHandle& paintHandle)
: OpItem(DrawOpItem::POINTS_OPITEM), mode(mode), pts(pts), paintHandle(paintHandle) {}
~ConstructorHandle() override = default;
PointMode mode;
std::pair<uint32_t, size_t> pts;
std::pair<size_t, size_t> pts;
PaintHandle paintHandle;
};
DrawPointsOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle);
@ -696,8 +697,8 @@ private:
class DrawAtlasOpItem : public DrawWithPaintOpItem {
public:
struct ConstructorHandle : public OpItem {
ConstructorHandle(const OpDataHandle& atlas, const std::pair<uint32_t, size_t>& xform,
const std::pair<uint32_t, size_t>& tex, const std::pair<uint32_t, size_t>& colors, BlendMode mode,
ConstructorHandle(const OpDataHandle& atlas, const std::pair<size_t, size_t>& xform,
const std::pair<size_t, size_t>& tex, const std::pair<size_t, size_t>& colors, BlendMode mode,
const SamplingOptions& samplingOptions, bool hasCullRect, const Rect& cullRect,
const PaintHandle& paintHandle)
: OpItem(DrawOpItem::ATLAS_OPITEM), atlas(atlas), xform(xform), tex(tex), colors(colors), mode(mode),
@ -705,9 +706,9 @@ public:
paintHandle(paintHandle) {}
~ConstructorHandle() override = default;
OpDataHandle atlas;
std::pair<uint32_t, size_t> xform;
std::pair<uint32_t, size_t> tex;
std::pair<uint32_t, size_t> colors;
std::pair<size_t, size_t> xform;
std::pair<size_t, size_t> tex;
std::pair<size_t, size_t> colors;
BlendMode mode;
SamplingOptions samplingOptions;
bool hasCullRect;
@ -1320,10 +1321,10 @@ public:
class ClipAdaptiveRoundRectOpItem : public DrawOpItem {
public:
struct ConstructorHandle : public OpItem {
ConstructorHandle(const std::pair<uint32_t, size_t>& radiusData)
ConstructorHandle(const std::pair<size_t, size_t>& radiusData)
: OpItem(DrawOpItem::CLIP_ADAPTIVE_ROUND_RECT_OPITEM), radiusData(radiusData) {}
~ConstructorHandle() override = default;
std::pair<uint32_t, size_t> radiusData;
std::pair<size_t, size_t> radiusData;
};
ClipAdaptiveRoundRectOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle);
explicit ClipAdaptiveRoundRectOpItem(const std::vector<Point>& radiusData)

View File

@ -85,9 +85,11 @@ public:
uint32_t offset = opAllocator_.AddrToOffset(op);
if (lastOpItemOffset_.has_value()) {
#ifdef CROSS_PLATFORM
auto* lastOpItem = static_cast<OpItem*>(opAllocator_.OffsetToAddr(lastOpItemOffset_.__get()));
auto* lastOpItem = static_cast<OpItem*>(
opAllocator_.OffsetToAddr(lastOpItemOffset_.__get(), sizeof(OpItem)));
#else
auto* lastOpItem = static_cast<OpItem*>(opAllocator_.OffsetToAddr(lastOpItemOffset_.value()));
auto* lastOpItem = static_cast<OpItem*>(
opAllocator_.OffsetToAddr(lastOpItemOffset_.value(), sizeof(OpItem)));
#endif
if (lastOpItem != nullptr) {
lastOpItem->SetNextOpItemOffset(offset);
@ -185,9 +187,9 @@ public:
void SetCachedHighContrast(bool cachedHighContrast);
std::vector<std::pair<uint32_t, uint32_t>> GetReplacedOpList();
std::vector<std::pair<size_t, size_t>> GetReplacedOpList();
void SetReplacedOpList(std::vector<std::pair<uint32_t, uint32_t>> replacedOpList);
void SetReplacedOpList(std::vector<std::pair<size_t, size_t>> replacedOpList);
void UpdateNodeIdToPicture(NodeId nodeId);
@ -209,11 +211,11 @@ private:
int32_t width_;
int32_t height_;
const UnmarshalMode mode_;
const uint32_t offset_ = 2 * sizeof(int32_t); // 2 is width and height.Offset of first OpItem is behind the w and h
const size_t offset_ = 2 * sizeof(int32_t); // 2 is width and height.Offset of first OpItem is behind the w and h
std::vector<std::shared_ptr<DrawOpItem>> drawOpItems_;
size_t lastOpGenSize_ = 0;
std::vector<std::pair<uint32_t, uint32_t>> replacedOpListForBuffer_;
std::vector<std::pair<size_t, size_t>> replacedOpListForBuffer_;
std::vector<std::pair<int, std::shared_ptr<DrawOpItem>>> replacedOpListForVector_;
bool isCached_ = false;
bool cachedHighContrast_ = false;

View File

@ -97,13 +97,14 @@ public:
* held by the MemAllocator based on the addr.
* @param addr To get the offset from the header pointer.
*/
uint32_t AddrToOffset(const void* addr) const;
size_t AddrToOffset(const void* addr) const;
/**
* @brief Gets the address of the contiguous memory buffer held by the memory allocator from the offset.
* @param offset To get the address of the offset.
* @param size The desirable size to used.
*/
void* OffsetToAddr(size_t offset) const;
void* OffsetToAddr(size_t offset, size_t size) const;
void ClearData();

View File

@ -29,7 +29,7 @@ public:
/**
* @brief Gets the offset of next OpItem.
*/
uint32_t GetNextOpItemOffset() const
size_t GetNextOpItemOffset() const
{
return nextOpItem_;
}
@ -38,7 +38,7 @@ public:
* @brief Sets the offset of next OpItem.
* @param offset The offset of next OpItem.
*/
void SetNextOpItemOffset(uint32_t offset)
void SetNextOpItemOffset(size_t offset)
{
nextOpItem_ = offset;
}
@ -56,7 +56,7 @@ public:
OpItem& operator=(OpItem&&) = delete;
OpItem& operator=(const OpItem&) = default;
private:
uint32_t nextOpItem_ = 0;
size_t nextOpItem_ = 0;
uint32_t type_;
};
} // namespace Drawing

View File

@ -26,7 +26,7 @@ namespace OHOS {
namespace Rosen {
namespace Drawing {
struct ImageHandle {
uint32_t offset = 0;
size_t offset = 0;
size_t size = 0;
int32_t width = 0;
int32_t height = 0;
@ -35,50 +35,50 @@ struct ImageHandle {
};
struct OpDataHandle {
uint32_t offset = 0;
size_t offset = 0;
size_t size = 0;
};
struct FlattenableHandle {
uint32_t offset = 0;
size_t offset = 0;
size_t size = 0;
uint32_t type = 0;
};
struct CmdListHandle {
uint32_t type = 0;
uint32_t offset = 0;
size_t offset = 0;
size_t size = 0;
uint32_t imageOffset = 0;
size_t imageOffset = 0;
size_t imageSize = 0;
uint32_t bitmapOffset = 0;
size_t bitmapOffset = 0;
size_t bitmapSize = 0;
};
struct GroupInfoHandle {
std::pair<uint32_t, size_t> vec1 = {0, 0};
std::pair<uint32_t, size_t> vec2 = {0, 0};
std::pair<size_t, size_t> vec1 = {0, 0};
std::pair<size_t, size_t> vec2 = {0, 0};
};
struct RenderGroupHandle {
std::pair<uint32_t, size_t> infos = {0, 0};
std::pair<size_t, size_t> infos = {0, 0};
DrawingSColor color;
};
struct SymbolLayersHandle {
uint32_t id = 0;
std::pair<uint32_t, size_t> layers = {0, 0};
std::pair<uint32_t, size_t> groups = {0, 0};
std::pair<size_t, size_t> layers = {0, 0};
std::pair<size_t, size_t> groups = {0, 0};
};
struct LatticeHandle {
std::pair<uint32_t, size_t> fXDivs = {0, 0};
std::pair<uint32_t, size_t> fYDivs = {0, 0};
std::pair<uint32_t, size_t> fRectTypes = {0, 0};
std::pair<size_t, size_t> fXDivs = {0, 0};
std::pair<size_t, size_t> fYDivs = {0, 0};
std::pair<size_t, size_t> fRectTypes = {0, 0};
int fXCount = 0;
int fYCount = 0;
std::pair<uint32_t, size_t> fBounds = {0, 0};
std::pair<uint32_t, size_t> fColors = {0, 0};
std::pair<size_t, size_t> fBounds = {0, 0};
std::pair<size_t, size_t> fColors = {0, 0};
};
struct SymbolOpHandle {

View File

@ -27,6 +27,13 @@ public:
void HoldResource(const std::shared_ptr<Drawing::Image>& img);
void ReleaseResource();
bool IsEmpty() const;
/* @name: HasRealseableResourceCheck.
* @desc: Check if there are any resources in the ResourceHolder that can be released.
* @return Return False means there are no resources that can be released.
* Return True means there maybe has resources that can be released.
*/
bool HasRealseableResourceCheck() const;
private:
std::shared_ptr<ResourceHolderImpl> impl_;
};

View File

@ -0,0 +1,27 @@
/*
* 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 GRAPHIC_GRAPHIC_2D_STRING_UTIL_H
#define GRAPHIC_GRAPHIC_2D_STRING_UTIL_H
namespace OHOS {
namespace Rosen {
bool IsUtf8(const char* text, int len);
}
} // namespace OHOS
#endif // GRAPHIC_GRAPHIC_2D_STRING_UTIL_H

View File

@ -29,6 +29,13 @@ public:
virtual void HoldResource(const std::shared_ptr<Drawing::Image>& img) = 0;
virtual void ReleaseResource() = 0;
virtual bool IsEmpty() const = 0;
/* @name: HasRealseableResourceCheck.
* @desc: Check if there are any resources in the ResourceHolder that can be released.
* @return Return False means there are no resources that can be released.
* Return True means there maybe has resources that can be released.
*/
virtual bool HasRealseableResourceCheck() = 0;
};
} // namespace Drawing
} // namespace Rosen

View File

@ -107,7 +107,7 @@ void SkiaColorFilter::SetColorFilter(const sk_sp<SkColorFilter>& filter)
std::shared_ptr<Data> SkiaColorFilter::Serialize() const
{
if (filter_ == nullptr) {
LOGE("SkiaColorFilter::Serialize, filter_ is nullptr!");
LOGD("SkiaColorFilter::Serialize, filter_ is nullptr!");
return nullptr;
}
@ -117,7 +117,7 @@ std::shared_ptr<Data> SkiaColorFilter::Serialize() const
bool SkiaColorFilter::Deserialize(std::shared_ptr<Data> data)
{
if (data == nullptr) {
LOGE("SkiaColorFilter::Deserialize, data is invalid!");
LOGD("SkiaColorFilter::Deserialize, data is invalid!");
return false;
}

View File

@ -109,7 +109,7 @@ sk_sp<SkColorSpace> SkiaColorSpace::GetSkColorSpace() const
std::shared_ptr<Data> SkiaColorSpace::Serialize() const
{
if (colorSpace_ == nullptr) {
LOGE("SkiaColorSpace::Serialize, colorSpace_ is nullptr!");
LOGD("SkiaColorSpace::Serialize, colorSpace_ is nullptr!");
return nullptr;
}
@ -122,7 +122,7 @@ std::shared_ptr<Data> SkiaColorSpace::Serialize() const
bool SkiaColorSpace::Deserialize(std::shared_ptr<Data> data)
{
if (data == nullptr) {
LOGE("SkiaColorSpace::Deserialize, data is invalid!");
LOGD("SkiaColorSpace::Deserialize, data is invalid!");
return false;
}

View File

@ -111,8 +111,8 @@ void SkiaData::SetSkData(const sk_sp<SkData>& data)
std::shared_ptr<Data> SkiaData::Serialize() const
{
#ifdef ROSEN_OHOS
if (skData_ == nullptr || skData_->isEmpty()) {
LOGE("SkiaData::Serialize, skData_ is invalid!");
if (skData_ == nullptr) {
LOGD("SkiaData::Serialize, skData_ is nullptr!");
return nullptr;
}

View File

@ -276,7 +276,7 @@ bool SkiaFont::GetPathForGlyph(uint16_t glyph, Path* path) const
return true;
}
void SkiaFont::GetTextPath(const void* text, size_t length, TextEncoding encoding,
void SkiaFont::GetTextPath(const void* text, size_t byteLength, TextEncoding encoding,
float x, float y, Path* path) const
{
if (path == nullptr || text == nullptr) {
@ -305,13 +305,13 @@ void SkiaFont::GetTextPath(const void* text, size_t length, TextEncoding encodin
break;
}
case TextEncoding::GLYPH_ID: {
strLength = length;
strLength = byteLength;
break;
}
default:
break;
}
SkTextUtils::GetPath(text, std::min(strLength, length), static_cast<SkTextEncoding>(encoding), x, y, skFont_,
SkTextUtils::GetPath(text, std::min(strLength, byteLength), static_cast<SkTextEncoding>(encoding), x, y, skFont_,
&skpath);
}

View File

@ -558,7 +558,7 @@ sk_sp<GrDirectContext> SkiaImage::GetGrContext() const
std::shared_ptr<Data> SkiaImage::Serialize() const
{
if (skiaImage_ == nullptr) {
LOGE("SkiaImage::Serialize, SkImage is nullptr!");
LOGD("SkiaImage::Serialize, SkImage is nullptr!");
return nullptr;
}
@ -577,21 +577,18 @@ std::shared_ptr<Data> SkiaImage::Serialize() const
auto context = as_IB(skiaImage_.get())->directContext();
if (!as_IB(skiaImage_.get())->getROPixels(context, &bitmap)) {
LOGE("SkiaImage::SerializeNoLazyImage SkImage getROPixels failed");
LOGD("SkiaImage::SerializeNoLazyImage SkImage getROPixels failed");
return nullptr;
}
SkPixmap pixmap;
if (!bitmap.peekPixels(&pixmap)) {
LOGE("SkiaImage::SerializeNoLazyImage SkImage peekPixels failed");
LOGD("SkiaImage::SerializeNoLazyImage SkImage peekPixels failed");
return nullptr;
}
size_t rb = pixmap.rowBytes();
int32_t width = pixmap.width();
int32_t height = pixmap.height();
const void* addr = pixmap.addr();
if (addr == nullptr) {
return nullptr;
}
size_t size = pixmap.computeByteSize();
writer.writeUInt(size);
@ -621,7 +618,7 @@ std::shared_ptr<Data> SkiaImage::Serialize() const
bool SkiaImage::Deserialize(std::shared_ptr<Data> data)
{
if (data == nullptr) {
LOGE("SkiaImage::Deserialize, data is invalid!");
LOGD("SkiaImage::Deserialize, data is invalid!");
return false;
}

View File

@ -42,7 +42,6 @@ void SkiaMaskFilter::SetSkMaskFilter(const sk_sp<SkMaskFilter>& filter)
std::shared_ptr<Data> SkiaMaskFilter::Serialize() const
{
if (filter_ == nullptr) {
LOGE("SkiaMaskFilter::Serialize, filter is nullptr!");
return nullptr;
}
@ -52,7 +51,7 @@ std::shared_ptr<Data> SkiaMaskFilter::Serialize() const
bool SkiaMaskFilter::Deserialize(std::shared_ptr<Data> data)
{
if (data == nullptr) {
LOGE("SkiaMaskFilter::Deserialize, data is invalid!");
LOGD("SkiaMaskFilter::Deserialize, data is invalid!");
return false;
}

View File

@ -471,7 +471,6 @@ std::shared_ptr<Data> SkiaPath::Serialize() const
{
if (path_.isEmpty()) {
LOGE("SkiaPath::Serialize, path is empty!");
return nullptr;
}
SkBinaryWriteBuffer writer;
writer.writePath(path_);

View File

@ -89,7 +89,7 @@ void SkiaPathEffect::SetSkPathEffect(const sk_sp<SkPathEffect>& pathEffect)
std::shared_ptr<Data> SkiaPathEffect::Serialize() const
{
if (pathEffect_ == nullptr) {
LOGE("SkiaPathEffect::Serialize, pathEffect_ is nullptr!");
LOGD("SkiaPathEffect::Serialize, pathEffect_ is nullptr!");
return nullptr;
}
@ -99,7 +99,7 @@ std::shared_ptr<Data> SkiaPathEffect::Serialize() const
bool SkiaPathEffect::Deserialize(std::shared_ptr<Data> data)
{
if (data == nullptr) {
LOGE("SkiaPathEffect::Deserialize, data is invalid!");
LOGD("SkiaPathEffect::Deserialize, data is invalid!");
return false;
}

View File

@ -30,7 +30,7 @@ const sk_sp<SkPicture> SkiaPicture::GetPicture() const
std::shared_ptr<Data> SkiaPicture::Serialize() const
{
if (skiaPicture_ == nullptr) {
LOGE("SkiaPicture::Serialize, SkPicture is nullptr!");
LOGD("SkiaPicture::Serialize, SkPicture is nullptr!");
return nullptr;
}
@ -44,7 +44,6 @@ std::shared_ptr<Data> SkiaPicture::Serialize() const
bool SkiaPicture::Deserialize(std::shared_ptr<Data> data)
{
if (data == nullptr) {
LOGE("SkiaPicture::Deserialize, data is nullptr!");
return false;
}

View File

@ -130,10 +130,6 @@ void SkiaRegion::Clone(const Region& other)
std::shared_ptr<Data> SkiaRegion::Serialize() const
{
if (skRegion_ == nullptr || skRegion_->isEmpty()) {
LOGE("SkiaRegion::Serialize, region is empty!");
return nullptr;
}
SkBinaryWriteBuffer writer;
writer.writeRegion(*skRegion_);
size_t length = writer.bytesWritten();
@ -146,7 +142,7 @@ std::shared_ptr<Data> SkiaRegion::Serialize() const
bool SkiaRegion::Deserialize(std::shared_ptr<Data> data)
{
if (data == nullptr) {
LOGE("SkiaRegion::Deserialize, data is invalid!");
LOGD("SkiaRegion::Deserialize, data is invalid!");
return false;
}
SkReadBuffer reader(data->GetData(), data->GetSize());

View File

@ -23,6 +23,7 @@
namespace OHOS {
namespace Rosen {
namespace Drawing {
constexpr uint32_t MAX_CHECK_SIZE = 20;
class SkiaResourceHolder : public ResourceHolderImpl {
public:
static inline constexpr AdapterType TYPE = AdapterType::SKIA_ADAPTER;
@ -62,6 +63,24 @@ public:
return images_.empty();
}
bool HasRealseableResourceCheck() override
{
if (images_.empty()) {
return false;
}
if (images_.size() > MAX_CHECK_SIZE) {
return true;
}
auto iter = images_.begin();
while (iter != images_.end()) {
if (iter->second.use_count() == 1) {
return true;
}
++iter;
}
return false;
}
private:
std::unordered_map<uintptr_t, const std::shared_ptr<Image>> images_;
};

View File

@ -274,7 +274,7 @@ void SkiaShaderEffect::SetSkShader(const sk_sp<SkShader>& skShader)
std::shared_ptr<Data> SkiaShaderEffect::Serialize() const
{
if (shader_ == nullptr) {
LOGE("SkiaShaderEffect::Serialize, shader_ is nullptr!");
LOGD("SkiaShaderEffect::Serialize, shader_ is nullptr!");
return nullptr;
}
@ -290,7 +290,7 @@ std::shared_ptr<Data> SkiaShaderEffect::Serialize() const
bool SkiaShaderEffect::Deserialize(std::shared_ptr<Data> data)
{
if (data == nullptr) {
LOGE("SkiaShaderEffect::Deserialize, data is invalid!");
LOGD("SkiaShaderEffect::Deserialize, data is invalid!");
return false;
}
SkReadBuffer reader(data->GetData(), data->GetSize());

View File

@ -459,6 +459,16 @@ void SkiaSurface::Flush(FlushInfo *drawingflushInfo)
{
if (skSurface_ == nullptr) {
LOGD("skSurface is nullptr");
// handle exception such as skia
if (!drawingflushInfo) {
return;
}
if (drawingflushInfo->submittedProc) {
drawingflushInfo->submittedProc(drawingflushInfo->submittedContext, false);
}
if (drawingflushInfo->finishedProc) {
drawingflushInfo->finishedProc(drawingflushInfo->finishedContext);
}
return;
}
if (drawingflushInfo != nullptr) {

View File

@ -113,7 +113,7 @@ std::shared_ptr<TextBlob> SkiaTextBlob::MakeFromRSXform(const void* text, size_t
std::shared_ptr<Data> SkiaTextBlob::Serialize(void* ctx) const
{
if (!skTextBlob_) {
LOGE("skTextBlob nullptr, %{public}s, %{public}d", __FUNCTION__, __LINE__);
LOGD("skTextBlob nullptr, %{public}s, %{public}d", __FUNCTION__, __LINE__);
return nullptr;
}
SkSerialProcs procs;
@ -123,7 +123,7 @@ std::shared_ptr<Data> SkiaTextBlob::Serialize(void* ctx) const
auto data = std::make_shared<Data>();
auto skiaData = data->GetImpl<SkiaData>();
if (!skiaData) {
LOGE("skiaData nullptr, %{public}s, %{public}d", __FUNCTION__, __LINE__);
LOGD("skiaData nullptr, %{public}s, %{public}d", __FUNCTION__, __LINE__);
return nullptr;
}
skiaData->SetSkData(skData);
@ -137,7 +137,7 @@ std::shared_ptr<TextBlob> SkiaTextBlob::Deserialize(const void* data, size_t siz
procs.fTypefaceCtx = ctx;
sk_sp<SkTextBlob> skTextBlob = SkTextBlob::Deserialize(data, size, procs);
if (!skTextBlob) {
LOGE("skTextBlob nullptr, %{public}s, %{public}d", __FUNCTION__, __LINE__);
LOGD("skTextBlob nullptr, %{public}s, %{public}d", __FUNCTION__, __LINE__);
return nullptr;
}
std::shared_ptr<TextBlobImpl> textBlobImpl = std::make_shared<SkiaTextBlob>(skTextBlob);

View File

@ -252,7 +252,7 @@ std::shared_ptr<Typeface> SkiaTypeface::MakeFromName(const char familyName[], Fo
sk_sp<SkData> SkiaTypeface::SerializeTypeface(SkTypeface* typeface, void* ctx)
{
if (!typeface) {
LOGE("typeface nullptr, %{public}s, %{public}d", __FUNCTION__, __LINE__);
LOGD("typeface nullptr, %{public}s, %{public}d", __FUNCTION__, __LINE__);
return nullptr;
}
TextBlob::Context* textblobCtx = reinterpret_cast<TextBlob::Context*>(ctx);
@ -268,7 +268,7 @@ sk_sp<SkData> SkiaTypeface::SerializeTypeface(SkTypeface* typeface, void* ctx)
sk_sp<SkTypeface> SkiaTypeface::DeserializeTypeface(const void* data, size_t length, void* ctx)
{
if (data == nullptr) {
LOGE("data nullptr, %{public}s, %{public}d", __FUNCTION__, __LINE__);
LOGD("data nullptr, %{public}s, %{public}d", __FUNCTION__, __LINE__);
return nullptr;
}
@ -279,12 +279,12 @@ sk_sp<SkTypeface> SkiaTypeface::DeserializeTypeface(const void* data, size_t len
}
auto& typeface = textblobCtx->GetTypeface();
if (typeface == nullptr) {
LOGE("typeface nullptr, %{public}s, %{public}d", __FUNCTION__, __LINE__);
LOGD("typeface nullptr, %{public}s, %{public}d", __FUNCTION__, __LINE__);
return nullptr;
}
auto skiaTypeface = typeface->GetImpl<SkiaTypeface>();
if (skiaTypeface == nullptr) {
LOGE("skiaTypeface nullptr, %{public}s, %{public}d", __FUNCTION__, __LINE__);
LOGD("skiaTypeface nullptr, %{public}s, %{public}d", __FUNCTION__, __LINE__);
return nullptr;
}
auto skTypeface = skiaTypeface->GetSkTypeface();
@ -294,14 +294,14 @@ sk_sp<SkTypeface> SkiaTypeface::DeserializeTypeface(const void* data, size_t len
std::shared_ptr<Data> SkiaTypeface::Serialize() const
{
if (!skTypeface_) {
LOGE("skTypeface nullptr, %{public}s, %{public}d", __FUNCTION__, __LINE__);
LOGD("skTypeface nullptr, %{public}s, %{public}d", __FUNCTION__, __LINE__);
return nullptr;
}
auto skData = skTypeface_->serialize(SkTypeface::SerializeBehavior::kDoIncludeData);
auto data = std::make_shared<Data>();
auto skiaData = data->GetImpl<SkiaData>();
if (!skiaData) {
LOGE("skiaData nullptr, %{public}s, %{public}d", __FUNCTION__, __LINE__);
LOGD("skiaData nullptr, %{public}s, %{public}d", __FUNCTION__, __LINE__);
return nullptr;
}
skiaData->SetSkData(skData);
@ -313,7 +313,7 @@ std::shared_ptr<Typeface> SkiaTypeface::Deserialize(const void* data, size_t siz
SkMemoryStream stream(data, size);
auto skTypeface = SkTypeface::MakeDeserialize(&stream);
if (!skTypeface) {
LOGE("skTypeface nullptr, %{public}s, %{public}d", __FUNCTION__, __LINE__);
LOGD("skTypeface nullptr, %{public}s, %{public}d", __FUNCTION__, __LINE__);
return nullptr;
}
auto typefaceImpl = std::make_shared<SkiaTypeface>(skTypeface);

View File

@ -115,7 +115,7 @@ bool SkiaVertices::MakeCopy(VertexMode mode,
std::shared_ptr<Data> SkiaVertices::Serialize() const
{
if (skiaVertices_ == nullptr) {
LOGE("SkiaVertices::Serialize, SkVertices is nullptr!");
LOGD("SkiaVertices::Serialize, SkVertices is nullptr!");
return nullptr;
}
@ -131,7 +131,7 @@ std::shared_ptr<Data> SkiaVertices::Serialize() const
bool SkiaVertices::Deserialize(std::shared_ptr<Data> data)
{
if (data == nullptr) {
LOGE("SkiaVertices::Deserialize, data is invalid!");
LOGD("SkiaVertices::Deserialize, data is invalid!");
return false;
}

View File

@ -37,7 +37,7 @@ CmdList::~CmdList()
#endif
}
uint32_t CmdList::AddCmdListData(const CmdListData& data)
size_t CmdList::AddCmdListData(const CmdListData& data)
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
if (!lastOpItemOffset_.has_value()) {
@ -56,9 +56,9 @@ uint32_t CmdList::AddCmdListData(const CmdListData& data)
return opAllocator_.AddrToOffset(addr);
}
const void* CmdList::GetCmdListData(uint32_t offset) const
const void* CmdList::GetCmdListData(size_t offset, size_t size) const
{
return opAllocator_.OffsetToAddr(offset);
return opAllocator_.OffsetToAddr(offset, size);
}
CmdListData CmdList::GetData() const
@ -71,7 +71,7 @@ bool CmdList::SetUpImageData(const void* data, size_t size)
return imageAllocator_.BuildFromDataWithCopy(data, size);
}
uint32_t CmdList::AddImageData(const void* data, size_t size)
size_t CmdList::AddImageData(const void* data, size_t size)
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
void* addr = imageAllocator_.Add(data, size);
@ -82,9 +82,9 @@ uint32_t CmdList::AddImageData(const void* data, size_t size)
return imageAllocator_.AddrToOffset(addr);
}
const void* CmdList::GetImageData(uint32_t offset) const
const void* CmdList::GetImageData(size_t offset, size_t size) const
{
return imageAllocator_.OffsetToAddr(offset);
return imageAllocator_.OffsetToAddr(offset, size);
}
CmdListData CmdList::GetAllImageData() const
@ -114,8 +114,8 @@ OpDataHandle CmdList::AddImage(const Image& image)
LOGD("CmdList AddImageData failed!");
return ret;
}
uint32_t offset = imageAllocator_.AddrToOffset(addr);
imageHandleVec_.push_back(std::pair<uint32_t, OpDataHandle>(uniqueId, {offset, data->GetSize()}));
size_t offset = imageAllocator_.AddrToOffset(addr);
imageHandleVec_.push_back(std::pair<size_t, OpDataHandle>(uniqueId, {offset, data->GetSize()}));
return {offset, data->GetSize()};
}
@ -133,7 +133,7 @@ std::shared_ptr<Image> CmdList::GetImage(const OpDataHandle& imageHandle)
return nullptr;
}
const void* ptr = imageAllocator_.OffsetToAddr(imageHandle.offset);
const void* ptr = imageAllocator_.OffsetToAddr(imageHandle.offset, imageHandle.size);
if (ptr == nullptr) {
LOGD("get image data failed");
return nullptr;
@ -150,7 +150,7 @@ std::shared_ptr<Image> CmdList::GetImage(const OpDataHandle& imageHandle)
return image;
}
uint32_t CmdList::AddBitmapData(const void* data, size_t size)
size_t CmdList::AddBitmapData(const void* data, size_t size)
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
void* addr = bitmapAllocator_.Add(data, size);
@ -161,9 +161,9 @@ uint32_t CmdList::AddBitmapData(const void* data, size_t size)
return bitmapAllocator_.AddrToOffset(addr);
}
const void* CmdList::GetBitmapData(uint32_t offset) const
const void* CmdList::GetBitmapData(size_t offset, size_t size) const
{
return bitmapAllocator_.OffsetToAddr(offset);
return bitmapAllocator_.OffsetToAddr(offset, size);
}
bool CmdList::SetUpBitmapData(const void* data, size_t size)

View File

@ -65,7 +65,7 @@ OpDataHandle CmdListHelper::AddImageToCmdList(CmdList& cmdList, const Image& ima
OpDataHandle CmdListHelper::AddImageToCmdList(CmdList& cmdList, const std::shared_ptr<Image>& image)
{
if (image == nullptr) {
LOGE("image is nullptr!");
LOGD("image is nullptr!");
return { 0 };
}
return CmdListHelper::AddImageToCmdList(cmdList, *image);
@ -80,7 +80,7 @@ OpDataHandle CmdListHelper::AddVerticesToCmdList(CmdList& cmdList, const Vertice
{
auto data = vertices.Serialize();
if (data == nullptr || data->GetSize() == 0) {
LOGE("vertices is valid!");
LOGD("vertices is valid!");
return { 0 };
}
@ -95,9 +95,9 @@ std::shared_ptr<Vertices> CmdListHelper::GetVerticesFromCmdList(
return nullptr;
}
const void* ptr = cmdList.GetImageData(opDataHandle.offset);
const void* ptr = cmdList.GetImageData(opDataHandle.offset, opDataHandle.size);
if (ptr == nullptr) {
LOGE("get vertices data failed!");
LOGD("get vertices data failed!");
return nullptr;
}
@ -105,7 +105,7 @@ std::shared_ptr<Vertices> CmdListHelper::GetVerticesFromCmdList(
verticesData->BuildWithoutCopy(ptr, opDataHandle.size);
auto vertices = std::make_shared<Vertices>();
if (vertices->Deserialize(verticesData) == false) {
LOGE("vertices deserialize failed!");
LOGD("vertices deserialize failed!");
return nullptr;
}
return vertices;
@ -117,7 +117,7 @@ ImageHandle CmdListHelper::AddBitmapToCmdList(CmdList& cmdList, const Bitmap& bi
auto bpp = ColorTypeToBytesPerPixel(format.colorType);
auto bitmapSize = bitmap.GetHeight() * bitmap.GetWidth() * bpp;
if (bitmapSize == 0) {
LOGE("bitmap is valid!");
LOGD("bitmap is valid!");
return { 0 };
}
@ -131,16 +131,16 @@ std::shared_ptr<Bitmap> CmdListHelper::GetBitmapFromCmdList(const CmdList& cmdLi
return nullptr;
}
const void* ptr = cmdList.GetBitmapData(bitmapHandle.offset);
const void* ptr = cmdList.GetBitmapData(bitmapHandle.offset, bitmapHandle.size);
if (ptr == nullptr) {
LOGE("get bitmap data failed!");
LOGD("get bitmap data failed!");
return nullptr;
}
BitmapFormat format = { bitmapHandle.colorType, bitmapHandle.alphaType };
auto bitmap = std::make_shared<Bitmap>();
bitmap->Build(bitmapHandle.width, bitmapHandle.height, format);
bitmap->SetPixels(const_cast<void*>(cmdList.GetBitmapData(bitmapHandle.offset)));
bitmap->SetPixels(const_cast<void*>(ptr));
return bitmap;
}
@ -187,7 +187,7 @@ OpDataHandle CmdListHelper::AddPictureToCmdList(CmdList& cmdList, const Picture&
{
auto data = picture.Serialize();
if (data == nullptr || data->GetSize() == 0) {
LOGE("picture is valid!");
LOGD("picture is valid!");
return { 0 };
}
@ -201,9 +201,9 @@ std::shared_ptr<Picture> CmdListHelper::GetPictureFromCmdList(const CmdList& cmd
return nullptr;
}
const void* ptr = cmdList.GetImageData(pictureHandle.offset);
const void* ptr = cmdList.GetImageData(pictureHandle.offset, pictureHandle.size);
if (ptr == nullptr) {
LOGE("get picture data failed!");
LOGD("get picture data failed!");
return nullptr;
}
@ -211,7 +211,7 @@ std::shared_ptr<Picture> CmdListHelper::GetPictureFromCmdList(const CmdList& cmd
pictureData->BuildWithoutCopy(ptr, pictureHandle.size);
auto picture = std::make_shared<Picture>();
if (picture->Deserialize(pictureData) == false) {
LOGE("picture deserialize failed!");
LOGD("picture deserialize failed!");
return nullptr;
}
return picture;
@ -220,7 +220,7 @@ std::shared_ptr<Picture> CmdListHelper::GetPictureFromCmdList(const CmdList& cmd
OpDataHandle CmdListHelper::AddCompressDataToCmdList(CmdList& cmdList, const std::shared_ptr<Data>& data)
{
if (data == nullptr || data->GetSize() == 0) {
LOGE("data is valid!");
LOGD("data is valid!");
return { 0 };
}
@ -234,9 +234,9 @@ std::shared_ptr<Data> CmdListHelper::GetCompressDataFromCmdList(const CmdList& c
return nullptr;
}
const void* ptr = cmdList.GetImageData(imageHandle.offset);
const void* ptr = cmdList.GetImageData(imageHandle.offset, imageHandle.size);
if (ptr == nullptr) {
LOGE("get image data failed!");
LOGD("get image data failed!");
return nullptr;
}
@ -330,18 +330,18 @@ DrawingHMSymbolData CmdListHelper::GetSymbolFromCmdList(const CmdList& cmdList,
SymbolLayersHandle CmdListHelper::AddSymbolLayersToCmdList(CmdList& cmdList, const DrawingSymbolLayers& symbolLayers)
{
auto layers = symbolLayers.layers;
std::vector<std::pair<uint32_t, size_t>> handleVector1;
std::vector<std::pair<size_t, size_t>> handleVector1;
for (size_t i = 0; i < layers.size(); i++) {
handleVector1.push_back(AddVectorToCmdList(cmdList, layers.at(i)));
}
std::pair<uint32_t, size_t> layersHandle = AddVectorToCmdList(cmdList, handleVector1);
std::pair<size_t, size_t> layersHandle = AddVectorToCmdList(cmdList, handleVector1);
auto groups = symbolLayers.renderGroups;
std::vector<RenderGroupHandle> handleVector2;
for (size_t i = 0; i < groups.size(); i++) {
handleVector2.push_back(AddRenderGroupToCmdList(cmdList, groups.at(i)));
}
std::pair<uint32_t, size_t> groupsHandle = AddVectorToCmdList(cmdList, handleVector2);
std::pair<size_t, size_t> groupsHandle = AddVectorToCmdList(cmdList, handleVector2);
return { symbolLayers.symbolGlyphId, layersHandle, groupsHandle};
}
@ -352,7 +352,7 @@ DrawingSymbolLayers CmdListHelper::GetSymbolLayersFromCmdList(const CmdList& cmd
DrawingSymbolLayers symbolLayers;
symbolLayers.symbolGlyphId = symbolLayersHandle.id;
auto handleVector1 = GetVectorFromCmdList<std::pair<uint32_t, size_t>>(cmdList, symbolLayersHandle.layers);
auto handleVector1 = GetVectorFromCmdList<std::pair<size_t, size_t>>(cmdList, symbolLayersHandle.layers);
std::vector<std::vector<size_t>> layers;
for (size_t i = 0; i < handleVector1.size(); i++) {
layers.push_back(GetVectorFromCmdList<size_t>(cmdList, handleVector1.at(i)));
@ -376,7 +376,7 @@ RenderGroupHandle CmdListHelper::AddRenderGroupToCmdList(CmdList& cmdList, const
for (size_t i = 0; i < infos.size(); i++) {
handleVector.push_back(AddGroupInfoToCmdList(cmdList, infos.at(i)));
}
std::pair<uint32_t, size_t> groupInfosHandle = AddVectorToCmdList(cmdList, handleVector);
std::pair<size_t, size_t> groupInfosHandle = AddVectorToCmdList(cmdList, handleVector);
return { groupInfosHandle, group.color };
}
@ -398,8 +398,8 @@ DrawingRenderGroup CmdListHelper::GetRenderGroupFromCmdList(const CmdList& cmdLi
GroupInfoHandle CmdListHelper::AddGroupInfoToCmdList(CmdList& cmdList, const DrawingGroupInfo& groupInfo)
{
std::pair<uint32_t, size_t> layerIndexes = AddVectorToCmdList(cmdList, groupInfo.layerIndexes);
std::pair<uint32_t, size_t> maskIndexes = AddVectorToCmdList(cmdList, groupInfo.maskIndexes);
std::pair<size_t, size_t> layerIndexes = AddVectorToCmdList(cmdList, groupInfo.layerIndexes);
std::pair<size_t, size_t> maskIndexes = AddVectorToCmdList(cmdList, groupInfo.maskIndexes);
return { layerIndexes, maskIndexes };
}
@ -418,7 +418,7 @@ OpDataHandle CmdListHelper::AddTextBlobToCmdList(CmdList& cmdList, const TextBlo
}
auto data = textBlob->Serialize(ctx);
if (!data || data->GetSize() == 0) {
LOGE("textBlob serialize invalid, %{public}s, %{public}d", __FUNCTION__, __LINE__);
LOGD("textBlob serialize invalid, %{public}s, %{public}d", __FUNCTION__, __LINE__);
return { 0 };
}
@ -439,9 +439,9 @@ std::shared_ptr<TextBlob> CmdListHelper::GetTextBlobFromCmdList(const CmdList& c
}
TextBlob::Context customCtx {typeface, false};
const void* data = cmdList.GetImageData(textBlobHandle.offset);
const void* data = cmdList.GetImageData(textBlobHandle.offset, textBlobHandle.size);
if (!data) {
LOGE("textBlob data nullptr, %{public}s, %{public}d", __FUNCTION__, __LINE__);
LOGD("textBlob data nullptr, %{public}s, %{public}d", __FUNCTION__, __LINE__);
return nullptr;
}
@ -453,13 +453,13 @@ std::shared_ptr<TextBlob> CmdListHelper::GetTextBlobFromCmdList(const CmdList& c
OpDataHandle CmdListHelper::AddDataToCmdList(CmdList& cmdList, const Data* srcData)
{
if (!srcData) {
LOGE("data nullptr, %{public}s, %{public}d", __FUNCTION__, __LINE__);
LOGD("data nullptr, %{public}s, %{public}d", __FUNCTION__, __LINE__);
return { 0 };
}
auto data = srcData->Serialize();
if (data == nullptr || data->GetSize() == 0) {
LOGE("srcData is invalid!");
LOGD("srcData is invalid!");
return { 0 };
}
@ -473,9 +473,9 @@ std::shared_ptr<Data> CmdListHelper::GetDataFromCmdList(const CmdList& cmdList,
return nullptr;
}
const void* ptr = cmdList.GetImageData(imageHandle.offset);
const void* ptr = cmdList.GetImageData(imageHandle.offset, imageHandle.size);
if (ptr == nullptr) {
LOGE("get data failed!");
LOGD("get data failed!");
return nullptr;
}
@ -500,10 +500,11 @@ std::shared_ptr<Path> CmdListHelper::GetPathFromCmdList(const CmdList& cmdList,
const OpDataHandle& pathHandle)
{
if (pathHandle.size == 0) {
LOGE("pathHandle is invalid!");
return nullptr;
}
const void* ptr = cmdList.GetImageData(pathHandle.offset);
const void* ptr = cmdList.GetImageData(pathHandle.offset, pathHandle.size);
if (ptr == nullptr) {
LOGE("get path data failed!");
return nullptr;
@ -524,7 +525,7 @@ OpDataHandle CmdListHelper::AddRegionToCmdList(CmdList& cmdList, const Region& r
{
auto data = region.Serialize();
if (data == nullptr || data->GetSize() == 0) {
LOGE("region is invalid, %{public}s, %{public}d", __FUNCTION__, __LINE__);
LOGD("region is invalid, %{public}s, %{public}d", __FUNCTION__, __LINE__);
return { 0 };
}
@ -538,9 +539,9 @@ std::shared_ptr<Region> CmdListHelper::GetRegionFromCmdList(const CmdList& cmdLi
return nullptr;
}
const void* ptr = cmdList.GetImageData(regionHandle.offset);
const void* ptr = cmdList.GetImageData(regionHandle.offset, regionHandle.size);
if (ptr == nullptr) {
LOGE("get region data failed!");
LOGD("get region data failed!");
return nullptr;
}
@ -548,7 +549,7 @@ std::shared_ptr<Region> CmdListHelper::GetRegionFromCmdList(const CmdList& cmdLi
regionData->BuildWithoutCopy(ptr, regionHandle.size);
auto region = std::make_shared<Region>();
if (region->Deserialize(regionData) == false) {
LOGE("region deserialize failed!");
LOGD("region deserialize failed!");
return nullptr;
}
@ -563,7 +564,7 @@ OpDataHandle CmdListHelper::AddColorSpaceToCmdList(CmdList& cmdList, const std::
auto data = colorSpace->Serialize();
if (data == nullptr || data->GetSize() == 0) {
LOGE("colorSpace is invalid, %{public}s, %{public}d", __FUNCTION__, __LINE__);
LOGD("colorSpace is invalid, %{public}s, %{public}d", __FUNCTION__, __LINE__);
return { 0 };
}
@ -578,7 +579,7 @@ std::shared_ptr<ColorSpace> CmdListHelper::GetColorSpaceFromCmdList(const CmdLis
return nullptr;
}
const void* ptr = cmdList.GetImageData(imageHandle.offset);
const void* ptr = cmdList.GetImageData(imageHandle.offset, imageHandle.size);
if (ptr == nullptr) {
return nullptr;
}
@ -586,7 +587,7 @@ std::shared_ptr<ColorSpace> CmdListHelper::GetColorSpaceFromCmdList(const CmdLis
colorSpaceData->BuildWithoutCopy(ptr, imageHandle.size);
auto colorSpace = std::make_shared<ColorSpace>(ColorSpace::ColorSpaceType::REF_IMAGE);
if (colorSpace->Deserialize(colorSpaceData) == false) {
LOGE("colorSpace deserialize failed!");
LOGD("colorSpace deserialize failed!");
return nullptr;
}
@ -609,7 +610,7 @@ FlattenableHandle CmdListHelper::AddShaderEffectToCmdList(CmdList& cmdList, std:
}
auto data = shaderEffect->Serialize();
if (data == nullptr || data->GetSize() == 0) {
LOGE("shaderEffect is invalid, %{public}s, %{public}d", __FUNCTION__, __LINE__);
LOGD("shaderEffect is invalid, %{public}s, %{public}d", __FUNCTION__, __LINE__);
return { 0 };
}
auto offset = cmdList.AddImageData(data->GetData(), data->GetSize());
@ -637,7 +638,7 @@ std::shared_ptr<ShaderEffect> CmdListHelper::GetShaderEffectFromCmdList(const Cm
return shaderEffect;
}
const void* ptr = cmdList.GetImageData(shaderEffectHandle.offset);
const void* ptr = cmdList.GetImageData(shaderEffectHandle.offset, shaderEffectHandle.size);
if (ptr == nullptr) {
return nullptr;
}
@ -646,7 +647,7 @@ std::shared_ptr<ShaderEffect> CmdListHelper::GetShaderEffectFromCmdList(const Cm
shaderEffectData->BuildWithoutCopy(ptr, shaderEffectHandle.size);
auto shaderEffect = std::make_shared<ShaderEffect>(type);
if (shaderEffect->Deserialize(shaderEffectData) == false) {
LOGE("shaderEffect deserialize failed!");
LOGD("shaderEffect deserialize failed!");
return nullptr;
}
@ -661,7 +662,7 @@ FlattenableHandle CmdListHelper::AddPathEffectToCmdList(CmdList& cmdList, std::s
PathEffect::PathEffectType type = pathEffect->GetType();
auto data = pathEffect->Serialize();
if (data == nullptr || data->GetSize() == 0) {
LOGE("pathEffect is invalid, %{public}s, %{public}d", __FUNCTION__, __LINE__);
LOGD("pathEffect is invalid, %{public}s, %{public}d", __FUNCTION__, __LINE__);
return { 0 };
}
auto offset = cmdList.AddImageData(data->GetData(), data->GetSize());
@ -675,7 +676,7 @@ std::shared_ptr<PathEffect> CmdListHelper::GetPathEffectFromCmdList(const CmdLis
return nullptr;
}
const void* ptr = cmdList.GetImageData(pathEffectHandle.offset);
const void* ptr = cmdList.GetImageData(pathEffectHandle.offset, pathEffectHandle.size);
if (ptr == nullptr) {
return nullptr;
}
@ -685,7 +686,7 @@ std::shared_ptr<PathEffect> CmdListHelper::GetPathEffectFromCmdList(const CmdLis
auto pathEffect = std::make_shared<PathEffect>
(static_cast<PathEffect::PathEffectType>(pathEffectHandle.type));
if (pathEffect->Deserialize(pathEffectData) == false) {
LOGE("pathEffect deserialize failed!");
LOGD("pathEffect deserialize failed!");
return nullptr;
}
@ -700,7 +701,6 @@ FlattenableHandle CmdListHelper::AddMaskFilterToCmdList(CmdList& cmdList, std::s
MaskFilter::FilterType type = maskFilter->GetType();
auto data = maskFilter->Serialize();
if (data == nullptr || data->GetSize() == 0) {
LOGE("maskFilter is invalid, %{public}s, %{public}d", __FUNCTION__, __LINE__);
return { 0 };
}
auto offset = cmdList.AddImageData(data->GetData(), data->GetSize());
@ -714,7 +714,7 @@ std::shared_ptr<MaskFilter> CmdListHelper::GetMaskFilterFromCmdList(const CmdLis
return nullptr;
}
const void* ptr = cmdList.GetImageData(maskFilterHandle.offset);
const void* ptr = cmdList.GetImageData(maskFilterHandle.offset, maskFilterHandle.size);
if (ptr == nullptr) {
return nullptr;
}
@ -724,7 +724,7 @@ std::shared_ptr<MaskFilter> CmdListHelper::GetMaskFilterFromCmdList(const CmdLis
auto maskFilter = std::make_shared<MaskFilter>
(static_cast<MaskFilter::FilterType>(maskFilterHandle.type));
if (maskFilter->Deserialize(maskFilterData) == false) {
LOGE("maskFilter deserialize failed!");
LOGD("maskFilter deserialize failed!");
return nullptr;
}
@ -739,7 +739,7 @@ FlattenableHandle CmdListHelper::AddColorFilterToCmdList(CmdList& cmdList, std::
ColorFilter::FilterType type = colorFilter->GetType();
auto data = colorFilter->Serialize();
if (data == nullptr || data->GetSize() == 0) {
LOGE("colorFilter is invalid, %{public}s, %{public}d", __FUNCTION__, __LINE__);
LOGD("colorFilter is invalid, %{public}s, %{public}d", __FUNCTION__, __LINE__);
return { 0 };
}
auto offset = cmdList.AddImageData(data->GetData(), data->GetSize());
@ -753,7 +753,7 @@ std::shared_ptr<ColorFilter> CmdListHelper::GetColorFilterFromCmdList(const CmdL
return nullptr;
}
const void* ptr = cmdList.GetImageData(colorFilterHandle.offset);
const void* ptr = cmdList.GetImageData(colorFilterHandle.offset, colorFilterHandle.size);
if (ptr == nullptr) {
return nullptr;
}
@ -763,7 +763,7 @@ std::shared_ptr<ColorFilter> CmdListHelper::GetColorFilterFromCmdList(const CmdL
auto colorFilter = std::make_shared<ColorFilter>
(static_cast<ColorFilter::FilterType>(colorFilterHandle.type));
if (colorFilter->Deserialize(colorFilterData) == false) {
LOGE("colorFilter deserialize failed!");
LOGD("colorFilter deserialize failed!");
return nullptr;
}
@ -778,7 +778,6 @@ FlattenableHandle CmdListHelper::AddImageFilterToCmdList(CmdList& cmdList, const
ImageFilter::FilterType type = imageFilter->GetType();
auto data = imageFilter->Serialize();
if (data == nullptr || data->GetSize() == 0) {
LOGE("imageFilter is invalid, %{public}s, %{public}d", __FUNCTION__, __LINE__);
return { 0 };
}
auto offset = cmdList.AddImageData(data->GetData(), data->GetSize());
@ -798,7 +797,7 @@ std::shared_ptr<ImageFilter> CmdListHelper::GetImageFilterFromCmdList(const CmdL
return nullptr;
}
const void* ptr = cmdList.GetImageData(imageFilterHandle.offset);
const void* ptr = cmdList.GetImageData(imageFilterHandle.offset, imageFilterHandle.size);
if (ptr == nullptr) {
return nullptr;
}
@ -808,7 +807,7 @@ std::shared_ptr<ImageFilter> CmdListHelper::GetImageFilterFromCmdList(const CmdL
auto imageFilter = std::make_shared<ImageFilter>
(static_cast<ImageFilter::FilterType>(imageFilterHandle.type));
if (imageFilter->Deserialize(imageFilterData) == false) {
LOGE("imageFilter deserialize failed!");
LOGD("imageFilter deserialize failed!");
return nullptr;
}
@ -819,13 +818,13 @@ OpDataHandle CmdListHelper::AddBlurDrawLooperToCmdList(CmdList& cmdList,
std::shared_ptr<BlurDrawLooper> blurDrawLooper)
{
if (blurDrawLooper == nullptr) {
LOGE("blurDrawLooper is nullptr");
LOGD("blurDrawLooper is nullptr");
return { 0 };
}
auto data = blurDrawLooper->Serialize();
if (data == nullptr || data->GetSize() == 0) {
LOGE("blurDrawLooper serialize failed!");
LOGD("blurDrawLooper serialize failed!");
return { 0 };
}
auto offset = cmdList.AddImageData(data->GetData(), data->GetSize());
@ -839,7 +838,7 @@ std::shared_ptr<BlurDrawLooper> CmdListHelper::GetBlurDrawLooperFromCmdList(cons
return nullptr;
}
const void* ptr = cmdList.GetImageData(blurDrawLooperHandle.offset);
const void* ptr = cmdList.GetImageData(blurDrawLooperHandle.offset, blurDrawLooperHandle.size);
if (ptr == nullptr) {
return nullptr;
}

View File

@ -14,10 +14,10 @@
*/
#include "recording/draw_cmd.h"
#include <cstdint>
#include <sstream>
#include "platform/common/rs_system_properties.h"
#include "recording/cmd_list_helper.h"
#include "recording/draw_cmd_list.h"
#include "recording/mem_allocator.h"
@ -310,13 +310,13 @@ void DrawOpItem::Dump(std::string& out) const
GenerateCachedOpItemPlayer::GenerateCachedOpItemPlayer(DrawCmdList &cmdList, Canvas* canvas, const Rect* rect)
: canvas_(canvas), rect_(rect), cmdList_(cmdList) {}
bool GenerateCachedOpItemPlayer::GenerateCachedOpItem(uint32_t type, void* handle)
bool GenerateCachedOpItemPlayer::GenerateCachedOpItem(uint32_t type, void* handle, size_t avaliableSize)
{
if (handle == nullptr) {
return false;
}
if (type == DrawOpItem::TEXT_BLOB_OPITEM) {
if (type == DrawOpItem::TEXT_BLOB_OPITEM && avaliableSize >= sizeof(DrawTextBlobOpItem::ConstructorHandle)) {
auto* op = static_cast<DrawTextBlobOpItem::ConstructorHandle*>(handle);
return op->GenerateCachedOpItem(cmdList_, canvas_);
}
@ -330,35 +330,40 @@ UnmarshallingHelper& UnmarshallingHelper::Instance()
return instance;
}
bool UnmarshallingHelper::RegisterFunc(uint32_t type, UnmarshallingHelper::UnmarshallingFunc func)
bool UnmarshallingHelper::Register(uint32_t type, UnmarshallingHelper::UnmarshallingFunc func, size_t unmarshallingSize)
{
std::unique_lock lck(mtx_);
return opUnmarshallingFuncLUT_.emplace(type, func).second;
opUnmarshallingFuncLUT_.emplace(type, func);
opUnmarshallingSize_.emplace(type, unmarshallingSize);
return true;
}
UnmarshallingHelper::UnmarshallingFunc UnmarshallingHelper::GetFunc(uint32_t type)
std::pair<UnmarshallingHelper::UnmarshallingFunc, size_t> UnmarshallingHelper::GetFuncAndSize(uint32_t type)
{
std::shared_lock lck(mtx_);
auto it = opUnmarshallingFuncLUT_.find(type);
if (it == opUnmarshallingFuncLUT_.end()) {
return nullptr;
auto funcIt = opUnmarshallingFuncLUT_.find(type);
auto sizeIt = opUnmarshallingSize_.find(type);
if (funcIt == opUnmarshallingFuncLUT_.end() || sizeIt == opUnmarshallingSize_.end()) {
return { nullptr, 0 };
}
return it->second;
/* unmarshalling func, desirable size for unmarshalling*/
return { funcIt->second, sizeIt->second };
}
UnmarshallingPlayer::UnmarshallingPlayer(const DrawCmdList& cmdList) : cmdList_(cmdList) {}
std::shared_ptr<DrawOpItem> UnmarshallingPlayer::Unmarshalling(uint32_t type, void* handle)
std::shared_ptr<DrawOpItem> UnmarshallingPlayer::Unmarshalling(uint32_t type, void* handle, size_t avaliableSize)
{
if (type == DrawOpItem::OPITEM_HEAD) {
return nullptr;
}
const auto& func = UnmarshallingHelper::Instance().GetFunc(type);
if (func == nullptr) {
const auto unmarshallingPair = UnmarshallingHelper::Instance().GetFuncAndSize(type);
/* if unmarshalling func is null or avaliable size < desirable unmarshalling size, then return nullptr*/
if (unmarshallingPair.first == nullptr || unmarshallingPair.second > avaliableSize) {
return nullptr;
}
return (*func)(this->cmdList_, handle);
return (*unmarshallingPair.first)(this->cmdList_, handle);
}
/* DrawWithPaintOpItem */
@ -378,7 +383,8 @@ void DrawWithPaintOpItem::Dump(std::string& out) const
}
/* DrawPointOpItem */
REGISTER_UNMARSHALLING_FUNC(DrawPoint, DrawOpItem::POINT_OPITEM, DrawPointOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(DrawPoint, DrawOpItem::POINT_OPITEM,
DrawPointOpItem::Unmarshalling, sizeof(DrawPointOpItem::ConstructorHandle));
DrawPointOpItem::DrawPointOpItem(const DrawCmdList& cmdList, DrawPointOpItem::ConstructorHandle* handle)
: DrawWithPaintOpItem(cmdList, handle->paintHandle, POINT_OPITEM), point_(handle->point) {}
@ -408,7 +414,8 @@ void DrawPointOpItem::DumpItems(std::string& out) const
}
/* DrawPointsOpItem */
REGISTER_UNMARSHALLING_FUNC(DrawPoints, DrawOpItem::POINTS_OPITEM, DrawPointsOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(DrawPoints, DrawOpItem::POINTS_OPITEM,
DrawPointsOpItem::Unmarshalling, sizeof(DrawPointsOpItem::ConstructorHandle));
DrawPointsOpItem::DrawPointsOpItem(const DrawCmdList& cmdList, DrawPointsOpItem::ConstructorHandle* handle)
: DrawWithPaintOpItem(cmdList, handle->paintHandle, POINTS_OPITEM), mode_(handle->mode)
@ -436,7 +443,8 @@ void DrawPointsOpItem::Playback(Canvas* canvas, const Rect* rect)
}
/* DrawLineOpItem */
REGISTER_UNMARSHALLING_FUNC(DrawLine, DrawOpItem::LINE_OPITEM, DrawLineOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(DrawLine, DrawOpItem::LINE_OPITEM,
DrawLineOpItem::Unmarshalling, sizeof(DrawLineOpItem::ConstructorHandle));
DrawLineOpItem::DrawLineOpItem(const DrawCmdList& cmdList, DrawLineOpItem::ConstructorHandle* handle)
: DrawWithPaintOpItem(cmdList, handle->paintHandle, LINE_OPITEM),
@ -469,7 +477,8 @@ void DrawLineOpItem::DumpItems(std::string& out) const
}
/* DrawRectOpItem */
REGISTER_UNMARSHALLING_FUNC(DrawRect, DrawOpItem::RECT_OPITEM, DrawRectOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(DrawRect, DrawOpItem::RECT_OPITEM,
DrawRectOpItem::Unmarshalling, sizeof(DrawRectOpItem::ConstructorHandle));
DrawRectOpItem::DrawRectOpItem(const DrawCmdList& cmdList, DrawRectOpItem::ConstructorHandle* handle)
: DrawWithPaintOpItem(cmdList, handle->paintHandle, RECT_OPITEM), rect_(handle->rect) {}
@ -499,7 +508,8 @@ void DrawRectOpItem::DumpItems(std::string& out) const
}
/* DrawRoundRectOpItem */
REGISTER_UNMARSHALLING_FUNC(DrawRoundRect, DrawOpItem::ROUND_RECT_OPITEM, DrawRoundRectOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(DrawRoundRect, DrawOpItem::ROUND_RECT_OPITEM,
DrawRoundRectOpItem::Unmarshalling, sizeof(DrawRoundRectOpItem::ConstructorHandle));
DrawRoundRectOpItem::DrawRoundRectOpItem(const DrawCmdList& cmdList, DrawRoundRectOpItem::ConstructorHandle* handle)
: DrawWithPaintOpItem(cmdList, handle->paintHandle, ROUND_RECT_OPITEM), rrect_(handle->rrect) {}
@ -529,8 +539,8 @@ void DrawRoundRectOpItem::DumpItems(std::string& out) const
}
/* DrawNestedRoundRectOpItem */
REGISTER_UNMARSHALLING_FUNC(
DrawNestedRoundRect, DrawOpItem::NESTED_ROUND_RECT_OPITEM, DrawNestedRoundRectOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(DrawNestedRoundRect, DrawOpItem::NESTED_ROUND_RECT_OPITEM,
DrawNestedRoundRectOpItem::Unmarshalling, sizeof(DrawNestedRoundRectOpItem::ConstructorHandle));
DrawNestedRoundRectOpItem::DrawNestedRoundRectOpItem(
const DrawCmdList& cmdList, DrawNestedRoundRectOpItem::ConstructorHandle* handle)
@ -565,7 +575,8 @@ void DrawNestedRoundRectOpItem::DumpItems(std::string& out) const
}
/* DrawArcOpItem */
REGISTER_UNMARSHALLING_FUNC(DrawArc, DrawOpItem::ARC_OPITEM, DrawArcOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(DrawArc, DrawOpItem::ARC_OPITEM,
DrawArcOpItem::Unmarshalling, sizeof(DrawArcOpItem::ConstructorHandle));
DrawArcOpItem::DrawArcOpItem(const DrawCmdList& cmdList, DrawArcOpItem::ConstructorHandle* handle)
: DrawWithPaintOpItem(cmdList, handle->paintHandle, ARC_OPITEM), rect_(handle->rect),
@ -598,7 +609,8 @@ void DrawArcOpItem::DumpItems(std::string& out) const
}
/* DrawPieOpItem */
REGISTER_UNMARSHALLING_FUNC(DrawPie, DrawOpItem::PIE_OPITEM, DrawPieOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(DrawPie, DrawOpItem::PIE_OPITEM,
DrawPieOpItem::Unmarshalling, sizeof(DrawPieOpItem::ConstructorHandle));
DrawPieOpItem::DrawPieOpItem(const DrawCmdList& cmdList, DrawPieOpItem::ConstructorHandle* handle)
: DrawWithPaintOpItem(cmdList, handle->paintHandle, PIE_OPITEM), rect_(handle->rect),
@ -631,7 +643,8 @@ void DrawPieOpItem::DumpItems(std::string& out) const
}
/* DrawOvalOpItem */
REGISTER_UNMARSHALLING_FUNC(DrawOval, DrawOpItem::OVAL_OPITEM, DrawOvalOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(DrawOval, DrawOpItem::OVAL_OPITEM,
DrawOvalOpItem::Unmarshalling, sizeof(DrawOvalOpItem::ConstructorHandle));
DrawOvalOpItem::DrawOvalOpItem(const DrawCmdList& cmdList, DrawOvalOpItem::ConstructorHandle* handle)
: DrawWithPaintOpItem(cmdList, handle->paintHandle, OVAL_OPITEM), rect_(handle->rect) {}
@ -661,7 +674,8 @@ void DrawOvalOpItem::DumpItems(std::string& out) const
}
/* DrawCircleOpItem */
REGISTER_UNMARSHALLING_FUNC(DrawCircle, DrawOpItem::CIRCLE_OPITEM, DrawCircleOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(DrawCircle, DrawOpItem::CIRCLE_OPITEM,
DrawCircleOpItem::Unmarshalling, sizeof(DrawCircleOpItem::ConstructorHandle));
DrawCircleOpItem::DrawCircleOpItem(const DrawCmdList& cmdList, DrawCircleOpItem::ConstructorHandle* handle)
: DrawWithPaintOpItem(cmdList, handle->paintHandle, CIRCLE_OPITEM),
@ -693,7 +707,8 @@ void DrawCircleOpItem::DumpItems(std::string& out) const
}
/* DrawPathOpItem */
REGISTER_UNMARSHALLING_FUNC(DrawPath, DrawOpItem::PATH_OPITEM, DrawPathOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(DrawPath, DrawOpItem::PATH_OPITEM,
DrawPathOpItem::Unmarshalling, sizeof(DrawPathOpItem::ConstructorHandle));
DrawPathOpItem::DrawPathOpItem(const DrawCmdList& cmdList, DrawPathOpItem::ConstructorHandle* handle)
: DrawWithPaintOpItem(cmdList, handle->paintHandle, PATH_OPITEM)
@ -736,7 +751,8 @@ void DrawPathOpItem::DumpItems(std::string& out) const
}
/* DrawBackgroundOpItem */
REGISTER_UNMARSHALLING_FUNC(DrawBackground, DrawOpItem::BACKGROUND_OPITEM, DrawBackgroundOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(DrawBackground, DrawOpItem::BACKGROUND_OPITEM,
DrawBackgroundOpItem::Unmarshalling, sizeof(DrawBackgroundOpItem::ConstructorHandle));
DrawBackgroundOpItem::DrawBackgroundOpItem(const DrawCmdList& cmdList, DrawBackgroundOpItem::ConstructorHandle* handle)
: DrawOpItem(BACKGROUND_OPITEM)
@ -763,7 +779,8 @@ void DrawBackgroundOpItem::Playback(Canvas* canvas, const Rect* rect)
}
/* DrawShadowStyleOpItem */
REGISTER_UNMARSHALLING_FUNC(DrawShadowStyle, DrawOpItem::SHADOW_STYLE_OPITEM, DrawShadowStyleOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(DrawShadowStyle, DrawOpItem::SHADOW_STYLE_OPITEM,
DrawShadowStyleOpItem::Unmarshalling, sizeof(DrawShadowStyleOpItem::ConstructorHandle));
DrawShadowStyleOpItem::DrawShadowStyleOpItem(
const DrawCmdList& cmdList, DrawShadowStyleOpItem::ConstructorHandle* handle)
@ -822,7 +839,8 @@ void DrawShadowStyleOpItem::Dump(std::string& out) const
}
/* DrawShadowOpItem */
REGISTER_UNMARSHALLING_FUNC(DrawShadow, DrawOpItem::SHADOW_OPITEM, DrawShadowOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(DrawShadow, DrawOpItem::SHADOW_OPITEM,
DrawShadowOpItem::Unmarshalling, sizeof(DrawShadowOpItem::ConstructorHandle));
DrawShadowOpItem::DrawShadowOpItem(const DrawCmdList& cmdList, DrawShadowOpItem::ConstructorHandle* handle)
: DrawOpItem(SHADOW_OPITEM), planeParams_(handle->planeParams), devLightPos_(handle->devLightPos),
@ -879,7 +897,8 @@ void DrawShadowOpItem::Dump(std::string& out) const
}
/* DrawRegionOpItem */
REGISTER_UNMARSHALLING_FUNC(DrawRegion, DrawOpItem::REGION_OPITEM, DrawRegionOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(DrawRegion, DrawOpItem::REGION_OPITEM,
DrawRegionOpItem::Unmarshalling, sizeof(DrawRegionOpItem::ConstructorHandle));
DrawRegionOpItem::DrawRegionOpItem(const DrawCmdList& cmdList, DrawRegionOpItem::ConstructorHandle* handle)
: DrawWithPaintOpItem(cmdList, handle->paintHandle, REGION_OPITEM)
@ -922,7 +941,8 @@ void DrawRegionOpItem::DumpItems(std::string& out) const
}
/* DrawVerticesOpItem */
REGISTER_UNMARSHALLING_FUNC(DrawVertices, DrawOpItem::VERTICES_OPITEM, DrawVerticesOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(DrawVertices, DrawOpItem::VERTICES_OPITEM,
DrawVerticesOpItem::Unmarshalling, sizeof(DrawVerticesOpItem::ConstructorHandle));
DrawVerticesOpItem::DrawVerticesOpItem(const DrawCmdList& cmdList, DrawVerticesOpItem::ConstructorHandle* handle)
: DrawWithPaintOpItem(cmdList, handle->paintHandle, VERTICES_OPITEM), mode_(handle->mode)
@ -966,7 +986,8 @@ void DrawVerticesOpItem::DumpItems(std::string& out) const
}
/* DrawColorOpItem */
REGISTER_UNMARSHALLING_FUNC(DrawColor, DrawOpItem::COLOR_OPITEM, DrawColorOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(DrawColor, DrawOpItem::COLOR_OPITEM,
DrawColorOpItem::Unmarshalling, sizeof(DrawColorOpItem::ConstructorHandle));
DrawColorOpItem::DrawColorOpItem(DrawColorOpItem::ConstructorHandle* handle)
: DrawOpItem(COLOR_OPITEM), color_(handle->color), mode_(handle->mode) {}
@ -995,7 +1016,8 @@ void DrawColorOpItem::Dump(std::string& out) const
}
/* DrawImageNineOpItem */
REGISTER_UNMARSHALLING_FUNC(DrawImageNine, DrawOpItem::IMAGE_NINE_OPITEM, DrawImageNineOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(DrawImageNine, DrawOpItem::IMAGE_NINE_OPITEM,
DrawImageNineOpItem::Unmarshalling, sizeof(DrawImageNineOpItem::ConstructorHandle));
DrawImageNineOpItem::DrawImageNineOpItem(const DrawCmdList& cmdList, DrawImageNineOpItem::ConstructorHandle* handle)
: DrawOpItem(IMAGE_NINE_OPITEM), center_(handle->center), dst_(handle->dst), filter_(handle->filter),
@ -1062,7 +1084,8 @@ void DrawImageNineOpItem::Dump(std::string& out) const
}
/* DrawImageLatticeOpItem */
REGISTER_UNMARSHALLING_FUNC(DrawImageLattice, DrawOpItem::IMAGE_LATTICE_OPITEM, DrawImageLatticeOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(DrawImageLattice, DrawOpItem::IMAGE_LATTICE_OPITEM,
DrawImageLatticeOpItem::Unmarshalling, sizeof(DrawImageLatticeOpItem::ConstructorHandle));
DrawImageLatticeOpItem::DrawImageLatticeOpItem(
const DrawCmdList& cmdList, DrawImageLatticeOpItem::ConstructorHandle* handle)
@ -1142,7 +1165,8 @@ void DrawImageLatticeOpItem::Dump(std::string& out) const
}
/* DrawAtlasOpItem */
REGISTER_UNMARSHALLING_FUNC(DrawAtlas, DrawOpItem::ATLAS_OPITEM, DrawAtlasOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(DrawAtlas, DrawOpItem::ATLAS_OPITEM,
DrawAtlasOpItem::Unmarshalling, sizeof(DrawAtlasOpItem::ConstructorHandle));
DrawAtlasOpItem::DrawAtlasOpItem(const DrawCmdList& cmdList, DrawAtlasOpItem::ConstructorHandle* handle)
: DrawWithPaintOpItem(cmdList, handle->paintHandle, ATLAS_OPITEM), mode_(handle->mode),
@ -1235,7 +1259,8 @@ void DrawAtlasOpItem::DumpItems(std::string& out) const
}
/* DrawBitmapOpItem */
REGISTER_UNMARSHALLING_FUNC(DrawBitmap, DrawOpItem::BITMAP_OPITEM, DrawBitmapOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(DrawBitmap, DrawOpItem::BITMAP_OPITEM,
DrawBitmapOpItem::Unmarshalling, sizeof(DrawBitmapOpItem::ConstructorHandle));
DrawBitmapOpItem::DrawBitmapOpItem(const DrawCmdList& cmdList, DrawBitmapOpItem::ConstructorHandle* handle)
: DrawWithPaintOpItem(cmdList, handle->paintHandle, BITMAP_OPITEM), px_(handle->px), py_(handle->py)
@ -1279,7 +1304,8 @@ void DrawBitmapOpItem::DumpItems(std::string& out) const
}
/* DrawImageOpItem */
REGISTER_UNMARSHALLING_FUNC(DrawImage, DrawOpItem::IMAGE_OPITEM, DrawImageOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(DrawImage, DrawOpItem::IMAGE_OPITEM,
DrawImageOpItem::Unmarshalling, sizeof(DrawImageOpItem::ConstructorHandle));
DrawImageOpItem::DrawImageOpItem(const DrawCmdList& cmdList, DrawImageOpItem::ConstructorHandle* handle)
: DrawWithPaintOpItem(cmdList, handle->paintHandle, IMAGE_OPITEM), px_(handle->px), py_(handle->py),
@ -1329,7 +1355,8 @@ void DrawImageOpItem::DumpItems(std::string& out) const
}
/* DrawImageRectOpItem */
REGISTER_UNMARSHALLING_FUNC(DrawImageRect, DrawOpItem::IMAGE_RECT_OPITEM, DrawImageRectOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(DrawImageRect, DrawOpItem::IMAGE_RECT_OPITEM,
DrawImageRectOpItem::Unmarshalling, sizeof(DrawImageRectOpItem::ConstructorHandle));
DrawImageRectOpItem::DrawImageRectOpItem(const DrawCmdList& cmdList, DrawImageRectOpItem::ConstructorHandle* handle)
: DrawWithPaintOpItem(cmdList, handle->paintHandle, IMAGE_RECT_OPITEM), src_(handle->src), dst_(handle->dst),
@ -1407,7 +1434,8 @@ void DrawImageRectOpItem::DumpItems(std::string& out) const
}
/* DrawRecordCmdOpItem */
REGISTER_UNMARSHALLING_FUNC(DrawRecordCmd, DrawOpItem::RECORD_CMD_OPITEM, DrawRecordCmdOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(DrawRecordCmd, DrawOpItem::RECORD_CMD_OPITEM,
DrawRecordCmdOpItem::Unmarshalling, sizeof(DrawRecordCmdOpItem::ConstructorHandle));
DrawRecordCmdOpItem::DrawRecordCmdOpItem(
const DrawCmdList& cmdList, DrawRecordCmdOpItem::ConstructorHandle* handle)
@ -1459,7 +1487,8 @@ void DrawRecordCmdOpItem::Playback(Canvas* canvas, const Rect* rect)
}
/* DrawPictureOpItem */
REGISTER_UNMARSHALLING_FUNC(DrawPicture, DrawOpItem::PICTURE_OPITEM, DrawPictureOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(DrawPicture, DrawOpItem::PICTURE_OPITEM,
DrawPictureOpItem::Unmarshalling, sizeof(DrawPictureOpItem::ConstructorHandle));
DrawPictureOpItem::DrawPictureOpItem(const DrawCmdList& cmdList, DrawPictureOpItem::ConstructorHandle* handle)
: DrawOpItem(PICTURE_OPITEM)
@ -1491,7 +1520,8 @@ void DrawPictureOpItem::Playback(Canvas* canvas, const Rect* rect)
}
/* DrawTextBlobOpItem */
REGISTER_UNMARSHALLING_FUNC(DrawTextBlob, DrawOpItem::TEXT_BLOB_OPITEM, DrawTextBlobOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(DrawTextBlob, DrawOpItem::TEXT_BLOB_OPITEM,
DrawTextBlobOpItem::Unmarshalling, sizeof(DrawTextBlobOpItem::ConstructorHandle));
void SimplifyPaint(ColorQuad colorQuad, Paint& paint)
{
@ -1829,7 +1859,8 @@ void DrawTextBlobOpItem::DumpItems(std::string& out) const
}
/* DrawSymbolOpItem */
REGISTER_UNMARSHALLING_FUNC(DrawSymbol, DrawOpItem::SYMBOL_OPITEM, DrawSymbolOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(DrawSymbol, DrawOpItem::SYMBOL_OPITEM,
DrawSymbolOpItem::Unmarshalling, sizeof(DrawSymbolOpItem::ConstructorHandle));
DrawSymbolOpItem::DrawSymbolOpItem(const DrawCmdList& cmdList, DrawSymbolOpItem::ConstructorHandle* handle)
: DrawWithPaintOpItem(cmdList, handle->paintHandle, SYMBOL_OPITEM), locate_(handle->locate)
@ -1931,7 +1962,8 @@ void DrawSymbolOpItem::DumpItems(std::string& out) const
}
/* ClipRectOpItem */
REGISTER_UNMARSHALLING_FUNC(ClipRect, DrawOpItem::CLIP_RECT_OPITEM, ClipRectOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(ClipRect, DrawOpItem::CLIP_RECT_OPITEM,
ClipRectOpItem::Unmarshalling, sizeof(ClipRectOpItem::ConstructorHandle));
ClipRectOpItem::ClipRectOpItem(ClipRectOpItem::ConstructorHandle* handle)
: DrawOpItem(CLIP_RECT_OPITEM), rect_(handle->rect), clipOp_(handle->clipOp), doAntiAlias_(handle->doAntiAlias) {}
@ -1961,7 +1993,8 @@ void ClipRectOpItem::Dump(std::string& out) const
}
/* ClipIRectOpItem */
REGISTER_UNMARSHALLING_FUNC(ClipIRect, DrawOpItem::CLIP_IRECT_OPITEM, ClipIRectOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(ClipIRect, DrawOpItem::CLIP_IRECT_OPITEM,
ClipIRectOpItem::Unmarshalling, sizeof(ClipIRectOpItem::ConstructorHandle));
ClipIRectOpItem::ClipIRectOpItem(ClipIRectOpItem::ConstructorHandle* handle)
: DrawOpItem(CLIP_IRECT_OPITEM), rect_(handle->rect), clipOp_(handle->clipOp) {}
@ -1990,7 +2023,8 @@ void ClipIRectOpItem::Dump(std::string& out) const
}
/* ClipRoundRectOpItem */
REGISTER_UNMARSHALLING_FUNC(ClipRoundRect, DrawOpItem::CLIP_ROUND_RECT_OPITEM, ClipRoundRectOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(ClipRoundRect, DrawOpItem::CLIP_ROUND_RECT_OPITEM,
ClipRoundRectOpItem::Unmarshalling, sizeof(ClipRoundRectOpItem::ConstructorHandle));
ClipRoundRectOpItem::ClipRoundRectOpItem(ClipRoundRectOpItem::ConstructorHandle* handle)
: DrawOpItem(CLIP_ROUND_RECT_OPITEM), rrect_(handle->rrect), clipOp_(handle->clipOp),
@ -2021,7 +2055,8 @@ void ClipRoundRectOpItem::Dump(std::string& out) const
}
/* ClipPathOpItem */
REGISTER_UNMARSHALLING_FUNC(ClipPath, DrawOpItem::CLIP_PATH_OPITEM, ClipPathOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(ClipPath, DrawOpItem::CLIP_PATH_OPITEM,
ClipPathOpItem::Unmarshalling, sizeof(ClipPathOpItem::ConstructorHandle));
ClipPathOpItem::ClipPathOpItem(const DrawCmdList& cmdList, ClipPathOpItem::ConstructorHandle* handle)
: DrawOpItem(CLIP_PATH_OPITEM), clipOp_(handle->clipOp), doAntiAlias_(handle->doAntiAlias)
@ -2053,7 +2088,8 @@ void ClipPathOpItem::Playback(Canvas* canvas, const Rect* rect)
}
/* ClipRegionOpItem */
REGISTER_UNMARSHALLING_FUNC(ClipRegion, DrawOpItem::CLIP_REGION_OPITEM, ClipRegionOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(ClipRegion, DrawOpItem::CLIP_REGION_OPITEM,
ClipRegionOpItem::Unmarshalling, sizeof(ClipRegionOpItem::ConstructorHandle));
ClipRegionOpItem::ClipRegionOpItem(const DrawCmdList& cmdList, ClipRegionOpItem::ConstructorHandle* handle)
: DrawOpItem(CLIP_REGION_OPITEM), clipOp_(handle->clipOp)
@ -2097,7 +2133,8 @@ void ClipRegionOpItem::Dump(std::string& out) const
}
/* SetMatrixOpItem */
REGISTER_UNMARSHALLING_FUNC(SetMatrix, DrawOpItem::SET_MATRIX_OPITEM, SetMatrixOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(SetMatrix, DrawOpItem::SET_MATRIX_OPITEM,
SetMatrixOpItem::Unmarshalling, sizeof(SetMatrixOpItem::ConstructorHandle));
SetMatrixOpItem::SetMatrixOpItem(SetMatrixOpItem::ConstructorHandle* handle) : DrawOpItem(SET_MATRIX_OPITEM)
{
@ -2133,7 +2170,8 @@ void SetMatrixOpItem::Dump(std::string& out) const
}
/* ResetMatrixOpItem */
REGISTER_UNMARSHALLING_FUNC(ResetMatrix, DrawOpItem::RESET_MATRIX_OPITEM, ResetMatrixOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(ResetMatrix, DrawOpItem::RESET_MATRIX_OPITEM,
ResetMatrixOpItem::Unmarshalling, sizeof(ResetMatrixOpItem::ConstructorHandle));
ResetMatrixOpItem::ResetMatrixOpItem() : DrawOpItem(RESET_MATRIX_OPITEM) {}
@ -2153,7 +2191,8 @@ void ResetMatrixOpItem::Playback(Canvas* canvas, const Rect* rect)
}
/* ConcatMatrixOpItem */
REGISTER_UNMARSHALLING_FUNC(ConcatMatrix, DrawOpItem::CONCAT_MATRIX_OPITEM, ConcatMatrixOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(ConcatMatrix, DrawOpItem::CONCAT_MATRIX_OPITEM,
ConcatMatrixOpItem::Unmarshalling, sizeof(ConcatMatrixOpItem::ConstructorHandle));
ConcatMatrixOpItem::ConcatMatrixOpItem(ConcatMatrixOpItem::ConstructorHandle* handle) : DrawOpItem(CONCAT_MATRIX_OPITEM)
{
@ -2189,7 +2228,8 @@ void ConcatMatrixOpItem::Dump(std::string& out) const
}
/* TranslateOpItem */
REGISTER_UNMARSHALLING_FUNC(Translate, DrawOpItem::TRANSLATE_OPITEM, TranslateOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(Translate, DrawOpItem::TRANSLATE_OPITEM,
TranslateOpItem::Unmarshalling, sizeof(TranslateOpItem::ConstructorHandle));
TranslateOpItem::TranslateOpItem(TranslateOpItem::ConstructorHandle* handle)
: DrawOpItem(TRANSLATE_OPITEM), dx_(handle->dx), dy_(handle->dy) {}
@ -2218,7 +2258,8 @@ void TranslateOpItem::Dump(std::string& out) const
}
/* ScaleOpItem */
REGISTER_UNMARSHALLING_FUNC(Scale, DrawOpItem::SCALE_OPITEM, ScaleOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(Scale, DrawOpItem::SCALE_OPITEM,
ScaleOpItem::Unmarshalling, sizeof(ScaleOpItem::ConstructorHandle));
ScaleOpItem::ScaleOpItem(ScaleOpItem::ConstructorHandle* handle)
: DrawOpItem(SCALE_OPITEM), sx_(handle->sx), sy_(handle->sy) {}
@ -2247,7 +2288,8 @@ void ScaleOpItem::Dump(std::string& out) const
}
/* RotateOpItem */
REGISTER_UNMARSHALLING_FUNC(Rotate, DrawOpItem::ROTATE_OPITEM, RotateOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(Rotate, DrawOpItem::ROTATE_OPITEM,
RotateOpItem::Unmarshalling, sizeof(RotateOpItem::ConstructorHandle));
RotateOpItem::RotateOpItem(RotateOpItem::ConstructorHandle* handle)
: DrawOpItem(ROTATE_OPITEM), deg_(handle->deg), sx_(handle->sx), sy_(handle->sy) {}
@ -2277,7 +2319,8 @@ void RotateOpItem::Dump(std::string& out) const
}
/* ShearOpItem */
REGISTER_UNMARSHALLING_FUNC(Shear, DrawOpItem::SHEAR_OPITEM, ShearOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(Shear, DrawOpItem::SHEAR_OPITEM,
ShearOpItem::Unmarshalling, sizeof(ShearOpItem::ConstructorHandle));
ShearOpItem::ShearOpItem(ShearOpItem::ConstructorHandle* handle)
: DrawOpItem(SHEAR_OPITEM), sx_(handle->sx), sy_(handle->sy) {}
@ -2306,7 +2349,8 @@ void ShearOpItem::Dump(std::string& out) const
}
/* FlushOpItem */
REGISTER_UNMARSHALLING_FUNC(Flush, DrawOpItem::FLUSH_OPITEM, FlushOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(Flush, DrawOpItem::FLUSH_OPITEM,
FlushOpItem::Unmarshalling, sizeof(FlushOpItem::ConstructorHandle));
FlushOpItem::FlushOpItem() : DrawOpItem(FLUSH_OPITEM) {}
@ -2326,7 +2370,8 @@ void FlushOpItem::Playback(Canvas* canvas, const Rect* rect)
}
/* ClearOpItem */
REGISTER_UNMARSHALLING_FUNC(Clear, DrawOpItem::CLEAR_OPITEM, ClearOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(Clear, DrawOpItem::CLEAR_OPITEM,
ClearOpItem::Unmarshalling, sizeof(ClearOpItem::ConstructorHandle));
ClearOpItem::ClearOpItem(ClearOpItem::ConstructorHandle* handle)
: DrawOpItem(CLEAR_OPITEM), color_(handle->color) {}
@ -2353,7 +2398,8 @@ void ClearOpItem::Dump(std::string& out) const
}
/* SaveOpItem */
REGISTER_UNMARSHALLING_FUNC(Save, DrawOpItem::SAVE_OPITEM, SaveOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(Save, DrawOpItem::SAVE_OPITEM,
SaveOpItem::Unmarshalling, sizeof(SaveOpItem::ConstructorHandle));
SaveOpItem::SaveOpItem() : DrawOpItem(SAVE_OPITEM) {}
@ -2373,7 +2419,8 @@ void SaveOpItem::Playback(Canvas* canvas, const Rect* rect)
}
/* SaveLayerOpItem */
REGISTER_UNMARSHALLING_FUNC(SaveLayer, DrawOpItem::SAVE_LAYER_OPITEM, SaveLayerOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(SaveLayer, DrawOpItem::SAVE_LAYER_OPITEM,
SaveLayerOpItem::Unmarshalling, sizeof(SaveLayerOpItem::ConstructorHandle));
SaveLayerOpItem::SaveLayerOpItem(const DrawCmdList& cmdList, SaveLayerOpItem::ConstructorHandle* handle)
: DrawOpItem(SAVE_LAYER_OPITEM), saveLayerFlags_(handle->saveLayerFlags), rect_(handle->rect),
@ -2424,7 +2471,8 @@ void SaveLayerOpItem::Dump(std::string& out) const
}
/* RestoreOpItem */
REGISTER_UNMARSHALLING_FUNC(Restore, DrawOpItem::RESTORE_OPITEM, RestoreOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(Restore, DrawOpItem::RESTORE_OPITEM,
RestoreOpItem::Unmarshalling, sizeof(RestoreOpItem::ConstructorHandle));
RestoreOpItem::RestoreOpItem() : DrawOpItem(RESTORE_OPITEM) {}
@ -2444,7 +2492,8 @@ void RestoreOpItem::Playback(Canvas* canvas, const Rect* rect)
}
/* DiscardOpItem */
REGISTER_UNMARSHALLING_FUNC(Discard, DrawOpItem::DISCARD_OPITEM, DiscardOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(Discard, DrawOpItem::DISCARD_OPITEM,
DiscardOpItem::Unmarshalling, sizeof(DiscardOpItem::ConstructorHandle));
DiscardOpItem::DiscardOpItem() : DrawOpItem(DISCARD_OPITEM) {}
@ -2464,8 +2513,8 @@ void DiscardOpItem::Playback(Canvas* canvas, const Rect* rect)
}
/* ClipAdaptiveRoundRectOpItem */
REGISTER_UNMARSHALLING_FUNC(
ClipAdaptiveRoundRect, DrawOpItem::CLIP_ADAPTIVE_ROUND_RECT_OPITEM, ClipAdaptiveRoundRectOpItem::Unmarshalling);
UNMARSHALLING_REGISTER(ClipAdaptiveRoundRect, DrawOpItem::CLIP_ADAPTIVE_ROUND_RECT_OPITEM,
ClipAdaptiveRoundRectOpItem::Unmarshalling, sizeof(ClipAdaptiveRoundRectOpItem::ConstructorHandle));
ClipAdaptiveRoundRectOpItem::ClipAdaptiveRoundRectOpItem(
const DrawCmdList& cmdList, ClipAdaptiveRoundRectOpItem::ConstructorHandle* handle)

View File

@ -36,8 +36,8 @@ std::shared_ptr<DrawCmdList> DrawCmdList::CreateFromData(const CmdListData& data
cmdList->opAllocator_.BuildFromData(data.first, data.second);
}
int32_t* width = static_cast<int32_t*>(cmdList->opAllocator_.OffsetToAddr(0));
int32_t* height = static_cast<int32_t*>(cmdList->opAllocator_.OffsetToAddr(sizeof(int32_t)));
int32_t* width = static_cast<int32_t*>(cmdList->opAllocator_.OffsetToAddr(0, sizeof(int32_t)));
int32_t* height = static_cast<int32_t*>(cmdList->opAllocator_.OffsetToAddr(sizeof(int32_t), sizeof(int32_t)));
if (width && height) {
cmdList->width_ = *width;
cmdList->height_ = *height;
@ -130,7 +130,7 @@ bool DrawCmdList::IsEmpty() const
if (mode_ == DrawCmdList::UnmarshalMode::DEFERRED) {
return drawOpItems_.empty();
}
uint32_t offset = 2 * sizeof(int32_t); // 2 is width and height.Offset of first OpItem is behind the w and h
size_t offset = 2 * sizeof(int32_t); // 2 is width and height.Offset of first OpItem is behind the w and h
if (opAllocator_.GetSize() <= offset && drawOpItems_.size() == 0) {
return true;
}
@ -211,11 +211,11 @@ void DrawCmdList::MarshallingDrawOps()
void DrawCmdList::CaculatePerformanceOpType()
{
uint32_t offset = offset_;
size_t offset = offset_;
const int caculatePerformaceCount = 500; // 被测单接口用例至少出现500次以上
std::map<uint32_t, uint32_t> opTypeCountMap;
do {
void* itemPtr = opAllocator_.OffsetToAddr(offset);
void* itemPtr = opAllocator_.OffsetToAddr(offset, sizeof(OpItem));
auto* curOpItemPtr = static_cast<OpItem*>(itemPtr);
if (curOpItemPtr == nullptr) {
break;
@ -251,29 +251,31 @@ void DrawCmdList::UnmarshallingDrawOps()
drawOpItems_.clear();
lastOpGenSize_ = 0;
uint32_t opReplaceIndex = 0;
uint32_t offset = offset_;
size_t offset = offset_;
do {
void* itemPtr = opAllocator_.OffsetToAddr(offset);
void* itemPtr = opAllocator_.OffsetToAddr(offset, sizeof(OpItem));
auto* curOpItemPtr = static_cast<OpItem*>(itemPtr);
if (curOpItemPtr == nullptr) {
LOGE("DrawCmdList::UnmarshallingOps failed, opItem is nullptr");
break;
}
uint32_t type = curOpItemPtr->GetType();
auto op = player.Unmarshalling(type, itemPtr);
auto op = player.Unmarshalling(type, itemPtr, opAllocator_.GetSize() - offset);
if (!op) {
offset = curOpItemPtr->GetNextOpItemOffset();
continue;
}
if (opReplaceIndex < replacedOpListForBuffer_.size() &&
replacedOpListForBuffer_[opReplaceIndex].first == offset) {
auto* replacePtr = opAllocator_.OffsetToAddr(replacedOpListForBuffer_[opReplaceIndex].second);
auto* replacePtr = opAllocator_.OffsetToAddr(
replacedOpListForBuffer_[opReplaceIndex].second, sizeof(OpItem));
if (replacePtr == nullptr) {
LOGE("DrawCmdList::Unmarshalling replace Ops failed, replace op is nullptr");
break;
}
auto* replaceOpItemPtr = static_cast<OpItem*>(replacePtr);
auto replaceOp = player.Unmarshalling(replaceOpItemPtr->GetType(), replacePtr);
size_t avaliableSize = opAllocator_.GetSize() - replacedOpListForBuffer_[opReplaceIndex].second;
auto replaceOp = player.Unmarshalling(replaceOpItemPtr->GetType(), replacePtr, avaliableSize);
if (replaceOp) {
drawOpItems_.emplace_back(replaceOp);
replacedOpListForVector_.emplace_back((drawOpItems_.size() - 1), op);
@ -292,9 +294,9 @@ void DrawCmdList::UnmarshallingDrawOps()
} while (offset != 0);
lastOpGenSize_ = opAllocator_.GetSize();
if ((int)imageAllocator_.GetSize() > 0) {
imageAllocator_.ClearData();
}
opAllocator_.ClearData();
imageAllocator_.ClearData();
bitmapAllocator_.ClearData();
if (performanceCaculateOpType_ != 0) {
LOGI("Drawing Performance UnmarshallingDrawOps end %{public}lld", PerformanceCaculate::GetUpTime());
@ -379,12 +381,12 @@ void DrawCmdList::SetCachedHighContrast(bool cachedHighContrast)
cachedHighContrast_ = cachedHighContrast;
}
std::vector<std::pair<uint32_t, uint32_t>> DrawCmdList::GetReplacedOpList()
std::vector<std::pair<size_t, size_t>> DrawCmdList::GetReplacedOpList()
{
return replacedOpListForBuffer_;
}
void DrawCmdList::SetReplacedOpList(std::vector<std::pair<uint32_t, uint32_t>> replacedOpList)
void DrawCmdList::SetReplacedOpList(std::vector<std::pair<size_t, size_t>> replacedOpList)
{
replacedOpListForBuffer_ = replacedOpList;
}
@ -447,17 +449,18 @@ void DrawCmdList::GenerateCacheByBuffer(Canvas* canvas, const Rect* rect)
return;
}
uint32_t offset = offset_;
size_t offset = offset_;
GenerateCachedOpItemPlayer player = { *this, canvas, rect };
uint32_t maxOffset = opAllocator_.GetSize();
do {
void* itemPtr = opAllocator_.OffsetToAddr(offset);
void* itemPtr = opAllocator_.OffsetToAddr(offset, sizeof(OpItem));
auto* curOpItemPtr = static_cast<OpItem*>(itemPtr);
if (curOpItemPtr == nullptr) {
LOGE("DrawCmdList::GenerateCacheByBuffer failed, opItem is nullptr");
break;
}
bool replaceSuccess = player.GenerateCachedOpItem(curOpItemPtr->GetType(), itemPtr);
size_t avaliableSize = opAllocator_.GetSize() - offset;
bool replaceSuccess = player.GenerateCachedOpItem(curOpItemPtr->GetType(), itemPtr, avaliableSize);
if (replaceSuccess) {
replacedOpListForBuffer_.push_back({offset, lastOpItemOffset_.value()});
}
@ -480,7 +483,7 @@ void DrawCmdList::PlaybackToDrawCmdList(std::shared_ptr<DrawCmdList> drawCmdList
return;
}
void* addr = opAllocator_.OffsetToAddr(offset_);
void* addr = opAllocator_.OffsetToAddr(offset_, 0);
if (addr == nullptr) {
return;
}
@ -530,18 +533,18 @@ void DrawCmdList::PlaybackByBuffer(Canvas& canvas, const Rect* rect)
if (opAllocator_.GetSize() <= offset_) {
return;
}
uint32_t offset = offset_;
size_t offset = offset_;
if (lastOpGenSize_ != opAllocator_.GetSize()) {
UnmarshallingPlayer player = { *this };
drawOpItems_.clear();
do {
void* itemPtr = opAllocator_.OffsetToAddr(offset);
void* itemPtr = opAllocator_.OffsetToAddr(offset, sizeof(OpItem));
auto* curOpItemPtr = static_cast<OpItem*>(itemPtr);
if (curOpItemPtr == nullptr) {
break;
}
uint32_t type = curOpItemPtr->GetType();
if (auto op = player.Unmarshalling(type, itemPtr)) {
if (auto op = player.Unmarshalling(type, itemPtr, opAllocator_.GetSize() - offset)) {
drawOpItems_.emplace_back(op);
}
offset = curOpItemPtr->GetNextOpItemOffset();
@ -560,10 +563,10 @@ size_t DrawCmdList::CountTextBlobNum()
{
size_t textBlobCnt = 0;
if (mode_ == DrawCmdList::UnmarshalMode::IMMEDIATE) {
uint32_t offset = offset_;
uint32_t maxOffset = opAllocator_.GetSize();
size_t offset = offset_;
size_t maxOffset = opAllocator_.GetSize();
do {
void* itemPtr = opAllocator_.OffsetToAddr(offset);
void* itemPtr = opAllocator_.OffsetToAddr(offset, sizeof(OpItem));
auto* curOpItemPtr = static_cast<OpItem*>(itemPtr);
if (curOpItemPtr == nullptr) {
break;
@ -582,10 +585,10 @@ void DrawCmdList::PatchTypefaceIds()
{
constexpr int bitNumber = 30 + 32;
uint64_t replayMask = (uint64_t)1 << bitNumber;
uint32_t offset = offset_;
uint32_t maxOffset = opAllocator_.GetSize();
size_t offset = offset_;
size_t maxOffset = opAllocator_.GetSize();
do {
void* itemPtr = opAllocator_.OffsetToAddr(offset);
void* itemPtr = opAllocator_.OffsetToAddr(offset, sizeof(OpItem));
auto* curOpItemPtr = static_cast<OpItem*>(itemPtr);
if (curOpItemPtr == nullptr) {
break;

View File

@ -45,7 +45,7 @@ bool MaskCmdList::Playback(MaskPlayer &player) const
LOGD("MaskCmdList::Playback size error");
return false;
}
void* itemPtr = opAllocator_.OffsetToAddr(offset);
void* itemPtr = opAllocator_.OffsetToAddr(offset, sizeof(OpItem));
OpItem* curOpItemPtr = static_cast<OpItem*>(itemPtr);
if (curOpItemPtr != nullptr) {
if (!player.Playback(curOpItemPtr->GetType(), itemPtr, totalSize - offset)) {

View File

@ -142,22 +142,23 @@ const void* MemAllocator::GetData() const
return startPtr_;
}
uint32_t MemAllocator::AddrToOffset(const void* addr) const
size_t MemAllocator::AddrToOffset(const void* addr) const
{
if (!addr) {
return 0;
}
auto offset = static_cast<uint32_t>(static_cast<const char*>(addr) - startPtr_);
size_t offset = static_cast<size_t>(static_cast<const char*>(addr) - startPtr_);
if (offset > size_) {
return 0;
}
return offset;
}
void* MemAllocator::OffsetToAddr(size_t offset) const
void* MemAllocator::OffsetToAddr(size_t offset, size_t size) const
{
if (offset >= size_) {
if (offset >= size_ || size > size_ || offset > size_ - size) {
LOGE("MemAllocator::OffsetToAddr return nullptr.");
return nullptr;
}

View File

@ -36,6 +36,11 @@ bool ResourceHolder::IsEmpty() const
{
return impl_->IsEmpty();
}
bool ResourceHolder::HasRealseableResourceCheck() const
{
return impl_->HasRealseableResourceCheck();
}
} // namespace Drawing
} // namespace Rosen
} // namespace OHOS

View File

@ -0,0 +1,52 @@
/*
* 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 <cstdint>
#include "utils/string_util.h"
namespace OHOS {
namespace Rosen {
bool IsUtf8(const char* text, int len)
{
int n;
int i = 0;
while (i < len) {
uint32_t c = text[i];
if (c <= 0x7F) { // 0x00 and 0x7F is the range of utf-8
n = 0;
} else if ((c & 0xE0) == 0xC0) { // 0xE0 and 0xC0 is the range of utf-8
n = 1;
} else if (c == 0xED && i < (len - 1) && (text[i + 1] & 0xA0) == 0xA0) { // 0xA0 and 0xED is the range of utf-8
return false;
} else if ((c & 0xF0) == 0xE0) { // 0xE0 and 0xF0 is the range of utf-8
n = 2; // 2 means the size of range
} else if ((c & 0xF8) == 0xF0) { // 0xF0 and 0xF8 is the range of utf-8
n = 3; // 3 means the size of range
} else {
return false;
}
for (int j = 0; j < n && i < len; j++) {
// 0x80 and 0xC0 is the range of utf-8
if ((++i == len) || ((text[i] & 0xC0) != 0x80)) {
return false;
}
}
i++; // move to the next character
}
return true;
}
} // namespace Rosen
} // namespace OHOS

View File

@ -139,6 +139,7 @@ public:
sk_sp<SkColorSpace> ColorSpace() const { return color_space_; }
bool UpdateStorageSizeIfNecessary();
bool ResourceMakeCurrent();
static const EGLContext GetResourceContext();
#endif
static sk_sp<SkColorSpace> ConvertColorGamutToSkColorSpace(GraphicColorGamut colorGamut);
@ -155,7 +156,9 @@ protected:
#ifdef ROSEN_IOS
sk_sp<SkColorSpace> color_space_ = nullptr;
void *layer_ = nullptr;
EGLContext resource_context_ = EGL_NO_CONTEXT;
static EGLContext resourceContext;
static std::mutex resourceContextMutex;
uint32_t framebuffer_ = 0;
uint32_t colorbuffer_ = 0;
int32_t storage_width_ = 0;

View File

@ -198,10 +198,13 @@ void ShaderCache::Store(const Drawing::Data& key, const Drawing::Data& data)
LOGD("store: cachedata has been destructed");
return;
}
RS_TRACE_BEGIN("Rewrite valueSize = " + std::to_string(valueSize) + ", keySize = " + std::to_string(keySize));
cacheData_->Rewrite(key.GetData(), keySize, value, valueSize);
RS_TRACE_END();
if (!savePending_ && saveDelaySeconds_ > 0) {
savePending_ = true;
RS_TRACE_NAME("Post Writing Task");
std::thread deferredSaveThread([this]() {
sleep(saveDelaySeconds_);
std::lock_guard<std::mutex> lock(mutex_);

View File

@ -1,4 +1,4 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# 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
@ -9,10 +9,13 @@
# 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.
group("fuzztest") {
testonly = true
deps = [ "rswindowanimation_fuzzer:fuzztest" ]
deps = [
"rswindowanimation_fuzzer:fuzztest",
"rswindowanimationtarget_fuzzer:fuzztest",
]
}

View File

@ -0,0 +1,54 @@
# 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.
#####################hydra-fuzz###################
import("//build/config/features.gni")
import("//build/test.gni")
import("//foundation/graphic/graphic_2d/graphic_config.gni")
module_output_path = "graphic_2d/graphic_2d"
##############################fuzztest##########################################
ohos_fuzztest("RSWindowAnimationTargetFuzzTest") {
fuzz_config_file = "$graphic_2d_root/rosen/modules/animation/window_animation/test/fuzztest/rswindowanimationtarget_fuzzer"
module_out_path = module_output_path
include_dirs =
[ "$graphic_2d_root/modules/animation/window_animation/include" ]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "rswindowanimationtarget_fuzzer.cpp" ]
deps = [
"$graphic_2d_root/rosen/modules/animation/window_animation:window_animation",
"$graphic_2d_root/rosen/modules/render_service_client:librender_service_client",
]
external_deps = [
"c_utils:utils",
"hilog:libhilog",
]
}
###############################################################################
group("fuzztest") {
testonly = true
deps = []
deps += [
# deps file
":RSWindowAnimationTargetFuzzTest",
]
}
###############################################################################

View File

@ -0,0 +1,14 @@
# 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.
FUZZ

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->
<fuzz_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -0,0 +1,120 @@
/*
* 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 "rswindowanimationtarget_fuzzer.h"
#include <securec.h>
#include "rs_window_animation_target.h"
#include "ui/rs_surface_node.h"
namespace OHOS {
using namespace Rosen;
namespace {
constexpr size_t STR_LEN = 10;
const uint8_t* g_data = nullptr;
size_t g_size = 0;
size_t g_pos;
}
/*
* describe: get data from outside untrusted data(g_data) which size is according to sizeof(T)
* tips: only support basic type
*/
template<class T>
T GetData()
{
T object {};
size_t objectSize = sizeof(object);
if (g_data == nullptr || objectSize > g_size - g_pos) {
return object;
}
errno_t ret = memcpy_s(&object, objectSize, g_data + g_pos, objectSize);
if (ret != EOK) {
return {};
}
g_pos += objectSize;
return object;
}
/*
* get a string from g_data
*/
std::string GetStringFromData(int strlen)
{
char cstr[strlen];
cstr[strlen - 1] = '\0';
for (int i = 0; i < strlen - 1; i++) {
char tmp = GetData<char>();
if (tmp == '\0') {
tmp = '1';
}
cstr[i] = tmp;
}
std::string str(cstr);
return str;
}
void RSWindowAnimationTargetFuzzTest()
{
// get data
std::string bundleName = GetStringFromData(STR_LEN);
std::string abilityName = GetStringFromData(STR_LEN);
uint32_t windowId = GetData<uint32_t>();
uint64_t displayId = GetData<uint64_t>();
int32_t missionId = GetData<int32_t>();
// test
RSSurfaceNodeConfig config;
std::shared_ptr<RSSurfaceNode> animationSurfaceNode = RSSurfaceNode::Create(config, true);
std::shared_ptr<RSWindowAnimationTarget> windowAnimationTarget = std::make_shared<RSWindowAnimationTarget>();
windowAnimationTarget->bundleName_ = bundleName;
windowAnimationTarget->abilityName_ = abilityName;
windowAnimationTarget->windowBounds_ = RRect();
windowAnimationTarget->surfaceNode_ = animationSurfaceNode;
windowAnimationTarget->windowId_ = windowId;
windowAnimationTarget->displayId_ = displayId;
windowAnimationTarget->missionId_ = missionId;
Parcel parcel;
windowAnimationTarget->Marshalling(parcel);
auto newTarget = windowAnimationTarget->Unmarshalling(parcel);
newTarget->ReadFromParcel(parcel);
delete newTarget;
}
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
{
if (data == nullptr) {
return false;
}
// initialize
g_data = data;
g_size = size;
g_pos = 0;
RSWindowAnimationTargetFuzzTest();
return true;
}
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
OHOS::DoSomethingInterestingWithMyAPI(data, size);
return 0;
}

View File

@ -0,0 +1,21 @@
/*
* Copyright (c) 2022 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 TEST_RS_WINDOW_ANIMATION_TARGET_FUZZER_H
#define TEST_RS_WINDOW_ANIMATION_TARGET_FUZZER_H
#define FUZZ_PROJECT_NAME "rswindowanimationtarget_fuzzer"
#endif // TEST_RS_WINDOW_ANIMATION_FUZZER_H

View File

@ -92,6 +92,7 @@ ohos_shared_library("libcomposer") {
"init:libbeget_proxy",
"init:libbegetutil",
"ipc:ipc_core",
"samgr:samgr_proxy",
]
part_name = "graphic_2d"

View File

@ -173,21 +173,21 @@ public:
boundRect_ = boundRect;
}
void SetLayerAdditionalInfo(void *info)
{
additionalInfo_ = info;
}
void* GetLayerAdditionalInfo()
{
return additionalInfo_;
}
void SetLayerColor(GraphicLayerColor layerColor)
{
layerColor_ = layerColor;
}
void SetBackgroundColor(GraphicLayerColor backgroundColor)
{
backgroundColor_ = backgroundColor;
}
void SetCornerRadiusInfoForDRM(const std::vector<float>& drmCornerRadiusInfo)
{
drmCornerRadiusInfo_ = drmCornerRadiusInfo;
}
void SetColorTransform(const std::vector<float> &matrix)
{
colorTransformMatrix_ = matrix;
@ -363,6 +363,16 @@ public:
return layerColor_;
}
GraphicLayerColor GetBackgroundColor() const
{
return backgroundColor_;
}
const std::vector<float>& GetCornerRadiusInfoForDRM() const
{
return drmCornerRadiusInfo_;
}
std::vector<GraphicHDRMetaData> &GetMetaData()
{
return metaData_;
@ -591,6 +601,7 @@ private:
GraphicBlendType blendType_;
std::vector<float> colorTransformMatrix_;
GraphicLayerColor layerColor_;
GraphicLayerColor backgroundColor_;
GraphicColorDataSpace colorSpace_ = GraphicColorDataSpace::GRAPHIC_COLOR_DATA_SPACE_UNKNOWN;
std::vector<GraphicHDRMetaData> metaData_;
GraphicHDRMetaDataSet metaDataSet_;
@ -600,7 +611,6 @@ private:
bool IsSupportedPresentTimestamp_ = false;
GraphicPresentTimestamp presentTimestamp_ = {GRAPHIC_DISPLAY_PTS_UNSUPPORTED, 0};
void *additionalInfo_ = nullptr;
sptr<IConsumerSurface> cSurface_ = nullptr;
sptr<SyncFence> acquireFence_ = SyncFence::InvalidFence();
sptr<SurfaceBuffer> sbuffer_ = nullptr;
@ -616,6 +626,7 @@ private:
int32_t layerSource_ = 0; // default layer source tag
bool rotationFixed_ = false;
bool arsrTag_ = true;
std::vector<float> drmCornerRadiusInfo_;
};
} // namespace Rosen
} // namespace OHOS

Some files were not shown because too many files have changed in this diff Show More