This source file includes following definitions.
- colorSpaceTest
- TEST_F
#include "config.h"
#include "SkImageFilter.h"
#include "platform/graphics/filters/FEBlend.h"
#include "platform/graphics/filters/FEGaussianBlur.h"
#include "platform/graphics/filters/FEMerge.h"
#include "platform/graphics/filters/FilterOperations.h"
#include "platform/graphics/filters/ReferenceFilter.h"
#include "platform/graphics/filters/SkiaImageFilterBuilder.h"
#include "platform/graphics/filters/SourceGraphic.h"
#include <gtest/gtest.h>
using testing::Test;
using namespace WebCore;
class ImageFilterBuilderTest : public Test {
protected:
void colorSpaceTest()
{
RefPtr<ReferenceFilter> referenceFilter = ReferenceFilter::create();
RefPtr<FilterEffect> sourceEffect = referenceFilter->sourceGraphic();
sourceEffect->setOperatingColorSpace(ColorSpaceDeviceRGB);
RefPtr<FilterEffect> blurEffect =
FEGaussianBlur::create(referenceFilter.get(), 3.0f, 3.0f);
blurEffect->setOperatingColorSpace(ColorSpaceLinearRGB);
blurEffect->inputEffects().append(sourceEffect);
RefPtr<FilterEffect> blendEffect =
FEBlend::create(referenceFilter.get(), FEBLEND_MODE_NORMAL);
blendEffect->setOperatingColorSpace(ColorSpaceDeviceRGB);
FilterEffectVector& blendInputs = blendEffect->inputEffects();
blendInputs.reserveCapacity(2);
blendInputs.append(sourceEffect);
blendInputs.append(blurEffect);
RefPtr<FilterEffect> mergeEffect = FEMerge::create(referenceFilter.get());
mergeEffect->setOperatingColorSpace(ColorSpaceLinearRGB);
FilterEffectVector& mergeInputs = mergeEffect->inputEffects();
mergeInputs.reserveCapacity(2);
mergeInputs.append(blurEffect);
mergeInputs.append(blendEffect);
referenceFilter->setLastEffect(mergeEffect);
SkiaImageFilterBuilder builder;
RefPtr<SkImageFilter> filter = builder.build(referenceFilter->lastEffect(), ColorSpaceDeviceRGB);
EXPECT_EQ(filter->countInputs(), 1);
SkImageFilter* child = filter->getInput(0);
EXPECT_EQ(child->asColorFilter(0), false);
EXPECT_EQ(child->countInputs(), 2);
child = child->getInput(1);
EXPECT_EQ(child->asColorFilter(0), true);
EXPECT_EQ(child->countInputs(), 1);
child = child->getInput(0);
EXPECT_EQ(child->asColorFilter(0), false);
EXPECT_EQ(child->countInputs(), 2);
child = child->getInput(0);
EXPECT_EQ(child->asColorFilter(0), true);
EXPECT_EQ(child->countInputs(), 1);
child = child->getInput(0);
EXPECT_EQ(child->asColorFilter(0), false);
EXPECT_EQ(child->countInputs(), 1);
child = child->getInput(0);
EXPECT_EQ(child->asColorFilter(0), true);
EXPECT_EQ(child->countInputs(), 1);
}
};
namespace {
TEST_F(ImageFilterBuilderTest, testColorSpace)
{
colorSpaceTest();
}
}