1616#define INK_STROKES_BRUSH_BRUSH_BEHAVIOR_H_
1717
1818#include < array>
19+ #include < cstdint>
1920#include < string>
2021#include < variant>
2122#include < vector>
@@ -378,6 +379,12 @@ struct BrushBehavior {
378379
379380 friend bool operator ==(const EnabledToolTypes&,
380381 const EnabledToolTypes&) = default ;
382+
383+ template <typename H>
384+ friend H AbslHashValue (H h, const EnabledToolTypes& ett) {
385+ return H::combine (std::move (h), ett.unknown , ett.mouse , ett.touch ,
386+ ett.stylus );
387+ }
381388 };
382389
383390 static constexpr EnabledToolTypes kAllToolTypes = {
@@ -461,6 +468,12 @@ struct BrushBehavior {
461468 std::array<float , 2 > source_value_range;
462469
463470 friend bool operator ==(const SourceNode&, const SourceNode&) = default ;
471+
472+ template <typename H>
473+ friend H AbslHashValue (H h, const SourceNode& sn) {
474+ return H::combine (std::move (h), sn.source ,
475+ sn.source_out_of_range_behavior , sn.source_value_range );
476+ }
464477 };
465478
466479 // Value node for producing a constant value.
@@ -471,6 +484,11 @@ struct BrushBehavior {
471484 float value;
472485
473486 friend bool operator ==(const ConstantNode&, const ConstantNode&) = default ;
487+
488+ template <typename H>
489+ friend H AbslHashValue (H h, const ConstantNode& cn) {
490+ return H::combine (std::move (h), cn.value );
491+ }
474492 };
475493
476494 // Value node for producing a continuous random noise function with values
@@ -492,6 +510,11 @@ struct BrushBehavior {
492510 float base_period;
493511
494512 friend bool operator ==(const NoiseNode&, const NoiseNode&) = default ;
513+
514+ template <typename H>
515+ friend H AbslHashValue (H h, const NoiseNode& nn) {
516+ return H::combine (std::move (h), nn.seed , nn.vary_over , nn.base_period );
517+ }
495518 };
496519
497520 // ////////////////////////
@@ -509,6 +532,11 @@ struct BrushBehavior {
509532
510533 friend bool operator ==(const ToolTypeFilterNode&,
511534 const ToolTypeFilterNode&) = default ;
535+
536+ template <typename H>
537+ friend H AbslHashValue (H h, const ToolTypeFilterNode& ttfn) {
538+ return H::combine (std::move (h), ttfn.enabled_tool_types );
539+ }
512540 };
513541
514542 // //////////////////////////
@@ -534,6 +562,11 @@ struct BrushBehavior {
534562 float damping_gap;
535563
536564 friend bool operator ==(const DampingNode&, const DampingNode&) = default ;
565+
566+ template <typename H>
567+ friend H AbslHashValue (H h, const DampingNode& dn) {
568+ return H::combine (std::move (h), dn.damping_source , dn.damping_gap );
569+ }
537570 };
538571
539572 // Value node for mapping a value through a response curve.
@@ -546,6 +579,11 @@ struct BrushBehavior {
546579 EasingFunction response_curve;
547580
548581 friend bool operator ==(const ResponseNode&, const ResponseNode&) = default ;
582+
583+ template <typename H>
584+ friend H AbslHashValue (H h, const ResponseNode& rn) {
585+ return H::combine (std::move (h), rn.response_curve );
586+ }
549587 };
550588
551589 // Value node for integrating an input value over time or distance.
@@ -571,6 +609,13 @@ struct BrushBehavior {
571609 std::array<float , 2 > integral_value_range;
572610
573611 friend bool operator ==(const IntegralNode&, const IntegralNode&) = default ;
612+
613+ template <typename H>
614+ friend H AbslHashValue (H h, const IntegralNode& in) {
615+ return H::combine (std::move (h), in.integrate_over ,
616+ in.integral_out_of_range_behavior ,
617+ in.integral_value_range );
618+ }
574619 };
575620
576621 // Value node for combining two other values with a binary operation.
@@ -583,6 +628,11 @@ struct BrushBehavior {
583628 BinaryOp operation;
584629
585630 friend bool operator ==(const BinaryOpNode&, const BinaryOpNode&) = default ;
631+
632+ template <typename H>
633+ friend H AbslHashValue (H h, const BinaryOpNode& bon) {
634+ return H::combine (std::move (h), bon.operation );
635+ }
586636 };
587637
588638 // Value node for interpolating to/from a range of two values.
@@ -596,6 +646,11 @@ struct BrushBehavior {
596646
597647 friend bool operator ==(const InterpolationNode&,
598648 const InterpolationNode&) = default ;
649+
650+ template <typename H>
651+ friend H AbslHashValue (H h, const InterpolationNode& in) {
652+ return H::combine (std::move (h), in.interpolation );
653+ }
599654 };
600655
601656 // ////////////////////
@@ -617,6 +672,11 @@ struct BrushBehavior {
617672 std::array<float , 2 > target_modifier_range;
618673
619674 friend bool operator ==(const TargetNode&, const TargetNode&) = default ;
675+
676+ template <typename H>
677+ friend H AbslHashValue (H h, const TargetNode& tn) {
678+ return H::combine (std::move (h), tn.target , tn.target_modifier_range );
679+ }
620680 };
621681
622682 // Terminal node that consumes two input values (angle and magnitude), forming
@@ -638,6 +698,12 @@ struct BrushBehavior {
638698
639699 friend bool operator ==(const PolarTargetNode&,
640700 const PolarTargetNode&) = default ;
701+
702+ template <typename H>
703+ friend H AbslHashValue (H h, const PolarTargetNode& ptn) {
704+ return H::combine (std::move (h), ptn.target , ptn.angle_range ,
705+ ptn.magnitude_range );
706+ }
641707 };
642708
643709 // A single node in a behavior's graph. Each node type is either a "value
@@ -659,6 +725,11 @@ struct BrushBehavior {
659725 std::string developer_comment;
660726
661727 friend bool operator ==(const BrushBehavior&, const BrushBehavior&) = default ;
728+
729+ template <typename H>
730+ friend H AbslHashValue (H h, const BrushBehavior& behavior) {
731+ return H::combine (std::move (h), behavior.nodes , behavior.developer_comment );
732+ }
662733};
663734
664735namespace brush_internal {
0 commit comments