Skip to content

Refactor mutator class  #108470

Description

@cyanglaz

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:

  1. Pointers in unions need to manually managed and it is error prone.
  2. 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.

  1. Make the Mutator class abstract.
  2. Mutator class contains a type method that gets the type of the mutator.
  3. Make each type of Mutator a subclass of Mutator, for example, class TransformMutator : public Mutator
  4. Mutator class contains a asXXX method that casting the object to the particular mutator. For example, asClipRect returns a ClipRectMutator object.
  5. Each subclass of Mutator contains a shared_ptr member that represents the content of the mutator.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectengineflutter/engine related. See also e: labels.team-engineOwned by Engine teamtriaged-engineTriaged by Engine team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions