|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/scriptbinding_renderer.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/scriptbinding_scene.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/scriptbinding_level.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txsheet.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshsimplelevel.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/toonzscene.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "trenderer.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/scenefx.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/sceneproperties.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tcamera.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toutputproperties.h"
|
|
Toshihiro Shimizu |
890ddd |
#include <qeventloop></qeventloop>
|
|
Toshihiro Shimizu |
890ddd |
#include <qwaitcondition></qwaitcondition>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "timagecache.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace TScriptBinding
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=======================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QScriptValue getScene(QScriptContext *context, const QScriptValue &sceneArg, Scene *&scene)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
scene = qscriptvalue_cast<scene *="">(sceneArg);</scene>
|
|
Toshihiro Shimizu |
890ddd |
if (!scene)
|
|
Toshihiro Shimizu |
890ddd |
return context->throwError(QObject::tr("First argument must be a scene : %1").arg(sceneArg.toString()));
|
|
Toshihiro Shimizu |
890ddd |
if (scene->getToonzScene() == 0)
|
|
Toshihiro Shimizu |
890ddd |
return context->throwError(QObject::tr("Can't render empty scene"));
|
|
Toshihiro Shimizu |
890ddd |
return QScriptValue();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void valueToIntList(const QScriptValue &arr, QList<int> &list)</int>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
list.clear();
|
|
Toshihiro Shimizu |
890ddd |
if (arr.isArray()) {
|
|
Toshihiro Shimizu |
890ddd |
int length = arr.property("length").toInteger();
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < length; i++)
|
|
Toshihiro Shimizu |
890ddd |
list.append(arr.property(i).toInteger());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=======================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class Renderer::Imp : public TRenderPort
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
TScriptBinding::Image *m_outputImage;
|
|
Toshihiro Shimizu |
890ddd |
TScriptBinding::Level *m_outputLevel;
|
|
Toshihiro Shimizu |
890ddd |
TPointD m_cameraDpi;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool m_completed;
|
|
Toshihiro Shimizu |
890ddd |
TRenderer m_renderer;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QList<int> m_columnList;</int>
|
|
Toshihiro Shimizu |
890ddd |
QList<int> m_frameList;</int>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Imp() : m_completed(false)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_renderer.setThreadsCount(1);
|
|
Toshihiro Shimizu |
890ddd |
m_renderer.addPort(this);
|
|
Toshihiro Shimizu |
890ddd |
m_outputImage = 0;
|
|
Toshihiro Shimizu |
890ddd |
m_outputLevel = 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
~Imp()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void setRenderArea(ToonzScene *scene)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TDimension cameraRes = scene->getCurrentCamera()->getRes();
|
|
Toshihiro Shimizu |
890ddd |
double rx = cameraRes.lx * 0.5, ry = cameraRes.ly * 0.5;
|
|
Toshihiro Shimizu |
890ddd |
TRectD renderArea(-rx, -ry, rx, ry);
|
|
Toshihiro Shimizu |
890ddd |
TRenderPort::setRenderArea(renderArea);
|
|
Toshihiro Shimizu |
890ddd |
m_cameraDpi = scene->getCurrentCamera()->getDpi();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void enableColumns(ToonzScene *scene, QList<bool> &oldStatus)</bool>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_columnList.empty())
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
QList<bool> newStatus;</bool>
|
|
Toshihiro Shimizu |
890ddd |
TXsheet *xsh = scene->getXsheet();
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < xsh->getColumnCount(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
oldStatus.append(xsh->getColumn(i)->isPreviewVisible());
|
|
Toshihiro Shimizu |
890ddd |
newStatus.append(false);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
foreach (int i, m_columnList) {
|
|
Toshihiro Shimizu |
890ddd |
if (0 <= i && i < xsh->getColumnCount())
|
|
Toshihiro Shimizu |
890ddd |
newStatus[i] = true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < newStatus.length(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
xsh->getColumn(i)->setPreviewVisible(newStatus[i]);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void restoreColumns(ToonzScene *scene, const QList<bool> &oldStatus)</bool>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TXsheet *xsh = scene->getXsheet();
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < oldStatus.length(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
xsh->getColumn(i)->setPreviewVisible(oldStatus[i]);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
std::vector<trenderer::renderdata> *makeRenderData(ToonzScene *scene, const std::vector<int> &rows)</int></trenderer::renderdata>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TRenderSettings settings = scene
|
|
Toshihiro Shimizu |
890ddd |
->getProperties()
|
|
Toshihiro Shimizu |
890ddd |
->getOutputProperties()
|
|
Toshihiro Shimizu |
890ddd |
->getRenderSettings();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QList<bool> oldColumnStates;</bool>
|
|
Toshihiro Shimizu |
890ddd |
enableColumns(scene, oldColumnStates);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
std::vector<trenderer::renderdata> *rds = new std::vector<trenderer::renderdata>;</trenderer::renderdata></trenderer::renderdata>
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < (int)rows.size(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
double frame = rows[i];
|
|
Toshihiro Shimizu |
890ddd |
TFxP sceneFx = buildSceneFx(scene, frame, 1, false);
|
|
Toshihiro Shimizu |
890ddd |
TFxPair fxPair;
|
|
Toshihiro Shimizu |
890ddd |
fxPair.m_frameA = sceneFx;
|
|
Toshihiro Shimizu |
890ddd |
rds->push_back(TRenderer::RenderData(frame, settings, fxPair));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
restoreColumns(scene, oldColumnStates);
|
|
Toshihiro Shimizu |
890ddd |
return rds;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void render(std::vector<trenderer::renderdata> *rds)</trenderer::renderdata>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QMutex mutex;
|
|
Toshihiro Shimizu |
890ddd |
mutex.lock();
|
|
Toshihiro Shimizu |
890ddd |
m_completed = false;
|
|
Toshihiro Shimizu |
890ddd |
m_renderer.startRendering(rds);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
while (!m_completed) {
|
|
Toshihiro Shimizu |
890ddd |
QEventLoop loop;
|
|
Toshihiro Shimizu |
890ddd |
loop.processEvents();
|
|
Toshihiro Shimizu |
890ddd |
QWaitCondition waitCondition;
|
|
Toshihiro Shimizu |
890ddd |
waitCondition.wait(&mutex, 100);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
mutex.unlock();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void renderFrame(ToonzScene *scene, int row, Image *outputImage)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
setRenderArea(scene);
|
|
Toshihiro Shimizu |
890ddd |
std::vector<int> rows;</int>
|
|
Toshihiro Shimizu |
890ddd |
rows.push_back(row);
|
|
Toshihiro Shimizu |
890ddd |
m_outputImage = outputImage;
|
|
Toshihiro Shimizu |
890ddd |
m_outputLevel = 0;
|
|
Toshihiro Shimizu |
890ddd |
render(makeRenderData(scene, rows));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void renderScene(ToonzScene *scene, Level *outputLevel)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
setRenderArea(scene);
|
|
Toshihiro Shimizu |
890ddd |
std::vector<int> rows;</int>
|
|
Toshihiro Shimizu |
890ddd |
if (m_frameList.empty()) {
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < scene->getFrameCount(); i++)
|
|
Toshihiro Shimizu |
890ddd |
rows.push_back(i);
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < m_frameList.length(); i++)
|
|
Toshihiro Shimizu |
890ddd |
rows.push_back(m_frameList[i]);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
m_outputImage = 0;
|
|
Toshihiro Shimizu |
890ddd |
m_outputLevel = outputLevel;
|
|
Toshihiro Shimizu |
890ddd |
render(makeRenderData(scene, rows));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void onRenderRasterStarted(const RenderData &renderData)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int a = 1;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
void onRenderRasterCompleted(const RenderData &renderData)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TRasterP outputRaster = renderData.m_rasA;
|
|
Toshihiro Shimizu |
890ddd |
TRasterImageP img(outputRaster->clone());
|
|
Toshihiro Shimizu |
890ddd |
img->setDpi(m_cameraDpi.x, m_cameraDpi.y);
|
|
Toshihiro Shimizu |
890ddd |
if (m_outputImage)
|
|
Toshihiro Shimizu |
890ddd |
m_outputImage->setImg(img);
|
|
Toshihiro Shimizu |
890ddd |
else if (m_outputLevel) {
|
|
Shinya Kitaoka |
3bfa54 |
std::vector<std::string> ids;</std::string>
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < (int)renderData.m_frames.size(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
TFrameId fid((int)(renderData.m_frames[i]) + 1);
|
|
Toshihiro Shimizu |
890ddd |
m_outputLevel->setFrame(fid, img);
|
|
Shinya Kitaoka |
3bfa54 |
std::string id = m_outputLevel->getSimpleLevel()->getImageId(fid);
|
|
Toshihiro Shimizu |
890ddd |
ids.push_back(id);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
img = TImageP();
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < (int)ids.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
TImageCache::instance()->compress(ids[i]);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
void onRenderFailure(const RenderData &renderData, TException &e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
void onRenderFinished()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_completed = true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}; // class RenderEngine
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=======================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Renderer::Renderer()
|
|
Toshihiro Shimizu |
890ddd |
: m_imp(new Imp())
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Renderer::~Renderer()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QScriptValue Renderer::ctor(QScriptContext *context, QScriptEngine *engine)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QScriptValue r = create(engine, new Renderer());
|
|
Toshihiro Shimizu |
890ddd |
r.setProperty("frames", engine->newArray());
|
|
Toshihiro Shimizu |
890ddd |
r.setProperty("columns", engine->newArray());
|
|
Toshihiro Shimizu |
890ddd |
return r;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QScriptValue Renderer::toString()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return "Renderer";
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QScriptValue Renderer::renderScene(const QScriptValue &sceneArg)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QScriptValue obj = context()->thisObject();
|
|
Toshihiro Shimizu |
890ddd |
valueToIntList(obj.property("frames"), m_imp->m_frameList);
|
|
Toshihiro Shimizu |
890ddd |
valueToIntList(obj.property("columns"), m_imp->m_columnList);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Scene *scene = 0;
|
|
Toshihiro Shimizu |
890ddd |
QScriptValue err = getScene(context(), sceneArg, scene);
|
|
Toshihiro Shimizu |
890ddd |
if (err.isError())
|
|
Toshihiro Shimizu |
890ddd |
return err;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Level *outputLevel = new Level();
|
|
Toshihiro Shimizu |
890ddd |
// engine()->collectGarbage();
|
|
Toshihiro Shimizu |
890ddd |
m_imp->renderScene(scene->getToonzScene(), outputLevel);
|
|
Toshihiro Shimizu |
890ddd |
return create(engine(), outputLevel);
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
for(int row=0;row<scene->getToonzScene()->getFrameCount();row++)</scene->
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
engine()->collectGarbage();
|
|
Toshihiro Shimizu |
890ddd |
TImageP img = renderEngine.renderFrame(row);
|
|
Toshihiro Shimizu |
890ddd |
if(img)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QScriptValue frame = create(new Image(img));
|
|
Toshihiro Shimizu |
890ddd |
QScriptValueList args; args << QString::number(row+1) << frame;
|
|
Toshihiro Shimizu |
890ddd |
newLevel.property("setFrame").call(newLevel, args);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return context()->throwError(tr("Render failed"));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
return newLevel;
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Q_INVOKABLE QScriptValue Renderer::renderFrame(const QScriptValue &sceneArg, int frame)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QScriptValue obj = context()->thisObject();
|
|
Toshihiro Shimizu |
890ddd |
valueToIntList(obj.property("columns"), m_imp->m_columnList);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Scene *scene = 0;
|
|
Toshihiro Shimizu |
890ddd |
QScriptValue err = getScene(context(), sceneArg, scene);
|
|
Toshihiro Shimizu |
890ddd |
if (err.isError())
|
|
Toshihiro Shimizu |
890ddd |
return err;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Image *outputImage = new Image();
|
|
Toshihiro Shimizu |
890ddd |
engine()->collectGarbage();
|
|
Toshihiro Shimizu |
890ddd |
m_imp->renderFrame(scene->getToonzScene(), frame, outputImage);
|
|
Toshihiro Shimizu |
890ddd |
return create(engine(), outputImage);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
Scene *scene = 0;
|
|
Toshihiro Shimizu |
890ddd |
QScriptValue err = getScene(context(), sceneArg, scene);
|
|
Toshihiro Shimizu |
890ddd |
if(err.isError()) return err;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
engine()->collectGarbage();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
RenderEngine renderEngine(scene->getToonzScene());
|
|
Toshihiro Shimizu |
890ddd |
TImageP img = renderEngine.renderFrame(frame);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
for(int i=0;i
|
|
Toshihiro Shimizu |
890ddd |
xsh->getColumn(i)->setPreviewVisible(oldStatus[i]);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if(img)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return create(engine(), new Image(img));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return context()->throwError(tr("Render failed"));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
QScriptValue Renderer::renderColumns(const QScriptValue &sceneArg, const QScriptValue &columnListArg)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
Scene *scene = 0;
|
|
Toshihiro Shimizu |
890ddd |
QScriptValue err = getScene(context(), sceneArg, scene);
|
|
Toshihiro Shimizu |
890ddd |
if(err.isError()) return err;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QList<bool> oldStatus;</bool>
|
|
Toshihiro Shimizu |
890ddd |
QList<bool> newStatus;</bool>
|
|
Toshihiro Shimizu |
890ddd |
TXsheet *xsh = scene->getToonzScene()->getXsheet();
|
|
Toshihiro Shimizu |
890ddd |
for(int i=0;i<xsh->getColumnCount();i++)</xsh->
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
oldStatus.append(xsh->getColumn(i)->isPreviewVisible());
|
|
Toshihiro Shimizu |
890ddd |
newStatus.append(false);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if(!columnListArg.isArray())
|
|
Toshihiro Shimizu |
890ddd |
return context()->throwError(tr("Second argument must be an array of column indices : ").arg(columnListArg.toString()));
|
|
Toshihiro Shimizu |
890ddd |
int m = columnListArg.property("length").toInt32();
|
|
Toshihiro Shimizu |
890ddd |
for(quint32 i=0;i<(int)m;i++)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QScriptValue c = columnListArg.property(i);
|
|
Toshihiro Shimizu |
890ddd |
if(!c.isNumber())
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return context()->throwError(tr("Second argument must be an array of integer numbers : %1 (#%2)")
|
|
Toshihiro Shimizu |
890ddd |
.arg(columnListArg.toString())
|
|
Toshihiro Shimizu |
890ddd |
.arg(i));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
int index = c.toInteger();
|
|
Toshihiro Shimizu |
890ddd |
if(0<=index && index
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
for(int i=0;i
|
|
Toshihiro Shimizu |
890ddd |
xsh->getColumn(i)->setPreviewVisible(newStatus[i]);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
err = QScriptValue();
|
|
Toshihiro Shimizu |
890ddd |
QScriptValue newLevel = create(new Level());
|
|
Toshihiro Shimizu |
890ddd |
RenderEngine renderEngine(scene->getToonzScene());
|
|
Toshihiro Shimizu |
890ddd |
for(int row=0;row<scene->getToonzScene()->getFrameCount();row++)</scene->
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
engine()->collectGarbage();
|
|
Toshihiro Shimizu |
890ddd |
TImageP img = renderEngine.renderFrame(row);
|
|
Toshihiro Shimizu |
890ddd |
if(img)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QScriptValue frame = create(new Image(img));
|
|
Toshihiro Shimizu |
890ddd |
QScriptValueList args; args << QString::number(row+1) << frame;
|
|
Toshihiro Shimizu |
890ddd |
newLevel.property("setFrame").call(newLevel, args);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
err = context()->throwError(tr("Render failed"));
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
for(int i=0;i
|
|
Toshihiro Shimizu |
890ddd |
xsh->getColumn(i)->setPreviewVisible(oldStatus[i]);
|
|
Toshihiro Shimizu |
890ddd |
if(err.isError()) return err;
|
|
Toshihiro Shimizu |
890ddd |
else return newLevel;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void Renderer::dumpCache()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TImageCache::instance()->outputMap(0, "C:\\Users\\gmt\\PLI\\cache.log");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} // namespace TScriptBinding
|