/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// #ifndef OD_SR_METAFILE #define OD_SR_METAFILE #include "Gs/GsBaseInclude.h" #include #include #include #include "rendering/SrTriangleRenderer.h" class OdSrFrameContext; class OdSrRecord; class OdGiSrGeometry; class OdGsSrVectorizerDevice; class OdGsSrVectorizeView; class OdGePoint2d; class OdSrMetafile : public OdRxObject { OdSrRecord* m_pHead; OdSrRecord* m_pTail; public: OdSrMetafile(); ~OdSrMetafile() override; virtual void play(OdSrFrameContext& pContext); void begin(); void end(); void addRecord(OdSrRecord* pRec); }; typedef OdSmartPtr OdSrMetafilePtr; class OdSrRecord { public: OdSrRecord* m_pNext; OdSrRecord() : m_pNext(nullptr) {} virtual ~OdSrRecord() {} void destroy() { OdSrRecord* pCurr = this; while (pCurr) { OdSrRecord* pTail = pCurr->m_pNext; delete pCurr; pCurr = pTail; } } virtual void play(OdSrFrameContext& pContext) const = 0; virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } protected: ODCOLORREF m_color = 0; //to be removed }; class OdSrPointRecord : public OdSrRecord { public: void play(OdSrFrameContext& pContext) const; static void play(OdSrFrameContext& context, const OdGePoint3d& point, OdDb::LineWeight lineweight, ODCOLORREF color); static OdSrPointRecord* createObject(const OdGePoint3d& point, OdDb::LineWeight lineweight, ODCOLORREF color); private: OdGePoint3d m_point; OdDb::LineWeight m_lineweight; }; class OdSrPolylineRecord : public OdSrRecord { public: void play(OdSrFrameContext& pContext) const; static void play(OdSrFrameContext& context, OdInt32 nPoints, const OdGePoint3d* pPoints, OdDb::LineWeight lineweight, ODCOLORREF color, bool closed); static OdSrPolylineRecord* createObject(OdInt32 nPoints, const OdGePoint3d* pPoints, OdDb::LineWeight lineweight, ODCOLORREF color, bool closed); private: OdArray m_points; OdDb::LineWeight m_lineweight; bool m_closed; }; class OdSrArcRecord : public OdSrRecord { public: OdGePoint3d m_center; OdGeVector3d m_refVector; OdGeVector3d m_normal; double m_radius; double m_angle; bool m_filled; OdGiArcType m_arcType; void play(OdSrFrameContext& pContext) const override; static OdSrArcRecord* createObject(const OdGePoint3d& center, double radius, const OdGeVector3d& normal, bool filled, double angle, OdGiArcType arcType, const OdGeVector3d& refVector, ODCOLORREF color); }; class OdSrCircleRecord : public OdSrRecord { public: OdGePoint3d m_center; double m_radius; OdGeVector3d m_normal; bool m_filled; void play(OdSrFrameContext& pContext) const override; static OdSrCircleRecord* createObject(const OdGePoint3d& center, double radius, const OdGeVector3d& normal, bool filled, ODCOLORREF color); }; class OdSrFullEllipseRecord : public OdSrRecord { public: OdGePoint2d m_center; double m_radiusMajor; double m_radiusMinor; OdGiArcType m_arcType; void play(OdSrFrameContext& pContext) const override; static OdSrFullEllipseRecord* createObject(const OdGePoint2d& center, double radiusMajor, double radiusMinor, OdGiArcType arcType, ODCOLORREF color); }; class OdSrEllipticArcRecord : public OdSrRecord { public: OdGePoint2d m_center; double m_radiusMajor; double m_radiusMinor; OdGeVector2d m_axisMajor; OdGeVector2d m_axisMinor; OdGePoint2d m_startPoint; OdGePoint2d m_endPoint; double m_startAngle; double m_endAngle; bool m_filled; OdGiArcType m_arcType; void play(OdSrFrameContext& pContext) const override; static OdSrEllipticArcRecord* createObject(const OdGePoint2d& center, double radiusMajor, double radiusMinor, const OdGeVector2d& axisMajor, const OdGeVector2d& axisMinor, const OdGePoint2d& startPoint, const OdGePoint2d& endPoint, double startAngle, double endAngle, bool filled, OdGiArcType arcType, ODCOLORREF color); }; class OdSrPolygonRecord : public OdSrRecord { public: void play(OdSrFrameContext& pContext) const override; static OdSrPolygonRecord* createObject(OdInt32 nPoints, const OdGePoint3d* pPoints, ODCOLORREF color); private: OdArray m_points; }; class OdSrSingleColorTriangleRecord : public OdSrRecord { public: void play(OdSrFrameContext& context) const override; static void play(OdSrFrameContext& context, ODCOLORREF color, const OdGePoint3d* points, bool clipBuffer); static OdSrSingleColorTriangleRecord* createObject(const OdGePoint3d* pPoints, ODCOLORREF color, bool clipBuffer); private: OdArray m_points; bool m_clipBuffer = false; }; class OdSrEmptyDebugTriangleRecord : public OdSrRecord { public: void play(OdSrFrameContext& context) const; static void play(OdSrFrameContext& context, ODCOLORREF m_color, const OdGePoint3d* points, bool clipBuffer); static OdSrEmptyDebugTriangleRecord* createObject(const OdGePoint3d* pPoints, ODCOLORREF color, bool clipBuffer); private: OdArray m_points; bool m_clipBuffer = false; }; class OdSrMultiColorTriangleRecord : public OdSrRecord { public: void play(OdSrFrameContext& context) const override; static OdSrMultiColorTriangleRecord* createObject(const OdGePoint3d* pPoints); private: OdArray m_points; }; class OdSrMetafilePackager { public: OdSrMetafilePackager(OdGsSrVectorizeView* pVectorizeView) : m_pVectorizeView(pVectorizeView), m_d3dDevice(nullptr) {} void addRecord(OdSrRecord* pRec); bool isPacking(); void playImmediately(OdSrRecord* pRec); void startPacking(OdGsSrVectorizeView* pVectorizer, OdGsSrVectorizerDevice* d3dDevice, OdSrMetafilePtr pMetafile); void stopPacking(); private: bool m_bIsPacking = false; int counter = 0; OdGsSrVectorizeView* m_pVectorizeView; // Current render view OdGsSrVectorizerDevice* m_d3dDevice; // Current D3D device OdSrMetafilePtr m_pMetafile; // Current recording metafile }; struct OdSrLineweightOverrideRecord : OdSrRecord { OdGiLineweightOverride m_lwdOverride; void play(OdSrFrameContext& pContext) const override; static OdSrLineweightOverrideRecord* createObject(const OdGiLineweightOverride& lwdOverride); }; class OdSrSetColorsRecord : public OdSrRecord { public: void play(OdSrFrameContext& context) const; static OdSrSetColorsRecord* createObject(const ODCOLORREF* color, OdUInt32 colorLength); static OdSrSetColorsRecord* createObject(ODCOLORREF color); ~OdSrSetColorsRecord() { delete m_colors; } private: const ODCOLORREF* m_colors; OdUInt32 m_colorLength; }; struct OdSrTextureTransform; class OdSrSetTextureRecord : public OdSrRecord { public: void play(OdSrFrameContext& context) const; static OdSrSetTextureRecord* createObject( const OdGiRasterImage* pImage, const OdSrTextureTransform& textureTransform, const OdSrTextureParams& textureParams); private: OdArray m_textureData; OdUInt32 m_width, m_height, m_scanLineLength; OdSrTextureTransform m_textureTransform; OdGiRasterImage::PixelFormatInfo m_pixelFormat; OdSrTextureParams m_textureParams; }; class OdSrResetTextureRecord : public OdSrRecord { public: void play(OdSrFrameContext& context) const; static OdSrResetTextureRecord* createObject(); }; /** * TexturedTriangleRecord class for software renderer metafile * Represents a textured triangle drawing operation in the metafile */ class OdSrTexturedTriangleRecord : public OdSrRecord { public: void play(OdSrFrameContext& context) const; static void play( OdSrFrameContext& context, const OdGePoint3d* points); static OdSrTexturedTriangleRecord* createObject( const OdGePoint3d* triPoints, OdUInt8 alpha); ~OdSrTexturedTriangleRecord() { delete[] m_vertexPoints; } private: // Vertex coordinates OdGePoint3d* m_vertexPoints; // Alpha value OdUInt8 m_alpha; }; #endif // OD_SR_METAFILE