-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathdrawable.cpp
More file actions
86 lines (78 loc) · 2.42 KB
/
Copy pathdrawable.cpp
File metadata and controls
86 lines (78 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include "rive/drawable.hpp"
#include "rive/artboard.hpp"
#include "rive/layout_component.hpp"
#include "rive/shapes/clipping_shape.hpp"
#include "rive/shapes/path_composer.hpp"
#include "rive/shapes/shape.hpp"
#include "rive/clip_result.hpp"
using namespace rive;
StatusCode Drawable::onAddedDirty(CoreContext* context)
{
auto code = Super::onAddedDirty(context);
if (code != StatusCode::Ok)
{
return code;
}
auto blendMode = static_cast<rive::BlendMode>(blendModeValue());
switch (blendMode)
{
case rive::BlendMode::srcOver:
case rive::BlendMode::screen:
case rive::BlendMode::overlay:
case rive::BlendMode::darken:
case rive::BlendMode::lighten:
case rive::BlendMode::colorDodge:
case rive::BlendMode::colorBurn:
case rive::BlendMode::hardLight:
case rive::BlendMode::softLight:
case rive::BlendMode::difference:
case rive::BlendMode::exclusion:
case rive::BlendMode::multiply:
case rive::BlendMode::hue:
case rive::BlendMode::saturation:
case rive::BlendMode::color:
case rive::BlendMode::luminosity:
return StatusCode::Ok;
}
return StatusCode::InvalidObject;
}
void Drawable::addClippingShape(ClippingShape* shape) { m_ClippingShapes.push_back(shape); }
ClipResult Drawable::applyClip(Renderer* renderer) const
{
if (m_ClippingShapes.size() == 0)
{
return ClipResult::noClip;
}
renderer->save();
for (auto clippingShape : m_ClippingShapes)
{
if (!clippingShape->isVisible())
{
continue;
}
RenderPath* renderPath = clippingShape->renderPath();
// Can intentionally be null if all the clipping shapes are hidden.
if (renderPath != nullptr)
{
renderer->clipPath(renderPath);
}
else
{
// If one renderPath is null we exit early because we are treating it
// as an empty path and its intersection will always be an empty path
return ClipResult::emptyClip;
}
}
return ClipResult::clip;
}
bool Drawable::isChildOfLayout(LayoutComponent* layout)
{
for (ContainerComponent* parent = this; parent != nullptr; parent = parent->parent())
{
if (parent->is<LayoutComponent>() && parent->as<LayoutComponent>() == layout)
{
return true;
}
}
return false;
}