Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TaskList, FrameMask : Reimplement in C++ #5530

Merged
merged 3 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Improvements

- Toolbars : Changed hotkey behavior to toogle any tool on and off. Exclusive tools such as the Translate and Crop Window tools activate the first tool (currently Selection Tool) when they are toggled off.
- CropWindowTool : Added <kbd>`Alt` + <kbd>`C` for toggling both the crop window tool and the relevant crop window `enabled` plug.
- TaskList, FrameMask : Reimplemented in C++ for improved performance.

Breaking Changes
----------------
Expand Down
73 changes: 73 additions & 0 deletions include/GafferDispatch/FrameMask.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2023, John Haddon. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above
// copyright notice, this list of conditions and the following
// disclaimer.
//
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided with
// the distribution.
//
// * Neither the name of John Haddon nor the names of
// any other contributors to this software may be used to endorse or
// promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////

#pragma once

#include "GafferDispatch/TaskNode.h"

#include "Gaffer/StringPlug.h"

namespace GafferDispatch
{

class GAFFERDISPATCH_API FrameMask : public TaskNode
{

public :

GAFFER_NODE_DECLARE_TYPE( GafferDispatch::FrameMask, FrameMaskTypeId, TaskNode );

explicit FrameMask( const std::string &name=defaultName<FrameMask>() );
~FrameMask() override;

Gaffer::StringPlug *maskPlug();
const Gaffer::StringPlug *maskPlug() const;

protected :

void preTasks( const Gaffer::Context *context, Tasks &tasks ) const override;
IECore::MurmurHash hash( const Gaffer::Context *context ) const override;
void execute() const override;

private :

static size_t g_firstPlugIndex;

// Friendship for the bindings
friend struct GafferDispatchBindings::Detail::TaskNodeAccessor;
};

} // namespace GafferDispatch
71 changes: 71 additions & 0 deletions include/GafferDispatch/TaskList.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2023, John Haddon. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above
// copyright notice, this list of conditions and the following
// disclaimer.
//
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided with
// the distribution.
//
// * Neither the name of John Haddon nor the names of
// any other contributors to this software may be used to endorse or
// promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////

#pragma once

#include "GafferDispatch/TaskNode.h"

namespace GafferDispatch
{

class GAFFERDISPATCH_API TaskList : public TaskNode
{

public :

GAFFER_NODE_DECLARE_TYPE( GafferDispatch::TaskList, TaskListTypeId, TaskNode );

explicit TaskList( const std::string &name=defaultName<TaskList>() );
~TaskList() override;

Gaffer::BoolPlug *sequencePlug();
const Gaffer::BoolPlug *sequencePlug() const;

protected :

IECore::MurmurHash hash( const Gaffer::Context *context ) const override;
void execute() const override;
bool requiresSequenceExecution() const override;

private :

static size_t g_firstPlugIndex;

// Friendship for the bindings
friend struct GafferDispatchBindings::Detail::TaskNodeAccessor;
};

} // namespace GafferDispatch
2 changes: 2 additions & 0 deletions include/GafferDispatch/TypeIds.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ enum TypeId
TaskNodeTypeId = 110160,
TaskNodeTaskPlugTypeId = 110161,
DispatcherTypeId = 110162,
TaskListTypeId = 110163,
FrameMaskTypeId = 110164,

LastTypeId = 110180,

Expand Down
77 changes: 0 additions & 77 deletions python/GafferDispatch/FrameMask.py

This file was deleted.

62 changes: 0 additions & 62 deletions python/GafferDispatch/TaskList.py

This file was deleted.

2 changes: 0 additions & 2 deletions python/GafferDispatch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@
from ._GafferDispatch import *
from .LocalDispatcher import LocalDispatcher
from .SystemCommand import SystemCommand
from .TaskList import TaskList
from .TaskContextProcessor import TaskContextProcessor
from .Wedge import Wedge
from .TaskContextVariables import TaskContextVariables
from .TaskSwitch import TaskSwitch
from .PythonCommand import PythonCommand
from .FrameMask import FrameMask

__import__( "IECore" ).loadConfig( "GAFFER_STARTUP_PATHS", subdirectory = "GafferDispatch" )
18 changes: 12 additions & 6 deletions python/GafferDispatchTest/TaskListTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,24 @@ def test( self ) :
n = GafferDispatch.TaskList()
with Gaffer.Context() as c :

h1 = n["task"].hash()
self.assertEqual( n["task"].hash(), IECore.MurmurHash() )
c["frame"] = 10.0
h2 = n["task"].hash()

self.assertEqual( h1, h2 )
self.assertEqual( n["task"].hash(), IECore.MurmurHash() )

n2 = GafferDispatch.TaskList( "TaskList2" )
with Gaffer.Context() as c :

self.assertEqual( n2["task"].hash(), h1 )
self.assertEqual( n2["task"].hash(), IECore.MurmurHash() )
c["frame"] = 10.0
self.assertEqual( n2["task"].hash(), h2 )
self.assertEqual( n2["task"].hash(), IECore.MurmurHash() )

def testSequenceExecution( self ) :

n = GafferDispatch.TaskList()
self.assertFalse( n["task"].requiresSequenceExecution() )

n["sequence"].setValue( True )
self.assertTrue( n["task"].requiresSequenceExecution() )

if __name__ == "__main__":
unittest.main()
Loading
Loading