/////////////////////////////////////////////////////////////////////////////// // 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. /////////////////////////////////////////////////////////////////////////////// // GLES2 device metafile definition #ifndef ODTRVISMETAFILEDEF #define ODTRVISMETAFILEDEF #include "TD_PackPush.h" #include "UInt8Array.h" #include "Ge/GeExtents3d.h" #include "SharedPtr.h" #include "TPtr.h" #include "TrVisDefs.h" #include "TrVisAtomics.h" #include "TrVisMetafileStream.h" // Forward declaration class OdTrRndSgExpand; /** \details This template class is a specialization of the OdSharedPtr class for OdTrVisFlatMetafileContainer object pointers. */ typedef OdSharedPtr OdTrVisFlatMetafileContainerPtr; /** \details */ struct OdTrVisMetafileContainer : public OdTrVisFlatMetafileContainer { enum MetafileDefFlags { kMfVisible = (1 << 0), // Visibility flag (false for invisible metafiles). kMfHighlighted = (1 << 1), // Highlighting flag (always false for nested metafiles). kMfTemporary = (1 << 2), // True for transient drawables, false for persistent drawables. kMfNested = (1 << 3), // Marks nested drawables (true for drawables inside blocks, false for top-level always). kMfBlockRef = (1 << 4), // Marks block reference container metafile. kMfUtilitary = (1 << 5), // Marks utilitary metafiles (TTF characters cache for example). kMfSectionable = (1 << 6), // Marks sectionable metafiles. kMfComposite = (1 << 7), // Marks composite metafiles (containing data for multipass rendering). kMfXRef = (1 << 8), // Marks external reference metafiles. kMfRefEditFade = (1 << 9), // Fade metafile flag (true if metafile faded onto vectorizer side). kMfCastShadows = (1 << 10), // Metafile geometry can cast shadows. kMfRcivShadows = (1 << 11), // Metafile geometry can receive shadows. kMfUnited = (1 << 12), // Mark metafiles, which represents union of metafile streams. kMfLtpRegen = (1 << 13), // Mark metafiles, which requires linetypes regeneration when become visible. // Set of metafile flags which incompatibility must prevent Scene Graph metafiles joining. kSgIncompatible = kMfXRef | kMfSectionable | kMfCastShadows | kMfRcivShadows }; OdUInt16 m_mfFlags; // Metafile bit flags OdUInt16 m_rtFlags; // Ray-trace related flags // Note: for 64bit configuration we has Int32 padding here, which can be used without container size grow. // Or we can increase flags container size. OdIntPtr m_revData; // Allocation address OdTrRndSgExpand *m_pSgData; // Runtime scene graph rendering data OdTrVisMetafileContainer() : m_mfFlags(0), m_rtFlags(0), m_revData(0), m_pSgData(NULL) {} bool hasRevData() const { return m_revData != 0; } OdIntPtr getRevData() const { return m_revData; } void setRevData(OdIntPtr revData) { m_revData = revData; } virtual void selfRelease(); virtual OdTrVisMetafileContainer *selfRenderStream() const { return const_cast(this); } // OdFlatMetafileContainer overrides OdFlatMetafileContainer *createMe() const override; // Clone stream data with gaps elimination OdFlatMetafileContainer *clone(const Gap *pGaps = NULL) const override { OdTrVisMetafileContainer *pClone = static_cast(OdTrVisFlatMetafileContainer::clone(pGaps)); pClone->setCloned(this); return pClone; } // Reset metafile flags void resetMetafileFlags(OdUInt16 mfFlags = 0) { m_mfFlags = mfFlags; } // Visiblity flag bool isMetafileVisible() const { return GETBIT(m_mfFlags, kMfVisible); } void setMetafileVisible(bool bSet) { SETBIT(m_mfFlags, kMfVisible, bSet); } // Highlighting flag bool isMetafileHighlighted() const { return GETBIT(m_mfFlags, kMfHighlighted); } void setMetafileHighlighted(bool bSet) { SETBIT(m_mfFlags, kMfHighlighted, bSet); } // Temporary drawable flag bool isTemporaryMetafile() const { return GETBIT(m_mfFlags, kMfTemporary); } void setTemporaryMetafile(bool bSet) { SETBIT(m_mfFlags, kMfTemporary, bSet); } // Nested metafile flag bool isNestedMetafile() const { return GETBIT(m_mfFlags, kMfNested); } void setNestedMetafile(bool bSet) { SETBIT(m_mfFlags, kMfNested, bSet); } // Block reference flag bool isBlockRefMetafile() const { return GETBIT(m_mfFlags, kMfBlockRef); } void setBlockRefMetafile(bool bSet) { SETBIT(m_mfFlags, kMfBlockRef, bSet); } // Utilitary metafile flag bool isUtilitaryMetafile() const { return GETBIT(m_mfFlags, kMfUtilitary); } void setUtilitaryMetafile(bool bSet) { SETBIT(m_mfFlags, kMfUtilitary, bSet); } // Sectionable metafile flag bool isSectionableMetafile() const { return GETBIT(m_mfFlags, kMfSectionable); } void setSectionableMetafile(bool bSet) { SETBIT(m_mfFlags, kMfSectionable, bSet); } // Composite metafile flag bool isCompositeMetafile() const { return GETBIT(m_mfFlags, kMfComposite); } void setCompositeMetafile(bool bSet) { SETBIT(m_mfFlags, kMfComposite, bSet); } // XRef metafile flag bool isXRefMetafile() const { return GETBIT(m_mfFlags, kMfXRef); } void setXRefMetafile(bool bSet) { SETBIT(m_mfFlags, kMfXRef, bSet); } // RefEditFade metafile flag bool isMetafileFaded() const { return GETBIT(m_mfFlags, kMfRefEditFade); } void setMetafileFaded(bool bSet) { SETBIT(m_mfFlags, kMfRefEditFade, bSet); } // CastShadows metafile flag bool isMetafileCastShadows() const { return GETBIT(m_mfFlags, kMfCastShadows); } void setMetafileCastShadows(bool bSet) { SETBIT(m_mfFlags, kMfCastShadows, bSet); } // RcivShadows metafile flag bool isMetafileReceiveShadows() const { return GETBIT(m_mfFlags, kMfRcivShadows); } void setMetafileReceiveShadows(bool bSet) { SETBIT(m_mfFlags, kMfRcivShadows, bSet); } // United metafile flag bool isUnitedMetafile() const { return GETBIT(m_mfFlags, kMfUnited); } void setUnitedMetafile(bool bSet) { SETBIT(m_mfFlags, kMfUnited, bSet); } // LtpRegen metafile flag bool isMetafileLinetypesNeedRegen() const { return GETBIT(m_mfFlags, kMfLtpRegen); } void setMetafileLinetypesNeedRegen(bool bSet) { SETBIT(m_mfFlags, kMfLtpRegen, bSet); } // Scene-Graph connection bool hasSceneGraphExpands() const { return !!m_pSgData; } void setSceneGraphExpands(OdTrRndSgExpand *pExpand) { m_pSgData = pExpand; } void resetSceneGraphExpands() { m_pSgData = NULL; } OdTrRndSgExpand *sceneGraphExpands() const { return m_pSgData; } // Calculate size of underlying stream OdUInt64 calcSize() const { return OdUInt64(size()) + calcArrayElementsSize() + sizeof(OdTrVisMetafileContainer); } void setCloned(const OdTrVisMetafileContainer *pSrc) { resetMetafileFlags(pSrc->m_mfFlags); } void setDefault() { resetMetafileFlags(); } }; /** \details */ class OdTrVisMfContainerRelease { public: #ifdef TD_SINGLE_THREAD static void addRef(OdTrVisMetafileContainer* pObj) { if (pObj) { pObj->m_nRefs++; } } static void release(OdTrVisMetafileContainer* pObj) { if (pObj) { pObj->m_nRefs--; if (!pObj->m_nRefs) pObj->selfRelease(); } } #else static void addRef(OdTrVisMetafileContainer *pObj) { if (pObj) { OdTrVisAtomics::interlockedIncrement32(pObj->m_nRefs); } } static void release(OdTrVisMetafileContainer *pObj) { if (pObj && !OdTrVisAtomics::interlockedDecrement32(pObj->m_nRefs)) pObj->selfRelease(); } #endif }; /** \details This template class is a specialization of the TPtr class for OdTrVisMetafileContainer object pointers. */ typedef TPtr OdTrVisMetafileContainerPtr; /** \details */ struct OdTrVisMetafileDef { // Metafile stream and related flags OdTrVisMetafileContainerPtr m_pMetafile; // Metafile extents OdGeExtents3d m_extents; // Generator viewport Id OdTrVisViewportId m_generatorId; void setDefault() { m_pMetafile = NULL; m_extents = OdGeExtents3d(); m_generatorId = kTrVisNullId; } }; #include "TD_PackPop.h" #endif // ODTRVISMETAFILEDEF