tahoma2d/toonz/sources/include/tofflinegl.h

99 lines
2.4 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
#ifndef TOFFLINEGL_INCLUDED
#define TOFFLINEGL_INCLUDED
2016-04-14 22:15:09 +12:00
#include <memory>
2016-03-19 06:57:51 +13:00
#include "tgl.h"
#undef DVAPI
#undef DVVAR
#ifdef TVRENDER_EXPORTS
#define DVAPI DV_EXPORT_API
#define DVVAR DV_EXPORT_VAR
#else
#define DVAPI DV_IMPORT_API
#define DVVAR DV_IMPORT_VAR
#endif
class TVectorRenderData;
class TVectorImageP;
class TRasterImageP;
//------------------------------------------------------
2016-06-15 18:43:10 +12:00
class DVAPI TGLContextManager {
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
virtual void store() = 0;
virtual void restore() = 0;
2016-03-19 06:57:51 +13:00
};
//------------------------------------------------------
2016-06-15 18:43:10 +12:00
class DVAPI TOfflineGL {
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
class Imp {
protected:
int m_lx, m_ly;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
public:
Imp(int lx, int ly) : m_lx(lx), m_ly(ly) {}
virtual ~Imp(){};
virtual void makeCurrent() = 0;
virtual void doneCurrent() = 0; // Da implementare in Imp
virtual void createContext(TDimension rasterSize,
std::shared_ptr<Imp> shared) = 0;
virtual void getRaster(TRaster32P) = 0;
virtual int getLx() const { return m_lx; }
virtual int getLy() const { return m_ly; }
};
typedef std::shared_ptr<Imp> ImpGenerator(const TDimension &dim,
std::shared_ptr<Imp> shared);
static ImpGenerator *defineImpGenerator(ImpGenerator *impGenerator);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TOfflineGL(TDimension dim, const TOfflineGL *shared = 0);
TOfflineGL(const TRaster32P &raster, const TOfflineGL *shared = 0);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
~TOfflineGL();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void makeCurrent();
void doneCurrent();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
static void setContextManager(TGLContextManager *contextManager);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void initMatrix();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void clear(TPixel32 color);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void draw(TVectorImageP image, const TVectorRenderData &rd,
bool doInitMatrix = false);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void draw(TRasterImageP image, const TAffine &aff, bool doInitMatrix = false);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void flush();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TRaster32P getRaster(); // Ritorna il raster copiandolo dal buffer offline
void getRaster(TRaster32P raster);
void getRaster(TRasterP raster);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
int getLx() const;
int getLy() const;
TDimension getSize() const { return TDimension(getLx(), getLy()); };
TRect getBounds() const { return TRect(0, 0, getLx() - 1, getLy() - 1); };
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
static TOfflineGL *getStock(TDimension dim);
// si usa cosi': TOfflineGL *ogl = TOfflineGL::getStock(d);
// non bisogna liberare ogl
std::shared_ptr<Imp> m_imp;
2016-03-19 06:57:51 +13:00
private:
private:
2016-06-15 18:43:10 +12:00
// not implemented
TOfflineGL(const TOfflineGL &);
TOfflineGL &operator=(const TOfflineGL &);
2016-03-19 06:57:51 +13:00
};
#endif