Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef T32BITSRV_WRAP
Toshihiro Shimizu 890ddd
#define T32BITSRV_WRAP
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzBase includes
Toshihiro Shimizu 890ddd
#include "tenv.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzCore includes
Toshihiro Shimizu 890ddd
#include "tcommon.h"
Toshihiro Shimizu 890ddd
#include "traster.h"
Toshihiro Shimizu 890ddd
#include "tipc.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// Qt includes
Toshihiro Shimizu 890ddd
#include <qcoreapplication></qcoreapplication>
Toshihiro Shimizu 890ddd
#include <qdir></qdir>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
#ifdef TNZCORE_EXPORTS
Toshihiro Shimizu 890ddd
#define DVAPI DV_EXPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_EXPORT_VAR
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define DVAPI DV_IMPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_IMPORT_VAR
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*
Toshihiro Shimizu 890ddd
  This file contains the platform-specific command lines and server names to
Toshihiro Shimizu 890ddd
  address 64-bit Toonz's background 32-bit process (used to deal with QuickTime,
Toshihiro Shimizu 890ddd
  to say one).
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
namespace t32bitsrv {
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//*************************************************************************************
Toshihiro Shimizu 890ddd
//  Platform-specific Server Command Lines
Toshihiro Shimizu 890ddd
//*************************************************************************************
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
static QString srvName() {
Shinya Kitaoka 120a6e
  static QString name(tipc::applicationSpecificServerName("t32bitsrv"));
Shinya Kitaoka 120a6e
  return name;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 9f5a1b
#ifdef _WIN32
shun-iwasawa 443318
static QString srvCmdlinePrg() {
shun-iwasawa 443318
  static QString cmd("srv/t32bitsrv.exe");
Shinya Kitaoka 120a6e
  return cmd;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
#else
shun-iwasawa 443318
static QString srvCmdlinePrg() {
shun-iwasawa 443318
  return "\"" + QCoreApplication::applicationDirPath() + "/t32bitsrv";
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
shun-iwasawa 443318
static QStringList srvCmdlineArgs() {
shun-iwasawa 443318
  static QStringList args = {srvName()};
shun-iwasawa 443318
  return args;
shun-iwasawa 443318
}
shun-iwasawa 443318
Toshihiro Shimizu 890ddd
//*************************************************************************************
Toshihiro Shimizu 890ddd
//  Buffer data exchanger
Toshihiro Shimizu 890ddd
//*************************************************************************************
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class DVAPI BufferExchanger final : public tipc::ShMemReader,
Shinya Kitaoka d1f6c4
                                    public tipc::ShMemWriter {
Shinya Kitaoka 120a6e
  UCHAR *m_buf;
Shinya Kitaoka 120a6e
  UCHAR *m_data;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  BufferExchanger(UCHAR *buf) : m_buf(buf), m_data(buf) {}
Shinya Kitaoka 120a6e
  ~BufferExchanger() {}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  UCHAR *buffer() const { return m_buf; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  int read(const char *srcBuf, int len) override;
Shinya Kitaoka 473e70
  int write(char *dstBuf, int len) override;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//*************************************************************************************
Toshihiro Shimizu 890ddd
//  Raster data exchanger
Toshihiro Shimizu 890ddd
//*************************************************************************************
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <typename pixel=""></typename>
Shinya Kitaoka d1f6c4
class DVAPI RasterExchanger final : public tipc::ShMemReader,
Shinya Kitaoka d1f6c4
                                    public tipc::ShMemWriter {
Shinya Kitaoka 120a6e
  typedef PIXEL pix_type;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TRasterPT<pixel> m_ras;</pixel>
Shinya Kitaoka 120a6e
  PIXEL *m_pix;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  RasterExchanger(TRasterP ras) : m_ras(ras) {
Shinya Kitaoka 120a6e
    m_ras->lock();
Shinya Kitaoka 120a6e
    m_pix = m_ras->pixels(0);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  ~RasterExchanger() { m_ras->unlock(); }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TRasterP raster() const { return m_ras; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  int read(const char *srcBuf, int len) override;
Shinya Kitaoka 473e70
  int write(char *dstBuf, int len) override;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
}  // namespace t32bitsrv
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
#endif  // T32BITSRV_WRAP