// The offset of the current project in canonical coordinates.
// The offset is related to the kOfxImageEffectPropProjectSize and is the offset from the origin
// of the project 'subwindow'. For example for a PAL SD project that is in letterbox form, the
// project offset is the offset to the bottom left hand corner of the letter box. The project
// offset is in canonical coordinates.
void
OfxImageEffectInstance::getProjectOffset(double & xOffset,
                                         double & yOffset) const
{
    Format f;
    _ofxEffectInstance->getRenderFormat(&f);
    RectI pixelF;
    pixelF.x1 = f.x1;
    pixelF.x2 = f.x2;
    pixelF.y1 = f.y1;
    pixelF.y2 = f.y2;
    RectD canonicalF;
    pixelF.toCanonical_noClipping(0, f.getPixelAspectRatio(), &canonicalF);
    xOffset = canonicalF.left();
    yOffset = canonicalF.bottom();
}
// The extent of the current project in canonical coordinates.
// The extent is the size of the 'output' for the current project. See ProjectCoordinateSystems
// for more infomation on the project extent. The extent is in canonical coordinates and only
// returns the top right position, as the extent is always rooted at 0,0. For example a PAL SD
// project would have an extent of 768, 576.
void
OfxImageEffectInstance::getProjectExtent(double & xSize,
                                         double & ySize) const
{
    Format f;
    _ofxEffectInstance->getRenderFormat(&f);
    RectI pixelF;
    pixelF.x1 = f.x1;
    pixelF.x2 = f.x2;
    pixelF.y1 = f.y1;
    pixelF.y2 = f.y2;
    RectD canonicalF;
    pixelF.toCanonical_noClipping(0, f.getPixelAspectRatio(), &canonicalF);
    xSize = canonicalF.right();
    ySize = canonicalF.top();
}
示例#3
0
ActionRetCodeEnum
RotoShapeRenderNode::getRegionOfDefinition(TimeValue time, const RenderScale& scale, ViewIdx view, RectD* rod)
{

    RotoDrawableItemPtr item = getAttachedRotoItem();
    assert(item);
    assert((isRenderClone() && item->isRenderClone()) ||
           (!isRenderClone() && !item->isRenderClone()));
    const bool isPainting = isDuringPaintStrokeCreation();
    RectD shapeRoD;
    getRoDFromItem(item, time, view, isPainting, &shapeRoD);

    bool clipToFormat = _imp->clipToFormatKnob.lock()->getValue();

    RotoShapeRenderTypeEnum type = (RotoShapeRenderTypeEnum)_imp->renderType.lock()->getValue();
    switch (type) {
        case eRotoShapeRenderTypeSmear: {
            RectD defaultRod;
            ActionRetCodeEnum stat = EffectInstance::getRegionOfDefinition(time, scale, view, &defaultRod);
            if (isFailureRetCode(stat)) {
                return stat;
            }
            if (!defaultRod.isNull()) {
                *rod = shapeRoD;
                rod->merge(defaultRod);
            }
        }   break;
        case eRotoShapeRenderTypeSolid: {
            RotoPaintOutputRoDTypeEnum rodType = (RotoPaintOutputRoDTypeEnum)_imp->outputRoDTypeKnob.lock()->getValue();
            switch (rodType) {
                case eRotoPaintOutputRoDTypeDefault: {
                    *rod = shapeRoD;
                    // No format is set, use the format from the input
                    if (clipToFormat) {
                        EffectInstancePtr inputEffect = getInputRenderEffectAtAnyTimeView(0);
                        if (inputEffect) {
                            RectI outputFormat = inputEffect->getOutputFormat();
                            RectD outputFormatCanonical;
                            outputFormat.toCanonical_noClipping(scale, inputEffect->getAspectRatio(-1), &outputFormatCanonical);
                            rod->intersect(outputFormatCanonical, rod);
                        }
                    }
                }   break;
                case eRotoPaintOutputRoDTypeFormat: {
                    KnobIntPtr sizeKnob = _imp->outputFormatSizeKnob.lock();
                    int w = sizeKnob->getValue(DimIdx(0));
                    int h = _imp->outputFormatSizeKnob.lock()->getValue(DimIdx(1));
                    double par = _imp->outputFormatParKnob.lock()->getValue();

                    RectI pixelFormat;
                    pixelFormat.x1 = pixelFormat.y1 = 0;
                    pixelFormat.x2 = w;
                    pixelFormat.y2 = h;
                    RenderScale renderScale(1.);
                    pixelFormat.toCanonical_noClipping(renderScale, par, rod);
                    if (!clipToFormat) {
                        rod->merge(shapeRoD);
                    }
                }   break;

                case eRotoPaintOutputRoDTypeProject: {
                    Format f;
                    getApp()->getProject()->getProjectDefaultFormat(&f);
                    f.toCanonical_noClipping(RenderScale(1.), f.getPixelAspectRatio(), rod);
                    if (!clipToFormat) {
                        rod->merge(shapeRoD);
                    }
                }   break;
            }
        }   break;
    }

    return eActionStatusOK;

}