CFx SDK Documentation  2022 SP0
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
#define NULL
Definition: GsProperties.h:177
unsigned int OdUInt32
int OdInt32
unsigned char OdUInt8
OdSmartPtr< OdTrVecResourceSharingProvider > OdTrVecResourceSharingProviderPtr
virtual OdDrawOrderMetafileBase & resourceBitSet()=0
virtual TypeOfResource resourceType() const =0
OdTrVecVisualStyleContainer * visualStylesCache(OdTrVecDevice *pDevice)
OdTrVisRendition * rendition(OdTrVecDevice *pRequestFor) const
OdTrVecDevice * findUsage(const OdDrawOrderMetafileBase &bitSet, OdTrVecDevice *pStartFrom=NULL) const
OdGsDevice * gsDevice(OdTrVecDevice *pRequestFor) const
OdTrVecLayerContainer * layersCache(OdTrVecDevice *pDevice)
void broadcastFunction(const OdDrawOrderMetafileBase &bitSet, broadcastProc pProc, void *pArg) const
OdTrVecVisualStyleContainer * m_pVSCache
ODRX_USING_HEAP_OPERATORS(OdTrVisSharingProviderClient)
virtual bool shareMetafile(OdTrVecDevice *pRequestedFor, OdTrVecDevice *pRequestedFrom, OdTrVisMetafileId metafileId, void *pInternalDataPtr, void *pOriginatorPtr)
virtual bool shareTexture(OdTrVecDevice *pRequestedFor, OdDrawOrderMetafileBase &bitSet, OdTrVisTextureId textureId, void *pInternalDataPtr, void *pOriginatorPtr)
void shareIdRegistration(OdTrVecDevice *pRequestedFor, OdTrVecDevice *pRequestedFrom, OdTrVisId id, OdInt32 type)
virtual void openResourceSharing(OdTrVecDevice *pDevice)
virtual bool shareMaterial(OdTrVecDevice *pRequestedFor, OdDrawOrderMetafileBase &bitSet, OdTrVisMaterialId materialId, void *pInternalDataPtr, void *pOriginatorPtr)
void broadcastFunctionForAll(broadcastProc pProc, void *pArg, const OdTrVecDevice *pExclusion=NULL) const
virtual bool shareMetafile(OdTrVecDevice *pRequestedFor, OdDrawOrderMetafileBase &bitSet, OdTrVisMetafileId metafileId, void *pInternalDataPtr, void *pOriginatorPtr)
virtual void onDeleteRequest(onDeleteRequestProc pReqProc, void *pData)
virtual bool shareMaterial(OdTrVecDevice *pRequestedFor, OdTrVecDevice *pRequestedFrom, OdTrVisMaterialId materialId, void *pInternalDataPtr, void *pOriginatorPtr)
virtual bool shareTexture(OdTrVecDevice *pRequestedFor, OdTrVecDevice *pRequestedFrom, OdTrVisTextureId textureId, void *pInternalDataPtr, void *pOriginatorPtr)
OdTrVisRenderClient * renderClient(OdTrVecDevice *pRequestFor) const
OdTrVecTtfFontsCache * ttfFontsCache(OdTrVecDevice *pDevice)
const OdTrVisRendition::ClientSettings & clientSettings(const OdTrVecDevice *pRequestFor) const
bool materialTexturesProc(OdTrVecDevice *pRequestedFor, OdTrVecDevice *pRequestedFrom, OdTrVisMaterialId materialId, void *pInternalDataPtr, void *pOriginatorPtr)
bool internalTextureProc(OdTrVecDevice *pRequestedFor, OdTrVecDevice *pRequestedFrom, OdTrVisTextureId textureId, void *pInternalDataPtr, void *pOriginatorPtr, OdTrVisTextureDef &resTexture, bool &bCreated)
static OdSmartPtr< OdTrVecResourceSharingProvider > createObject()
void(* broadcastProc)(OdDrawOrderBaseDevice *pDevice, void *pData)
virtual void closeResourceSharing(OdTrVecDevice *pDevice)
bool isResourceSharingOpened(OdTrVecDevice *pDevice) const
typedef void(APIENTRYP PFNGLACTIVETEXTUREPROC)(GLenum texture)
GLuint GLsizei GLsizei GLint GLenum * type
Definition: gles2_ext.h:274
static void attach(OdDrawOrderMetafileBase &bitSet, const OdTrVecDevice *pDevice)
static void clear(OdDrawOrderMetafileBase &bitSet)
static void compress(OdDrawOrderMetafileBase &bitSet, OdUInt32 nBit)
static bool isAttached(const OdDrawOrderMetafileBase &bitSet, const OdTrVecDevice *pDevice)
static void detach(OdDrawOrderMetafileBase &bitSet, const OdTrVecDevice *pDevice)
static void eliminate(OdDrawOrderMetafileBase &bitSet, const OdTrVecDevice *pDevice)
OdUInt8 m_flags
DeviceEntry()
DeviceEntry(OdTrVecDevice *pDevice)
OdTrVecDevice * m_pDevice
Flags
@ kConnected