mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2024-11-23 15:11:51 +00:00
commit
7c7bf32335
@ -21,6 +21,7 @@
|
||||
#include "filter/include/filter_blur_para.h"
|
||||
#include "filter/include/filter_pixel_stretch_para.h"
|
||||
#include "filter/include/filter_water_ripple_para.h"
|
||||
#include "filter/include/filter_fly_out_para.h"
|
||||
#include "napi/native_api.h"
|
||||
#include "napi/native_node_api.h"
|
||||
|
||||
@ -51,6 +52,7 @@ private:
|
||||
static napi_value SetBlur(napi_env env, napi_callback_info info);
|
||||
static napi_value SetPixelStretch(napi_env env, napi_callback_info info);
|
||||
static napi_value SetWaterRipple(napi_env env, napi_callback_info info);
|
||||
static napi_value SetFlyOut(napi_env env, napi_callback_info info);
|
||||
static Drawing::TileMode ParserArgumentType(napi_env env, napi_value argv);
|
||||
|
||||
static float GetSpecialValue(napi_env env, napi_value argValue);
|
||||
|
@ -159,6 +159,7 @@ napi_value FilterNapi::CreateFilter(napi_env env, napi_callback_info info)
|
||||
DECLARE_NAPI_FUNCTION("blur", SetBlur),
|
||||
DECLARE_NAPI_FUNCTION("pixelStretch", SetPixelStretch),
|
||||
DECLARE_NAPI_FUNCTION("waterRipple", SetWaterRipple),
|
||||
DECLARE_NAPI_FUNCTION("flyInFlyOutEffect", SetFlyOut),
|
||||
};
|
||||
NAPI_CALL(env, napi_define_properties(env, object, sizeof(resultFuncs) / sizeof(resultFuncs[0]), resultFuncs));
|
||||
return object;
|
||||
@ -299,7 +300,7 @@ uint32_t FilterNapi::GetSpecialIntValue(napi_env env, napi_value argValue)
|
||||
{
|
||||
uint32_t tmp = 0;
|
||||
if (UIEffectNapiUtils::getType(env, argValue) == napi_number &&
|
||||
UIEFFECT_IS_OK(napi_get_value_uint32(env, argValue, &tmp)) && tmp >= 0) {
|
||||
UIEFFECT_IS_OK(napi_get_value_uint32(env, argValue, &tmp))) {
|
||||
return tmp;
|
||||
}
|
||||
return tmp;
|
||||
@ -351,6 +352,43 @@ napi_value FilterNapi::SetWaterRipple(napi_env env, napi_callback_info info)
|
||||
return thisVar;
|
||||
}
|
||||
|
||||
napi_value FilterNapi::SetFlyOut(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value result = nullptr;
|
||||
napi_get_undefined(env, &result);
|
||||
napi_status status;
|
||||
napi_value thisVar = nullptr;
|
||||
napi_value argValue[NUM_2] = {0};
|
||||
size_t argCount = NUM_2;
|
||||
UIEFFECT_JS_ARGS(env, info, status, argCount, argValue, thisVar);
|
||||
UIEFFECT_NAPI_CHECK_RET_D(UIEFFECT_IS_OK(status), nullptr, FILTER_LOG_E("fail to napi_get_fly_out_info"));
|
||||
|
||||
std::shared_ptr<FlyOutPara> para = std::make_shared<FlyOutPara>();
|
||||
|
||||
float degree = 0.0f;
|
||||
uint32_t flyMode = 0;
|
||||
|
||||
if (argCount != NUM_2) {
|
||||
FILTER_LOG_E("Args number less than 2");
|
||||
}
|
||||
|
||||
degree = GetSpecialValue(env, argValue[NUM_0]);
|
||||
flyMode = GetSpecialIntValue(env, argValue[NUM_1]);
|
||||
|
||||
para->SetDegree(degree);
|
||||
para->SetFlyMode(flyMode);
|
||||
|
||||
Filter* filterObj = nullptr;
|
||||
NAPI_CALL(env, napi_unwrap(env, thisVar, reinterpret_cast<void**>(&filterObj)));
|
||||
if (filterObj == nullptr) {
|
||||
FILTER_LOG_E("filterNapi is nullptr");
|
||||
return thisVar;
|
||||
}
|
||||
filterObj->AddPara(para);
|
||||
|
||||
return thisVar;
|
||||
}
|
||||
|
||||
Drawing::TileMode FilterNapi::ParserArgumentType(napi_env env, napi_value argv)
|
||||
{
|
||||
int32_t mode = 0;
|
||||
|
@ -255,6 +255,7 @@ ohos_source_set("render_service_base_src") {
|
||||
"src/render/rs_colorful_shadow_filter.cpp",
|
||||
"src/render/rs_drawing_filter.cpp",
|
||||
"src/render/rs_filter.cpp",
|
||||
"src/render/rs_fly_out_shader_filter.cpp",
|
||||
"src/render/rs_foreground_effect_filter.cpp",
|
||||
"src/render/rs_grey_shader_filter.cpp",
|
||||
"src/render/rs_hps_blur.cpp",
|
||||
|
@ -71,6 +71,7 @@ enum RSNodeCommandType : uint16_t {
|
||||
UPDATE_MODIFIER_MOTION_BLUR_PTR,
|
||||
UPDATE_MODIFIER_MAGNIFIER_PTR,
|
||||
UPDATE_MODIFIER_WATER_RIPPLE,
|
||||
UPDATE_MODIFIER_FLY_OUT,
|
||||
REMOVE_ALL_MODIFIERS,
|
||||
};
|
||||
|
||||
@ -190,6 +191,10 @@ ADD_COMMAND(RSUpdatePropertyWaterRipple,
|
||||
ARG(RS_NODE, UPDATE_MODIFIER_WATER_RIPPLE,
|
||||
RSNodeCommandHelper::UpdateModifier<RSWaterRipplePara>,
|
||||
NodeId, RSWaterRipplePara, PropertyId, PropertyUpdateType))
|
||||
ADD_COMMAND(RSUpdatePropertyFlyOut,
|
||||
ARG(RS_NODE, UPDATE_MODIFIER_FLY_OUT,
|
||||
RSNodeCommandHelper::UpdateModifier<RSFlyOutPara>,
|
||||
NodeId, RSFlyOutPara, PropertyId, PropertyUpdateType))
|
||||
ADD_COMMAND(RSUpdatePropertyLinearGradientBlurPara,
|
||||
ARG(RS_NODE, UPDATE_MODIFIER_GRADIENT_BLUR_PTR,
|
||||
RSNodeCommandHelper::UpdateModifier<std::shared_ptr<RSLinearGradientBlurPara>>,
|
||||
|
@ -135,6 +135,8 @@ enum class RSModifierType : int16_t {
|
||||
PARTICLE_NOISE_FIELD,
|
||||
FOREGROUND_EFFECT_RADIUS,
|
||||
MOTION_BLUR_PARA,
|
||||
FLY_OUT_DEGREE,
|
||||
FLY_OUT_PARAMS,
|
||||
DYNAMIC_DIM_DEGREE,
|
||||
MAGNIFIER_PARA,
|
||||
BACKGROUND_BLUR_RADIUS,
|
||||
|
@ -176,6 +176,10 @@ DECLARE_ANIMATABLE_MODIFIER(WaterRippleProgress, float, WATER_RIPPLE_PROGRESS, A
|
||||
|
||||
DECLARE_NOANIMATABLE_MODIFIER(WaterRippleParams, RSWaterRipplePara, WATER_RIPPLE_PARAMS, Background)
|
||||
|
||||
DECLARE_ANIMATABLE_MODIFIER(FlyOutDegree, float, FLY_OUT_DEGREE, Add, Foreground, COARSE)
|
||||
|
||||
DECLARE_NOANIMATABLE_MODIFIER(FlyOutParams, RSFlyOutPara, FLY_OUT_PARAMS, Foreground)
|
||||
|
||||
DECLARE_ANIMATABLE_MODIFIER(HueRotate, float, HUE_ROTATE, Add, Foreground, COARSE)
|
||||
|
||||
DECLARE_ANIMATABLE_MODIFIER(ColorBlend, Color, COLOR_BLEND, Add, Foreground, COLOR)
|
||||
|
@ -272,6 +272,12 @@ public:
|
||||
void SetWaterRippleProgress(const float& progress);
|
||||
float GetWaterRippleProgress() const;
|
||||
|
||||
void SetFlyOutParams(const std::optional<RSFlyOutPara>& params);
|
||||
std::optional<RSFlyOutPara> GetFlyOutParams() const;
|
||||
void SetFlyOutDegree(const float& degree);
|
||||
float GetFlyOutDegree() const;
|
||||
void CreateFlyOutShaderFilter();
|
||||
|
||||
void SetBgBrightnessRates(const Vector4f& rates);
|
||||
Vector4f GetBgBrightnessRates() const;
|
||||
void SetBgBrightnessSaturation(const float& saturation);
|
||||
@ -463,6 +469,7 @@ public:
|
||||
bool IsFgBrightnessValid() const;
|
||||
bool IsBgBrightnessValid() const;
|
||||
bool IsWaterRippleValid() const;
|
||||
bool IsFlyOutValid() const;
|
||||
std::string GetFgBrightnessDescription() const;
|
||||
std::string GetBgBrightnessDescription() const;
|
||||
|
||||
@ -597,6 +604,9 @@ private:
|
||||
std::optional<RSWaterRipplePara> waterRippleParams_ = std::nullopt;
|
||||
float waterRippleProgress_ = 0.0f;
|
||||
|
||||
std::optional<RSFlyOutPara> flyOutParams_ = std::nullopt;
|
||||
float flyOutDegree_ = 0.0f;
|
||||
|
||||
std::optional<RSDynamicBrightnessPara> fgBrightnessParams_;
|
||||
std::optional<RSDynamicBrightnessPara> bgBrightnessParams_;
|
||||
|
||||
|
@ -155,6 +155,14 @@ struct RSWaterRipplePara {
|
||||
}
|
||||
};
|
||||
|
||||
struct RSFlyOutPara {
|
||||
uint32_t flyMode = 0;
|
||||
bool operator==(const RSFlyOutPara& other) const
|
||||
{
|
||||
return (flyMode == other.flyMode);
|
||||
}
|
||||
};
|
||||
|
||||
class Decoration final {
|
||||
public:
|
||||
Decoration() {}
|
||||
|
@ -67,6 +67,7 @@ public:
|
||||
WATER_RIPPLE,
|
||||
COMPOUND_EFFECT,
|
||||
MAGNIFIER,
|
||||
FLY_OUT,
|
||||
};
|
||||
FilterType GetFilterType() const
|
||||
{
|
||||
|
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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 RENDER_SERVICE_CLIENT_CORE_RENDER_RS_FLY_OUT_SHADER_FILTER_H
|
||||
#define RENDER_SERVICE_CLIENT_CORE_RENDER_RS_FLY_OUT_SHADER_FILTER_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "effect/runtime_effect.h"
|
||||
#include "effect/runtime_shader_builder.h"
|
||||
#include "render/rs_skia_filter.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
class RSB_EXPORT RSFlyOutShaderFilter : public RSDrawingFilterOriginal {
|
||||
public:
|
||||
RSFlyOutShaderFilter(float degree_, uint32_t flyMode_);
|
||||
RSFlyOutShaderFilter(const RSFlyOutShaderFilter&) = delete;
|
||||
RSFlyOutShaderFilter operator=(const RSFlyOutShaderFilter&) = delete;
|
||||
~RSFlyOutShaderFilter() override;
|
||||
|
||||
bool IsValid() const override;
|
||||
std::string GetDescription() override;
|
||||
Drawing::Brush GetBrush(const std::shared_ptr<Drawing::Image>& image) const;
|
||||
void DrawImageRect(Drawing::Canvas& canvas, const std::shared_ptr<Drawing::Image>& image,
|
||||
const Drawing::Rect& src, const Drawing::Rect& dst) const override;
|
||||
void PreProcess(std::shared_ptr<Drawing::Image> image) override {};
|
||||
void PostProcess(Drawing::Canvas& canvas) override {};
|
||||
float GetDegree() const;
|
||||
uint32_t GetFlyMode() const;
|
||||
// 12 means anchor points of one patch
|
||||
void CalculateDeformation(std::array<Drawing::Point, 12>& flyUp,
|
||||
std::array<Drawing::Point, 12>& flyDown, const float deformWidth, const float deformHeight) const;
|
||||
|
||||
std::shared_ptr<RSDrawingFilterOriginal> Compose(
|
||||
const std::shared_ptr<RSDrawingFilterOriginal>& other) const override
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
float degree_ = 0.0f;
|
||||
uint32_t flyMode_ = 0;
|
||||
|
||||
friend class RSMarshallingHelper;
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // RENDER_SERVICE_CLIENT_CORE_RENDER_RS_FLY_OUT_SHADER_FILTER_H
|
@ -139,6 +139,8 @@ static constexpr std::array<RSDrawableSlot, DIRTY_LUT_SIZE> g_propertyToDrawable
|
||||
RSDrawableSlot::PARTICLE_EFFECT, // PARTICLE_NOISE_FIELD
|
||||
RSDrawableSlot::FOREGROUND_FILTER, // FOREGROUND_EFFECT_RADIUS
|
||||
RSDrawableSlot::FOREGROUND_FILTER, // MOTION_BLUR_PARA
|
||||
RSDrawableSlot::FOREGROUND_FILTER, // FLY_OUT_DEGREE
|
||||
RSDrawableSlot::FOREGROUND_FILTER, // FLY_OUT_PARAMS
|
||||
RSDrawableSlot::DYNAMIC_DIM, // DYNAMIC_DIM
|
||||
RSDrawableSlot::BACKGROUND_FILTER, // MAGNIFIER_PARA,
|
||||
RSDrawableSlot::BACKGROUND_FILTER, // BACKGROUND_BLUR_RADIUS
|
||||
|
@ -458,6 +458,7 @@ MARSHALLING_AND_UNMARSHALLING(RSRenderAnimatableProperty)
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, Color) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, RSDynamicBrightnessPara) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, RSWaterRipplePara) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, RSFlyOutPara) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, Gravity) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, ForegroundColorStrategyType) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, Matrix3f) \
|
||||
|
@ -1951,6 +1951,7 @@ MARSHALLING_AND_UNMARSHALLING(RSRenderAnimatableProperty)
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, Color) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, RSDynamicBrightnessPara) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, RSWaterRipplePara) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, RSFlyOutPara) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, Gravity) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, GradientDirection) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, ForegroundColorStrategyType) \
|
||||
|
@ -457,6 +457,7 @@ MARSHALLING_AND_UNMARSHALLING(RSRenderAnimatableProperty)
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, Color) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, RSDynamicBrightnessPara) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, RSWaterRipplePara) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, RSFlyOutPara) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, Gravity) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, GradientDirection) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, ForegroundColorStrategyType) \
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "render/rs_attraction_effect_filter.h"
|
||||
#include "src/core/SkOpts.h"
|
||||
#include "render/rs_water_ripple_shader_filter.h"
|
||||
#include "render/rs_fly_out_shader_filter.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
@ -177,6 +178,8 @@ constexpr static std::array<ResetPropertyFunc, static_cast<int>(RSModifierType::
|
||||
[](RSProperties* prop) { prop->SetParticleNoiseFields({}); }, // PARTICLE_NOISE_FIELD
|
||||
[](RSProperties* prop) { prop->SetForegroundEffectRadius(0.f); }, // FOREGROUND_EFFECT_RADIUS
|
||||
[](RSProperties* prop) { prop->SetMotionBlurPara({}); }, // MOTION_BLUR_PARA
|
||||
[](RSProperties* prop) { prop->SetFlyOutDegree(0.0f); }, // FLY_OUT_DEGREE
|
||||
[](RSProperties* prop) { prop->SetFlyOutParams({}); }, // FLY_OUT_PARAMS
|
||||
[](RSProperties* prop) { prop->SetDynamicDimDegree({}); }, // DYNAMIC_LIGHT_UP_DEGREE
|
||||
[](RSProperties* prop) { prop->SetMagnifierParams({}); }, // MAGNIFIER_PARA
|
||||
[](RSProperties* prop) { prop->SetBackgroundBlurRadius(0.f); }, // BACKGROUND_BLUR_RADIUS
|
||||
@ -1409,6 +1412,41 @@ bool RSProperties::IsWaterRippleValid() const
|
||||
waterRippleParams_->waveCount <= WAVE_COUNT_MAX;
|
||||
}
|
||||
|
||||
void RSProperties::SetFlyOutDegree(const float& degree)
|
||||
{
|
||||
flyOutDegree_ = degree;
|
||||
isDrawn_ = true;
|
||||
filterNeedUpdate_ = true;
|
||||
SetDirty();
|
||||
contentDirty_ = true;
|
||||
}
|
||||
|
||||
float RSProperties::GetFlyOutDegree() const
|
||||
{
|
||||
return flyOutDegree_;
|
||||
}
|
||||
|
||||
void RSProperties::SetFlyOutParams(const std::optional<RSFlyOutPara>& params)
|
||||
{
|
||||
flyOutParams_ = params;
|
||||
if (params.has_value()) {
|
||||
isDrawn_ = true;
|
||||
}
|
||||
filterNeedUpdate_ = true;
|
||||
SetDirty();
|
||||
contentDirty_ = true;
|
||||
}
|
||||
|
||||
std::optional<RSFlyOutPara> RSProperties::GetFlyOutParams() const
|
||||
{
|
||||
return flyOutParams_;
|
||||
}
|
||||
|
||||
bool RSProperties::IsFlyOutValid() const
|
||||
{
|
||||
return ROSEN_GE(flyOutDegree_, 0.0f) && ROSEN_LE(flyOutDegree_, 1.0f);
|
||||
}
|
||||
|
||||
void RSProperties::SetFgBrightnessRates(const Vector4f& rates)
|
||||
{
|
||||
if (!fgBrightnessParams_.has_value()) {
|
||||
@ -2328,6 +2366,13 @@ void RSProperties::CreateSphereEffectFilter()
|
||||
}
|
||||
}
|
||||
|
||||
void RSProperties::CreateFlyOutShaderFilter()
|
||||
{
|
||||
uint32_t flyMode = flyOutParams_->flyMode;
|
||||
auto flyOutShaderFilter = std::make_shared<RSFlyOutShaderFilter>(flyOutDegree_, flyMode);
|
||||
foregroundFilter_ = flyOutShaderFilter;
|
||||
}
|
||||
|
||||
void RSProperties::CreateAttractionEffectFilter()
|
||||
{
|
||||
float canvasWidth = GetBoundsRect().GetWidth();
|
||||
@ -4156,6 +4201,8 @@ void RSProperties::UpdateForegroundFilter()
|
||||
CreateSphereEffectFilter();
|
||||
} else if (IsAttractionValid()) {
|
||||
CreateAttractionEffectFilter();
|
||||
} else if (IsFlyOutValid()) {
|
||||
CreateFlyOutShaderFilter();
|
||||
} else if (GetShadowMask()) {
|
||||
float elevation = GetShadowElevation();
|
||||
Drawing::scalar n1 = 0.25f * elevation * (1 + elevation / 128.0f); // 0.25f 128.0f
|
||||
|
@ -98,6 +98,8 @@ static const std::unordered_map<RSModifierType, RSPropertyDrawableSlot> g_proper
|
||||
{ RSModifierType::LINEAR_GRADIENT_BLUR_PARA, RSPropertyDrawableSlot::COMPOSITING_FILTER },
|
||||
{ RSModifierType::FOREGROUND_EFFECT_RADIUS, RSPropertyDrawableSlot::FOREGROUND_FILTER },
|
||||
{ RSModifierType::MOTION_BLUR_PARA, RSPropertyDrawableSlot::FOREGROUND_FILTER },
|
||||
{ RSModifierType::FLY_OUT_DEGREE, RSPropertyDrawableSlot::FOREGROUND_FILTER },
|
||||
{ RSModifierType::FLY_OUT_PARAMS, RSPropertyDrawableSlot::FOREGROUND_FILTER },
|
||||
{ RSModifierType::MAGNIFIER_PARA, RSPropertyDrawableSlot::BACKGROUND_FILTER },
|
||||
{ RSModifierType::DYNAMIC_LIGHT_UP_RATE, RSPropertyDrawableSlot::DYNAMIC_LIGHT_UP },
|
||||
{ RSModifierType::DYNAMIC_LIGHT_UP_DEGREE, RSPropertyDrawableSlot::DYNAMIC_LIGHT_UP },
|
||||
|
@ -43,6 +43,7 @@ const std::map<int, std::string> FILTER_TYPE_MAP {
|
||||
{ RSFilter::WATER_RIPPLE, "RSWaterRippleFilter" },
|
||||
{ RSFilter::COMPOUND_EFFECT, "CompoundEffect" },
|
||||
{ RSFilter::MAGNIFIER, "RSMagnifierFilter" },
|
||||
{ RSFilter::FLY_OUT, "FlyOut" },
|
||||
};
|
||||
}
|
||||
RSDrawingFilter::RSDrawingFilter(std::shared_ptr<Drawing::ImageFilter> imageFilter, uint32_t hash)
|
||||
|
@ -0,0 +1,195 @@
|
||||
/*
|
||||
* 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 "render/rs_fly_out_shader_filter.h"
|
||||
|
||||
#include "common/rs_common_def.h"
|
||||
#include "common/rs_optional_trace.h"
|
||||
#include "platform/common/rs_log.h"
|
||||
#include "src/core/SkOpts.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
// 0.22 means the ratio of deformation distance of the first four points a, a1, b1, b to width when fly out
|
||||
static const float FLYOUT_DEFORM_PERCENTAGE_ONE = 0.22;
|
||||
// 0.19 means the ratio of deformation distance of the points a2, b2 to width when fly out
|
||||
static const float FLYOUT_DEFORM_PERCENTAGE_TWO = 0.19;
|
||||
// 0.07 means the ratio of deformation distance of the points c3, c2, d3, d2 to width when fly in
|
||||
static const float FLYIN_DEFORM_PERCENTAGE_ONE = 0.07;
|
||||
// 0.04 means the ratio of deformation distance of the points c3, c2, d3, d2 to height when fly in
|
||||
static const float FLYIN_DEFORM_PERCENTAGE_HEIGHT = 0.04;
|
||||
// 0.21 means the ratio of deformation distance of the points e, e2, f, f2 to width when fly in
|
||||
static const float FLYIN_DEFORM_PERCENTAGE_TWO = 0.21;
|
||||
static const size_t POINT_NUM = 12; // 12 anchor points of a patch
|
||||
static const uint32_t FLY_OUT_MODE = 0;
|
||||
static const uint32_t FLY_IN_MODE = 1;
|
||||
|
||||
|
||||
RSFlyOutShaderFilter::RSFlyOutShaderFilter(float degree, uint32_t flyMode)
|
||||
: RSDrawingFilterOriginal(nullptr), degree_(degree), flyMode_(flyMode)
|
||||
{
|
||||
type_ = FilterType::FLY_OUT;
|
||||
|
||||
hash_ = SkOpts::hash(&type_, sizeof(type_), 0);
|
||||
hash_ = SkOpts::hash(°ree_, sizeof(degree_), hash_);
|
||||
hash_ = SkOpts::hash(&flyMode_, sizeof(flyMode_), hash_);
|
||||
}
|
||||
|
||||
|
||||
RSFlyOutShaderFilter::~RSFlyOutShaderFilter() = default;
|
||||
|
||||
std::string RSFlyOutShaderFilter::GetDescription()
|
||||
{
|
||||
return "RSFlyOutShaderFilter " + std::to_string(degree_);
|
||||
}
|
||||
|
||||
bool RSFlyOutShaderFilter::IsValid() const
|
||||
{
|
||||
constexpr float epsilon = 0.001f;
|
||||
return degree_ > epsilon;
|
||||
}
|
||||
|
||||
float RSFlyOutShaderFilter::GetDegree() const
|
||||
{
|
||||
return degree_;
|
||||
}
|
||||
|
||||
uint32_t RSFlyOutShaderFilter::GetFlyMode() const
|
||||
{
|
||||
return flyMode_;
|
||||
}
|
||||
|
||||
Drawing::Brush RSFlyOutShaderFilter::GetBrush(const std::shared_ptr<Drawing::Image>& image) const
|
||||
{
|
||||
Drawing::Brush brush;
|
||||
brush.SetBlendMode(Drawing::BlendMode::SRC_OVER);
|
||||
Drawing::SamplingOptions samplingOptions;
|
||||
Drawing::Matrix scaleMat;
|
||||
brush.SetShaderEffect(Drawing::ShaderEffect::CreateImageShader(
|
||||
*image, Drawing::TileMode::CLAMP, Drawing::TileMode::CLAMP, samplingOptions, scaleMat));
|
||||
return brush;
|
||||
}
|
||||
|
||||
void RSFlyOutShaderFilter::CalculateDeformation(std::array<Drawing::Point, POINT_NUM>& flyUp,
|
||||
std::array<Drawing::Point, POINT_NUM>& flyDown, const float deformWidth, const float deformHeight) const
|
||||
{
|
||||
float flyOutOffsetOne = FLYOUT_DEFORM_PERCENTAGE_ONE * deformWidth * degree_;
|
||||
float flyOutOffsetTwo = FLYOUT_DEFORM_PERCENTAGE_TWO * deformWidth * degree_;
|
||||
float flyInOffsetOne = FLYIN_DEFORM_PERCENTAGE_ONE * deformWidth * (1.0 - degree_);
|
||||
float flyInOffsetTwo = FLYIN_DEFORM_PERCENTAGE_TWO * deformWidth * (1.0 - degree_);
|
||||
float flyInOffsetHeight = FLYIN_DEFORM_PERCENTAGE_HEIGHT * deformHeight * (1.0 - degree_);
|
||||
|
||||
if (flyMode_ == FLY_OUT_MODE) {
|
||||
// upper half part
|
||||
flyUp[0].Offset(flyOutOffsetOne, 0); // Point 0 is a, which is the top left control point
|
||||
flyUp[1].Offset(flyOutOffsetOne, 0); // Point 1 is a1 on the left one-third of the top edge
|
||||
flyUp[2].Offset(-flyOutOffsetOne, 0); // Point 2 is b1 on the right one-third of the top edge
|
||||
flyUp[3].Offset(-flyOutOffsetOne, 0); // Point 3 is b, which is thetop right control point
|
||||
flyUp[4].Offset(-flyOutOffsetTwo, 0); // Point 4 is b2 on the upper one-third of the right edge
|
||||
flyUp[11].Offset(flyOutOffsetTwo, 0); // Point 11 is a2 on the upper one-third of the left edge
|
||||
} else if (flyMode_ == FLY_IN_MODE) {
|
||||
// upper half part
|
||||
flyUp[5].Offset(flyInOffsetOne, flyInOffsetHeight); // Point 5 is d2 on the upper two-thirds of the right edge
|
||||
flyUp[10].Offset(-flyInOffsetOne, flyInOffsetHeight); // Point 10 is c2 on the upper two-thirds of left edge
|
||||
// lower half part
|
||||
flyDown[4].Offset(-flyInOffsetOne, -flyInOffsetHeight); // Point 4 is d3 on the lower two-thirds of right edge
|
||||
flyDown[5].Offset(-flyInOffsetTwo, 0); // Point 5 is f2 on the lower one-third of the right edge
|
||||
flyDown[6].Offset(-flyInOffsetTwo, 0); // Point 6 is f, which is the bottom right control point
|
||||
flyDown[7].Offset(flyInOffsetTwo, 0); // Point 7 is f1 on the right one-third of the bottom edge
|
||||
flyDown[8].Offset(-flyInOffsetTwo, 0); // Point 8 is e1 on the left one-third of the bottom edge
|
||||
flyDown[9].Offset(flyInOffsetTwo, 0); // Point 9 is e, which is the bottom left control point
|
||||
flyDown[10].Offset(flyInOffsetTwo, 0); // Point 10 is e2 on the lower one-third of the left edge
|
||||
flyDown[11].Offset(flyInOffsetOne, -flyInOffsetHeight); // Point 11 is c3 on the lower two-thirds of left edge
|
||||
}
|
||||
}
|
||||
|
||||
void RSFlyOutShaderFilter::DrawImageRect(Drawing::Canvas& canvas, const std::shared_ptr<Drawing::Image>& image,
|
||||
const Drawing::Rect& src, const Drawing::Rect& dst) const
|
||||
{
|
||||
if (!image || image->GetWidth() == 0 || image->GetHeight() == 0) {
|
||||
ROSEN_LOGE("RSFlyOutShaderFilter::shader error");
|
||||
return;
|
||||
}
|
||||
|
||||
auto brush = GetBrush(image);
|
||||
canvas.AttachBrush(brush);
|
||||
|
||||
int imageWidth = image->GetWidth();
|
||||
int imageHeight = image->GetHeight();
|
||||
float width = imageWidth; // the width of two deformation part
|
||||
float height = imageHeight / 2.0; // the height of two deformation part
|
||||
// 4 coordinates of image texture
|
||||
const std::array<Drawing::Point, 4> texCoordsUp = {
|
||||
Drawing::Point{ 0.0f, 0.0f }, Drawing::Point{ imageWidth, 0.0f },
|
||||
Drawing::Point{ imageWidth, height }, Drawing::Point{ 0.0f, height } };
|
||||
// 4 coordinates of image texture
|
||||
const std::array<Drawing::Point, 4> texCoordsDown = {
|
||||
Drawing::Point{ 0.0f, height }, Drawing::Point{ imageWidth, height },
|
||||
Drawing::Point{ imageWidth, imageHeight}, Drawing::Point{ 0.0f, imageHeight } };
|
||||
|
||||
// coordinates init of deformation part
|
||||
float segmentWidthOne = width / 3.0; // Anchor point 1 is located at one-third of the width.
|
||||
float segmentWidthTwo = width / 3.0 * 2.0; // Anchor point 2 is located at two-thirds of the width.
|
||||
float segmentHeightOne = height / 3.0; // Anchor point 1 is located at one-third of the height.
|
||||
float segmentHeightTwo = height / 3.0 * 2.0; // Anchor point 2 is located at two-thirds of the height.
|
||||
std::array<Drawing::Point, POINT_NUM> flyUp = {
|
||||
// top edge control points of upper part
|
||||
Drawing::Point{0.0f, 0.0f}, Drawing::Point{segmentWidthOne, 0.0f},
|
||||
Drawing::Point{segmentWidthTwo, 0.0f}, Drawing::Point{width, 0.0f},
|
||||
// right edge control points of upper part
|
||||
Drawing::Point{width, segmentHeightOne}, Drawing::Point{width, segmentHeightTwo},
|
||||
// bottom edge control points of upper part
|
||||
Drawing::Point{width, height}, Drawing::Point{segmentWidthTwo, height},
|
||||
Drawing::Point{segmentWidthOne, height}, Drawing::Point{0.0f, height},
|
||||
// left edge control points of upper part
|
||||
Drawing::Point{0.0f, segmentHeightTwo}, Drawing::Point{0.0f, segmentHeightOne}
|
||||
};
|
||||
std::array<Drawing::Point, POINT_NUM> flyDown = {
|
||||
// top edge control points of lower part
|
||||
Drawing::Point{0.0f, height}, Drawing::Point{segmentWidthOne, height},
|
||||
Drawing::Point{segmentWidthTwo, height}, Drawing::Point{width, height},
|
||||
// right edge control points of lower part
|
||||
Drawing::Point{width, height + segmentHeightOne}, Drawing::Point{width, height + segmentHeightTwo},
|
||||
// bottom edge control points of lower part
|
||||
Drawing::Point{width, imageHeight}, Drawing::Point{segmentWidthTwo, imageHeight},
|
||||
Drawing::Point{segmentWidthOne, imageHeight}, Drawing::Point{0.0f, imageHeight},
|
||||
// left edge control points of lower part
|
||||
Drawing::Point{0.0f, height + segmentHeightTwo}, Drawing::Point{0.0f, height + segmentHeightOne}
|
||||
};
|
||||
|
||||
// deformation coordinate
|
||||
CalculateDeformation(flyUp, flyDown, width, imageHeight);
|
||||
|
||||
Drawing::Path path;
|
||||
// The 0th point is the starting point of drawing.
|
||||
path.MoveTo(flyUp[0].GetX(), flyUp[0].GetY());
|
||||
// The 1st, 2nd, and 3rd control points are connected to represent the upper edge.
|
||||
path.CubicTo(flyUp[1], flyUp[2], flyUp[3]);
|
||||
// The 4th, 5th and 6th control points are connected to represent the right edge of upper part.
|
||||
path.CubicTo(flyUp[4], flyUp[5], flyUp[6]);
|
||||
// The 4th, 5th and 6th control points are connected to represent the right edge of lower part.
|
||||
path.CubicTo(flyDown[4], flyDown[5], flyDown[6]);
|
||||
// The 7th, 8th, and 9th control points are connected to represent the bottom edge.
|
||||
path.CubicTo(flyDown[7], flyDown[8], flyDown[9]);
|
||||
// The 0th, 10th, and 11th control points are connected to represent the left edge of lower part.
|
||||
path.CubicTo(flyDown[10], flyDown[11], flyDown[0]);
|
||||
// The 0th, 10th, and 11th control points are connected to represent the left edge upper part.
|
||||
path.CubicTo(flyUp[10], flyUp[11], flyUp[0]);
|
||||
canvas.ClipPath(path, Drawing::ClipOp::INTERSECT, true);
|
||||
canvas.DrawPatch(flyUp.data(), nullptr, texCoordsUp.data(), Drawing::BlendMode::SRC_OVER);
|
||||
canvas.DrawPatch(flyDown.data(), nullptr, texCoordsDown.data(), Drawing::BlendMode::SRC_OVER);
|
||||
canvas.DetachBrush();
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
@ -254,6 +254,12 @@ void RSProperty<RSWaterRipplePara>::UpdateToRender(
|
||||
UPDATE_TO_RENDER(RSUpdatePropertyWaterRipple, value, type);
|
||||
}
|
||||
template<>
|
||||
void RSProperty<RSFlyOutPara>::UpdateToRender(
|
||||
const RSFlyOutPara& value, PropertyUpdateType type) const
|
||||
{
|
||||
UPDATE_TO_RENDER(RSUpdatePropertyFlyOut, value, type);
|
||||
}
|
||||
template<>
|
||||
void RSProperty<std::shared_ptr<MotionBlurParam>>::UpdateToRender(
|
||||
const std::shared_ptr<MotionBlurParam>& value, PropertyUpdateType type) const
|
||||
{
|
||||
|
@ -712,6 +712,9 @@ template<>
|
||||
RSC_EXPORT void RSProperty<RSWaterRipplePara>::UpdateToRender(
|
||||
const RSWaterRipplePara& value, PropertyUpdateType type) const;
|
||||
template<>
|
||||
RSC_EXPORT void RSProperty<RSFlyOutPara>::UpdateToRender(
|
||||
const RSFlyOutPara& value, PropertyUpdateType type) const;
|
||||
template<>
|
||||
RSC_EXPORT void RSProperty<std::shared_ptr<RSLinearGradientBlurPara>>::UpdateToRender(
|
||||
const std::shared_ptr<RSLinearGradientBlurPara>& value, PropertyUpdateType type) const;
|
||||
template<>
|
||||
|
@ -622,6 +622,24 @@ protected:
|
||||
std::shared_ptr<RSRenderModifier> CreateRenderModifier() const override;
|
||||
};
|
||||
|
||||
class RSC_EXPORT RSFlyOutParamsModifier : public RSForegroundModifier {
|
||||
public:
|
||||
explicit RSFlyOutParamsModifier(const std::shared_ptr<RSPropertyBase>& property);
|
||||
virtual ~RSFlyOutParamsModifier() = default;
|
||||
protected:
|
||||
RSModifierType GetModifierType() const override;
|
||||
std::shared_ptr<RSRenderModifier> CreateRenderModifier() const override;
|
||||
};
|
||||
|
||||
class RSC_EXPORT RSFlyOutDegreeModifier : public RSForegroundModifier {
|
||||
public:
|
||||
explicit RSFlyOutDegreeModifier(const std::shared_ptr<RSPropertyBase>& property);
|
||||
virtual ~RSFlyOutDegreeModifier() = default;
|
||||
protected:
|
||||
RSModifierType GetModifierType() const override;
|
||||
std::shared_ptr<RSRenderModifier> CreateRenderModifier() const override;
|
||||
};
|
||||
|
||||
class RSC_EXPORT RSFgBrightnessRatesModifier : public RSForegroundModifier {
|
||||
public:
|
||||
explicit RSFgBrightnessRatesModifier(const std::shared_ptr<RSPropertyBase>& property);
|
||||
|
@ -1422,6 +1422,15 @@ void RSNode::SetUIForegroundFilter(const OHOS::Rosen::Filter* foregroundFilter)
|
||||
auto blurRadius = filterBlurPara->GetRadius();
|
||||
SetForegroundEffectRadius(blurRadius);
|
||||
}
|
||||
if (filterPara->GetParaType() == FilterPara::FLY_OUT) {
|
||||
auto flyOutPara = std::static_pointer_cast<FlyOutPara>(filterPara);
|
||||
auto flyMode = flyOutPara->GetFlyMode();
|
||||
auto degree = flyOutPara->GetDegree();
|
||||
RSFlyOutPara rs_fly_out_param = {
|
||||
flyMode,
|
||||
};
|
||||
SetFlyOutParams(rs_fly_out_param, degree);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1791,6 +1800,14 @@ void RSNode::SetWaterRippleParams(const RSWaterRipplePara& params, float progres
|
||||
RSAnimatableProperty<float>>(RSModifierType::WATER_RIPPLE_PROGRESS, progress);
|
||||
}
|
||||
|
||||
void RSNode::SetFlyOutParams(const RSFlyOutPara& params, float degree)
|
||||
{
|
||||
SetProperty<RSFlyOutParamsModifier,
|
||||
RSProperty<RSFlyOutPara>>(RSModifierType::FLY_OUT_PARAMS, params);
|
||||
SetProperty<RSFlyOutDegreeModifier,
|
||||
RSAnimatableProperty<float>>(RSModifierType::FLY_OUT_DEGREE, degree);
|
||||
}
|
||||
|
||||
void RSNode::SetFreeze(bool isFreeze)
|
||||
{
|
||||
ROSEN_LOGE("SetFreeze only support RSSurfaceNode and RSCanvasNode in uniRender");
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "ui_effect/filter/include/filter_pixel_stretch_para.h"
|
||||
#include "ui_effect/filter/include/filter_blur_para.h"
|
||||
#include "ui_effect/filter/include/filter_water_ripple_para.h"
|
||||
#include "ui_effect/filter/include/filter_fly_out_para.h"
|
||||
|
||||
#include "recording/recording_canvas.h"
|
||||
|
||||
@ -345,6 +346,7 @@ public:
|
||||
Drawing::TileMode stretchTileMode = Drawing::TileMode::CLAMP);
|
||||
|
||||
void SetWaterRippleParams(const RSWaterRipplePara& params, float progress);
|
||||
void SetFlyOutParams(const RSFlyOutPara& params, float degree);
|
||||
|
||||
void SetPaintOrder(bool drawContentLast);
|
||||
|
||||
|
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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 UIEFFECT_FILTER_FLY_OUT_PARA_H
|
||||
#define UIEFFECT_FILTER_FLY_OUT_PARA_H
|
||||
#include <iostream>
|
||||
#include "filter_para.h"
|
||||
#include "common/rs_vector2.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
class FlyOutPara : public FilterPara {
|
||||
public:
|
||||
FlyOutPara()
|
||||
{
|
||||
this->type_ = FilterPara::ParaType::FLY_OUT;
|
||||
}
|
||||
~FlyOutPara() override = default;
|
||||
|
||||
void SetDegree(float degree)
|
||||
{
|
||||
degree_ = degree;
|
||||
}
|
||||
|
||||
float GetDegree() const
|
||||
{
|
||||
return degree_;
|
||||
}
|
||||
|
||||
void SetFlyMode(uint32_t flyMode)
|
||||
{
|
||||
flyMode_ = flyMode;
|
||||
}
|
||||
|
||||
uint32_t GetFlyMode () const
|
||||
{
|
||||
return flyMode_;
|
||||
}
|
||||
|
||||
private:
|
||||
float degree_ = 0.0f;
|
||||
uint32_t flyMode_ = 0;
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
#endif // UIEFFECT_FILTER_FLY_OUT_PARA_H
|
@ -41,6 +41,7 @@ public:
|
||||
BLUR,
|
||||
PIXEL_STRETCH,
|
||||
WATER_RIPPLE,
|
||||
FLY_OUT,
|
||||
};
|
||||
|
||||
FilterPara() = default;
|
||||
|
@ -248,6 +248,16 @@ HWTEST_F(PropertiesTest, UpdateFilterTest, TestSize.Level1)
|
||||
properties.motionBlurPara_ = std::make_shared<MotionBlurParam>(1.f, scaleAnchor);
|
||||
properties.UpdateFilter();
|
||||
EXPECT_TRUE(properties.foregroundFilter_);
|
||||
|
||||
properties.foregroundEffectRadius_ = -0.1f;
|
||||
properties.flyOutDegree_ = 0.5;
|
||||
properties.UpdateFilter();
|
||||
EXPECT_TRUE(properties.foregroundFilter_);
|
||||
|
||||
properties.flyOutDegree_ = 0.5;
|
||||
properties.shadow_->imageMask_ = true;
|
||||
properties.UpdateFilter();
|
||||
EXPECT_TRUE(properties.foregroundFilter_);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32,6 +32,7 @@ ohos_unittest("RSRenderServiceBaseRenderTest") {
|
||||
"rs_colorful_shadow_filter_test.cpp",
|
||||
"rs_drawing_filter_test.cpp",
|
||||
"rs_filter_test.cpp",
|
||||
"rs_fly_out_shader_filter_test.cpp",
|
||||
"rs_foreground_effect_filter_test.cpp",
|
||||
"rs_image_base_test.cpp",
|
||||
"rs_image_cache_test.cpp",
|
||||
|
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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 "gtest/gtest.h"
|
||||
|
||||
#include "render/rs_fly_out_shader_filter.h"
|
||||
#include "draw/color.h"
|
||||
#include "image/image_info.h"
|
||||
#include "skia_image.h"
|
||||
#include "skia_image_info.h"
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
|
||||
class RSFlyOutShaderFilterTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp() override;
|
||||
void TearDown() override;
|
||||
};
|
||||
|
||||
void RSFlyOutShaderFilterTest::SetUpTestCase() {}
|
||||
void RSFlyOutShaderFilterTest::TearDownTestCase() {}
|
||||
void RSFlyOutShaderFilterTest::SetUp() {}
|
||||
void RSFlyOutShaderFilterTest::TearDown() {}
|
||||
|
||||
/**
|
||||
* @tc.name: DrawImageRect001
|
||||
* @tc.desc: test results of DrawImageRect
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueIAH2TY
|
||||
*/
|
||||
HWTEST_F(RSFlyOutShaderFilterTest, DrawImageRect001, TestSize.Level1)
|
||||
{
|
||||
RSFlyOutShaderFilter effectFilter(0.f, 0);
|
||||
Drawing::Canvas canvas;
|
||||
std::shared_ptr<Drawing::Image> image;
|
||||
Drawing::Rect src;
|
||||
Drawing::Rect dst;
|
||||
effectFilter.DrawImageRect(canvas, image, src, dst);
|
||||
EXPECT_FALSE(image);
|
||||
|
||||
effectFilter.degree_ = 1.0f;
|
||||
image = std::make_shared<Drawing::Image>();
|
||||
effectFilter.DrawImageRect(canvas, image, src, dst);
|
||||
EXPECT_TRUE(image);
|
||||
|
||||
Drawing::ImageInfo imageInfo(1, 1, Drawing::ColorType::COLORTYPE_ALPHA_8, Drawing::AlphaType::ALPHATYPE_OPAQUE);
|
||||
auto skImageInfo = Drawing::SkiaImageInfo::ConvertToSkImageInfo(imageInfo);
|
||||
int addr1 = 1;
|
||||
int* addr = &addr1;
|
||||
auto skiaPixmap = SkPixmap(skImageInfo, addr, 1);
|
||||
Drawing::ReleaseContext releaseContext = nullptr;
|
||||
Drawing::RasterReleaseProc rasterReleaseProc = nullptr;
|
||||
sk_sp<SkImage> skImage = SkImage::MakeFromRaster(skiaPixmap, rasterReleaseProc, releaseContext);
|
||||
auto skiaImage = std::make_shared<Drawing::SkiaImage>(skImage);
|
||||
image->imageImplPtr = skiaImage;
|
||||
effectFilter.DrawImageRect(canvas, image, src, dst);
|
||||
EXPECT_TRUE(image->GetWidth());
|
||||
EXPECT_TRUE(image->GetHeight());
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
Loading…
Reference in New Issue
Block a user