ZenitUI
Retained-mode C++20 UI framework
Loading...
Searching...
No Matches
FilterRegistry.hpp File Reference

Post-processing filter registry and the filter execution context. More...

#include "Common.hpp"
#include "CoreTypes.hpp"
#include "Style.hpp"
#include <functional>

Go to the source code of this file.

Classes

struct  ZenitUI::FilterParam
 One uniform exposed by a filter shader. More...
struct  ZenitUI::FilterContext
 Per-invocation state passed to applyFilter and to custom filters. More...
struct  ZenitUI::FilterDef
 Complete description of one filter. More...
class  ZenitUI::FilterRegistry
 Per-context map from CSS filter name to FilterDef. More...

Typedefs

using ZenitUI::FilterCustomFn = std::function<void(const FilterContext &)>
 Callback signature for FilterPattern::Custom filters.

Enumerations

enum class  ZenitUI::FilterPattern { FilterPattern::SinglePass , FilterPattern::Separable , FilterPattern::Silhouette , FilterPattern::Custom }
 Execution pattern for a filter definition. More...
enum class  ZenitUI::FilterParamType {
  Float , Vec2 , Vec3 , Vec4 ,
  Color
}
 Type of a filter parameter.

Functions

void ZenitUI::applyFilter (const FilterDef &def, const FilterContext &ctx)
 Execute one filter against the given context.

Detailed Description

Post-processing filter registry and the filter execution context.

A "filter" is a named post-processing effect applied to a node's rendered layer (the off-screen target produced by Layout::drawLayer). Filters are declared in CSS via filter: blur(4px), drop-shadow(2px, 2px, #000) and resolved at draw time through the active UIContext::filters registry.

Four execution patterns are supported:

  • SinglePass: one shader, one draw. Used for effects that need only the source target (color matrices, vignettes, custom shaders, …).
  • Separable: two passes (horizontal then vertical). Efficient for Gaussian-style blurs. Uses scratch (or a downscaled pooled target) as the intermediate target.
  • Silhouette: draw the source offset by dx/dy through a colour shader, then the source on top. Used by drop-shadow.
  • Custom: a std::function invoked directly.