All the mutators are currently represented in a single Mutator class : https://github.com/flutter/engine/blob/main/flow/embedded_views.h#L38
The Mutator class has a union member that contains local variables for different types of mutators.
This causes some issue:
- Pointers in unions need to manually managed and it is error prone.
- Storing a copy of a scalar object creates overhead.
We can refactor the Mutator class in the following way so that each type of the mutator stores shared_pointers of the wrapped object separately.
- Make the
Mutator class abstract.
Mutator class contains a type method that gets the type of the mutator.
- Make each type of Mutator a subclass of
Mutator, for example, class TransformMutator : public Mutator
Mutator class contains a asXXX method that casting the object to the particular mutator. For example, asClipRect returns a ClipRectMutator object.
- Each subclass of
Mutator contains a shared_ptr member that represents the content of the mutator.
All the mutators are currently represented in a single Mutator class : https://github.com/flutter/engine/blob/main/flow/embedded_views.h#L38
The Mutator class has a union member that contains local variables for different types of mutators.
This causes some issue:
We can refactor the Mutator class in the following way so that each type of the mutator stores shared_pointers of the wrapped object separately.
Mutatorclass abstract.Mutatorclass contains atypemethod that gets the type of the mutator.Mutator, for example,class TransformMutator : public MutatorMutatorclass contains aasXXXmethod that casting the object to the particular mutator. For example,asClipRectreturns aClipRectMutatorobject.Mutatorcontains a shared_ptr member that represents the content of the mutator.