QCPatch Events

From QuartzCompositions.com the central source for Quartz Composer :: wiki

When implementing Custom Patches, the developer has the option to override these event methods in a subclass of QCPatch.


Table of contents

Patch Setup (Instance Methods)

- (id)initWithIdentifier:(id)fp8;

  • Called once during the lifetime of the patch instance.
  • Called first during the lifetime of the patch instance.
  • Initialize default values for Input and Output Ports here --- initWithIdentifier is called before user-defined values are populated when loading a composition, so user-defined values will override defaults set here.

- (void)nodeDidAddToGraph:(id)fp8;

  • Called once during the lifetime of the patch instance.
  • Called just after initWithIdentifier().

- (id)setup:(id)p;

  • Called multiple times during the lifetime of the patch instance.
  • Called when the Viewer goes into "Run" state, but doesn't necessarily mean that the patch is going to be executed() --- if the patch isn't connected to a Renderer, setup() and cleanup() will be called, but enable(), execute(), and disable() will not be called.

- (void)cleanup:(id)p;

  • Called multiple times during the lifetime of the patch instance.
  • Called when the Viewer goes into "Stop" state.

- (void)nodeWillRemoveFromGraph;

  • Called once during the lifetime of the patch instance.
  • Called when the patch is deleted from the GFGraph --- unlike dealloc().
  • Called before dealloc().

- (void)dealloc;

  • Called once during the lifetime of the patch instance.
  • Called last during the lifetime of the patch instance, when QC is shutting down. Sometimes called after the patch is deleted from the GFGraph but before QC is shut down.

Patch Execution (Instance Methods)

- (void)enable:(id)fp8;

  • Called multiple times during the lifetime of the patch instance.
  • Called when the Viewer goes into "Run" state, after setup() is called.
  • Called immediately before the a stream of execute()s.
  • If enable() is called, it seems to be guaranteed that at least one execute() will follow.
  • Opposite of disable().

- (BOOL)execute:(QCOpenGLContext*)qcglctx time:(double)exec_time arguments:(id)arg;

  • Execute / Render / Fetch / Process the patch.
  • Called multiple times during the lifetime of the patch instance.
  • How often this is called depends on executionMode(), timeMode(), and how the GFGraph is connected --- in some circumstances, patches are only executed() when inputs change; in other circumstances, patches are executed() every video frame.

- (void)disable:(id)fp8;

  • Called multiple times during the lifetime of the patch instance.
  • Called when the Viewer goes into "Stop" state, before cleanup() is called.
  • Called immediately after the last execute() in a stream of execute()s.
  • Opposite of enable().