mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
fix clang tidy
This commit is contained in:
@@ -949,33 +949,6 @@ bool js_register_engine_CanvasGradient(se::Object* obj) // NOLINT(readability-id
|
||||
se::Object* __jsb_cc_CanvasRenderingContext2D_proto = nullptr;
|
||||
se::Class* __jsb_cc_CanvasRenderingContext2D_class = nullptr;
|
||||
|
||||
static bool js_engine_CanvasRenderingContext2D__fillImageData(se::State& s) // NOLINT(readability-identifier-naming, google-runtime-references)
|
||||
{
|
||||
auto* cobj = SE_THIS_OBJECT<cc::CanvasRenderingContext2D>(s);
|
||||
SE_PRECONDITION2(cobj, false, "js_engine_CanvasRenderingContext2D__fillImageData : Invalid Native Object");
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
CC_UNUSED bool ok = true;
|
||||
if (argc == 5) {
|
||||
HolderType<cc::Data, true> arg0 = {};
|
||||
HolderType<float, false> arg1 = {};
|
||||
HolderType<float, false> arg2 = {};
|
||||
HolderType<float, false> arg3 = {};
|
||||
HolderType<float, false> arg4 = {};
|
||||
ok &= sevalue_to_native(args[0], &arg0, s.thisObject());
|
||||
ok &= sevalue_to_native(args[1], &arg1, s.thisObject());
|
||||
ok &= sevalue_to_native(args[2], &arg2, s.thisObject());
|
||||
ok &= sevalue_to_native(args[3], &arg3, s.thisObject());
|
||||
ok &= sevalue_to_native(args[4], &arg4, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "js_engine_CanvasRenderingContext2D__fillImageData : Error processing arguments");
|
||||
cobj->_fillImageData(arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value());
|
||||
return true;
|
||||
}
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 5);
|
||||
return false;
|
||||
}
|
||||
SE_BIND_FUNC(js_engine_CanvasRenderingContext2D__fillImageData)
|
||||
|
||||
static bool js_engine_CanvasRenderingContext2D_beginPath(se::State& s) // NOLINT(readability-identifier-naming, google-runtime-references)
|
||||
{
|
||||
auto* cobj = SE_THIS_OBJECT<cc::CanvasRenderingContext2D>(s);
|
||||
@@ -1074,6 +1047,33 @@ static bool js_engine_CanvasRenderingContext2D_fill(se::State& s) // NOLINT(read
|
||||
}
|
||||
SE_BIND_FUNC(js_engine_CanvasRenderingContext2D_fill)
|
||||
|
||||
static bool js_engine_CanvasRenderingContext2D_fillImageData(se::State& s) // NOLINT(readability-identifier-naming, google-runtime-references)
|
||||
{
|
||||
auto* cobj = SE_THIS_OBJECT<cc::CanvasRenderingContext2D>(s);
|
||||
SE_PRECONDITION2(cobj, false, "js_engine_CanvasRenderingContext2D_fillImageData : Invalid Native Object");
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
CC_UNUSED bool ok = true;
|
||||
if (argc == 5) {
|
||||
HolderType<cc::Data, true> arg0 = {};
|
||||
HolderType<float, false> arg1 = {};
|
||||
HolderType<float, false> arg2 = {};
|
||||
HolderType<float, false> arg3 = {};
|
||||
HolderType<float, false> arg4 = {};
|
||||
ok &= sevalue_to_native(args[0], &arg0, s.thisObject());
|
||||
ok &= sevalue_to_native(args[1], &arg1, s.thisObject());
|
||||
ok &= sevalue_to_native(args[2], &arg2, s.thisObject());
|
||||
ok &= sevalue_to_native(args[3], &arg3, s.thisObject());
|
||||
ok &= sevalue_to_native(args[4], &arg4, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "js_engine_CanvasRenderingContext2D_fillImageData : Error processing arguments");
|
||||
cobj->fillImageData(arg0.value(), arg1.value(), arg2.value(), arg3.value(), arg4.value());
|
||||
return true;
|
||||
}
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 5);
|
||||
return false;
|
||||
}
|
||||
SE_BIND_FUNC(js_engine_CanvasRenderingContext2D_fillImageData)
|
||||
|
||||
static bool js_engine_CanvasRenderingContext2D_lineTo(se::State& s) // NOLINT(readability-identifier-naming, google-runtime-references)
|
||||
{
|
||||
auto* cobj = SE_THIS_OBJECT<cc::CanvasRenderingContext2D>(s);
|
||||
@@ -1211,6 +1211,196 @@ static bool js_engine_CanvasRenderingContext2D_scale(se::State& s) // NOLINT(rea
|
||||
}
|
||||
SE_BIND_FUNC(js_engine_CanvasRenderingContext2D_scale)
|
||||
|
||||
static bool js_engine_CanvasRenderingContext2D_setFillStyle(se::State& s) // NOLINT(readability-identifier-naming, google-runtime-references)
|
||||
{
|
||||
auto* cobj = SE_THIS_OBJECT<cc::CanvasRenderingContext2D>(s);
|
||||
SE_PRECONDITION2(cobj, false, "js_engine_CanvasRenderingContext2D_setFillStyle : Invalid Native Object");
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
CC_UNUSED bool ok = true;
|
||||
if (argc == 1) {
|
||||
HolderType<std::string, true> arg0 = {};
|
||||
ok &= sevalue_to_native(args[0], &arg0, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "js_engine_CanvasRenderingContext2D_setFillStyle : Error processing arguments");
|
||||
cobj->setFillStyle(arg0.value());
|
||||
return true;
|
||||
}
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
|
||||
return false;
|
||||
}
|
||||
SE_BIND_FUNC(js_engine_CanvasRenderingContext2D_setFillStyle)
|
||||
|
||||
static bool js_engine_CanvasRenderingContext2D_setFont(se::State& s) // NOLINT(readability-identifier-naming, google-runtime-references)
|
||||
{
|
||||
auto* cobj = SE_THIS_OBJECT<cc::CanvasRenderingContext2D>(s);
|
||||
SE_PRECONDITION2(cobj, false, "js_engine_CanvasRenderingContext2D_setFont : Invalid Native Object");
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
CC_UNUSED bool ok = true;
|
||||
if (argc == 1) {
|
||||
HolderType<std::string, true> arg0 = {};
|
||||
ok &= sevalue_to_native(args[0], &arg0, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "js_engine_CanvasRenderingContext2D_setFont : Error processing arguments");
|
||||
cobj->setFont(arg0.value());
|
||||
return true;
|
||||
}
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
|
||||
return false;
|
||||
}
|
||||
SE_BIND_FUNC(js_engine_CanvasRenderingContext2D_setFont)
|
||||
|
||||
static bool js_engine_CanvasRenderingContext2D_setGlobalCompositeOperation(se::State& s) // NOLINT(readability-identifier-naming, google-runtime-references)
|
||||
{
|
||||
auto* cobj = SE_THIS_OBJECT<cc::CanvasRenderingContext2D>(s);
|
||||
SE_PRECONDITION2(cobj, false, "js_engine_CanvasRenderingContext2D_setGlobalCompositeOperation : Invalid Native Object");
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
CC_UNUSED bool ok = true;
|
||||
if (argc == 1) {
|
||||
HolderType<std::string, true> arg0 = {};
|
||||
ok &= sevalue_to_native(args[0], &arg0, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "js_engine_CanvasRenderingContext2D_setGlobalCompositeOperation : Error processing arguments");
|
||||
cobj->setGlobalCompositeOperation(arg0.value());
|
||||
return true;
|
||||
}
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
|
||||
return false;
|
||||
}
|
||||
SE_BIND_FUNC(js_engine_CanvasRenderingContext2D_setGlobalCompositeOperation)
|
||||
|
||||
static bool js_engine_CanvasRenderingContext2D_setHeight(se::State& s) // NOLINT(readability-identifier-naming, google-runtime-references)
|
||||
{
|
||||
auto* cobj = SE_THIS_OBJECT<cc::CanvasRenderingContext2D>(s);
|
||||
SE_PRECONDITION2(cobj, false, "js_engine_CanvasRenderingContext2D_setHeight : Invalid Native Object");
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
CC_UNUSED bool ok = true;
|
||||
if (argc == 1) {
|
||||
HolderType<float, false> arg0 = {};
|
||||
ok &= sevalue_to_native(args[0], &arg0, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "js_engine_CanvasRenderingContext2D_setHeight : Error processing arguments");
|
||||
cobj->setHeight(arg0.value());
|
||||
return true;
|
||||
}
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
|
||||
return false;
|
||||
}
|
||||
SE_BIND_FUNC(js_engine_CanvasRenderingContext2D_setHeight)
|
||||
|
||||
static bool js_engine_CanvasRenderingContext2D_setLineCap(se::State& s) // NOLINT(readability-identifier-naming, google-runtime-references)
|
||||
{
|
||||
auto* cobj = SE_THIS_OBJECT<cc::CanvasRenderingContext2D>(s);
|
||||
SE_PRECONDITION2(cobj, false, "js_engine_CanvasRenderingContext2D_setLineCap : Invalid Native Object");
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
CC_UNUSED bool ok = true;
|
||||
if (argc == 1) {
|
||||
HolderType<std::string, true> arg0 = {};
|
||||
ok &= sevalue_to_native(args[0], &arg0, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "js_engine_CanvasRenderingContext2D_setLineCap : Error processing arguments");
|
||||
cobj->setLineCap(arg0.value());
|
||||
return true;
|
||||
}
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
|
||||
return false;
|
||||
}
|
||||
SE_BIND_FUNC(js_engine_CanvasRenderingContext2D_setLineCap)
|
||||
|
||||
static bool js_engine_CanvasRenderingContext2D_setLineJoin(se::State& s) // NOLINT(readability-identifier-naming, google-runtime-references)
|
||||
{
|
||||
auto* cobj = SE_THIS_OBJECT<cc::CanvasRenderingContext2D>(s);
|
||||
SE_PRECONDITION2(cobj, false, "js_engine_CanvasRenderingContext2D_setLineJoin : Invalid Native Object");
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
CC_UNUSED bool ok = true;
|
||||
if (argc == 1) {
|
||||
HolderType<std::string, true> arg0 = {};
|
||||
ok &= sevalue_to_native(args[0], &arg0, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "js_engine_CanvasRenderingContext2D_setLineJoin : Error processing arguments");
|
||||
cobj->setLineJoin(arg0.value());
|
||||
return true;
|
||||
}
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
|
||||
return false;
|
||||
}
|
||||
SE_BIND_FUNC(js_engine_CanvasRenderingContext2D_setLineJoin)
|
||||
|
||||
static bool js_engine_CanvasRenderingContext2D_setLineWidth(se::State& s) // NOLINT(readability-identifier-naming, google-runtime-references)
|
||||
{
|
||||
auto* cobj = SE_THIS_OBJECT<cc::CanvasRenderingContext2D>(s);
|
||||
SE_PRECONDITION2(cobj, false, "js_engine_CanvasRenderingContext2D_setLineWidth : Invalid Native Object");
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
CC_UNUSED bool ok = true;
|
||||
if (argc == 1) {
|
||||
HolderType<float, false> arg0 = {};
|
||||
ok &= sevalue_to_native(args[0], &arg0, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "js_engine_CanvasRenderingContext2D_setLineWidth : Error processing arguments");
|
||||
cobj->setLineWidth(arg0.value());
|
||||
return true;
|
||||
}
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
|
||||
return false;
|
||||
}
|
||||
SE_BIND_FUNC(js_engine_CanvasRenderingContext2D_setLineWidth)
|
||||
|
||||
static bool js_engine_CanvasRenderingContext2D_setStrokeStyle(se::State& s) // NOLINT(readability-identifier-naming, google-runtime-references)
|
||||
{
|
||||
auto* cobj = SE_THIS_OBJECT<cc::CanvasRenderingContext2D>(s);
|
||||
SE_PRECONDITION2(cobj, false, "js_engine_CanvasRenderingContext2D_setStrokeStyle : Invalid Native Object");
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
CC_UNUSED bool ok = true;
|
||||
if (argc == 1) {
|
||||
HolderType<std::string, true> arg0 = {};
|
||||
ok &= sevalue_to_native(args[0], &arg0, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "js_engine_CanvasRenderingContext2D_setStrokeStyle : Error processing arguments");
|
||||
cobj->setStrokeStyle(arg0.value());
|
||||
return true;
|
||||
}
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
|
||||
return false;
|
||||
}
|
||||
SE_BIND_FUNC(js_engine_CanvasRenderingContext2D_setStrokeStyle)
|
||||
|
||||
static bool js_engine_CanvasRenderingContext2D_setTextAlign(se::State& s) // NOLINT(readability-identifier-naming, google-runtime-references)
|
||||
{
|
||||
auto* cobj = SE_THIS_OBJECT<cc::CanvasRenderingContext2D>(s);
|
||||
SE_PRECONDITION2(cobj, false, "js_engine_CanvasRenderingContext2D_setTextAlign : Invalid Native Object");
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
CC_UNUSED bool ok = true;
|
||||
if (argc == 1) {
|
||||
HolderType<std::string, true> arg0 = {};
|
||||
ok &= sevalue_to_native(args[0], &arg0, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "js_engine_CanvasRenderingContext2D_setTextAlign : Error processing arguments");
|
||||
cobj->setTextAlign(arg0.value());
|
||||
return true;
|
||||
}
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
|
||||
return false;
|
||||
}
|
||||
SE_BIND_FUNC(js_engine_CanvasRenderingContext2D_setTextAlign)
|
||||
|
||||
static bool js_engine_CanvasRenderingContext2D_setTextBaseline(se::State& s) // NOLINT(readability-identifier-naming, google-runtime-references)
|
||||
{
|
||||
auto* cobj = SE_THIS_OBJECT<cc::CanvasRenderingContext2D>(s);
|
||||
SE_PRECONDITION2(cobj, false, "js_engine_CanvasRenderingContext2D_setTextBaseline : Invalid Native Object");
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
CC_UNUSED bool ok = true;
|
||||
if (argc == 1) {
|
||||
HolderType<std::string, true> arg0 = {};
|
||||
ok &= sevalue_to_native(args[0], &arg0, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "js_engine_CanvasRenderingContext2D_setTextBaseline : Error processing arguments");
|
||||
cobj->setTextBaseline(arg0.value());
|
||||
return true;
|
||||
}
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
|
||||
return false;
|
||||
}
|
||||
SE_BIND_FUNC(js_engine_CanvasRenderingContext2D_setTextBaseline)
|
||||
|
||||
static bool js_engine_CanvasRenderingContext2D_setTransform(se::State& s) // NOLINT(readability-identifier-naming, google-runtime-references)
|
||||
{
|
||||
auto* cobj = SE_THIS_OBJECT<cc::CanvasRenderingContext2D>(s);
|
||||
@@ -1240,6 +1430,25 @@ static bool js_engine_CanvasRenderingContext2D_setTransform(se::State& s) // NOL
|
||||
}
|
||||
SE_BIND_FUNC(js_engine_CanvasRenderingContext2D_setTransform)
|
||||
|
||||
static bool js_engine_CanvasRenderingContext2D_setWidth(se::State& s) // NOLINT(readability-identifier-naming, google-runtime-references)
|
||||
{
|
||||
auto* cobj = SE_THIS_OBJECT<cc::CanvasRenderingContext2D>(s);
|
||||
SE_PRECONDITION2(cobj, false, "js_engine_CanvasRenderingContext2D_setWidth : Invalid Native Object");
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
CC_UNUSED bool ok = true;
|
||||
if (argc == 1) {
|
||||
HolderType<float, false> arg0 = {};
|
||||
ok &= sevalue_to_native(args[0], &arg0, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "js_engine_CanvasRenderingContext2D_setWidth : Error processing arguments");
|
||||
cobj->setWidth(arg0.value());
|
||||
return true;
|
||||
}
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
|
||||
return false;
|
||||
}
|
||||
SE_BIND_FUNC(js_engine_CanvasRenderingContext2D_setWidth)
|
||||
|
||||
static bool js_engine_CanvasRenderingContext2D_stroke(se::State& s) // NOLINT(readability-identifier-naming, google-runtime-references)
|
||||
{
|
||||
auto* cobj = SE_THIS_OBJECT<cc::CanvasRenderingContext2D>(s);
|
||||
@@ -1342,12 +1551,12 @@ bool js_register_engine_CanvasRenderingContext2D(se::Object* obj) // NOLINT(read
|
||||
{
|
||||
auto* cls = se::Class::create("CanvasRenderingContext2D", obj, nullptr, _SE(js_engine_CanvasRenderingContext2D_constructor));
|
||||
|
||||
cls->defineFunction("_fillImageData", _SE(js_engine_CanvasRenderingContext2D__fillImageData));
|
||||
cls->defineFunction("beginPath", _SE(js_engine_CanvasRenderingContext2D_beginPath));
|
||||
cls->defineFunction("clearRect", _SE(js_engine_CanvasRenderingContext2D_clearRect));
|
||||
cls->defineFunction("closePath", _SE(js_engine_CanvasRenderingContext2D_closePath));
|
||||
cls->defineFunction("createLinearGradient", _SE(js_engine_CanvasRenderingContext2D_createLinearGradient));
|
||||
cls->defineFunction("fill", _SE(js_engine_CanvasRenderingContext2D_fill));
|
||||
cls->defineFunction("fillImageData", _SE(js_engine_CanvasRenderingContext2D_fillImageData));
|
||||
cls->defineFunction("lineTo", _SE(js_engine_CanvasRenderingContext2D_lineTo));
|
||||
cls->defineFunction("moveTo", _SE(js_engine_CanvasRenderingContext2D_moveTo));
|
||||
cls->defineFunction("rect", _SE(js_engine_CanvasRenderingContext2D_rect));
|
||||
@@ -1355,7 +1564,18 @@ bool js_register_engine_CanvasRenderingContext2D(se::Object* obj) // NOLINT(read
|
||||
cls->defineFunction("rotate", _SE(js_engine_CanvasRenderingContext2D_rotate));
|
||||
cls->defineFunction("save", _SE(js_engine_CanvasRenderingContext2D_save));
|
||||
cls->defineFunction("scale", _SE(js_engine_CanvasRenderingContext2D_scale));
|
||||
cls->defineFunction("setFillStyle", _SE(js_engine_CanvasRenderingContext2D_setFillStyle));
|
||||
cls->defineFunction("setFont", _SE(js_engine_CanvasRenderingContext2D_setFont));
|
||||
cls->defineFunction("setGlobalCompositeOperation", _SE(js_engine_CanvasRenderingContext2D_setGlobalCompositeOperation));
|
||||
cls->defineFunction("setHeight", _SE(js_engine_CanvasRenderingContext2D_setHeight));
|
||||
cls->defineFunction("setLineCap", _SE(js_engine_CanvasRenderingContext2D_setLineCap));
|
||||
cls->defineFunction("setLineJoin", _SE(js_engine_CanvasRenderingContext2D_setLineJoin));
|
||||
cls->defineFunction("setLineWidth", _SE(js_engine_CanvasRenderingContext2D_setLineWidth));
|
||||
cls->defineFunction("setStrokeStyle", _SE(js_engine_CanvasRenderingContext2D_setStrokeStyle));
|
||||
cls->defineFunction("setTextAlign", _SE(js_engine_CanvasRenderingContext2D_setTextAlign));
|
||||
cls->defineFunction("setTextBaseline", _SE(js_engine_CanvasRenderingContext2D_setTextBaseline));
|
||||
cls->defineFunction("setTransform", _SE(js_engine_CanvasRenderingContext2D_setTransform));
|
||||
cls->defineFunction("setWidth", _SE(js_engine_CanvasRenderingContext2D_setWidth));
|
||||
cls->defineFunction("stroke", _SE(js_engine_CanvasRenderingContext2D_stroke));
|
||||
cls->defineFunction("transform", _SE(js_engine_CanvasRenderingContext2D_transform));
|
||||
cls->defineFunction("translate", _SE(js_engine_CanvasRenderingContext2D_translate));
|
||||
|
||||
@@ -69,12 +69,12 @@ bool js_register_cc_CanvasRenderingContext2D(se::Object* obj);
|
||||
bool register_all_engine(se::Object* obj);
|
||||
|
||||
JSB_REGISTER_OBJECT_TYPE(cc::CanvasRenderingContext2D);
|
||||
SE_DECLARE_FUNC(js_engine_CanvasRenderingContext2D__fillImageData);
|
||||
SE_DECLARE_FUNC(js_engine_CanvasRenderingContext2D_beginPath);
|
||||
SE_DECLARE_FUNC(js_engine_CanvasRenderingContext2D_clearRect);
|
||||
SE_DECLARE_FUNC(js_engine_CanvasRenderingContext2D_closePath);
|
||||
SE_DECLARE_FUNC(js_engine_CanvasRenderingContext2D_createLinearGradient);
|
||||
SE_DECLARE_FUNC(js_engine_CanvasRenderingContext2D_fill);
|
||||
SE_DECLARE_FUNC(js_engine_CanvasRenderingContext2D_fillImageData);
|
||||
SE_DECLARE_FUNC(js_engine_CanvasRenderingContext2D_lineTo);
|
||||
SE_DECLARE_FUNC(js_engine_CanvasRenderingContext2D_moveTo);
|
||||
SE_DECLARE_FUNC(js_engine_CanvasRenderingContext2D_rect);
|
||||
@@ -82,7 +82,18 @@ SE_DECLARE_FUNC(js_engine_CanvasRenderingContext2D_restore);
|
||||
SE_DECLARE_FUNC(js_engine_CanvasRenderingContext2D_rotate);
|
||||
SE_DECLARE_FUNC(js_engine_CanvasRenderingContext2D_save);
|
||||
SE_DECLARE_FUNC(js_engine_CanvasRenderingContext2D_scale);
|
||||
SE_DECLARE_FUNC(js_engine_CanvasRenderingContext2D_setFillStyle);
|
||||
SE_DECLARE_FUNC(js_engine_CanvasRenderingContext2D_setFont);
|
||||
SE_DECLARE_FUNC(js_engine_CanvasRenderingContext2D_setGlobalCompositeOperation);
|
||||
SE_DECLARE_FUNC(js_engine_CanvasRenderingContext2D_setHeight);
|
||||
SE_DECLARE_FUNC(js_engine_CanvasRenderingContext2D_setLineCap);
|
||||
SE_DECLARE_FUNC(js_engine_CanvasRenderingContext2D_setLineJoin);
|
||||
SE_DECLARE_FUNC(js_engine_CanvasRenderingContext2D_setLineWidth);
|
||||
SE_DECLARE_FUNC(js_engine_CanvasRenderingContext2D_setStrokeStyle);
|
||||
SE_DECLARE_FUNC(js_engine_CanvasRenderingContext2D_setTextAlign);
|
||||
SE_DECLARE_FUNC(js_engine_CanvasRenderingContext2D_setTextBaseline);
|
||||
SE_DECLARE_FUNC(js_engine_CanvasRenderingContext2D_setTransform);
|
||||
SE_DECLARE_FUNC(js_engine_CanvasRenderingContext2D_setWidth);
|
||||
SE_DECLARE_FUNC(js_engine_CanvasRenderingContext2D_stroke);
|
||||
SE_DECLARE_FUNC(js_engine_CanvasRenderingContext2D_transform);
|
||||
SE_DECLARE_FUNC(js_engine_CanvasRenderingContext2D_translate);
|
||||
|
||||
@@ -32,26 +32,24 @@
|
||||
|
||||
#include "storage/local-storage/LocalStorage.h"
|
||||
|
||||
using namespace cc;
|
||||
extern se::Object *__jsb_cc_FileUtils_proto; // NOLINT(readability-redundant-declaration)
|
||||
|
||||
extern se::Object *__jsb_cc_FileUtils_proto;
|
||||
|
||||
static bool jsb_ccx_empty_func(se::State &s) {
|
||||
static bool jsb_ccx_empty_func(const se::State &/*s*/) { // NOLINT(readability-identifier-naming)
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(jsb_ccx_empty_func)
|
||||
SE_BIND_FUNC(jsb_ccx_empty_func) // NOLINT(readability-identifier-naming)
|
||||
|
||||
class __JSPlistDelegator : public cc::SAXDelegator {
|
||||
class JSPlistDelegator : public cc::SAXDelegator {
|
||||
public:
|
||||
static __JSPlistDelegator *getInstance() {
|
||||
static __JSPlistDelegator *pInstance = NULL;
|
||||
if (pInstance == NULL) {
|
||||
pInstance = new (std::nothrow) __JSPlistDelegator();
|
||||
static JSPlistDelegator *getInstance() {
|
||||
static JSPlistDelegator *pInstance = nullptr;
|
||||
if (pInstance == nullptr) {
|
||||
pInstance = new (std::nothrow) JSPlistDelegator();
|
||||
}
|
||||
return pInstance;
|
||||
};
|
||||
|
||||
virtual ~__JSPlistDelegator();
|
||||
~JSPlistDelegator() override;
|
||||
|
||||
cc::SAXParser *getParser();
|
||||
|
||||
@@ -71,23 +69,23 @@ private:
|
||||
};
|
||||
|
||||
// cc.PlistParser.getInstance()
|
||||
static bool js_PlistParser_getInstance(se::State &s) {
|
||||
__JSPlistDelegator *delegator = __JSPlistDelegator::getInstance();
|
||||
SAXParser *parser = delegator->getParser();
|
||||
static bool js_PlistParser_getInstance(se::State &s) { // NOLINT(readability-identifier-naming, google-runtime-references)
|
||||
JSPlistDelegator *delegator = JSPlistDelegator::getInstance();
|
||||
cc::SAXParser *parser = delegator->getParser();
|
||||
|
||||
if (parser) {
|
||||
native_ptr_to_rooted_seval<SAXParser>(parser, __jsb_cc_SAXParser_class, &s.rval());
|
||||
native_ptr_to_rooted_seval<cc::SAXParser>(parser, __jsb_cc_SAXParser_class, &s.rval());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
SE_BIND_FUNC(js_PlistParser_getInstance)
|
||||
SE_BIND_FUNC(js_PlistParser_getInstance) // NOLINT(readability-identifier-naming)
|
||||
|
||||
// cc.PlistParser.getInstance().parse(text)
|
||||
static bool js_PlistParser_parse(se::State &s) {
|
||||
static bool js_PlistParser_parse(se::State &s) { // NOLINT(readability-identifier-naming, google-runtime-references)
|
||||
const auto &args = s.args();
|
||||
size_t argc = args.size();
|
||||
__JSPlistDelegator *delegator = __JSPlistDelegator::getInstance();
|
||||
JSPlistDelegator *delegator = JSPlistDelegator::getInstance();
|
||||
|
||||
bool ok = true;
|
||||
if (argc == 1) {
|
||||
@@ -110,31 +108,31 @@ static bool js_PlistParser_parse(se::State &s) {
|
||||
}
|
||||
SE_BIND_FUNC(js_PlistParser_parse)
|
||||
|
||||
cc::SAXParser *__JSPlistDelegator::getParser() {
|
||||
cc::SAXParser *JSPlistDelegator::getParser() {
|
||||
return &_parser;
|
||||
}
|
||||
|
||||
std::string __JSPlistDelegator::parse(const std::string &path) {
|
||||
std::string JSPlistDelegator::parse(const std::string &path) {
|
||||
_result.clear();
|
||||
|
||||
SAXParser parser;
|
||||
if (false != parser.init("UTF-8")) {
|
||||
cc::SAXParser parser;
|
||||
if (parser.init("UTF-8")) {
|
||||
parser.setDelegator(this);
|
||||
parser.parse(FileUtils::getInstance()->fullPathForFilename(path));
|
||||
parser.parse(cc::FileUtils::getInstance()->fullPathForFilename(path));
|
||||
}
|
||||
|
||||
return _result;
|
||||
}
|
||||
|
||||
__JSPlistDelegator::~__JSPlistDelegator() {
|
||||
JSPlistDelegator::~JSPlistDelegator() {
|
||||
CC_LOG_INFO("deallocing __JSSAXDelegator: %p", this);
|
||||
}
|
||||
|
||||
std::string __JSPlistDelegator::parseText(const std::string &text) {
|
||||
std::string JSPlistDelegator::parseText(const std::string &text) {
|
||||
_result.clear();
|
||||
|
||||
SAXParser parser;
|
||||
if (false != parser.init("UTF-8")) {
|
||||
cc::SAXParser parser;
|
||||
if (parser.init("UTF-8")) {
|
||||
parser.setDelegator(this);
|
||||
parser.parse(text.c_str(), text.size());
|
||||
}
|
||||
@@ -142,13 +140,13 @@ std::string __JSPlistDelegator::parseText(const std::string &text) {
|
||||
return _result;
|
||||
}
|
||||
|
||||
void __JSPlistDelegator::startElement(void *ctx, const char *name, const char **atts) {
|
||||
void JSPlistDelegator::startElement(void */*ctx*/, const char *name, const char **/*atts*/) {
|
||||
_isStoringCharacters = true;
|
||||
_currentValue.clear();
|
||||
|
||||
std::string elementName = (char *)name;
|
||||
std::string elementName{name};
|
||||
|
||||
int end = (int)_result.size() - 1;
|
||||
auto end = static_cast<int>(_result.size()) - 1;
|
||||
if (end >= 0 && _result[end] != '{' && _result[end] != '[' && _result[end] != ':') {
|
||||
_result += ",";
|
||||
}
|
||||
@@ -160,9 +158,9 @@ void __JSPlistDelegator::startElement(void *ctx, const char *name, const char **
|
||||
}
|
||||
}
|
||||
|
||||
void __JSPlistDelegator::endElement(void *ctx, const char *name) {
|
||||
void JSPlistDelegator::endElement(void */*ctx*/, const char *name) {
|
||||
_isStoringCharacters = false;
|
||||
std::string elementName = (char *)name;
|
||||
std::string elementName{name};
|
||||
|
||||
if (elementName == "dict") {
|
||||
_result += "}";
|
||||
@@ -179,15 +177,15 @@ void __JSPlistDelegator::endElement(void *ctx, const char *name) {
|
||||
}
|
||||
}
|
||||
|
||||
void __JSPlistDelegator::textHandler(void *, const char *ch, int len) {
|
||||
std::string text((char *)ch, 0, len);
|
||||
void JSPlistDelegator::textHandler(void */*unused*/, const char *ch, int len) {
|
||||
std::string text(ch, 0, len);
|
||||
|
||||
if (_isStoringCharacters) {
|
||||
_currentValue += text;
|
||||
}
|
||||
}
|
||||
|
||||
static bool register_plist_parser(se::Object *obj) {
|
||||
static bool register_plist_parser(se::Object */*obj*/) { // NOLINT(readability-identifier-naming)
|
||||
se::Value v;
|
||||
__jsbObj->getProperty("PlistParser", &v);
|
||||
assert(v.isObject());
|
||||
@@ -202,21 +200,22 @@ static bool register_plist_parser(se::Object *obj) {
|
||||
|
||||
// cc.sys.localStorage
|
||||
|
||||
static bool JSB_localStorageGetItem(se::State &s) {
|
||||
static bool JSB_localStorageGetItem(se::State &s) { // NOLINT(readability-identifier-naming, google-runtime-references)
|
||||
const auto &args = s.args();
|
||||
size_t argc = args.size();
|
||||
if (argc == 1) {
|
||||
std::string ret_val;
|
||||
bool ok = true;
|
||||
std::string key;
|
||||
ok = seval_to_std_string(args[0], &key);
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
std::string value;
|
||||
ok = localStorageGetItem(key, &value);
|
||||
if (ok)
|
||||
if (ok) {
|
||||
s.rval().setString(value);
|
||||
else
|
||||
}
|
||||
else {
|
||||
s.rval().setNull(); // Should return null to make JSB behavior same as Browser since returning undefined will make JSON.parse(undefined) trigger exception.
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -224,9 +223,9 @@ static bool JSB_localStorageGetItem(se::State &s) {
|
||||
SE_REPORT_ERROR("Invalid number of arguments");
|
||||
return false;
|
||||
}
|
||||
SE_BIND_FUNC(JSB_localStorageGetItem)
|
||||
SE_BIND_FUNC(JSB_localStorageGetItem) // NOLINT(readability-identifier-naming)
|
||||
|
||||
static bool JSB_localStorageRemoveItem(se::State &s) {
|
||||
static bool JSB_localStorageRemoveItem(const se::State &s) { // NOLINT(readability-identifier-naming)
|
||||
const auto &args = s.args();
|
||||
size_t argc = args.size();
|
||||
if (argc == 1) {
|
||||
@@ -241,9 +240,9 @@ static bool JSB_localStorageRemoveItem(se::State &s) {
|
||||
SE_REPORT_ERROR("Invalid number of arguments");
|
||||
return false;
|
||||
}
|
||||
SE_BIND_FUNC(JSB_localStorageRemoveItem)
|
||||
SE_BIND_FUNC(JSB_localStorageRemoveItem) // NOLINT(readability-identifier-naming)
|
||||
|
||||
static bool JSB_localStorageSetItem(se::State &s) {
|
||||
static bool JSB_localStorageSetItem(const se::State &s) { // NOLINT(readability-identifier-naming)
|
||||
const auto &args = s.args();
|
||||
size_t argc = args.size();
|
||||
if (argc == 2) {
|
||||
@@ -262,9 +261,9 @@ static bool JSB_localStorageSetItem(se::State &s) {
|
||||
SE_REPORT_ERROR("Invalid number of arguments");
|
||||
return false;
|
||||
}
|
||||
SE_BIND_FUNC(JSB_localStorageSetItem)
|
||||
SE_BIND_FUNC(JSB_localStorageSetItem) // NOLINT(readability-identifier-naming)
|
||||
|
||||
static bool JSB_localStorageClear(se::State &s) {
|
||||
static bool JSB_localStorageClear(const se::State &s) { // NOLINT(readability-identifier-naming)
|
||||
const auto &args = s.args();
|
||||
size_t argc = args.size();
|
||||
if (argc == 0) {
|
||||
@@ -275,9 +274,9 @@ static bool JSB_localStorageClear(se::State &s) {
|
||||
SE_REPORT_ERROR("Invalid number of arguments");
|
||||
return false;
|
||||
}
|
||||
SE_BIND_FUNC(JSB_localStorageClear)
|
||||
SE_BIND_FUNC(JSB_localStorageClear) // NOLINT(readability-identifier-naming)
|
||||
|
||||
static bool JSB_localStorageKey(se::State &s) {
|
||||
static bool JSB_localStorageKey(se::State &s) { // NOLINT(readability-identifier-naming, google-runtime-references)
|
||||
const auto &args = s.args();
|
||||
size_t argc = args.size();
|
||||
if (argc == 1) {
|
||||
@@ -294,9 +293,9 @@ static bool JSB_localStorageKey(se::State &s) {
|
||||
SE_REPORT_ERROR("Invalid number of arguments");
|
||||
return false;
|
||||
}
|
||||
SE_BIND_FUNC(JSB_localStorageKey)
|
||||
SE_BIND_FUNC(JSB_localStorageKey) // NOLINT(readability-identifier-naming)
|
||||
|
||||
static bool JSB_localStorage_getLength(se::State &s) {
|
||||
static bool JSB_localStorage_getLength(se::State &s) { // NOLINT(readability-identifier-naming, google-runtime-references)
|
||||
const auto &args = s.args();
|
||||
size_t argc = args.size();
|
||||
if (argc == 0) {
|
||||
@@ -310,9 +309,9 @@ static bool JSB_localStorage_getLength(se::State &s) {
|
||||
SE_REPORT_ERROR("Invalid number of arguments");
|
||||
return false;
|
||||
}
|
||||
SE_BIND_PROP_GET(JSB_localStorage_getLength);
|
||||
SE_BIND_PROP_GET(JSB_localStorage_getLength); // NOLINT(readability-identifier-naming)
|
||||
|
||||
static bool register_sys_localStorage(se::Object *obj) {
|
||||
static bool register_sys_localStorage(se::Object *obj) { // NOLINT(readability-identifier-naming)
|
||||
se::Value sys;
|
||||
if (!obj->getProperty("sys", &sys)) {
|
||||
se::HandleObject sysObj(se::Object::createPlainObject());
|
||||
@@ -343,42 +342,9 @@ static bool register_sys_localStorage(se::Object *obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
#define BIND_PROP_WITH_TYPE__CONV_FUNC__RETURN(cls, property, type, convertFunc, returnFunc) \
|
||||
static bool js_##cls_set_##property(se::State &s) { \
|
||||
cc::cls *cobj = (cc::cls *)s.nativeThisObject(); \
|
||||
SE_PRECONDITION2(cobj, false, "js_#cls_set_#property : Invalid Native Object"); \
|
||||
const auto &args = s.args(); \
|
||||
size_t argc = args.size(); \
|
||||
bool ok = true; \
|
||||
if (argc == 1) { \
|
||||
type arg0; \
|
||||
ok &= convertFunc(args[0], &arg0); \
|
||||
SE_PRECONDITION2(ok, false, "js_#cls_set_#property : Error processing arguments"); \
|
||||
cobj->set_##property(arg0); \
|
||||
return true; \
|
||||
} \
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); \
|
||||
return false; \
|
||||
} \
|
||||
SE_BIND_PROP_SET(js_##cls_set_##property) \
|
||||
\
|
||||
static bool js_##cls_get_##property(se::State &s) { \
|
||||
cc::cls *cobj = (cc::cls *)s.nativeThisObject(); \
|
||||
SE_PRECONDITION2(cobj, false, "js_#cls_get_#property : Invalid Native Object"); \
|
||||
s.rval().returnFunc(cobj->_##property); \
|
||||
return true; \
|
||||
} \
|
||||
SE_BIND_PROP_GET(js_##cls_get_##property)
|
||||
|
||||
BIND_PROP_WITH_TYPE__CONV_FUNC__RETURN(CanvasRenderingContext2D, width, float, seval_to_float, setFloat)
|
||||
BIND_PROP_WITH_TYPE__CONV_FUNC__RETURN(CanvasRenderingContext2D, height, float, seval_to_float, setFloat)
|
||||
|
||||
#define _SE_DEFINE_PROP(cls, property) \
|
||||
__jsb_cc_##cls##_proto->defineProperty(#property, _SE(js_##cls_get_##property), _SE(js_##cls_set_##property));
|
||||
|
||||
//IDEA: move to auto bindings.
|
||||
static bool js_CanvasRenderingContext2D_setCanvasBufferUpdatedCallback(se::State &s) {
|
||||
cc::CanvasRenderingContext2D *cobj = (cc::CanvasRenderingContext2D *)s.nativeThisObject();
|
||||
static bool js_CanvasRenderingContext2D_setCanvasBufferUpdatedCallback(se::State &s) { // NOLINT(readability-identifier-naming, google-runtime-references)
|
||||
auto *cobj = static_cast<cc::CanvasRenderingContext2D *>(s.nativeThisObject());
|
||||
SE_PRECONDITION2(cobj, false, "js_CanvasRenderingContext2D_setCanvasBufferUpdatedCallback : Invalid Native Object");
|
||||
const auto &args = s.args();
|
||||
size_t argc = args.size();
|
||||
@@ -423,42 +389,42 @@ static bool js_CanvasRenderingContext2D_setCanvasBufferUpdatedCallback(se::State
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
|
||||
return false;
|
||||
}
|
||||
SE_BIND_FUNC(js_CanvasRenderingContext2D_setCanvasBufferUpdatedCallback)
|
||||
SE_BIND_FUNC(js_CanvasRenderingContext2D_setCanvasBufferUpdatedCallback) // NOLINT(readability-identifier-naming)
|
||||
|
||||
static void setCanvasRenderingContext2DProps(cc::CanvasRenderingContext2D *context, const se::Value &val) {
|
||||
se::Object *props = val.toObject();
|
||||
se::Value propVal;
|
||||
|
||||
props->getProperty("lineWidth", &propVal);
|
||||
if (!propVal.isUndefined()) context->set_lineWidth(propVal.toFloat());
|
||||
if (!propVal.isUndefined()) context->setLineWidth(propVal.toFloat());
|
||||
|
||||
props->getProperty("lineJoin", &propVal);
|
||||
if (!propVal.isUndefined()) context->set_lineJoin(propVal.toString());
|
||||
if (!propVal.isUndefined()) context->setLineJoin(propVal.toString());
|
||||
|
||||
props->getProperty("fillStyle", &propVal);
|
||||
if (!propVal.isUndefined()) context->set_fillStyle(propVal.toString());
|
||||
if (!propVal.isUndefined()) context->setFillStyle(propVal.toString());
|
||||
|
||||
props->getProperty("font", &propVal);
|
||||
if (!propVal.isUndefined()) context->set_font(propVal.toString());
|
||||
if (!propVal.isUndefined()) context->setFont(propVal.toString());
|
||||
|
||||
props->getProperty("lineCap", &propVal);
|
||||
if (!propVal.isUndefined()) context->set_lineCap(propVal.toString());
|
||||
if (!propVal.isUndefined()) context->setLineCap(propVal.toString());
|
||||
|
||||
props->getProperty("textAlign", &propVal);
|
||||
if (!propVal.isUndefined()) context->set_textAlign(propVal.toString());
|
||||
if (!propVal.isUndefined()) context->setTextAlign(propVal.toString());
|
||||
|
||||
props->getProperty("textBaseline", &propVal);
|
||||
if (!propVal.isUndefined()) context->set_textBaseline(propVal.toString());
|
||||
if (!propVal.isUndefined()) context->setTextBaseline(propVal.toString());
|
||||
|
||||
props->getProperty("strokeStyle", &propVal);
|
||||
if (!propVal.isUndefined()) context->set_strokeStyle(propVal.toString());
|
||||
if (!propVal.isUndefined()) context->setStrokeStyle(propVal.toString());
|
||||
|
||||
props->getProperty("globalCompositeOperation", &propVal);
|
||||
if (!propVal.isUndefined()) context->set_globalCompositeOperation(propVal.toString());
|
||||
if (!propVal.isUndefined()) context->setGlobalCompositeOperation(propVal.toString());
|
||||
}
|
||||
|
||||
static bool js_engine_CanvasRenderingContext2D_measureText(se::State &s) {
|
||||
cc::CanvasRenderingContext2D *cobj = (cc::CanvasRenderingContext2D *)s.nativeThisObject();
|
||||
static bool js_engine_CanvasRenderingContext2D_measureText(se::State &s) { // NOLINT(readability-identifier-naming, google-runtime-references)
|
||||
auto *cobj = static_cast<cc::CanvasRenderingContext2D *>(s.nativeThisObject());
|
||||
SE_PRECONDITION2(cobj, false, "js_engine_CanvasRenderingContext2D_measureText : Invalid Native Object");
|
||||
const auto &args = s.args();
|
||||
size_t argc = args.size();
|
||||
@@ -477,10 +443,10 @@ static bool js_engine_CanvasRenderingContext2D_measureText(se::State &s) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
|
||||
return false;
|
||||
}
|
||||
SE_BIND_FUNC(js_engine_CanvasRenderingContext2D_measureText)
|
||||
SE_BIND_FUNC(js_engine_CanvasRenderingContext2D_measureText) // NOLINT(readability-identifier-naming)
|
||||
|
||||
static bool js_engine_CanvasRenderingContext2D_fillRect(se::State &s) {
|
||||
cc::CanvasRenderingContext2D *cobj = (cc::CanvasRenderingContext2D *)s.nativeThisObject();
|
||||
static bool js_engine_CanvasRenderingContext2D_fillRect(const se::State &s) { // NOLINT(readability-identifier-naming)
|
||||
auto *cobj = static_cast<cc::CanvasRenderingContext2D *>(s.nativeThisObject());
|
||||
SE_PRECONDITION2(cobj, false, "js_engine_CanvasRenderingContext2D_fillRect : Invalid Native Object");
|
||||
const auto &args = s.args();
|
||||
size_t argc = args.size();
|
||||
@@ -503,10 +469,10 @@ static bool js_engine_CanvasRenderingContext2D_fillRect(se::State &s) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 4);
|
||||
return false;
|
||||
}
|
||||
SE_BIND_FUNC(js_engine_CanvasRenderingContext2D_fillRect)
|
||||
SE_BIND_FUNC(js_engine_CanvasRenderingContext2D_fillRect) // NOLINT(readability-identifier-naming)
|
||||
|
||||
static bool js_engine_CanvasRenderingContext2D_fillText(se::State &s) {
|
||||
cc::CanvasRenderingContext2D *cobj = (cc::CanvasRenderingContext2D *)s.nativeThisObject();
|
||||
static bool js_engine_CanvasRenderingContext2D_fillText(const se::State &s) { // NOLINT(readability-identifier-naming)
|
||||
auto *cobj = static_cast<cc::CanvasRenderingContext2D *>(s.nativeThisObject());
|
||||
SE_PRECONDITION2(cobj, false, "js_engine_CanvasRenderingContext2D_fillText : Invalid Native Object");
|
||||
const auto &args = s.args();
|
||||
size_t argc = args.size();
|
||||
@@ -534,14 +500,14 @@ static bool js_engine_CanvasRenderingContext2D_fillText(se::State &s) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 4);
|
||||
return false;
|
||||
}
|
||||
SE_BIND_FUNC(js_engine_CanvasRenderingContext2D_fillText)
|
||||
SE_BIND_FUNC(js_engine_CanvasRenderingContext2D_fillText) // NOLINT(readability-identifier-naming)
|
||||
|
||||
static bool js_engine_CanvasRenderingContext2D_strokeText(se::State &s) {
|
||||
cc::CanvasRenderingContext2D *cobj = (cc::CanvasRenderingContext2D *)s.nativeThisObject();
|
||||
static bool js_engine_CanvasRenderingContext2D_strokeText(const se::State &s) { // NOLINT(readability-identifier-naming)
|
||||
auto *cobj = static_cast<cc::CanvasRenderingContext2D *>(s.nativeThisObject());
|
||||
SE_PRECONDITION2(cobj, false, "js_engine_CanvasRenderingContext2D_strokeText : Invalid Native Object");
|
||||
const auto &args = s.args();
|
||||
size_t argc = args.size();
|
||||
CC_UNUSED bool ok = true;
|
||||
bool ok = true;
|
||||
if (argc == 5) {
|
||||
std::string arg0;
|
||||
float arg1 = 0;
|
||||
@@ -566,43 +532,43 @@ static bool js_engine_CanvasRenderingContext2D_strokeText(se::State &s) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 4);
|
||||
return false;
|
||||
}
|
||||
SE_BIND_FUNC(js_engine_CanvasRenderingContext2D_strokeText)
|
||||
SE_BIND_FUNC(js_engine_CanvasRenderingContext2D_strokeText) // NOLINT(readability-identifier-naming)
|
||||
|
||||
static se::Object *__deviceMotionObject = nullptr;
|
||||
static bool JSB_getDeviceMotionValue(se::State &s) {
|
||||
if (__deviceMotionObject == nullptr) {
|
||||
__deviceMotionObject = se::Object::createArrayObject(9);
|
||||
__deviceMotionObject->root();
|
||||
static se::Object *deviceMotionObject = nullptr;
|
||||
static bool JSB_getDeviceMotionValue(se::State &s) { // NOLINT(readability-identifier-naming, google-runtime-references)
|
||||
if (deviceMotionObject == nullptr) {
|
||||
deviceMotionObject = se::Object::createArrayObject(9);
|
||||
deviceMotionObject->root();
|
||||
}
|
||||
|
||||
const auto &v = Device::getDeviceMotionValue();
|
||||
const auto &v = cc::Device::getDeviceMotionValue();
|
||||
|
||||
__deviceMotionObject->setArrayElement(0, se::Value(v.accelerationX));
|
||||
__deviceMotionObject->setArrayElement(1, se::Value(v.accelerationY));
|
||||
__deviceMotionObject->setArrayElement(2, se::Value(v.accelerationZ));
|
||||
__deviceMotionObject->setArrayElement(3, se::Value(v.accelerationIncludingGravityX));
|
||||
__deviceMotionObject->setArrayElement(4, se::Value(v.accelerationIncludingGravityY));
|
||||
__deviceMotionObject->setArrayElement(5, se::Value(v.accelerationIncludingGravityZ));
|
||||
__deviceMotionObject->setArrayElement(6, se::Value(v.rotationRateAlpha));
|
||||
__deviceMotionObject->setArrayElement(7, se::Value(v.rotationRateBeta));
|
||||
__deviceMotionObject->setArrayElement(8, se::Value(v.rotationRateGamma));
|
||||
deviceMotionObject->setArrayElement(0, se::Value(v.accelerationX));
|
||||
deviceMotionObject->setArrayElement(1, se::Value(v.accelerationY));
|
||||
deviceMotionObject->setArrayElement(2, se::Value(v.accelerationZ));
|
||||
deviceMotionObject->setArrayElement(3, se::Value(v.accelerationIncludingGravityX));
|
||||
deviceMotionObject->setArrayElement(4, se::Value(v.accelerationIncludingGravityY));
|
||||
deviceMotionObject->setArrayElement(5, se::Value(v.accelerationIncludingGravityZ));
|
||||
deviceMotionObject->setArrayElement(6, se::Value(v.rotationRateAlpha));
|
||||
deviceMotionObject->setArrayElement(7, se::Value(v.rotationRateBeta));
|
||||
deviceMotionObject->setArrayElement(8, se::Value(v.rotationRateGamma));
|
||||
|
||||
s.rval().setObject(__deviceMotionObject);
|
||||
s.rval().setObject(deviceMotionObject);
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(JSB_getDeviceMotionValue)
|
||||
SE_BIND_FUNC(JSB_getDeviceMotionValue) // NOLINT(readability-identifier-naming)
|
||||
|
||||
static bool register_device(se::Object *obj) {
|
||||
static bool register_device(se::Object */*obj*/) { // NOLINT(readability-identifier-naming)
|
||||
se::Value device;
|
||||
__jsbObj->getProperty("Device", &device);
|
||||
|
||||
device.toObject()->defineFunction("getDeviceMotionValue", _SE(JSB_getDeviceMotionValue));
|
||||
|
||||
se::ScriptEngine::getInstance()->addBeforeCleanupHook([]() {
|
||||
if (__deviceMotionObject != nullptr) {
|
||||
__deviceMotionObject->unroot();
|
||||
__deviceMotionObject->decRef();
|
||||
__deviceMotionObject = nullptr;
|
||||
if (deviceMotionObject != nullptr) {
|
||||
deviceMotionObject->unroot();
|
||||
deviceMotionObject->decRef();
|
||||
deviceMotionObject = nullptr;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -610,10 +576,7 @@ static bool register_device(se::Object *obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool register_canvas_context2d(se::Object *obj) {
|
||||
_SE_DEFINE_PROP(CanvasRenderingContext2D, width)
|
||||
_SE_DEFINE_PROP(CanvasRenderingContext2D, height)
|
||||
|
||||
static bool register_canvas_context2d(se::Object */*obj*/) { // NOLINT(readability-identifier-naming, google-runtime-references)
|
||||
__jsb_cc_CanvasRenderingContext2D_proto->defineFunction("_setCanvasBufferUpdatedCallback", _SE(js_CanvasRenderingContext2D_setCanvasBufferUpdatedCallback));
|
||||
__jsb_cc_CanvasRenderingContext2D_proto->defineFunction("fillText", _SE(js_engine_CanvasRenderingContext2D_fillText));
|
||||
__jsb_cc_CanvasRenderingContext2D_proto->defineFunction("strokeText", _SE(js_engine_CanvasRenderingContext2D_strokeText));
|
||||
@@ -625,8 +588,8 @@ static bool register_canvas_context2d(se::Object *obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool js_engine_FileUtils_listFilesRecursively(se::State &s) {
|
||||
auto *cobj = (cc::FileUtils *)s.nativeThisObject();
|
||||
static bool js_engine_FileUtils_listFilesRecursively(const se::State &s) { // NOLINT(readability-identifier-naming)
|
||||
auto *cobj = static_cast<cc::FileUtils *>(s.nativeThisObject());
|
||||
SE_PRECONDITION2(cobj, false, "js_engine_FileUtils_listFilesRecursively : Invalid Native Object");
|
||||
const auto &args = s.args();
|
||||
size_t argc = args.size();
|
||||
@@ -648,10 +611,10 @@ static bool js_engine_FileUtils_listFilesRecursively(se::State &s) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2);
|
||||
return false;
|
||||
}
|
||||
SE_BIND_FUNC(js_engine_FileUtils_listFilesRecursively)
|
||||
SE_BIND_FUNC(js_engine_FileUtils_listFilesRecursively) // NOLINT(readability-identifier-naming)
|
||||
|
||||
static bool js_se_setExceptionCallback(se::State &s) {
|
||||
auto &args = s.args();
|
||||
static bool js_se_setExceptionCallback(se::State &s) { // NOLINT(readability-identifier-naming, google-runtime-references)
|
||||
const auto &args = s.args();
|
||||
if (args.size() != 1 || !args[0].isObject() || !args[0].toObject()->isFunction()) {
|
||||
SE_REPORT_ERROR("expect 1 arguments of Function type, %d provided", (int)args.size());
|
||||
return false;
|
||||
@@ -678,14 +641,14 @@ static bool js_se_setExceptionCallback(se::State &s) {
|
||||
});
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_se_setExceptionCallback)
|
||||
SE_BIND_FUNC(js_se_setExceptionCallback) // NOLINT(readability-identifier-naming)
|
||||
|
||||
static bool register_filetuils_ext(se::Object *obj) {
|
||||
static bool register_filetuils_ext(se::Object */*obj*/) { // NOLINT(readability-identifier-naming)
|
||||
__jsb_cc_FileUtils_proto->defineFunction("listFilesRecursively", _SE(js_engine_FileUtils_listFilesRecursively));
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool register_se_setExceptionCallback(se::Object *obj) {
|
||||
static bool register_se_setExceptionCallback(se::Object *obj) { // NOLINT(readability-identifier-naming)
|
||||
se::Value jsb;
|
||||
if (!obj->getProperty("jsb", &jsb)) {
|
||||
jsb.setObject(se::Object::createPlainObject());
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace cc {
|
||||
class CC_DLL CanvasGradient {
|
||||
public:
|
||||
CanvasGradient();
|
||||
~CanvasGradient();
|
||||
~CanvasGradient(); // NOLINT(performance-trivially-destructible)
|
||||
void addColorStop(float offset, const std::string &color);
|
||||
};
|
||||
|
||||
@@ -60,8 +60,8 @@ public:
|
||||
void clearRect(float x, float y, float width, float height);
|
||||
void fillRect(float x, float y, float width, float height);
|
||||
|
||||
void fillText(const std::string &text, float x, float y, float maxWidth = -1.0f);
|
||||
void strokeText(const std::string &text, float x, float y, float maxWidth = -1.0f);
|
||||
void fillText(const std::string &text, float x, float y, float maxWidth = -1.0F);
|
||||
void strokeText(const std::string &text, float x, float y, float maxWidth = -1.0F);
|
||||
Size measureText(const std::string &text);
|
||||
CanvasGradient *createLinearGradient(float x0, float y0, float x1, float y1);
|
||||
void save();
|
||||
@@ -79,20 +79,20 @@ public:
|
||||
void setCanvasBufferUpdatedCallback(const CanvasBufferUpdatedCallback &cb);
|
||||
|
||||
// functions for properties
|
||||
void set_width(float width);
|
||||
void set_height(float height);
|
||||
void set_lineWidth(float lineWidth);
|
||||
void set_lineJoin(const std::string &lineJoin);
|
||||
void set_lineCap(const std::string &lineCap);
|
||||
void set_font(const std::string &font);
|
||||
void set_textAlign(const std::string &textAlign);
|
||||
void set_textBaseline(const std::string &textBaseline);
|
||||
void set_fillStyle(const std::string &fillStyle);
|
||||
void set_strokeStyle(const std::string &strokeStyle);
|
||||
void set_globalCompositeOperation(const std::string &globalCompositeOperation);
|
||||
void setWidth(float width);
|
||||
void setHeight(float height);
|
||||
void setLineWidth(float lineWidth);
|
||||
void setLineJoin(const std::string &lineJoin);
|
||||
void setLineCap(const std::string &lineCap);
|
||||
void setFont(const std::string &font);
|
||||
void setTextAlign(const std::string &textAlign);
|
||||
void setTextBaseline(const std::string &textBaseline);
|
||||
void setFillStyle(const std::string &fillStyle);
|
||||
void setStrokeStyle(const std::string &strokeStyle);
|
||||
void setGlobalCompositeOperation(const std::string &globalCompositeOperation);
|
||||
|
||||
// fill image data into Context2D
|
||||
void _fillImageData(const Data &imageData, float imageWidth, float imageHeight, float offsetX, float offsetY);
|
||||
void fillImageData(const Data &imageData, float imageWidth, float imageHeight, float offsetX, float offsetY);
|
||||
|
||||
// transform
|
||||
void translate(float x, float y);
|
||||
@@ -106,11 +106,11 @@ private:
|
||||
void recreateBufferIfNeeded();
|
||||
|
||||
public:
|
||||
float _width = 0.0f;
|
||||
float _height = 0.0f;
|
||||
float _width = 0.0F;
|
||||
float _height = 0.0F;
|
||||
|
||||
// Line styles
|
||||
float _lineWidth = 1.0f;
|
||||
float _lineWidth = 1.0F;
|
||||
std::string _lineJoin = "miter";
|
||||
std::string _lineCap = "butt";
|
||||
|
||||
@@ -121,6 +121,7 @@ public:
|
||||
|
||||
// Fill and stroke styles
|
||||
std::string _fillStyle = "#000";
|
||||
|
||||
std::string _strokeStyle = "#000";
|
||||
|
||||
// Compositing
|
||||
|
||||
@@ -676,7 +676,7 @@ void CanvasRenderingContext2D::setCanvasBufferUpdatedCallback(const CanvasBuffer
|
||||
recreateBufferIfNeeded();
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::set_width(float width) {
|
||||
void CanvasRenderingContext2D::setWidth(float width) {
|
||||
// SE_LOGD("CanvasRenderingContext2D::set__width: %f\n", width);
|
||||
if (math::IsEqualF(width, _width)) return;
|
||||
_width = width;
|
||||
@@ -684,7 +684,7 @@ void CanvasRenderingContext2D::set_width(float width) {
|
||||
recreateBufferIfNeeded();
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::set_height(float height) {
|
||||
void CanvasRenderingContext2D::setHeight(float height) {
|
||||
// SE_LOGD("CanvasRenderingContext2D::set__height: %f\n", height);
|
||||
if (math::IsEqualF(height, _height)) return;
|
||||
_height = height;
|
||||
@@ -692,20 +692,20 @@ void CanvasRenderingContext2D::set_height(float height) {
|
||||
recreateBufferIfNeeded();
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::set_lineWidth(float lineWidth) {
|
||||
void CanvasRenderingContext2D::setLineWidth(float lineWidth) {
|
||||
_lineWidth = lineWidth;
|
||||
_impl.lineWidth = _lineWidth;
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::set_lineCap(const std::string &lineCap) {
|
||||
void CanvasRenderingContext2D::setLineCap(const std::string &lineCap) {
|
||||
//SE_LOGE("%s isn't implemented!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::set_lineJoin(const std::string &lineJoin) {
|
||||
void CanvasRenderingContext2D::setLineJoin(const std::string &lineJoin) {
|
||||
//SE_LOGE("%s isn't implemented!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::set_font(const std::string &font) {
|
||||
void CanvasRenderingContext2D::setFont(const std::string &font) {
|
||||
if (_font != font) {
|
||||
_font = font;
|
||||
|
||||
@@ -727,7 +727,7 @@ void CanvasRenderingContext2D::set_font(const std::string &font) {
|
||||
}
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::set_textAlign(const std::string &textAlign) {
|
||||
void CanvasRenderingContext2D::setTextAlign(const std::string &textAlign) {
|
||||
// SE_LOGD("CanvasRenderingContext2D::set_textAlign: %s\n", textAlign.c_str());
|
||||
if (textAlign == "left") {
|
||||
_impl.textAlign = CanvasTextAlign::LEFT;
|
||||
@@ -740,7 +740,7 @@ void CanvasRenderingContext2D::set_textAlign(const std::string &textAlign) {
|
||||
}
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::set_textBaseline(const std::string &textBaseline) {
|
||||
void CanvasRenderingContext2D::setTextBaseline(const std::string &textBaseline) {
|
||||
// SE_LOGD("CanvasRenderingContext2D::set_textBaseline: %s\n", textBaseline.c_str());
|
||||
if (textBaseline == "top") {
|
||||
_impl.textBaseLine = CanvasTextBaseline::TOP;
|
||||
@@ -756,22 +756,22 @@ void CanvasRenderingContext2D::set_textBaseline(const std::string &textBaseline)
|
||||
}
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::set_fillStyle(const std::string &fillStyle) {
|
||||
void CanvasRenderingContext2D::setFillStyle(const std::string &fillStyle) {
|
||||
CSSColorParser::Color color = CSSColorParser::parse(fillStyle);
|
||||
[_impl setFillStyleWithRed:color.r / 255.0f green:color.g / 255.0f blue:color.b / 255.0f alpha:color.a];
|
||||
// SE_LOGD("CanvasRenderingContext2D::set_fillStyle: %s, (%d, %d, %d, %f)\n", fillStyle.c_str(), color.r, color.g, color.b, color.a);
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::set_strokeStyle(const std::string &strokeStyle) {
|
||||
void CanvasRenderingContext2D::setStrokeStyle(const std::string &strokeStyle) {
|
||||
CSSColorParser::Color color = CSSColorParser::parse(strokeStyle);
|
||||
[_impl setStrokeStyleWithRed:color.r / 255.0f green:color.g / 255.0f blue:color.b / 255.0f alpha:color.a];
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::set_globalCompositeOperation(const std::string &globalCompositeOperation) {
|
||||
void CanvasRenderingContext2D::setGlobalCompositeOperation(const std::string &globalCompositeOperation) {
|
||||
//SE_LOGE("%s isn't implemented!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::_fillImageData(const Data &imageData, float imageWidth, float imageHeight, float offsetX, float offsetY) {
|
||||
void CanvasRenderingContext2D::fillImageData(const Data &imageData, float imageWidth, float imageHeight, float offsetX, float offsetY) {
|
||||
//SE_LOGE("%s isn't implemented!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
|
||||
@@ -219,13 +219,12 @@ public:
|
||||
JniHelper::callObjectVoidMethod(_obj, JCLS_CANVASIMPL, "setLineWidth", lineWidth);
|
||||
}
|
||||
|
||||
//NOLINTNEXTLINE(readability-identifier-naming)
|
||||
void _fillImageData(const Data &imageData, float imageWidth, float imageHeight, float offsetX, float offsetY) {
|
||||
void fillImageData(const Data &imageData, float imageWidth, float imageHeight, float offsetX, float offsetY) {
|
||||
if (_bufferWidth < 1.0F || _bufferHeight < 1.0F) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto arr = JniHelper::getEnv()->NewIntArray(imageData.getSize() / 4);
|
||||
auto *arr = JniHelper::getEnv()->NewIntArray(imageData.getSize() / 4);
|
||||
JniHelper::getEnv()->SetIntArrayRegion(arr, 0, imageData.getSize() / 4,
|
||||
reinterpret_cast<const jint *>(imageData.getBytes()));
|
||||
JniHelper::callObjectVoidMethod(_obj, JCLS_CANVASIMPL, "_fillImageData", arr, imageWidth,
|
||||
@@ -305,7 +304,8 @@ void fillRectWithColor(uint8_t *buf, uint32_t totalWidth, uint32_t totalHeight,
|
||||
namespace cc {
|
||||
|
||||
CanvasGradient::CanvasGradient() = default;
|
||||
CanvasGradient::~CanvasGradient() = default;
|
||||
CanvasGradient::~CanvasGradient() = default;
|
||||
|
||||
|
||||
void CanvasGradient::addColorStop(float offset, const std::string &color) {
|
||||
// SE_LOGD("CanvasGradient::addColorStop: %p\n", this);
|
||||
@@ -439,7 +439,7 @@ void CanvasRenderingContext2D::setCanvasBufferUpdatedCallback(const CanvasBuffer
|
||||
recreateBufferIfNeeded();
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::set_width(float width) { //NOLINT(readability-identifier-naming)
|
||||
void CanvasRenderingContext2D::setWidth(float width) { //NOLINT(readability-identifier-naming)
|
||||
// SE_LOGD("CanvasRenderingContext2D::set__width: %f\n", width);
|
||||
if (math::IsEqualF(width, _width)) return;
|
||||
_width = width;
|
||||
@@ -447,7 +447,7 @@ void CanvasRenderingContext2D::set_width(float width) { //NOLINT(readability-ide
|
||||
recreateBufferIfNeeded();
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::set_height(float height) { //NOLINT(readability-identifier-naming)
|
||||
void CanvasRenderingContext2D::setHeight(float height) { //NOLINT(readability-identifier-naming)
|
||||
// SE_LOGD("CanvasRenderingContext2D::set__height: %f\n", height);
|
||||
if (math::IsEqualF(height, _height)) return;
|
||||
_height = height;
|
||||
@@ -455,17 +455,17 @@ void CanvasRenderingContext2D::set_height(float height) { //NOLINT(readability-i
|
||||
recreateBufferIfNeeded();
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::set_lineWidth(float lineWidth) { //NOLINT(readability-identifier-naming)
|
||||
void CanvasRenderingContext2D::setLineWidth(float lineWidth) { //NOLINT(readability-identifier-naming)
|
||||
_lineWidth = lineWidth;
|
||||
_impl->setLineWidth(lineWidth);
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::set_lineJoin(const std::string &lineJoin) { //NOLINT(readability-identifier-naming)
|
||||
void CanvasRenderingContext2D::setLineJoin(const std::string &lineJoin) { //NOLINT(readability-identifier-naming)
|
||||
if (lineJoin.empty()) return;
|
||||
_impl->setLineJoin(lineJoin);
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::set_lineCap(const std::string &lineCap) { //NOLINT(readability-identifier-naming)
|
||||
void CanvasRenderingContext2D::setLineCap(const std::string &lineCap) { //NOLINT(readability-identifier-naming)
|
||||
if (lineCap.empty()) return;
|
||||
_impl->setLineCap(lineCap);
|
||||
}
|
||||
@@ -475,7 +475,7 @@ void CanvasRenderingContext2D::set_lineCap(const std::string &lineCap) { //NOLIN
|
||||
* "italic bold small-caps 25px Arial"
|
||||
* "italic 25px Arial"
|
||||
* */
|
||||
void CanvasRenderingContext2D::set_font(const std::string &font) { //NOLINT(readability-identifier-naming)
|
||||
void CanvasRenderingContext2D::setFont(const std::string &font) { //NOLINT(readability-identifier-naming)
|
||||
if (_font != font) {
|
||||
_font = font;
|
||||
std::string fontName = "sans-serif";
|
||||
@@ -507,7 +507,7 @@ void CanvasRenderingContext2D::set_font(const std::string &font) { //NOLINT(read
|
||||
}
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::set_textAlign(const std::string &textAlign) { //NOLINT(readability-identifier-naming)
|
||||
void CanvasRenderingContext2D::setTextAlign(const std::string &textAlign) { //NOLINT(readability-identifier-naming)
|
||||
// SE_LOGD("CanvasRenderingContext2D::set_textAlign: %s\n", textAlign.c_str());
|
||||
if (textAlign == "left") {
|
||||
_impl->setTextAlign(CanvasTextAlign::LEFT);
|
||||
@@ -520,7 +520,7 @@ void CanvasRenderingContext2D::set_textAlign(const std::string &textAlign) { //N
|
||||
}
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::set_textBaseline(const std::string &textBaseline) { //NOLINT(readability-identifier-naming)
|
||||
void CanvasRenderingContext2D::setTextBaseline(const std::string &textBaseline) { //NOLINT(readability-identifier-naming)
|
||||
// SE_LOGD("CanvasRenderingContext2D::set_textBaseline: %s\n", textBaseline.c_str());
|
||||
if (textBaseline == "top") {
|
||||
_impl->setTextBaseline(CanvasTextBaseline::TOP);
|
||||
@@ -536,23 +536,23 @@ void CanvasRenderingContext2D::set_textBaseline(const std::string &textBaseline)
|
||||
}
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::set_fillStyle(const std::string &fillStyle) { //NOLINT(readability-identifier-naming)
|
||||
void CanvasRenderingContext2D::setFillStyle(const std::string &fillStyle) { //NOLINT(readability-identifier-naming)
|
||||
CSSColorParser::Color color = CSSColorParser::parse(fillStyle);
|
||||
_impl->setFillStyle(static_cast<float>(color.r) / 255.0F, static_cast<float>(color.g) / 255.0F, static_cast<float>(color.b) / 255.0F, color.a);
|
||||
// SE_LOGD("CanvasRenderingContext2D::set_fillStyle: %s, (%d, %d, %d, %f)\n", fillStyle.c_str(), color.r, color.g, color.b, color.a);
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::set_strokeStyle(const std::string &strokeStyle) { //NOLINT(readability-identifier-naming)
|
||||
void CanvasRenderingContext2D::setStrokeStyle(const std::string &strokeStyle) { //NOLINT(readability-identifier-naming)
|
||||
CSSColorParser::Color color = CSSColorParser::parse(strokeStyle);
|
||||
_impl->setStrokeStyle(static_cast<float>(color.r) / 255.0F, static_cast<float>(color.g) / 255.0F, static_cast<float>(color.b) / 255.0F, color.a);
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::set_globalCompositeOperation(const std::string &globalCompositeOperation) { //NOLINT(readability-identifier-naming)
|
||||
void CanvasRenderingContext2D::setGlobalCompositeOperation(const std::string &globalCompositeOperation) { //NOLINT(readability-identifier-naming)
|
||||
// SE_LOGE("%s isn't implemented!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::_fillImageData(const Data &imageData, float imageWidth, float imageHeight, float offsetX, float offsetY) { //NOLINT(readability-identifier-naming)
|
||||
_impl->_fillImageData(imageData, imageWidth, imageHeight, offsetX, offsetY);
|
||||
void CanvasRenderingContext2D::fillImageData(const Data &imageData, float imageWidth, float imageHeight, float offsetX, float offsetY) { //NOLINT(readability-identifier-naming)
|
||||
_impl->fillImageData(imageData, imageWidth, imageHeight, offsetX, offsetY);
|
||||
if (_canvasBufferUpdatedCB != nullptr) {
|
||||
_canvasBufferUpdatedCB(_impl->getDataRef());
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ public:
|
||||
std::string signature = "(" + std::string(getJNISignature(xs...)) + ")[F";
|
||||
if (cc::JniHelper::getStaticMethodInfo(t, className.c_str(), methodName.c_str(), signature.c_str())) {
|
||||
LocalRefMapType localRefs;
|
||||
auto array = static_cast<jfloatArray>(t.env->CallStaticObjectMethod(t.classID, t.methodID, convert(&localRefs, &t, xs)...));
|
||||
auto *array = static_cast<jfloatArray>(t.env->CallStaticObjectMethod(t.classID, t.methodID, convert(&localRefs, &t, xs)...));
|
||||
CLEAR_EXCEPTON(t.env);
|
||||
jsize len = t.env->GetArrayLength(array);
|
||||
if (len <= 32) {
|
||||
@@ -298,7 +298,7 @@ public:
|
||||
std::string signature = "(" + std::string(getJNISignature(xs...)) + ")[F";
|
||||
if (cc::JniHelper::getStaticMethodInfo(t, className.c_str(), methodName.c_str(), signature.c_str())) {
|
||||
LocalRefMapType localRefs;
|
||||
auto array = static_cast<jfloatArray>(t.env->CallStaticObjectMethod(t.classID, t.methodID, convert(&localRefs, &t, xs)...));
|
||||
auto *array = static_cast<jfloatArray>(t.env->CallStaticObjectMethod(t.classID, t.methodID, convert(&localRefs, &t, xs)...));
|
||||
CLEAR_EXCEPTON(t.env);
|
||||
jsize len = t.env->GetArrayLength(array);
|
||||
if (len == 3) {
|
||||
@@ -350,7 +350,7 @@ public:
|
||||
std::string signature = "(" + std::string(getJNISignature(xs...)) + ")Ljava/lang/String;";
|
||||
if (cc::JniHelper::getStaticMethodInfo(t, className.c_str(), methodName.c_str(), signature.c_str())) {
|
||||
LocalRefMapType localRefs;
|
||||
auto jret = static_cast<jstring>(t.env->CallStaticObjectMethod(t.classID, t.methodID, convert(&localRefs, &t, xs)...));
|
||||
auto *jret = static_cast<jstring>(t.env->CallStaticObjectMethod(t.classID, t.methodID, convert(&localRefs, &t, xs)...));
|
||||
CLEAR_EXCEPTON(t.env);
|
||||
ret = cc::JniHelper::jstring2string(jret);
|
||||
ccDeleteLocalRef(t.env, jret);
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "platform/CanvasRenderingContext2D.h"
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
#include "base/csscolorparser.h"
|
||||
#include "math/Math.h"
|
||||
#include "cocos/bindings/jswrapper/SeApi.h"
|
||||
@@ -34,10 +34,10 @@
|
||||
#include <array>
|
||||
#include <Windows.h>
|
||||
|
||||
typedef std::array<float, 2> Point;
|
||||
typedef std::array<float, 2> Vec2;
|
||||
typedef std::array<float, 2> Size;
|
||||
typedef std::array<float, 4> Color4F;
|
||||
using Point = std::array<float, 2>;
|
||||
using Vec2 = std::array<float, 2>;
|
||||
using Size = std::array<float, 2>;
|
||||
using Color4F = std::array<float, 4>;
|
||||
|
||||
enum class CanvasTextAlign {
|
||||
LEFT,
|
||||
@@ -74,20 +74,15 @@ void fillRectWithColor(uint8_t *buf, uint32_t totalWidth, uint32_t totalHeight,
|
||||
|
||||
class CanvasRenderingContext2DImpl {
|
||||
public:
|
||||
CanvasRenderingContext2DImpl() : _DC(nullptr),
|
||||
_bmp(nullptr),
|
||||
_font((HFONT)GetStockObject(DEFAULT_GUI_FONT)),
|
||||
_wnd(nullptr),
|
||||
_savedDC(0) {
|
||||
_wnd = nullptr;
|
||||
CanvasRenderingContext2DImpl() {
|
||||
HDC hdc = GetDC(_wnd);
|
||||
_DC = CreateCompatibleDC(hdc);
|
||||
ReleaseDC(_wnd, hdc);
|
||||
}
|
||||
|
||||
~CanvasRenderingContext2DImpl() {
|
||||
_deleteBitmap();
|
||||
_removeCustomFont();
|
||||
deleteBitmap();
|
||||
removeCustomFont();
|
||||
if (_DC)
|
||||
DeleteDC(_DC);
|
||||
}
|
||||
@@ -95,17 +90,17 @@ public:
|
||||
void recreateBuffer(float w, float h) {
|
||||
_bufferWidth = w;
|
||||
_bufferHeight = h;
|
||||
if (_bufferWidth < 1.0f || _bufferHeight < 1.0f) {
|
||||
_deleteBitmap();
|
||||
if (_bufferWidth < 1.0F || _bufferHeight < 1.0F) {
|
||||
deleteBitmap();
|
||||
return;
|
||||
}
|
||||
|
||||
int textureSize = _bufferWidth * _bufferHeight * 4;
|
||||
uint8_t *data = (uint8_t *)malloc(sizeof(uint8_t) * textureSize);
|
||||
auto textureSize = static_cast<int>(_bufferWidth * _bufferHeight * 4);
|
||||
auto *data = static_cast<uint8_t *>(malloc(sizeof(uint8_t) * textureSize));
|
||||
memset(data, 0x00, textureSize);
|
||||
_imageData.fastSet(data, textureSize);
|
||||
|
||||
_prepareBitmap(_bufferWidth, _bufferHeight);
|
||||
prepareBitmap(_bufferWidth, _bufferHeight);
|
||||
}
|
||||
|
||||
void beginPath() {
|
||||
@@ -133,9 +128,11 @@ public:
|
||||
|
||||
void stroke() {
|
||||
DeleteObject(_hpen);
|
||||
if (_bufferWidth < 1.0f || _bufferHeight < 1.0f)
|
||||
if (_bufferWidth < 1.0F || _bufferHeight < 1.0F) {
|
||||
return;
|
||||
_fillTextureData();
|
||||
}
|
||||
|
||||
fillTextureData();
|
||||
}
|
||||
|
||||
void saveContext() {
|
||||
@@ -149,18 +146,22 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void clearRect(float x, float y, float w, float h) {
|
||||
if (_bufferWidth < 1.0f || _bufferHeight < 1.0f)
|
||||
return;
|
||||
if (_imageData.isNull())
|
||||
void clearRect(float /*x*/, float /*y*/, float w, float h) {
|
||||
if (_bufferWidth < 1.0F || _bufferHeight < 1.0F) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (_imageData.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
recreateBuffer(w, h);
|
||||
}
|
||||
|
||||
void fillRect(float x, float y, float w, float h) {
|
||||
if (_bufferWidth < 1.0f || _bufferHeight < 1.0f)
|
||||
if (_bufferWidth < 1.0F || _bufferHeight < 1.0F) {
|
||||
return;
|
||||
}
|
||||
|
||||
//not filled all Bits in buffer? the buffer length is _bufferWidth * _bufferHeight * 4, but it filled _bufferWidth * _bufferHeight * 3?
|
||||
uint8_t *buffer = _imageData.getBytes();
|
||||
@@ -169,25 +170,32 @@ public:
|
||||
uint8_t g = _fillStyle[1] * 255.0f;
|
||||
uint8_t b = _fillStyle[2] * 255.0f;
|
||||
uint8_t a = _fillStyle[3] * 255.0f;
|
||||
fillRectWithColor(buffer, (uint32_t)_bufferWidth, (uint32_t)_bufferHeight, (uint32_t)x, (uint32_t)y, (uint32_t)w, (uint32_t)h, r, g, b, a);
|
||||
fillRectWithColor(buffer,
|
||||
static_cast<uint32_t>(_bufferWidth),
|
||||
static_cast<uint32_t>(_bufferHeight),
|
||||
static_cast<uint32_t>(x),
|
||||
static_cast<uint32_t>(y),
|
||||
static_cast<uint32_t>(w),
|
||||
static_cast<uint32_t>(h), r, g, b, a);
|
||||
}
|
||||
}
|
||||
|
||||
void fillText(const std::string &text, float x, float y, float maxWidth) {
|
||||
if (text.empty() || _bufferWidth < 1.0f || _bufferHeight < 1.0f)
|
||||
void fillText(const std::string &text, float x, float y, float /*maxWidth*/) {
|
||||
if (text.empty() || _bufferWidth < 1.0F || _bufferHeight < 1.0F) {
|
||||
return;
|
||||
}
|
||||
|
||||
SIZE textSize = {0, 0};
|
||||
Point offsetPoint = _convertDrawPoint(Point{x, y}, text);
|
||||
Point offsetPoint = convertDrawPoint(Point{x, y}, text);
|
||||
|
||||
_drawText(text, (int)offsetPoint[0], (int)offsetPoint[1]);
|
||||
_fillTextureData();
|
||||
drawText(text, (int)offsetPoint[0], (int)offsetPoint[1]);
|
||||
fillTextureData();
|
||||
}
|
||||
|
||||
void strokeText(const std::string &text, float x, float y, float maxWidth) {
|
||||
if (text.empty() || _bufferWidth < 1.0f || _bufferHeight < 1.0f)
|
||||
void strokeText(const std::string &text, float /*x*/, float /*y*/, float /*maxWidth*/) const {
|
||||
if (text.empty() || _bufferWidth < 1.0F || _bufferHeight < 1.0F) {
|
||||
return;
|
||||
// REFINE
|
||||
}
|
||||
}
|
||||
|
||||
Size measureText(const std::string &text) {
|
||||
@@ -195,8 +203,8 @@ public:
|
||||
return std::array<float, 2>{0.0f, 0.0f};
|
||||
|
||||
int bufferLen = 0;
|
||||
wchar_t *pwszBuffer = _utf8ToUtf16(text, &bufferLen);
|
||||
Size size = _sizeWithText(pwszBuffer, bufferLen);
|
||||
wchar_t *pwszBuffer = CanvasRenderingContext2DImpl::utf8ToUtf16(text, &bufferLen);
|
||||
Size size = sizeWithText(pwszBuffer, bufferLen);
|
||||
//SE_LOGD("CanvasRenderingContext2DImpl::measureText: %s, %d, %d\n", text.c_str(), size.cx, size.cy);
|
||||
CC_SAFE_DELETE_ARRAY(pwszBuffer);
|
||||
return size;
|
||||
@@ -205,7 +213,7 @@ public:
|
||||
void updateFont(const std::string &fontName, float fontSize, bool bold = false) {
|
||||
do {
|
||||
_fontName = fontName;
|
||||
_fontSize = fontSize;
|
||||
_fontSize = static_cast<int>(fontSize);
|
||||
std::string fontPath;
|
||||
LOGFONTA tFont = {0};
|
||||
if (!_fontName.empty()) {
|
||||
@@ -247,11 +255,11 @@ public:
|
||||
tFont.lfQuality = ANTIALIASED_QUALITY;
|
||||
|
||||
// delete old font
|
||||
_removeCustomFont();
|
||||
removeCustomFont();
|
||||
|
||||
if (fontPath.size() > 0) {
|
||||
if (!fontPath.empty()) {
|
||||
_curFontPath = fontPath;
|
||||
wchar_t *pwszBuffer = _utf8ToUtf16(_curFontPath);
|
||||
wchar_t *pwszBuffer = utf8ToUtf16(_curFontPath);
|
||||
if (pwszBuffer) {
|
||||
if (AddFontResource(pwszBuffer)) {
|
||||
SendMessage(_wnd, WM_FONTCHANGE, 0, 0);
|
||||
@@ -267,12 +275,11 @@ public:
|
||||
// create failed, use default font
|
||||
SE_LOGE("Failed to create custom font(font name: %s, font size: %f), use default font.\n",
|
||||
_fontName.c_str(), fontSize);
|
||||
break;
|
||||
} else {
|
||||
SelectObject(_DC, _font);
|
||||
SendMessage(_wnd, WM_FONTCHANGE, 0, 0);
|
||||
}
|
||||
} while (0);
|
||||
} while (false);
|
||||
}
|
||||
|
||||
void setTextAlign(CanvasTextAlign align) {
|
||||
@@ -299,20 +306,20 @@ public:
|
||||
return _imageData;
|
||||
}
|
||||
|
||||
HDC _DC;
|
||||
HBITMAP _bmp;
|
||||
HDC _DC{nullptr};
|
||||
HBITMAP _bmp{nullptr};
|
||||
|
||||
private:
|
||||
cc::Data _imageData;
|
||||
HFONT _font;
|
||||
HWND _wnd;
|
||||
HFONT _font{static_cast<HFONT>(GetStockObject(DEFAULT_GUI_FONT))};
|
||||
HWND _wnd{nullptr};
|
||||
HPEN _hpen;
|
||||
PAINTSTRUCT _paintStruct;
|
||||
std::string _curFontPath;
|
||||
int _savedDC;
|
||||
float _lineWidth = 0.0f;
|
||||
float _bufferWidth = 0.0f;
|
||||
float _bufferHeight = 0.0f;
|
||||
int _savedDC{0};
|
||||
float _lineWidth = 0.0F;
|
||||
float _bufferWidth = 0.0F;
|
||||
float _bufferHeight = 0.0F;
|
||||
|
||||
std::string _fontName;
|
||||
int _fontSize;
|
||||
@@ -325,7 +332,7 @@ private:
|
||||
TEXTMETRIC _tm;
|
||||
|
||||
// change utf-8 string to utf-16, pRetLen is the string length after changing
|
||||
wchar_t *_utf8ToUtf16(const std::string &str, int *pRetLen = nullptr) {
|
||||
static wchar_t *utf8ToUtf16(const std::string &str, int *pRetLen = nullptr) {
|
||||
wchar_t *pwszBuffer = nullptr;
|
||||
do {
|
||||
if (str.empty()) {
|
||||
@@ -342,18 +349,18 @@ private:
|
||||
if (pRetLen != nullptr) {
|
||||
*pRetLen = actuallyLen;
|
||||
}
|
||||
} while (0);
|
||||
} while (false);
|
||||
return pwszBuffer;
|
||||
}
|
||||
|
||||
void _removeCustomFont() {
|
||||
void removeCustomFont() {
|
||||
HFONT hDefFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
|
||||
if (hDefFont != _font) {
|
||||
DeleteObject(SelectObject(_DC, hDefFont));
|
||||
}
|
||||
// release temp font resource
|
||||
if (_curFontPath.size() > 0) {
|
||||
wchar_t *pwszBuffer = _utf8ToUtf16(_curFontPath);
|
||||
if (!_curFontPath.empty()) {
|
||||
wchar_t *pwszBuffer = utf8ToUtf16(_curFontPath);
|
||||
if (pwszBuffer) {
|
||||
RemoveFontResource(pwszBuffer);
|
||||
SendMessage(_wnd, WM_FONTCHANGE, 0, 0);
|
||||
@@ -365,7 +372,7 @@ private:
|
||||
}
|
||||
|
||||
// x, y offset value
|
||||
int _drawText(const std::string &text, int x, int y) {
|
||||
int drawText(const std::string &text, int x, int y) {
|
||||
int nRet = 0;
|
||||
wchar_t *pwszBuffer = nullptr;
|
||||
do {
|
||||
@@ -374,9 +381,9 @@ private:
|
||||
DWORD dwFmt = DT_SINGLELINE | DT_NOPREFIX;
|
||||
|
||||
int bufferLen = 0;
|
||||
pwszBuffer = _utf8ToUtf16(text, &bufferLen);
|
||||
pwszBuffer = utf8ToUtf16(text, &bufferLen);
|
||||
|
||||
Size newSize = _sizeWithText(pwszBuffer, bufferLen);
|
||||
Size newSize = sizeWithText(pwszBuffer, bufferLen);
|
||||
|
||||
_textSize = newSize;
|
||||
|
||||
@@ -398,13 +405,13 @@ private:
|
||||
|
||||
// draw text
|
||||
nRet = DrawTextW(_DC, pwszBuffer, bufferLen, &rcText, dwFmt);
|
||||
} while (0);
|
||||
} while (false);
|
||||
CC_SAFE_DELETE_ARRAY(pwszBuffer);
|
||||
|
||||
return nRet;
|
||||
}
|
||||
|
||||
Size _sizeWithText(const wchar_t *pszText, int nLen) {
|
||||
Size sizeWithText(const wchar_t *pszText, int nLen) {
|
||||
Size tRet{0, 0};
|
||||
do {
|
||||
CC_BREAK_IF(!pszText || nLen <= 0);
|
||||
@@ -417,14 +424,14 @@ private:
|
||||
|
||||
tRet[0] = rc.right;
|
||||
tRet[1] = rc.bottom;
|
||||
} while (0);
|
||||
} while (false);
|
||||
|
||||
return tRet;
|
||||
}
|
||||
|
||||
void _prepareBitmap(int nWidth, int nHeight) {
|
||||
void prepareBitmap(int nWidth, int nHeight) {
|
||||
// release bitmap
|
||||
_deleteBitmap();
|
||||
deleteBitmap();
|
||||
|
||||
if (nWidth > 0 && nHeight > 0) {
|
||||
_bmp = CreateBitmap(nWidth, nHeight, 1, 32, nullptr);
|
||||
@@ -432,17 +439,17 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
void _deleteBitmap() {
|
||||
void deleteBitmap() {
|
||||
if (_bmp) {
|
||||
DeleteObject(_bmp);
|
||||
_bmp = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void _fillTextureData() {
|
||||
void fillTextureData() {
|
||||
do {
|
||||
int dataLen = _bufferWidth * _bufferHeight * 4;
|
||||
unsigned char *dataBuf = (unsigned char *)malloc(sizeof(unsigned char) * dataLen);
|
||||
auto dataLen = static_cast<int>(_bufferWidth * _bufferHeight * 4);
|
||||
auto *dataBuf = static_cast<unsigned char *>(malloc(sizeof(unsigned char) * dataLen));
|
||||
CC_BREAK_IF(!dataBuf);
|
||||
unsigned char *imageBuf = _imageData.getBytes();
|
||||
CC_BREAK_IF(!imageBuf);
|
||||
@@ -467,10 +474,12 @@ private:
|
||||
COLORREF textColor = (b << 16 | g << 8 | r) & 0x00ffffff;
|
||||
COLORREF *pPixel = nullptr;
|
||||
COLORREF *pImage = nullptr;
|
||||
for (int y = 0; y < _bufferHeight; ++y) {
|
||||
pPixel = (COLORREF *)dataBuf + y * (int)_bufferWidth;
|
||||
pImage = (COLORREF *)imageBuf + y * (int)_bufferWidth;
|
||||
for (int x = 0; x < _bufferWidth; ++x) {
|
||||
int bufferHeight = static_cast<int>(_bufferHeight);
|
||||
int bufferWidth = static_cast<int>(_bufferWidth);
|
||||
for (int y = 0; y < bufferHeight; ++y) {
|
||||
pPixel = (COLORREF *)dataBuf + y * bufferWidth;
|
||||
pImage = (COLORREF *)imageBuf + y * bufferWidth;
|
||||
for (int x = 0; x < bufferWidth; ++x) {
|
||||
COLORREF &clr = *pPixel;
|
||||
COLORREF &val = *pImage;
|
||||
// Because text is drawn in white color, and background color is black,
|
||||
@@ -485,10 +494,10 @@ private:
|
||||
}
|
||||
}
|
||||
free(dataBuf);
|
||||
} while (0);
|
||||
} while (false);
|
||||
}
|
||||
|
||||
std::array<float, 2> _convertDrawPoint(Point point, std::string text) {
|
||||
std::array<float, 2> convertDrawPoint(Point point, const std::string &text) {
|
||||
Size textSize = measureText(text);
|
||||
if (_textAlign == CanvasTextAlign::CENTER) {
|
||||
point[0] -= textSize[0] / 2.0f;
|
||||
@@ -515,13 +524,9 @@ private:
|
||||
|
||||
namespace cc {
|
||||
|
||||
CanvasGradient::CanvasGradient() {
|
||||
//SE_LOGD("CanvasGradient constructor: %p\n", this);
|
||||
}
|
||||
CanvasGradient::CanvasGradient() = default;
|
||||
|
||||
CanvasGradient::~CanvasGradient() {
|
||||
//SE_LOGD("CanvasGradient destructor: %p\n", this);
|
||||
}
|
||||
CanvasGradient::~CanvasGradient() = default;
|
||||
|
||||
void CanvasGradient::addColorStop(float offset, const std::string &color) {
|
||||
//SE_LOGD("CanvasGradient::addColorStop: %p\n", this);
|
||||
@@ -546,8 +551,9 @@ void CanvasRenderingContext2D::recreateBufferIfNeeded() {
|
||||
_isBufferSizeDirty = false;
|
||||
//SE_LOGD("Recreate buffer %p, w: %f, h:%f\n", this, __width, __height);
|
||||
_impl->recreateBuffer(_width, _height);
|
||||
if (_canvasBufferUpdatedCB != nullptr)
|
||||
if (_canvasBufferUpdatedCB != nullptr) {
|
||||
_canvasBufferUpdatedCB(_impl->getDataRef());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -561,31 +567,38 @@ void CanvasRenderingContext2D::fillRect(float x, float y, float width, float hei
|
||||
recreateBufferIfNeeded();
|
||||
_impl->fillRect(x, y, width, height);
|
||||
|
||||
if (_canvasBufferUpdatedCB != nullptr)
|
||||
if (_canvasBufferUpdatedCB != nullptr) {
|
||||
_canvasBufferUpdatedCB(_impl->getDataRef());
|
||||
}
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::fillText(const std::string &text, float x, float y, float maxWidth) {
|
||||
//SE_LOGD("CanvasRenderingContext2D::fillText: %s, offset: (%f, %f), %f\n", text.c_str(), x, y, maxWidth);
|
||||
if (text.empty())
|
||||
if (text.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
recreateBufferIfNeeded();
|
||||
|
||||
_impl->fillText(text, x, y, maxWidth);
|
||||
if (_canvasBufferUpdatedCB != nullptr)
|
||||
if (_canvasBufferUpdatedCB != nullptr) {
|
||||
_canvasBufferUpdatedCB(_impl->getDataRef());
|
||||
}
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::strokeText(const std::string &text, float x, float y, float maxWidth) {
|
||||
//SE_LOGD("CanvasRenderingContext2D::strokeText: %s, %f, %f, %f\n", text.c_str(), x, y, maxWidth);
|
||||
if (text.empty())
|
||||
if (text.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
recreateBufferIfNeeded();
|
||||
|
||||
_impl->strokeText(text, x, y, maxWidth);
|
||||
|
||||
if (_canvasBufferUpdatedCB != nullptr)
|
||||
if (_canvasBufferUpdatedCB != nullptr) {
|
||||
_canvasBufferUpdatedCB(_impl->getDataRef());
|
||||
}
|
||||
}
|
||||
|
||||
cc::Size CanvasRenderingContext2D::measureText(const std::string &text) {
|
||||
@@ -594,7 +607,7 @@ cc::Size CanvasRenderingContext2D::measureText(const std::string &text) {
|
||||
return cc::Size(s[0], s[1]);
|
||||
}
|
||||
|
||||
CanvasGradient *CanvasRenderingContext2D::createLinearGradient(float x0, float y0, float x1, float y1) {
|
||||
CanvasGradient *CanvasRenderingContext2D::createLinearGradient(float /*x0*/, float /*y0*/, float /*x1*/, float /*y1*/) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -627,8 +640,9 @@ void CanvasRenderingContext2D::stroke() {
|
||||
//SE_LOGD("CanvasRenderingContext2D::stroke\n");
|
||||
_impl->stroke();
|
||||
|
||||
if (_canvasBufferUpdatedCB != nullptr)
|
||||
if (_canvasBufferUpdatedCB != nullptr) {
|
||||
_canvasBufferUpdatedCB(_impl->getDataRef());
|
||||
}
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::restore() {
|
||||
@@ -641,7 +655,7 @@ void CanvasRenderingContext2D::setCanvasBufferUpdatedCallback(const CanvasBuffer
|
||||
recreateBufferIfNeeded();
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::set_width(float width) {
|
||||
void CanvasRenderingContext2D::setWidth(float width) {
|
||||
//SE_LOGD("CanvasRenderingContext2D::set__width: %f\n", width);
|
||||
if (math::IsEqualF(width, _width)) return;
|
||||
_width = width;
|
||||
@@ -649,7 +663,7 @@ void CanvasRenderingContext2D::set_width(float width) {
|
||||
recreateBufferIfNeeded();
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::set_height(float height) {
|
||||
void CanvasRenderingContext2D::setHeight(float height) {
|
||||
//SE_LOGD("CanvasRenderingContext2D::set__height: %f\n", height);
|
||||
if (math::IsEqualF(height, _height)) return;
|
||||
_height = height;
|
||||
@@ -657,17 +671,17 @@ void CanvasRenderingContext2D::set_height(float height) {
|
||||
recreateBufferIfNeeded();
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::set_lineWidth(float lineWidth) {
|
||||
void CanvasRenderingContext2D::setLineWidth(float lineWidth) {
|
||||
//SE_LOGD("CanvasRenderingContext2D::set_lineWidth %d\n", lineWidth);
|
||||
_lineWidth = lineWidth;
|
||||
_impl->setLineWidth(lineWidth);
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::set_lineCap(const std::string &lineCap) {
|
||||
void CanvasRenderingContext2D::setLineCap(const std::string &lineCap) {
|
||||
//SE_LOGE("%s isn't implemented!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::set_lineJoin(const std::string &lineJoin) {
|
||||
void CanvasRenderingContext2D::setLineJoin(const std::string &lineJoin) {
|
||||
//SE_LOGE("%s isn't implemented!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
@@ -678,7 +692,7 @@ void CanvasRenderingContext2D::rect(float x, float y, float w, float h) {
|
||||
// SE_LOGE("%s isn't implemented!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::set_font(const std::string &font) {
|
||||
void CanvasRenderingContext2D::setFont(const std::string &font) {
|
||||
if (_font != font) {
|
||||
_font = font;
|
||||
|
||||
@@ -695,13 +709,13 @@ void CanvasRenderingContext2D::set_font(const std::string &font) {
|
||||
fontName = results[5].str();
|
||||
}
|
||||
|
||||
float fontSize = atof(fontSizeStr.c_str());
|
||||
auto fontSize = static_cast<float>(atof(fontSizeStr.c_str()));
|
||||
//SE_LOGD("CanvasRenderingContext2D::set_font: %s, Size: %f, isBold: %b\n", fontName.c_str(), fontSize, !boldStr.empty());
|
||||
_impl->updateFont(fontName, fontSize, !boldStr.empty());
|
||||
}
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::set_textAlign(const std::string &textAlign) {
|
||||
void CanvasRenderingContext2D::setTextAlign(const std::string &textAlign) {
|
||||
//SE_LOGD("CanvasRenderingContext2D::set_textAlign: %s\n", textAlign.c_str());
|
||||
if (textAlign == "left") {
|
||||
_impl->setTextAlign(CanvasTextAlign::LEFT);
|
||||
@@ -714,7 +728,7 @@ void CanvasRenderingContext2D::set_textAlign(const std::string &textAlign) {
|
||||
}
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::set_textBaseline(const std::string &textBaseline) {
|
||||
void CanvasRenderingContext2D::setTextBaseline(const std::string &textBaseline) {
|
||||
//SE_LOGD("CanvasRenderingContext2D::set_textBaseline: %s\n", textBaseline.c_str());
|
||||
if (textBaseline == "top") {
|
||||
_impl->setTextBaseline(CanvasTextBaseline::TOP);
|
||||
@@ -730,22 +744,28 @@ void CanvasRenderingContext2D::set_textBaseline(const std::string &textBaseline)
|
||||
}
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::set_fillStyle(const std::string &fillStyle) {
|
||||
void CanvasRenderingContext2D::setFillStyle(const std::string &fillStyle) {
|
||||
CSSColorParser::Color color = CSSColorParser::parse(fillStyle);
|
||||
_impl->setFillStyle(color.r / 255.0f, color.g / 255.0f, color.b / 255.0f, color.a);
|
||||
_impl->setFillStyle(static_cast<float>(color.r) / 255.0F,
|
||||
static_cast<float>(color.g) / 255.0F,
|
||||
static_cast<float>(color.b) / 255.0F,
|
||||
color.a);
|
||||
//SE_LOGD("CanvasRenderingContext2D::set_fillStyle: %s, (%d, %d, %d, %f)\n", fillStyle.c_str(), color.r, color.g, color.b, color.a);
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::set_strokeStyle(const std::string &strokeStyle) {
|
||||
void CanvasRenderingContext2D::setStrokeStyle(const std::string &strokeStyle) {
|
||||
CSSColorParser::Color color = CSSColorParser::parse(strokeStyle);
|
||||
_impl->setStrokeStyle(color.r / 255.0f, color.g / 255.0f, color.b / 255.0f, color.a);
|
||||
_impl->setStrokeStyle(static_cast<float>(color.r) / 255.0F,
|
||||
static_cast<float>(color.g) / 255.0F,
|
||||
static_cast<float>(color.b) / 255.0F,
|
||||
color.a);
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::set_globalCompositeOperation(const std::string &globalCompositeOperation) {
|
||||
void CanvasRenderingContext2D::setGlobalCompositeOperation(const std::string &globalCompositeOperation) {
|
||||
//SE_LOGE("%s isn't implemented!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::_fillImageData(const Data &imageData, float imageWidth, float imageHeight, float offsetX, float offsetY) {
|
||||
void CanvasRenderingContext2D::fillImageData(const Data &imageData, float imageWidth, float imageHeight, float offsetX, float offsetY) {
|
||||
//SE_LOGE("%s isn't implemented!\n", __FUNCTION__);
|
||||
}
|
||||
// transform
|
||||
|
||||
@@ -51,8 +51,9 @@ skip = FileUtils::[getFileData setFilenameLookupDictionary destroyInstance getFu
|
||||
Data::[takeBuffer getBytes fastSet copy],
|
||||
Value::[asValueVector asValueMap asIntKeyMap]
|
||||
|
||||
rename_functions = FileUtils::[loadFilenameLookupDictionaryFromFile=loadFilenameLookup],
|
||||
CanvasRenderingContext2D::[getImageData=_getImageData]
|
||||
rename_functions = FileUtils::[loadFilenameLookupDictionaryFromFile=loadFilenameLookup]
|
||||
|
||||
getter_setter=CanvasRenderingContext2D::[width height]
|
||||
|
||||
rename_classes = SAXParser::PlistParser
|
||||
|
||||
|
||||
Reference in New Issue
Block a user