CFx SDK Documentation  2020SP3
TrVecResourceSharingProvider.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2017, Open Design Alliance (the "Alliance").
3 // All rights reserved.
4 //
5 // This software and its documentation and related materials are owned by
6 // the Alliance. The software may only be incorporated into application
7 // programs owned by members of the Alliance, subject to a signed
8 // Membership Agreement and Supplemental Software License Agreement with the
9 // Alliance. The structure and organization of this software are the valuable
10 // trade secrets of the Alliance and its suppliers. The software is also
11 // protected by copyright law and international treaty provisions. Application
12 // programs incorporating this software must include the following statement
13 // with their copyright notices:
14 //
15 // This application incorporates Teigha(R) software pursuant to a license
16 // agreement with Open Design Alliance.
17 // Teigha(R) Copyright (C) 2002-2017 by Open Design Alliance.
18 // All rights reserved.
19 //
20 // By use of this software, its documentation or related materials, you
21 // acknowledge and accept the above terms.
23 // GLES2 device resource sharing provider
24 
25 #ifndef ODTRVECRESOURCESHARINGPROVIDER
26 #define ODTRVECRESOURCESHARINGPROVIDER
27 
28 #include "TD_PackPush.h"
29 
30 #include "TrVecDefs.h"
31 #include "TrVisRendition.h"
32 #include "ExDrawOrderBase.h"
33 
34 #include "StaticRxObject.h"
35 
36 class OdTrVecDevice;
38 class OdTrVecVisualStyleContainer;
39 class OdTrVecLayerContainer;
40 
45  , public OdDrawOrderBaseDeviceMCCallback
46 {
47  public:
48  // Processing device bit sets
49  struct DeviceBitSet
50  {
51  // Max bit for current OS
52  static const OdUInt32 g_nMaxBit;
53  static const OdUInt32 g_nBitSys;
54  // Check does resource attached to device
55  static bool isAttached(const OdDrawOrderMetafileBase &bitSet, const OdTrVecDevice *pDevice);
56  // Attach resource to device
57  static void attach(OdDrawOrderMetafileBase &bitSet, const OdTrVecDevice *pDevice);
58  // Detach resource from device
59  static void detach(OdDrawOrderMetafileBase &bitSet, const OdTrVecDevice *pDevice);
60  // Eliminate device from bit set, compress bit set
61  static void eliminate(OdDrawOrderMetafileBase &bitSet, const OdTrVecDevice *pDevice);
62  static void compress(OdDrawOrderMetafileBase &bitSet, OdUInt32 nBit);
63  // Free bit set
64  static void clear(OdDrawOrderMetafileBase &bitSet);
65  };
66 
67  typedef void (*broadcastProc)(OdDrawOrderBaseDevice *pDevice, void *pData);
68  protected:
69  struct DeviceEntry
70  {
71  enum Flags
72  {
73  kConnected = (1 << 0)
74  };
75 
76  OdTrVecDevice *m_pDevice;
78 
80  DeviceEntry(OdTrVecDevice *pDevice) : m_pDevice(pDevice), m_flags(0) { }
81  };
82  protected:
86  OdTrVecVisualStyleContainer *m_pVSCache;
87  OdTrVecLayerContainer *m_pLayerCache;
88  public:
90 
93 
95 
96  // Opens resource sharing for device
97  virtual void openResourceSharing(OdTrVecDevice *pDevice);
98  // Close resource sharing for device
99  virtual void closeResourceSharing(OdTrVecDevice *pDevice);
100  // Check does resource sharing is opened for device
101  bool isResourceSharingOpened(OdTrVecDevice *pDevice) const;
102 
103  // Returns true in case if multiple devices (sharing) enabled
104  bool hasSharedResources() const { return m_nSharedDevices > 1; }
105 
106  // OdDrawOrderBaseDeviceMCCallback override
107  virtual void onDeleteRequest(onDeleteRequestProc pReqProc, void *pData);
108 
109  // Broadcast function for all registered devices
110  void broadcastFunction(const OdDrawOrderMetafileBase &bitSet, broadcastProc pProc, void *pArg) const;
111 
112  // Broadcast function for all devices
113  void broadcastFunctionForAll(broadcastProc pProc, void *pArg, const OdTrVecDevice *pExclusion = NULL) const;
114 
115  // Ttf fonts cache support
116  OdTrVecTtfFontsCache *ttfFontsCache(OdTrVecDevice *pDevice);
117 
118  // Visual Styles cache support
119  OdTrVecVisualStyleContainer *visualStylesCache(OdTrVecDevice *pDevice);
120 
121  // Layers cache support
122  OdTrVecLayerContainer *layersCache(OdTrVecDevice *pDevice);
123 
124  // Find first usage device
125  OdTrVecDevice *findUsage(const OdDrawOrderMetafileBase &bitSet, OdTrVecDevice *pStartFrom = NULL) const;
126 
127  // Share metafile with secondary device (base call, will be redirected to secondary override)
128  virtual bool shareMetafile(OdTrVecDevice *pRequestedFor, OdDrawOrderMetafileBase &bitSet,
129  OdTrVisMetafileId metafileId, void *pInternalDataPtr, void *pOriginatorPtr);
130 
131  // Share texture with secondary device (base call, will be redirected to secondary override)
132  virtual bool shareTexture(OdTrVecDevice *pRequestedFor, OdDrawOrderMetafileBase &bitSet,
133  OdTrVisTextureId textureId, void *pInternalDataPtr, void *pOriginatorPtr);
134 
135  // Share material with secondary device (base call, will be redirected to secondary override)
136  virtual bool shareMaterial(OdTrVecDevice *pRequestedFor, OdDrawOrderMetafileBase &bitSet,
137  OdTrVisMaterialId materialId, void *pInternalDataPtr, void *pOriginatorPtr);
138  protected:
139  // Share metafile with secondary device (should be overrided by client, do nothing by default)
140  virtual bool shareMetafile(OdTrVecDevice *pRequestedFor, OdTrVecDevice *pRequestedFrom,
141  OdTrVisMetafileId metafileId, void *pInternalDataPtr, void *pOriginatorPtr);
142  // Share texture with secondary device (should be overrided by client, do nothing by default)
143  virtual bool shareTexture(OdTrVecDevice *pRequestedFor, OdTrVecDevice *pRequestedFrom,
144  OdTrVisTextureId textureId, void *pInternalDataPtr, void *pOriginatorPtr);
145  // Share material with secondary device (should be overrided by client, do nothing by default)
146  virtual bool shareMaterial(OdTrVecDevice *pRequestedFor, OdTrVecDevice *pRequestedFrom,
147  OdTrVisMaterialId materialId, void *pInternalDataPtr, void *pOriginatorPtr);
148 
149  // Low-level accessors
150 
151  // Create compatible texture for device from another exist device
152  bool internalTextureProc(OdTrVecDevice *pRequestedFor, OdTrVecDevice *pRequestedFrom,
153  OdTrVisTextureId textureId, void *pInternalDataPtr, void *pOriginatorPtr,
154  OdTrVisTextureDef &resTexture, bool &bCreated);
155 
156  // Initiate conversion of textures from material for device from another exist device
157  bool materialTexturesProc(OdTrVecDevice *pRequestedFor, OdTrVecDevice *pRequestedFrom,
158  OdTrVisMaterialId materialId, void *pInternalDataPtr, void *pOriginatorPtr);
159 
160  // Share Id registration between devices
161  void shareIdRegistration(OdTrVecDevice *pRequestedFor, OdTrVecDevice *pRequestedFrom,
162  OdTrVisId id, OdInt32 type);
163  protected: // Helpers
164  OdTrVisRendition *rendition(OdTrVecDevice *pRequestFor) const;
165  const OdTrVisRendition::ClientSettings &clientSettings(const OdTrVecDevice *pRequestFor) const;
166  OdTrVisRenderClient *renderClient(OdTrVecDevice *pRequestFor) const;
167  OdGsDevice *gsDevice(OdTrVecDevice *pRequestFor) const;
168  public:
170  {
171  public:
173  {
178  };
179 
180  virtual TypeOfResource resourceType() const = 0;
181 
182  virtual OdTrVisId resourceId() const = 0;
183 
184  virtual OdDrawOrderMetafileBase &resourceBitSet() = 0;
185 
186  static OdRxClass *desc();
187  private:
188  typedef OdTrVisDescStub ResDepDesc;
189  static OdStaticRxObject<ResDepDesc> g_ResDepDesc;
190  };
191 };
192 
194 
195 #define OdTrVecResourceDependency_queryX(TypeOf, BaseClass) \
196  OdRxObject *queryX(const OdRxClass* pClass) const \
197  { \
198  if (pClass == OdTrVecResourceSharingProvider::ResourceDependency::desc()) \
199  return reinterpret_cast<OdRxObject*>((OdTrVecResourceSharingProvider::ResourceDependency*)this); \
200  return BaseClass::queryX(pClass); \
201  } \
202  TypeOfResource resourceType() const { return TypeOf; }
203 
204 #include "TD_PackPop.h"
205 
206 #endif // ODTRVECRESOURCESHARINGPROVIDER
NULL
#define NULL
Definition: GsProperties.h:177
OdUInt8
unsigned char OdUInt8
Definition: OdPlatformSettings.h:759
OdTrVecResourceSharingProvider::shareTexture
virtual bool shareTexture(OdTrVecDevice *pRequestedFor, OdDrawOrderMetafileBase &bitSet, OdTrVisTextureId textureId, void *pInternalDataPtr, void *pOriginatorPtr)
OdTrVecTtfFontsCache
Definition: TrVecTtfFontsCache.h:49
OdTrVecResourceSharingProvider::findUsage
OdTrVecDevice * findUsage(const OdDrawOrderMetafileBase &bitSet, OdTrVecDevice *pStartFrom=NULL) const
type
GLuint GLsizei GLsizei GLint GLenum * type
Definition: gles2_ext.h:274
OdTrVisSharingProviderClient
Definition: TrVisSharingProviderClient.h:36
OdTrVecResourceSharingProvider::internalTextureProc
bool internalTextureProc(OdTrVecDevice *pRequestedFor, OdTrVecDevice *pRequestedFrom, OdTrVisTextureId textureId, void *pInternalDataPtr, void *pOriginatorPtr, OdTrVisTextureDef &resTexture, bool &bCreated)
OdGsDevice
Definition: Gs.h:1061
OdTrVecResourceSharingProvider::broadcastProc
void(* broadcastProc)(OdDrawOrderBaseDevice *pDevice, void *pData)
Definition: TrVecResourceSharingProvider.h:67
OdTrVecResourceSharingProvider::DeviceEntry
Definition: TrVecResourceSharingProvider.h:70
OdTrVecResourceSharingProvider::visualStylesCache
OdTrVecVisualStyleContainer * visualStylesCache(OdTrVecDevice *pDevice)
OdArray
Definition: OdArray.h:591
TD_PackPop.h
OdTrVecResourceSharingProvider::materialTexturesProc
bool materialTexturesProc(OdTrVecDevice *pRequestedFor, OdTrVecDevice *pRequestedFrom, OdTrVisMaterialId materialId, void *pInternalDataPtr, void *pOriginatorPtr)
OdTrVecResourceSharingProvider::DeviceEntry::DeviceEntry
DeviceEntry()
Definition: TrVecResourceSharingProvider.h:79
OdTrVecResourceSharingProvider::shareTexture
virtual bool shareTexture(OdTrVecDevice *pRequestedFor, OdTrVecDevice *pRequestedFrom, OdTrVisTextureId textureId, void *pInternalDataPtr, void *pOriginatorPtr)
OdTrVecResourceSharingProvider::ttfFontsCache
OdTrVecTtfFontsCache * ttfFontsCache(OdTrVecDevice *pDevice)
OdTrVecResourceSharingProvider::openResourceSharing
virtual void openResourceSharing(OdTrVecDevice *pDevice)
OdUInt32
unsigned int OdUInt32
Definition: OdPlatformSettings.h:783
OdTrVecResourceSharingProvider::ResourceDependency
Definition: TrVecResourceSharingProvider.h:170
OdTrVecResourceSharingProvider::DeviceBitSet::g_nBitSys
static const OdUInt32 g_nBitSys
Definition: TrVecResourceSharingProvider.h:53
OdTrVecResourceSharingProvider::m_pLayerCache
OdTrVecLayerContainer * m_pLayerCache
Definition: TrVecResourceSharingProvider.h:87
OdTrVecResourceSharingProvider::rendition
OdTrVisRendition * rendition(OdTrVecDevice *pRequestFor) const
OdTrVecResourceSharingProvider::broadcastFunction
void broadcastFunction(const OdDrawOrderMetafileBase &bitSet, broadcastProc pProc, void *pArg) const
OdTrVecResourceSharingProvider::shareMaterial
virtual bool shareMaterial(OdTrVecDevice *pRequestedFor, OdTrVecDevice *pRequestedFrom, OdTrVisMaterialId materialId, void *pInternalDataPtr, void *pOriginatorPtr)
OdRxClass
Definition: RxObject.h:865
OdTrVecResourceSharingProvider::isResourceSharingOpened
bool isResourceSharingOpened(OdTrVecDevice *pDevice) const
OdTrVisRendition::ClientSettings
Definition: TrVisRendition.h:165
OdTrVecResourceSharingProvider::closeResourceSharing
virtual void closeResourceSharing(OdTrVecDevice *pDevice)
OdTrVecResourceSharingProvider::DeviceBitSet::clear
static void clear(OdDrawOrderMetafileBase &bitSet)
OdTrVecResourceSharingProvider::DeviceBitSet::g_nMaxBit
static const OdUInt32 g_nMaxBit
Definition: TrVecResourceSharingProvider.h:52
OdTrVecResourceSharingProvider::DeviceEntry::DeviceEntry
DeviceEntry(OdTrVecDevice *pDevice)
Definition: TrVecResourceSharingProvider.h:80
OdSmartPtr
Definition: SmartPtr.h:58
OdTrVecResourceSharingProvider::clientSettings
const OdTrVisRendition::ClientSettings & clientSettings(const OdTrVecDevice *pRequestFor) const
OdTrVecResourceSharingProvider::OdTrVecResourceSharingProvider
OdTrVecResourceSharingProvider()
TrVisRendition.h
OdInt32
int OdInt32
Definition: OdPlatformSettings.h:782
OdTrVecResourceSharingProvider::shareMaterial
virtual bool shareMaterial(OdTrVecDevice *pRequestedFor, OdDrawOrderMetafileBase &bitSet, OdTrVisMaterialId materialId, void *pInternalDataPtr, void *pOriginatorPtr)
OdTrVecResourceSharingProvider::DeviceBitSet::detach
static void detach(OdDrawOrderMetafileBase &bitSet, const OdTrVecDevice *pDevice)
OdTrVecResourceSharingProvider::shareIdRegistration
void shareIdRegistration(OdTrVecDevice *pRequestedFor, OdTrVecDevice *pRequestedFrom, OdTrVisId id, OdInt32 type)
OdTrVecResourceSharingProvider::createObject
static OdSmartPtr< OdTrVecResourceSharingProvider > createObject()
OdTrVisTextureDef
Definition: TrVisTextureDef.h:38
OdTrVecResourceSharingProvider::ResourceDependency::kMaterial
@ kMaterial
Definition: TrVecResourceSharingProvider.h:175
OdTrVecResourceSharingProvider::m_rmDevices
OdArray< DeviceEntry > m_rmDevices
Definition: TrVecResourceSharingProvider.h:83
OdTrVecResourceSharingProvider::~OdTrVecResourceSharingProvider
~OdTrVecResourceSharingProvider()
OdTrVecResourceSharingProvider::ResourceDependency::kRasterImage
@ kRasterImage
Definition: TrVecResourceSharingProvider.h:174
OdTrVisDescStub
Definition: TrVisDefs.h:236
OdTrVecResourceSharingProvider::DeviceBitSet
Definition: TrVecResourceSharingProvider.h:50
OdTrVecResourceSharingProvider::DeviceEntry::Flags
Flags
Definition: TrVecResourceSharingProvider.h:72
OdTrVecResourceSharingProvider::ODRX_USING_HEAP_OPERATORS
ODRX_USING_HEAP_OPERATORS(OdTrVisSharingProviderClient)
OdTrVecResourceSharingProvider::DeviceEntry::m_pDevice
OdTrVecDevice * m_pDevice
Definition: TrVecResourceSharingProvider.h:76
OdTrVecResourceSharingProvider::DeviceBitSet::attach
static void attach(OdDrawOrderMetafileBase &bitSet, const OdTrVecDevice *pDevice)
OdTrVecResourceSharingProvider::m_pTtfCache
OdTrVecTtfFontsCache * m_pTtfCache
Definition: TrVecResourceSharingProvider.h:85
TD_PackPush.h
StaticRxObject.h
OdTrVecResourceSharingProvider::m_pVSCache
OdTrVecVisualStyleContainer * m_pVSCache
Definition: TrVecResourceSharingProvider.h:86
TrVecDefs.h
OdTrVecResourceSharingProviderPtr
OdSmartPtr< OdTrVecResourceSharingProvider > OdTrVecResourceSharingProviderPtr
Definition: TrVecResourceSharingProvider.h:193
OdTrVecResourceSharingProvider::hasSharedResources
bool hasSharedResources() const
Definition: TrVecResourceSharingProvider.h:104
OdTrVecResourceSharingProvider::m_nSharedDevices
OdUInt32 m_nSharedDevices
Definition: TrVecResourceSharingProvider.h:84
OdTrVisRenderClient
Definition: TrVisRenderClient.h:40
OdTrVecResourceSharingProvider
Definition: TrVecResourceSharingProvider.h:46
OdTrVecResourceSharingProvider::DeviceBitSet::eliminate
static void eliminate(OdDrawOrderMetafileBase &bitSet, const OdTrVecDevice *pDevice)
OdTrVecResourceSharingProvider::DeviceEntry::kConnected
@ kConnected
Definition: TrVecResourceSharingProvider.h:73
OdTrVecResourceSharingProvider::shareMetafile
virtual bool shareMetafile(OdTrVecDevice *pRequestedFor, OdDrawOrderMetafileBase &bitSet, OdTrVisMetafileId metafileId, void *pInternalDataPtr, void *pOriginatorPtr)
OdStaticRxObject
Definition: StaticRxObject.h:57
OdTrVisRendition
Definition: TrVisRendition.h:61
OdTrVecResourceSharingProvider::gsDevice
OdGsDevice * gsDevice(OdTrVecDevice *pRequestFor) const
OdTrVecResourceSharingProvider::ResourceDependency::resourceType
virtual TypeOfResource resourceType() const =0
OdTrVecResourceSharingProvider::ResourceDependency::resourceBitSet
virtual OdDrawOrderMetafileBase & resourceBitSet()=0
OdTrVecResourceSharingProvider::onDeleteRequest
virtual void onDeleteRequest(onDeleteRequestProc pReqProc, void *pData)
OdTrVecResourceSharingProvider::layersCache
OdTrVecLayerContainer * layersCache(OdTrVecDevice *pDevice)
OdTrVecResourceSharingProvider::renderClient
OdTrVisRenderClient * renderClient(OdTrVecDevice *pRequestFor) const
OdTrVecResourceSharingProvider::DeviceBitSet::isAttached
static bool isAttached(const OdDrawOrderMetafileBase &bitSet, const OdTrVecDevice *pDevice)
OdTrVecResourceSharingProvider::ResourceDependency::kVisualStyle
@ kVisualStyle
Definition: TrVecResourceSharingProvider.h:177
OdTrVecResourceSharingProvider::ResourceDependency::TypeOfResource
TypeOfResource
Definition: TrVecResourceSharingProvider.h:173
OdTrVecResourceSharingProvider::ResourceDependency::resourceId
virtual OdTrVisId resourceId() const =0
OdTrVecResourceSharingProvider::DeviceEntry::m_flags
OdUInt8 m_flags
Definition: TrVecResourceSharingProvider.h:77
OdTrVecResourceSharingProvider::ResourceDependency::desc
static OdRxClass * desc()
void
typedef void(APIENTRYP PFNGLACTIVETEXTUREPROC)(GLenum texture)
OdTrVecResourceSharingProvider::ResourceDependency::kTexture
@ kTexture
Definition: TrVecResourceSharingProvider.h:176
OdTrVecResourceSharingProvider::broadcastFunctionForAll
void broadcastFunctionForAll(broadcastProc pProc, void *pArg, const OdTrVecDevice *pExclusion=NULL) const
OdTrVecResourceSharingProvider::DeviceBitSet::compress
static void compress(OdDrawOrderMetafileBase &bitSet, OdUInt32 nBit)
OdTrVecResourceSharingProvider::shareMetafile
virtual bool shareMetafile(OdTrVecDevice *pRequestedFor, OdTrVecDevice *pRequestedFrom, OdTrVisMetafileId metafileId, void *pInternalDataPtr, void *pOriginatorPtr)
OdUInt64
Definition: Int64.h:137