Automated with clang-tidy readability-identifier-naming (config added to .clang-tidy) plus scripted passes, per the updated rules now documented in CONTRIBUTING.md: - types (class/struct/enum/alias/template params): PascalCase - functions, variables, members: snake_case (incl. rational -> Rational) - private/protected members: trailing underscore; static member variables likewise (instance_, available_themes_) - constants and enum values: snake_case (kLinear -> k_linear, F32P -> f32p); ALL_CAPS reserved for macros - macros: OAK_ prefix (OLIVE_ADD_TEST/OLIVE_ASSERT/OLIVE_CONFIG -> OAK_ADD_TEST/OAK_ASSERT/OAK_CONFIG, GL_PREAMBLE -> OAK_GL_PREAMBLE, include guards -> OAK_*) - file names: all lowercase (Current/Plugin/OliveHost/OliveClip/ OlivePluginInstance -> current/plugin/olivehost/oliveclip/ oliveplugininstance) - getters share the member name sans underscore, setters set_foo() - Qt and third-party (OpenFX) virtual overrides and framework callbacks keep their original names (exempt in .clang-tidy) Manual follow-ups required where automation could not reach: - string-based QMetaObject/SIGNAL/SLOT references updated to renamed methods (AddTask, CreatedFile, DeleteSpecificFile, moveSelectionUp, ...) - macro bodies referencing renamed methods (OLIVE_CONFIG, NODE_DEFAULT_DESTRUCTOR, MANAGEDDISPLAYWIDGET_*) - self-shadowing locals renamed where signals/methods became same-named (size_changed, worker_count, selected_items, import param, filters) - third_party OFX member/namespace usages restored (OFX::Host::*, _created, _clipPrefsDirty, createInstance, clearPersistentMessage) - STL protocol aliases restored (const_iterator) with .clang-tidy ignore rules; qHash overloads restored Full build and test suite pass: ctest 4/4, ~1960 gtest cases green.
148 lines
4.9 KiB
C++
148 lines
4.9 KiB
C++
#include <gtest/gtest.h>
|
|
|
|
#include "ofxImageEffect.h"
|
|
#include "ofxhClip.h"
|
|
#include "pluginSupport/oliveclip.h"
|
|
#include "pluginSupport/image.h"
|
|
|
|
namespace
|
|
{
|
|
olive::VideoParams make_params(int width, int height,
|
|
olive::core::PixelFormat format, int channels,
|
|
bool premultiplied)
|
|
{
|
|
olive::VideoParams params;
|
|
params.set_width(width);
|
|
params.set_height(height);
|
|
params.set_format(format);
|
|
params.set_channel_count(channels);
|
|
params.set_premultiplied_alpha(premultiplied);
|
|
return params;
|
|
}
|
|
}
|
|
|
|
TEST(PluginSupportImage, AllocateFromParamsSetsProperties)
|
|
{
|
|
OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName);
|
|
olive::VideoParams params =
|
|
make_params(640, 480, olive::core::PixelFormat::u8, 4, true);
|
|
olive::plugin::OliveClipInstance clip(nullptr, desc, params);
|
|
|
|
olive::plugin::Image image(clip);
|
|
OfxRectI bounds = { 0, 0, 640, 480 };
|
|
OfxRectI rod = bounds;
|
|
image.allocate_from_params(params, bounds, rod, true);
|
|
|
|
EXPECT_NE(image.data(), nullptr);
|
|
EXPECT_EQ(image.width(), 640);
|
|
EXPECT_EQ(image.height(), 480);
|
|
EXPECT_EQ(image.row_bytes(), 640 * 4);
|
|
EXPECT_EQ(image.pixel_format(), olive::core::PixelFormat::u8);
|
|
EXPECT_EQ(image.channel_count(), 4);
|
|
EXPECT_TRUE(image.premultiplied_alpha());
|
|
}
|
|
|
|
TEST(PluginSupportImage, EnsureAllocatedFromParamsClearsAndResizes)
|
|
{
|
|
OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName);
|
|
olive::VideoParams params =
|
|
make_params(64, 32, olive::core::PixelFormat::u8, 3, false);
|
|
olive::plugin::OliveClipInstance clip(nullptr, desc, params);
|
|
|
|
olive::plugin::Image image(clip);
|
|
OfxRectI bounds = { 0, 0, 64, 32 };
|
|
OfxRectI rod = bounds;
|
|
image.allocate_from_params(params, bounds, rod, true);
|
|
ASSERT_NE(image.data(), nullptr);
|
|
image.data()[0] = 0xAB;
|
|
|
|
image.ensure_allocated_from_params(params, bounds, rod, true);
|
|
EXPECT_EQ(image.data()[0], 0);
|
|
|
|
OfxRectI new_bounds = { 0, 0, 16, 16 };
|
|
image.ensure_allocated_from_params(params, new_bounds, rod, false);
|
|
EXPECT_EQ(image.width(), 16);
|
|
EXPECT_EQ(image.height(), 16);
|
|
}
|
|
|
|
TEST(PluginSupportImage, PropertyFallbacks)
|
|
{
|
|
OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName);
|
|
olive::VideoParams params =
|
|
make_params(1, 1, olive::core::PixelFormat::invalid, 0, false);
|
|
olive::plugin::OliveClipInstance clip(nullptr, desc, params);
|
|
|
|
olive::plugin::Image image(clip);
|
|
image.setStringProperty(kOfxImageEffectPropPixelDepth, kOfxBitDepthHalf);
|
|
image.setStringProperty(kOfxImageEffectPropComponents,
|
|
kOfxImageComponentRGB);
|
|
image.setStringProperty(kOfxImageEffectPropPreMultiplication,
|
|
kOfxImagePreMultiplied);
|
|
image.setIntProperty(kOfxImagePropBounds, 10, 0);
|
|
image.setIntProperty(kOfxImagePropBounds, 20, 1);
|
|
image.setIntProperty(kOfxImagePropBounds, 42, 2);
|
|
image.setIntProperty(kOfxImagePropBounds, 70, 3);
|
|
|
|
EXPECT_EQ(image.pixel_format(), olive::core::PixelFormat::f16);
|
|
EXPECT_EQ(image.channel_count(), 3);
|
|
EXPECT_TRUE(image.premultiplied_alpha());
|
|
EXPECT_EQ(image.width(), 32);
|
|
EXPECT_EQ(image.height(), 50);
|
|
}
|
|
|
|
TEST(PluginSupportImage, AllocateSetsOfxProperties)
|
|
{
|
|
OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName);
|
|
olive::VideoParams params =
|
|
make_params(8, 6, olive::core::PixelFormat::f16, 4, false);
|
|
olive::plugin::OliveClipInstance clip(nullptr, desc, params);
|
|
|
|
olive::plugin::Image image(clip);
|
|
OfxRectI bounds = { 2, 3, 10, 9 };
|
|
OfxRectI rod = { 0, 0, 12, 12 };
|
|
image.allocate(8, 6, olive::core::PixelFormat::f16, 4, false, bounds, rod,
|
|
true);
|
|
|
|
EXPECT_NE(image.data(), nullptr);
|
|
EXPECT_EQ(image.row_bytes(), 8 * 4 * 2);
|
|
|
|
int bounds_props[4] = { 0 };
|
|
image.getIntPropertyN(kOfxImagePropBounds, bounds_props, 4);
|
|
EXPECT_EQ(bounds_props[0], bounds.x1);
|
|
EXPECT_EQ(bounds_props[1], bounds.y1);
|
|
EXPECT_EQ(bounds_props[2], bounds.x2);
|
|
EXPECT_EQ(bounds_props[3], bounds.y2);
|
|
|
|
int rod_props[4] = { 0 };
|
|
image.getIntPropertyN(kOfxImagePropRegionOfDefinition, rod_props, 4);
|
|
EXPECT_EQ(rod_props[0], rod.x1);
|
|
EXPECT_EQ(rod_props[1], rod.y1);
|
|
EXPECT_EQ(rod_props[2], rod.x2);
|
|
EXPECT_EQ(rod_props[3], rod.y2);
|
|
|
|
EXPECT_EQ(image.getStringProperty(kOfxImageEffectPropComponents),
|
|
std::string(kOfxImageComponentRGBA));
|
|
EXPECT_EQ(image.getStringProperty(kOfxImageEffectPropPixelDepth),
|
|
std::string(kOfxBitDepthHalf));
|
|
EXPECT_EQ(image.getStringProperty(kOfxImageEffectPropPreMultiplication),
|
|
std::string(kOfxImageUnPreMultiplied));
|
|
}
|
|
|
|
TEST(PluginSupportImage, EnsureAllocatedPreservesWithoutClear)
|
|
{
|
|
OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName);
|
|
olive::VideoParams params =
|
|
make_params(4, 4, olive::core::PixelFormat::u8, 3, false);
|
|
olive::plugin::OliveClipInstance clip(nullptr, desc, params);
|
|
|
|
olive::plugin::Image image(clip);
|
|
OfxRectI bounds = { 0, 0, 4, 4 };
|
|
OfxRectI rod = bounds;
|
|
image.allocate_from_params(params, bounds, rod, true);
|
|
ASSERT_NE(image.data(), nullptr);
|
|
image.data()[0] = 0x5A;
|
|
|
|
image.ensure_allocated_from_params(params, bounds, rod, false);
|
|
EXPECT_EQ(image.data()[0], 0x5A);
|
|
}
|