
#include "Precompile.h"

#include "FrameCompositionOutputStage.h"
#include "StreamComposition.h"
#include "ProgramOptions.h"

namespace fb = toa::frame_bender;


fb::FrameCompositionOutputStage::~FrameCompositionOutputStage() {
    
    if (ProgramOptions::global().sample_stages()) {
        auto stats = sampler_.collect_statistics();
        for (const auto& stat : stats) {
            FB_LOG_INFO << stage_.name() << ": " << stat;
        }
    }
}

void fb::FrameCompositionOutputStage::initialize_resources() {

    // Nothing to do

}

fb::StageCommand fb::FrameCompositionOutputStage::perform(TokenFrame& token_in) {

    StageCommand answer = StageCommand::NO_CHANGE;

    if (token_in.composition->output_callback_)
        token_in.composition->output_callback_(token_in.frame);

    return answer;
}