mirror of
https://github.com/rive-app/rive-cpp.git
synced 2026-01-18 13:11:19 +01:00
fix(scripting): search first parent transform component to build script node feature: modulate opacity (#11427) 128d9d61e0 * feature: modulate opacity * fix: clang-format * fix: rust renderer has a no-op modulateOpacity * fix: no-op modulateOpacity for canvas android * feature: modulate opacity on android canvas * fix: rcp ref * fix: missing override * fix: gms * fix: make flutter_renderer match cg one * fix: josh pr feedback * fix: remove CG transparency layer * fix: save modulated gradient up-front * fix: store only one gradient ref * fix: remove specific constructor * fix: use GradDataArray! * fix: expose currentModulatedOpacity * fix: cg_factory modulated opacity value * fix: modulate negative opacity test * fix: verify double modulate negative also clamps Co-authored-by: Luigi Rosso <luigi-rosso@users.noreply.github.com> Co-authored-by: hernan <hernan@rive.app>
95 lines
3.0 KiB
C++
95 lines
3.0 KiB
C++
#ifndef _RIVE_SHAPE_PAINT_HPP_
|
|
#define _RIVE_SHAPE_PAINT_HPP_
|
|
#include "rive/generated/shapes/paint/shape_paint_base.hpp"
|
|
#include "rive/shapes/paint/effects_container.hpp"
|
|
#include "rive/renderer.hpp"
|
|
#include "rive/shapes/paint/blend_mode.hpp"
|
|
#include "rive/shapes/paint/shape_paint_mutator.hpp"
|
|
#include "rive/shapes/path_flags.hpp"
|
|
#include "rive/shapes/shape_paint_path.hpp"
|
|
#include "rive/shapes/paint/stroke_effect.hpp"
|
|
#include "rive/math/raw_path.hpp"
|
|
|
|
namespace rive
|
|
{
|
|
class RenderPaint;
|
|
class ShapePaintMutator;
|
|
class Feather;
|
|
class ShapePaintContainer;
|
|
class TransformComponent;
|
|
class ShapePaint : public ShapePaintBase,
|
|
public EffectsContainer,
|
|
public PathProvider
|
|
{
|
|
protected:
|
|
rcp<RenderPaint> m_RenderPaint;
|
|
ShapePaintMutator* m_PaintMutator = nullptr;
|
|
|
|
public:
|
|
StatusCode onAddedClean(CoreContext* context) override;
|
|
void invalidateEffects(StrokeEffect* effect) override;
|
|
void invalidateEffects() override;
|
|
virtual void invalidateRendering();
|
|
|
|
float renderOpacity() const { return m_PaintMutator->renderOpacity(); }
|
|
void renderOpacity(float value) { m_PaintMutator->renderOpacity(value); }
|
|
|
|
void blendMode(BlendMode value);
|
|
|
|
void addStrokeEffect(StrokeEffect* effect) override;
|
|
|
|
/// Creates a RenderPaint object for the provided ShapePaintMutator*.
|
|
/// This should be called only once as the ShapePaint manages the
|
|
/// lifecycle of the RenderPaint.
|
|
virtual RenderPaint* initRenderPaint(ShapePaintMutator* mutator);
|
|
|
|
virtual PathFlags pathFlags() const = 0;
|
|
bool isFlagged(PathFlags flags) const
|
|
{
|
|
return (int)(pathFlags() & flags) != 0x00;
|
|
}
|
|
|
|
virtual void draw(Renderer* renderer,
|
|
ShapePaintPath* shapePaintPath,
|
|
const Mat2D& transform,
|
|
bool usePathFillRule = false,
|
|
RenderPaint* overridePaint = nullptr,
|
|
bool needsSaveOperation = true);
|
|
|
|
RenderPaint* renderPaint() { return m_RenderPaint.get(); }
|
|
|
|
/// Get the component that represents the ShapePaintMutator for this
|
|
/// ShapePaint. It'll be one of SolidColor, LinearGradient, or
|
|
/// RadialGradient.
|
|
Component* paint() const { return m_PaintMutator->component(); }
|
|
|
|
bool isTranslucent() const
|
|
{
|
|
return !this->isVisible() || m_PaintMutator->isTranslucent();
|
|
}
|
|
|
|
bool shouldDraw() const
|
|
{
|
|
return this->isVisible() && m_PaintMutator->isVisible();
|
|
}
|
|
|
|
/// Apply this ShapePaint to an external RenderPaint and optionally modulate
|
|
/// the opacity by opacityModifer.
|
|
virtual void applyTo(RenderPaint* renderPaint, float opacityModifier) = 0;
|
|
|
|
void feather(Feather* feather);
|
|
Feather* feather() const;
|
|
|
|
virtual ShapePaintPath* pickPath(ShapePaintContainer* shape) const = 0;
|
|
void update(ComponentDirt value) override;
|
|
virtual ShapePaintType paintType() const = 0;
|
|
|
|
TransformComponent* parentTransformComponent() const;
|
|
|
|
private:
|
|
Feather* m_feather = nullptr;
|
|
};
|
|
} // namespace rive
|
|
|
|
#endif
|