本文整理汇总了C++中FilterOperation类的典型用法代码示例。如果您正苦于以下问题:C++ FilterOperation类的具体用法?C++ FilterOperation怎么用?C++ FilterOperation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FilterOperation类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UNUSED_PARAM
bool FilterEffectRenderer::build(Document* document, const FilterOperations& operations)
{
#if !ENABLE(CSS_SHADERS) || !USE(3D_GRAPHICS)
UNUSED_PARAM(document);
#endif
#if ENABLE(CSS_SHADERS)
m_hasCustomShaderFilter = false;
#endif
m_hasFilterThatMovesPixels = operations.hasFilterThatMovesPixels();
if (m_hasFilterThatMovesPixels)
operations.getOutsets(m_topOutset, m_rightOutset, m_bottomOutset, m_leftOutset);
// Keep the old effects on the stack until we've created the new effects.
// New FECustomFilters can reuse cached resources from old FECustomFilters.
FilterEffectList oldEffects;
m_effects.swap(oldEffects);
RefPtr<FilterEffect> previousEffect = m_sourceGraphic;
for (size_t i = 0; i < operations.operations().size(); ++i) {
RefPtr<FilterEffect> effect;
FilterOperation* filterOperation = operations.operations().at(i).get();
switch (filterOperation->getOperationType()) {
case FilterOperation::REFERENCE: {
ReferenceFilterOperation* referenceOperation = static_cast<ReferenceFilterOperation*>(filterOperation);
effect = buildReferenceFilter(document, previousEffect, referenceOperation);
referenceOperation->setFilterEffect(effect);
break;
}
case FilterOperation::GRAYSCALE: {
BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast<BasicColorMatrixFilterOperation*>(filterOperation);
Vector<float> inputParameters;
double oneMinusAmount = clampTo(1 - colorMatrixOperation->amount(), 0.0, 1.0);
// See https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#grayscaleEquivalent
// for information on parameters.
inputParameters.append(narrowPrecisionToFloat(0.2126 + 0.7874 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.7152 - 0.7152 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.0722 - 0.0722 * oneMinusAmount));
endMatrixRow(inputParameters);
inputParameters.append(narrowPrecisionToFloat(0.2126 - 0.2126 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.7152 + 0.2848 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.0722 - 0.0722 * oneMinusAmount));
endMatrixRow(inputParameters);
inputParameters.append(narrowPrecisionToFloat(0.2126 - 0.2126 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.7152 - 0.7152 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.0722 + 0.9278 * oneMinusAmount));
endMatrixRow(inputParameters);
lastMatrixRow(inputParameters);
effect = FEColorMatrix::create(this, FECOLORMATRIX_TYPE_MATRIX, inputParameters);
break;
}
case FilterOperation::SEPIA: {
BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast<BasicColorMatrixFilterOperation*>(filterOperation);
Vector<float> inputParameters;
double oneMinusAmount = clampTo(1 - colorMatrixOperation->amount(), 0.0, 1.0);
// See https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#sepiaEquivalent
// for information on parameters.
inputParameters.append(narrowPrecisionToFloat(0.393 + 0.607 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.769 - 0.769 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.189 - 0.189 * oneMinusAmount));
endMatrixRow(inputParameters);
inputParameters.append(narrowPrecisionToFloat(0.349 - 0.349 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.686 + 0.314 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.168 - 0.168 * oneMinusAmount));
endMatrixRow(inputParameters);
inputParameters.append(narrowPrecisionToFloat(0.272 - 0.272 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.534 - 0.534 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.131 + 0.869 * oneMinusAmount));
endMatrixRow(inputParameters);
lastMatrixRow(inputParameters);
effect = FEColorMatrix::create(this, FECOLORMATRIX_TYPE_MATRIX, inputParameters);
break;
}
case FilterOperation::SATURATE: {
BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast<BasicColorMatrixFilterOperation*>(filterOperation);
Vector<float> inputParameters;
inputParameters.append(narrowPrecisionToFloat(colorMatrixOperation->amount()));
effect = FEColorMatrix::create(this, FECOLORMATRIX_TYPE_SATURATE, inputParameters);
break;
}
case FilterOperation::HUE_ROTATE: {
BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast<BasicColorMatrixFilterOperation*>(filterOperation);
Vector<float> inputParameters;
inputParameters.append(narrowPrecisionToFloat(colorMatrixOperation->amount()));
effect = FEColorMatrix::create(this, FECOLORMATRIX_TYPE_HUEROTATE, inputParameters);
break;
}
case FilterOperation::INVERT: {
//.........这里部分代码省略.........
示例2: blendFunc
static RefPtr<FilterOperation> blendFunc(FilterOperation* fromOp, FilterOperation& toOp, double progress, const FloatSize& size, bool blendToPassthrough = false)
{
if (toOp.blendingNeedsRendererSize())
return toOp.blend(fromOp, progress, LayoutSize(size), blendToPassthrough);
return toOp.blend(fromOp, progress, blendToPassthrough);
}
示例3: deviceScaleFactor
bool FilterEffectRenderer::build(RenderObject* renderer, const FilterOperations& operations)
{
m_hasCustomShaderFilter = false;
m_hasFilterThatMovesPixels = operations.hasFilterThatMovesPixels();
// Inverse zoom the pre-zoomed CSS shorthand filters, so that they are in the same zoom as the unzoomed reference filters.
const RenderStyle* style = renderer->style();
// FIXME: The effects now contain high dpi information, but the software path doesn't (yet) scale its backing.
// When the proper dpi dependant backing size is allocated, we should remove deviceScaleFactor(...) here.
float invZoom = 1.0f / ((style ? style->effectiveZoom() : 1.0f) * deviceScaleFactor(renderer->frame()));
RefPtr<FilterEffect> previousEffect = m_sourceGraphic;
for (size_t i = 0; i < operations.operations().size(); ++i) {
RefPtr<FilterEffect> effect;
FilterOperation* filterOperation = operations.operations().at(i).get();
switch (filterOperation->getOperationType()) {
case FilterOperation::REFERENCE: {
ReferenceFilterOperation* referenceOperation = static_cast<ReferenceFilterOperation*>(filterOperation);
effect = ReferenceFilterBuilder::build(this, renderer, previousEffect.get(), referenceOperation);
break;
}
case FilterOperation::GRAYSCALE: {
BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast<BasicColorMatrixFilterOperation*>(filterOperation);
Vector<float> inputParameters;
double oneMinusAmount = clampTo(1 - colorMatrixOperation->amount(), 0.0, 1.0);
// See https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#grayscaleEquivalent
// for information on parameters.
inputParameters.append(narrowPrecisionToFloat(0.2126 + 0.7874 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.7152 - 0.7152 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.0722 - 0.0722 * oneMinusAmount));
endMatrixRow(inputParameters);
inputParameters.append(narrowPrecisionToFloat(0.2126 - 0.2126 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.7152 + 0.2848 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.0722 - 0.0722 * oneMinusAmount));
endMatrixRow(inputParameters);
inputParameters.append(narrowPrecisionToFloat(0.2126 - 0.2126 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.7152 - 0.7152 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.0722 + 0.9278 * oneMinusAmount));
endMatrixRow(inputParameters);
lastMatrixRow(inputParameters);
effect = FEColorMatrix::create(this, FECOLORMATRIX_TYPE_MATRIX, inputParameters);
break;
}
case FilterOperation::SEPIA: {
BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast<BasicColorMatrixFilterOperation*>(filterOperation);
Vector<float> inputParameters;
double oneMinusAmount = clampTo(1 - colorMatrixOperation->amount(), 0.0, 1.0);
// See https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#sepiaEquivalent
// for information on parameters.
inputParameters.append(narrowPrecisionToFloat(0.393 + 0.607 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.769 - 0.769 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.189 - 0.189 * oneMinusAmount));
endMatrixRow(inputParameters);
inputParameters.append(narrowPrecisionToFloat(0.349 - 0.349 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.686 + 0.314 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.168 - 0.168 * oneMinusAmount));
endMatrixRow(inputParameters);
inputParameters.append(narrowPrecisionToFloat(0.272 - 0.272 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.534 - 0.534 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.131 + 0.869 * oneMinusAmount));
endMatrixRow(inputParameters);
lastMatrixRow(inputParameters);
effect = FEColorMatrix::create(this, FECOLORMATRIX_TYPE_MATRIX, inputParameters);
break;
}
case FilterOperation::SATURATE: {
BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast<BasicColorMatrixFilterOperation*>(filterOperation);
Vector<float> inputParameters;
inputParameters.append(narrowPrecisionToFloat(colorMatrixOperation->amount()));
effect = FEColorMatrix::create(this, FECOLORMATRIX_TYPE_SATURATE, inputParameters);
break;
}
case FilterOperation::HUE_ROTATE: {
BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast<BasicColorMatrixFilterOperation*>(filterOperation);
Vector<float> inputParameters;
inputParameters.append(narrowPrecisionToFloat(colorMatrixOperation->amount()));
effect = FEColorMatrix::create(this, FECOLORMATRIX_TYPE_HUEROTATE, inputParameters);
break;
}
case FilterOperation::INVERT: {
BasicComponentTransferFilterOperation* componentTransferOperation = static_cast<BasicComponentTransferFilterOperation*>(filterOperation);
ComponentTransferFunction transferFunction;
transferFunction.type = FECOMPONENTTRANSFER_TYPE_TABLE;
Vector<float> transferParameters;
transferParameters.append(narrowPrecisionToFloat(componentTransferOperation->amount()));
transferParameters.append(narrowPrecisionToFloat(1 - componentTransferOperation->amount()));
transferFunction.tableValues = transferParameters;
//.........这里部分代码省略.........
示例4: switch
bool FilterEffectBuilder::build(Element* element, const FilterOperations& operations, float zoom)
{
// Create a parent filter for shorthand filters. These have already been scaled by the CSS code for page zoom, so scale is 1.0 here.
RefPtrWillBeRawPtr<ReferenceFilter> parentFilter = ReferenceFilter::create(1.0f);
RefPtrWillBeRawPtr<FilterEffect> previousEffect = SourceGraphic::create(parentFilter.get());
for (size_t i = 0; i < operations.operations().size(); ++i) {
RefPtrWillBeRawPtr<FilterEffect> effect = nullptr;
FilterOperation* filterOperation = operations.operations().at(i).get();
switch (filterOperation->type()) {
case FilterOperation::REFERENCE: {
RefPtrWillBeRawPtr<ReferenceFilter> referenceFilter = ReferenceFilterBuilder::build(zoom, element, previousEffect.get(), toReferenceFilterOperation(*filterOperation));
if (referenceFilter) {
effect = referenceFilter->lastEffect();
m_referenceFilters.append(referenceFilter);
}
break;
}
case FilterOperation::GRAYSCALE: {
Vector<float> inputParameters;
double oneMinusAmount = clampTo(1 - toBasicColorMatrixFilterOperation(filterOperation)->amount(), 0.0, 1.0);
// See https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#grayscaleEquivalent
// for information on parameters.
inputParameters.append(narrowPrecisionToFloat(0.2126 + 0.7874 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.7152 - 0.7152 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.0722 - 0.0722 * oneMinusAmount));
endMatrixRow(inputParameters);
inputParameters.append(narrowPrecisionToFloat(0.2126 - 0.2126 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.7152 + 0.2848 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.0722 - 0.0722 * oneMinusAmount));
endMatrixRow(inputParameters);
inputParameters.append(narrowPrecisionToFloat(0.2126 - 0.2126 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.7152 - 0.7152 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.0722 + 0.9278 * oneMinusAmount));
endMatrixRow(inputParameters);
lastMatrixRow(inputParameters);
effect = FEColorMatrix::create(parentFilter.get(), FECOLORMATRIX_TYPE_MATRIX, inputParameters);
break;
}
case FilterOperation::SEPIA: {
Vector<float> inputParameters;
double oneMinusAmount = clampTo(1 - toBasicColorMatrixFilterOperation(filterOperation)->amount(), 0.0, 1.0);
// See https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#sepiaEquivalent
// for information on parameters.
inputParameters.append(narrowPrecisionToFloat(0.393 + 0.607 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.769 - 0.769 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.189 - 0.189 * oneMinusAmount));
endMatrixRow(inputParameters);
inputParameters.append(narrowPrecisionToFloat(0.349 - 0.349 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.686 + 0.314 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.168 - 0.168 * oneMinusAmount));
endMatrixRow(inputParameters);
inputParameters.append(narrowPrecisionToFloat(0.272 - 0.272 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.534 - 0.534 * oneMinusAmount));
inputParameters.append(narrowPrecisionToFloat(0.131 + 0.869 * oneMinusAmount));
endMatrixRow(inputParameters);
lastMatrixRow(inputParameters);
effect = FEColorMatrix::create(parentFilter.get(), FECOLORMATRIX_TYPE_MATRIX, inputParameters);
break;
}
case FilterOperation::SATURATE: {
Vector<float> inputParameters;
inputParameters.append(narrowPrecisionToFloat(toBasicColorMatrixFilterOperation(filterOperation)->amount()));
effect = FEColorMatrix::create(parentFilter.get(), FECOLORMATRIX_TYPE_SATURATE, inputParameters);
break;
}
case FilterOperation::HUE_ROTATE: {
Vector<float> inputParameters;
inputParameters.append(narrowPrecisionToFloat(toBasicColorMatrixFilterOperation(filterOperation)->amount()));
effect = FEColorMatrix::create(parentFilter.get(), FECOLORMATRIX_TYPE_HUEROTATE, inputParameters);
break;
}
case FilterOperation::INVERT: {
BasicComponentTransferFilterOperation* componentTransferOperation = toBasicComponentTransferFilterOperation(filterOperation);
ComponentTransferFunction transferFunction;
transferFunction.type = FECOMPONENTTRANSFER_TYPE_TABLE;
Vector<float> transferParameters;
transferParameters.append(narrowPrecisionToFloat(componentTransferOperation->amount()));
transferParameters.append(narrowPrecisionToFloat(1 - componentTransferOperation->amount()));
transferFunction.tableValues = transferParameters;
ComponentTransferFunction nullFunction;
effect = FEComponentTransfer::create(parentFilter.get(), transferFunction, transferFunction, transferFunction, nullFunction);
break;
}
case FilterOperation::OPACITY: {
ComponentTransferFunction transferFunction;
transferFunction.type = FECOMPONENTTRANSFER_TYPE_TABLE;
Vector<float> transferParameters;
//.........这里部分代码省略.........