/////////////////////////////////////////////////////////////////////////////// // 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 render client #ifndef ODTRVISRENDERCLIENT #define ODTRVISRENDERCLIENT #include "TD_PackPush.h" #include "TrVisDefs.h" #include "TrVisRendition.h" #include "TrVisSelectionStyle.h" #include "RxVariantValue.h" class OdTrVisTtfFontsCacheClient; /** \details */ class OdTrVisRenderAbort { public: virtual bool beginMeasurement() = 0; virtual bool checkMeasurement() const = 0; virtual bool releaseMeasurement() = 0; virtual bool isMeasurementStarted() const = 0; virtual bool pauseMeasurement( bool bPause ) = 0; }; /** \details */ struct OdTrVisRenderStats { enum Counter { kSuppressedLinetypesCounter = (1 << 0) }; virtual void counterCallback(Counter nCounter, OdTrVisId objectId, OdUInt32 nValue) = 0; OdTrVisRenderStats(OdUInt32 countersMask = 0) : m_nCounters(countersMask) { } virtual ~OdTrVisRenderStats() { } bool isCounts(Counter nCounter) const { return GETBIT(m_nCounters, nCounter); } protected: const OdUInt32 m_nCounters; }; /** \details */ class OdTrVisRenderClient { public: enum AntiAliasingMode { kAntiAliasDisabled = 0, // Anti-aliasing disabled. kAntiAliasLines = (1 << 0), // Lines anti-aliasing. kAntiAliasLines3d = (1 << 1) // Lines anti-aliasing in 3d. }; enum BlendingMode { kBlendingAlphaDefault = 0, // Alpha blending without sorting (default transparency behavior). kBlendingAlphaSorting, // Alpha blending with sorting from back to front using second rendering pass. kBlendingMultiPassOIT, // Weighted Blended Order-Independed Transparency using multiple rendering passes. kBlendingSinglePassOIT // Weighted Blended Order-Independed Transparency using multiple draw buffers. }; enum RenderBufferFormat { kRBufFmtRGBA = 0, // RGBA direct render buffer kRBufFmtRGB, // RGB direct render buffer kRBufFmtBGRA, // BGRA direct render buffer kRBufFmtBGR // BGR direct render buffer }; public: virtual ~OdTrVisRenderClient() {} // Properties accessibility virtual bool hasProperty(const OdChar *pPropName) const = 0; virtual OdRxVariantValue getProperty(const OdChar *pPropName) const = 0; virtual OdRxObjectPtr getPropertyObject(const OdChar *pPropName) const = 0; virtual void setProperty(const OdChar *pPropName, OdRxVariantValue pValue) = 0; virtual void setPropertyObject(const OdChar *pPropName, OdRxObjectPtr pValue) = 0; // Elementary properties virtual bool usePartialUpdate() const { // This property isn't currently configurable through properties dictionary. // It is comes from device specifics (on-screen devices prefer partial update availability, // off-screen devices typically prefer work w/o partial updates). //if (hasProperty(OD_T("UsePartialUpdate"))) // return getProperty(OD_T("UsePartialUpdate"))->getBool(); //if (hasProperty(OD_T("ForcePartialUpdate"))) // return getProperty(OD_T("ForcePartialUpdate"))->getBool(); return false; } virtual bool useCompositeMetafiles() const { if (hasProperty(OD_T("UseCompositeMetafiles"))) return getProperty(OD_T("UseCompositeMetafiles"))->getBool(); return false; } virtual bool useVisualStyles() const { if (hasProperty(OD_T("UseVisualStyles"))) return getProperty(OD_T("UseVisualStyles"))->getBool(); return false; } virtual bool useOverlays() const { if (hasProperty(OD_T("UseOverlays"))) return getProperty(OD_T("UseOverlays"))->getBool(); return false; } virtual bool useSceneGraph() const { if (hasProperty(OD_T("UseSceneGraph"))) return getProperty(OD_T("UseSceneGraph"))->getBool(); return false; } virtual OdUInt32 antiAliasingMode() const { // Configurable through GiContext. return kAntiAliasDisabled; } virtual OdUInt32 blendingMode() const { if (hasProperty(OD_T("BlendingMode"))) return getProperty(OD_T("BlendingMode"))->getUInt32(); return kBlendingAlphaDefault; } virtual bool rasterImageContentsHighlight() const { // Configurable through GiContext. return false; } // True if mltithreaded regeneration invoked virtual bool isMultithreadedUpdateEnabled() const { return false; } // Output window size virtual int outputWindowWidth() const = 0; virtual int outputWindowHeight() const = 0; // Direct render buffer accessibility virtual bool hasDirectRenderBuffer(bool* /*bTransparent*/ = NULL) const { return false; } virtual OdUInt8 *getDirectRenderBuffer(OdUInt32* /*pWidth*/, OdUInt32* /*pHeight*/, OdUInt32* /*pFormat*/ = NULL, OdUInt32* /*pAlignment*/ = NULL) { return NULL; } // Selection/highlighting styles virtual OdUInt32 getSelectionStyle(OdUInt32 nStyle, OdTrVisSelectionStyle &style) const { style.setForStippling(); return (nStyle < 1) ? 1 : 0; } // TrueType fonts cache virtual const OdTrVisTtfFontsCacheClient *ttfFontsCache() const { return NULL; } virtual const OdTrVisSharingProviderClient *sharingProvider() const { return NULL; } // Rendering process handlers virtual void emitError(const char *pError) = 0; virtual void emitWarning(const char *pWarn) = 0; // Queries virtual OdTrVisRenderStats *queryRenderStats() { return NULL; } virtual OdTrVisRenderAbort *queryRenderAbort(const OdTrVisDirectRenderPartialUpdateInvocation * /*pInvocation*/, bool /*bAutoStart*/ = false) { return NULL; } }; /** \details */ class OdTrVisRenderClientPropsDic { protected: struct DicPair { OdString m_propName; OdRxObjectPtr m_pValue; DicPair() : m_pValue() { } DicPair(const OdChar *pPropName, OdRxObjectPtr pValue) : m_propName(pPropName), m_pValue(pValue) { } }; typedef OdVector DicPairsArray; DicPairsArray m_dic; public: OdTrVisRenderClientPropsDic() {} OdUInt32 findProp(const OdChar *pPropName) const { OdUInt32 nSearchBase = 0, nSearchCur; OdUInt32 nSearchLimit = m_dic.size(); const DicPair *pDic = m_dic.getPtr(); for ( ; nSearchLimit != 0; nSearchLimit >>= 1) { nSearchCur = nSearchBase + (nSearchLimit >> 1); int nCmp = pDic[nSearchCur].m_propName.compare(pPropName); if (!nCmp) return nSearchCur; if (nCmp > 0) { nSearchBase = nSearchCur + 1; nSearchLimit--; } } return 0xFFFFFFFF; } OdUInt32 numProps() const { return m_dic.size(); } OdRxObjectPtr getPropAt(OdUInt32 nProp) const { return m_dic[nProp].m_pValue; } void setPropAt(OdUInt32 nProp, OdRxObjectPtr pValue) { m_dic[nProp].m_pValue = pValue; } void killPropAt(OdUInt32 nProp) { m_dic.removeAt(nProp); } bool isEmpty() { return m_dic.isEmpty(); } void clear() { m_dic.clear(); } bool hasProp(const OdChar *pPropName) const { return findProp(pPropName) != 0xFFFFFFFF; } void setProp(const OdChar *pPropName, OdRxObjectPtr pValue) { if (m_dic.isEmpty()) m_dic.push_back(DicPair(pPropName, pValue)); else { OdUInt32 nSearchBase = 0, nSearchCur = 0; OdUInt32 nSearchLimit = m_dic.size(); const DicPair *pDic = m_dic.getPtr(); for ( ; nSearchLimit != 0; nSearchLimit >>= 1) { nSearchCur = nSearchBase + (nSearchLimit >> 1); int nCmp = pDic[nSearchCur].m_propName.compare(pPropName); if (!nCmp) { m_dic[nSearchCur].m_pValue = pValue; return; } if (nCmp > 0) { nSearchBase = nSearchCur + 1; nSearchLimit--; } } if (!(pDic[nSearchCur].m_propName.compare(pPropName) < 0)) nSearchCur++; m_dic.insertAt(nSearchCur, DicPair(pPropName, pValue)); } } OdRxObjectPtr getProp(const OdChar *pPropName) const { OdUInt32 nProp = findProp(pPropName); if (nProp == 0xFFFFFFFF) return OdRxObjectPtr(); return m_dic.getPtr()[nProp].m_pValue; } void killProp(const OdChar *pPropName) { OdUInt32 nProp = findProp(pPropName); if (nProp != 0xFFFFFFFF) killPropAt(nProp); } }; /** \details */ class OdTrVisRenderClientPropImpl : public OdTrVisRenderClient { protected: OdTrVisRenderClientPropsDic m_props; public: // Properties accessibility bool hasProperty(const OdChar *pPropName) const override { return m_props.hasProp(pPropName); } OdRxVariantValue getProperty(const OdChar *pPropName) const override { return m_props.getProp(pPropName).get(); } OdRxObjectPtr getPropertyObject(const OdChar *pPropName) const override { return m_props.getProp(pPropName); } void setProperty(const OdChar *pPropName, OdRxVariantValue pValue) override { m_props.setProp(pPropName, pValue); } void setPropertyObject(const OdChar *pPropName, OdRxObjectPtr pValue) override { m_props.setProp(pPropName, pValue); } }; /** \details */ template class OdTrVisRenderClientWrapper : public RCInterface { protected: OdTrVisRenderClient *m_pRedirection; public: OdTrVisRenderClientWrapper(OdTrVisRenderClient *pRedirection = NULL) : m_pRedirection(pRedirection) { } bool hasRedirection() const { return m_pRedirection != NULL; } void setRedirection(OdTrVisRenderClient *pRedirection) { m_pRedirection = pRedirection; } void resetRedirection() { setRedirection(NULL); } OdTrVisRenderClient *redirection() const { return m_pRedirection; } // Properties accessibility virtual bool hasProperty(const OdChar *pPropName) const { if (hasRedirection()) return redirection()->hasProperty(pPropName); return false; } virtual OdRxVariantValue getProperty(const OdChar *pPropName) const { if (hasRedirection()) return redirection()->getProperty(pPropName); return OdRxVariantValue(false); } virtual OdRxObjectPtr getPropertyObject(const OdChar *pPropName) const { if (hasRedirection()) return redirection()->getPropertyObject(pPropName); return OdRxObjectPtr(); } virtual void setProperty(const OdChar *pPropName, OdRxVariantValue pValue) { if (hasRedirection()) redirection()->setProperty(pPropName, pValue); } virtual void setPropertyObject(const OdChar *pPropName, OdRxObjectPtr pValue) { if (hasRedirection()) redirection()->setPropertyObject(pPropName, pValue); } // Elementary properties virtual bool usePartialUpdate() const { if (hasRedirection()) return redirection()->usePartialUpdate(); return false; } virtual bool useCompositeMetafiles() const { if (hasRedirection()) return redirection()->useCompositeMetafiles(); return false; } virtual bool useVisualStyles() const { if (hasRedirection()) return redirection()->useVisualStyles(); return false; } virtual bool useOverlays() const { if (hasRedirection()) return redirection()->useOverlays(); return false; } virtual bool useSceneGraph() const { if (hasRedirection()) return redirection()->useSceneGraph(); return false; } virtual OdUInt32 antiAliasingMode() const { if (hasRedirection()) return redirection()->antiAliasingMode(); return OdTrVisRenderClient::kAntiAliasDisabled; } virtual OdUInt32 blendingMode() const { if (hasRedirection()) return redirection()->blendingMode(); return OdTrVisRenderClient::kBlendingAlphaDefault; } virtual bool rasterImageContentsHighlight() const { if (hasRedirection()) return redirection()->rasterImageContentsHighlight(); return false; } // Output window size virtual int outputWindowWidth() const { if (hasRedirection()) return redirection()->outputWindowWidth(); return 0; } virtual int outputWindowHeight() const { if (hasRedirection()) return redirection()->outputWindowHeight(); return 0; } // Direct render buffer accessibility virtual bool hasDirectRenderBuffer(bool *bTransparent = NULL) const { if (hasRedirection()) return redirection()->hasDirectRenderBuffer(bTransparent); return false; } virtual OdUInt8 *getDirectRenderBuffer(OdUInt32* pWidth, OdUInt32* pHeight, OdUInt32* pFormat = NULL, OdUInt32* pAlignment = NULL) { if (hasRedirection()) return redirection()->getDirectRenderBuffer(pWidth, pHeight, pFormat, pAlignment); return NULL; } // Selection/highlighting styles virtual OdUInt32 getSelectionStyle(OdUInt32 nStyle, OdTrVisSelectionStyle &style) const { if (hasRedirection()) return redirection()->getSelectionStyle(nStyle, style); return RCInterface::getSelectionStyle(nStyle, style); } // TrueType fonts cache virtual const OdTrVisTtfFontsCacheClient *ttfFontsCache() const { if (hasRedirection()) return redirection()->ttfFontsCache(); return NULL; } virtual const OdTrVisSharingProviderClient *sharingProvider() const { if (hasRedirection()) return redirection()->sharingProvider(); return NULL; } // Rendering process handlers virtual void emitError(const char *pError) { if (hasRedirection()) redirection()->emitError(pError); } virtual void emitWarning(const char *pWarn) { if (hasRedirection()) redirection()->emitWarning(pWarn); } // Queries virtual OdTrVisRenderStats *queryRenderStats() { if (hasRedirection()) return redirection()->queryRenderStats(); return NULL; } virtual OdTrVisRenderAbort *queryRenderAbort(const OdTrVisDirectRenderPartialUpdateInvocation *pInvocation, bool bAutoStart = false) { if (hasRedirection()) return redirection()->queryRenderAbort(pInvocation, bAutoStart); return NULL; } }; #include "TD_PackPop.h" #endif // ODTRVISRENDERCLIENT