-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRendererComponent.h
More file actions
126 lines (110 loc) · 4.43 KB
/
Copy pathRendererComponent.h
File metadata and controls
126 lines (110 loc) · 4.43 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#pragma once
#include <cstdint>
#include "DekiBehaviour.h"
#include "ISortableProvider.h"
#include "reflection/DekiProperty.h"
#include "QuadBlit.h"
// Forward declarations
class DekiObject;
class CameraComponent;
#ifdef V_ENGINE_ENABLE_MASK
/**
* @brief Mask render modes for stencil buffer usage
*/
enum class MaskRenderMode : uint8_t
{
None = 0, // No masking
RenderOutside = 1, // Render only outside the mask
RenderInside = 2 // Render only inside the mask
};
#endif
/**
* @brief How partial-alpha pixels are rendered.
*
* Blend = standard alpha blend (default; smooth, slower).
* OrderedDither = ordered-dither / screen-door (faster, visible stippling).
*
* NOTE: OrderedDither requires the dither blit paths shipped by the perf
* follow-up (item 2.1). Until those land, OrderedDither falls through to
* Blend with a one-time warning so existing scenes aren't broken.
*/
enum class AlphaMode : uint8_t
{
Blend = 0,
OrderedDither = 1,
};
/**
* @brief Abstract base class for all renderable components (e.g., sprites, particles)
*
* Extends DekiBehaviour to provide lifecycle methods (Start, Update, PreRender)
* in addition to the Render method for drawing.
*/
class RendererComponent : public DekiBehaviour, public ISortableProvider
{
public:
DEKI_COMPONENT(RendererComponent, DekiBehaviour, "Core", "9604fa26-8be9-428a-9c29-e67c2d52c913", "")
// Pure virtual destructor makes this class abstract
virtual ~RendererComponent() = 0;
DEKI_EXPORT
int sortingOrder = 0;
/** @brief If true, this renderer ignores parent ClipComponent bounds */
DEKI_EXPORT
bool ignore_clip = false;
/**
* @brief If true, snap final screen position to integer pixels at draw
* time (round-to-nearest). Default true preserves classic
* pixel-art alignment. Set false on renderers that should flow
* sub-pixel smoothly (particles, camera-shake-driven effects).
* Snap is per-renderer so a pixel-art sprite and a smooth
* particle effect can coexist in the same scene.
*/
DEKI_EXPORT
bool pixel_snap = true;
DEKI_TOOLTIP("How partial-alpha pixels are rendered. Blend = smooth alpha blend (slower, no artifacts). OrderedDither = stippling pattern (much faster, visible dither — best for fades and retro pixel art). NOTE: OrderedDither falls back to Blend until the dither blit paths land.")
DEKI_EXPORT
AlphaMode alpha_mode = AlphaMode::Blend;
#ifdef V_ENGINE_ENABLE_MASK
// Mask support - minimal memory overhead (2 bytes total)
MaskRenderMode mask_mode = MaskRenderMode::None;
uint8_t stencil_id = 0; // 0 = no stencil test, 1-255 = stencil values
#endif
void SetSortingOrder(int order);
int32_t GetSortingOrder() const override;
#ifdef V_ENGINE_ENABLE_MASK
// Mask configuration methods
void SetMaskMode(MaskRenderMode mode, uint8_t stencilId = 1);
void ClearMask();
#endif
/**
* @brief Render content to intermediate buffer at 1x scale (no transforms)
*
* Components that override this method produce raw pixel data.
* The render loop will use QuadBlit to apply transforms (position, scale, rotation).
*
* @param owner The owning DekiObject
* @param outSource Output QuadBlit::Source descriptor (buffer, dimensions, format)
* @param outPivotX Output pivot X (0.0-1.0, where 0.5 is center)
* @param outPivotY Output pivot Y (0.0-1.0, where 0.5 is center)
* @param outTintR Output tint red (255 = no tint)
* @param outTintG Output tint green (255 = no tint)
* @param outTintB Output tint blue (255 = no tint)
* @param outTintA Output tint alpha (255 = opaque)
* @return true if content was rendered, false if nothing to render
*
* NOTE: The caller is responsible for freeing outSource.pixels if this returns true
*/
virtual bool RenderContent(const DekiObject* owner,
QuadBlit::Source& outSource,
float& outPivotX,
float& outPivotY,
uint8_t& outTintR,
uint8_t& outTintG,
uint8_t& outTintB,
uint8_t& outTintA)
{
outTintR = outTintG = outTintB = outTintA = 255;
return false;
}
};
// Generated property metadata (after class definition for offsetof)
#include "generated/RendererComponent.gen.h"