CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
TrVecResourceSharingProvider.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2022, 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 Open Design Alliance software pursuant to a license
16// agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2022 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
36class OdTrVecDevice;
38class OdTrVecVisualStyleContainer;
39class OdTrVecLayerContainer;
40class OdTrVisMetafilesPool;
41class OdTrVisMtContext;
42
47 , public OdDrawOrderBaseDeviceMCCallback
48{
49 public:
50 // Processing device bit sets
52 {
53 // Max bit for current OS
54 static const OdUInt32 g_nMaxBit;
55 static const OdUInt32 g_nBitSys;
56 // Check does resource attached to device
57 static bool isAttached(const OdDrawOrderMetafileBase &bitSet, const OdTrVecDevice *pDevice);
58 // Attach resource to device
59 static void attach(OdDrawOrderMetafileBase &bitSet, const OdTrVecDevice *pDevice);
60 // Detach resource from device
61 static void detach(OdDrawOrderMetafileBase &bitSet, const OdTrVecDevice *pDevice);
62 // Eliminate device from bit set, compress bit set
63 static void eliminate(OdDrawOrderMetafileBase &bitSet, const OdTrVecDevice *pDevice);
64 static void compress(OdDrawOrderMetafileBase &bitSet, OdUInt32 nBit);
65 // Free bit set
66 static void clear(OdDrawOrderMetafileBase &bitSet);
67 };
68
69 typedef void (*broadcastProc)(OdDrawOrderBaseDevice *pDevice, void *pData);
70 protected:
72 {
73 enum Flags
74 {
75 kConnected = (1 << 0), // Device connected to sharing provider
76 kDeleted = (1 << 1) // Device physically deleted and haven't ability to reconnect
77 };
78
79 OdTrVecDevice *m_pDevice;
81
82 DeviceEntry() : m_pDevice(NULL), m_flags(0) { }
83 DeviceEntry(OdTrVecDevice *pDevice) : m_pDevice(pDevice), m_flags(0) { }
84 };
85 protected:
90 OdTrVecVisualStyleContainer *m_pVSCache;
91 OdTrVecLayerContainer *m_pLayerCache;
92 OdTrVisMetafilesPool *m_pMetafilesPool;
93 OdTrVisMtContext *m_pMfPoolMtCtx;
95 public:
97
100
102
103 // Opens resource sharing for device
104 virtual void openResourceSharing(OdTrVecDevice *pDevice);
105 // Close resource sharing for device
106 virtual void closeResourceSharing(OdTrVecDevice *pDevice, bool bTemporaryDisconnect = false);
107 // Check does resource sharing is opened for device
108 bool isResourceSharingOpened(OdTrVecDevice *pDevice) const;
109
110 // Returns true in case if multiple devices (sharing) enabled
111 bool hasSharedResources() const { return m_nSharedDevices > 1; }
112
113 // OdDrawOrderBaseDeviceMCCallback override
114 virtual void onDeleteRequest(onDeleteRequestProc pReqProc, void *pData);
115
116 // Broadcast function for all registered devices
117 void broadcastFunction(const OdDrawOrderMetafileBase &bitSet, broadcastProc pProc, void *pArg) const;
118
119 // Broadcast function for all devices
120 void broadcastFunctionForAll(broadcastProc pProc, void *pArg, const OdTrVecDevice *pExclusion = NULL) const;
121
122 // Ttf fonts cache support
123 OdTrVecTtfFontsCache *ttfFontsCache(OdTrVecDevice *pDevice);
124
125 // Visual Styles cache support
126 OdTrVecVisualStyleContainer *visualStylesCache(OdTrVecDevice *pDevice);
127
128 // Layers cache support
129 OdTrVecLayerContainer *layersCache(OdTrVecDevice *pDevice);
130
131 // Metafiles pool support
132 OdTrVisMetafilesPool *metafilesPool(OdTrVecDevice *pDevice);
133 void mtLockMetafilesPool(OdTrVecDevice *pDevice);
134 void mtUnlockMetafilesPool(OdTrVecDevice *pDevice);
135
136 // Server metafiles pool
137 OdRxObject *serverMetafilesPool(OdTrVecDevice *pDevice);
138 void setServerMetafilesPool(OdTrVecDevice *pDevice, OdRxObject *pMfPool);
139
140 // Find first usage device
141 OdTrVecDevice *findUsage(const OdDrawOrderMetafileBase &bitSet, OdTrVecDevice *pStartFrom = NULL) const;
142
143 // Share metafile with secondary device (base call, will be redirected to secondary override)
144 virtual bool shareMetafile(OdTrVecDevice *pRequestedFor, OdDrawOrderMetafileBase &bitSet,
145 OdTrVisMetafileId metafileId, void *pInternalDataPtr, void *pOriginatorPtr);
146
147 // Share metafiles group with secondary device (base call, will be redirected to secondary override)
148 virtual bool shareGroup(OdTrVecDevice *pRequestedFor, OdDrawOrderMetafileBase &bitSet,
149 OdTrVisGroupId groupId, void *pInternalDataPtr, void *pOriginatorPtr);
150
151 // Share texture with secondary device (base call, will be redirected to secondary override)
152 virtual bool shareTexture(OdTrVecDevice *pRequestedFor, OdDrawOrderMetafileBase &bitSet,
153 OdTrVisTextureId textureId, void *pInternalDataPtr, void *pOriginatorPtr);
154
155 // Share material with secondary device (base call, will be redirected to secondary override)
156 virtual bool shareMaterial(OdTrVecDevice *pRequestedFor, OdDrawOrderMetafileBase &bitSet,
157 OdTrVisMaterialId materialId, void *pInternalDataPtr, void *pOriginatorPtr);
158 protected:
159 // Share metafile with secondary device (should be overrided by client, do nothing by default)
160 virtual bool shareMetafile(OdTrVecDevice *pRequestedFor, OdTrVecDevice *pRequestedFrom,
161 OdTrVisMetafileId metafileId, void *pInternalDataPtr, void *pOriginatorPtr);
162 // Share metafiles group with secondary device (should be overrided by client, do nothing by default)
163 virtual bool shareGroup(OdTrVecDevice *pRequestedFor, OdTrVecDevice *pRequestedFrom,
164 OdTrVisGroupId groupId, void *pInternalDataPtr, void *pOriginatorPtr);
165 // Share texture with secondary device (should be overrided by client, do nothing by default)
166 virtual bool shareTexture(OdTrVecDevice *pRequestedFor, OdTrVecDevice *pRequestedFrom,
167 OdTrVisTextureId textureId, void *pInternalDataPtr, void *pOriginatorPtr);
168 // Share material with secondary device (should be overrided by client, do nothing by default)
169 virtual bool shareMaterial(OdTrVecDevice *pRequestedFor, OdTrVecDevice *pRequestedFrom,
170 OdTrVisMaterialId materialId, void *pInternalDataPtr, void *pOriginatorPtr);
171
172 // Low-level accessors
173
174 // Create compatible texture for device from another exist device
175 bool internalTextureProc(OdTrVecDevice *pRequestedFor, OdTrVecDevice *pRequestedFrom,
176 OdTrVisTextureId textureId, void *pInternalDataPtr, void *pOriginatorPtr,
177 OdTrVisTextureDef &resTexture, bool &bCreated);
178
179 // Initiate conversion of textures from material for device from another exist device
180 bool materialTexturesProc(OdTrVecDevice *pRequestedFor, OdTrVecDevice *pRequestedFrom,
181 OdTrVisMaterialId materialId, void *pInternalDataPtr, void *pOriginatorPtr);
182
183 // Share Id registration between devices
184 void shareIdRegistration(OdTrVecDevice *pRequestedFor, OdTrVecDevice *pRequestedFrom,
186 protected: // Helpers
187 OdTrVisRendition *rendition(OdTrVecDevice *pRequestFor) const;
188 const OdTrVisRendition::ClientSettings &clientSettings(const OdTrVecDevice *pRequestFor) const;
189 OdTrVisRenderClient *renderClient(OdTrVecDevice *pRequestFor) const;
190 OdGsDevice *gsDevice(OdTrVecDevice *pRequestFor) const;
191 public:
193 {
194 public:
196 {
202 };
203
204 virtual TypeOfResource resourceType() const = 0;
205
206 virtual OdTrVisId resourceId() const = 0;
207
208 virtual OdDrawOrderMetafileBase &resourceBitSet() = 0;
209
210 static OdRxClass *desc();
211 private:
213 static OdStaticRxObject<ResDepDesc> g_ResDepDesc;
214 };
215};
216
218
219#define OdTrVecResourceDependency_queryX(TypeOf, BaseClass) \
220 OdRxObject *queryX(const OdRxClass* pClass) const \
221 { \
222 if (pClass == OdTrVecResourceSharingProvider::ResourceDependency::desc()) \
223 return reinterpret_cast<OdRxObject*>((OdTrVecResourceSharingProvider::ResourceDependency*)this); \
224 return BaseClass::queryX(pClass); \
225 } \
226 TypeOfResource resourceType() const { return TypeOf; }
227
228#include "TD_PackPop.h"
229
230#endif // ODTRVECRESOURCESHARINGPROVIDER
int OdRefCounter
Definition: OdMutex.h:487
unsigned int OdUInt32
int OdInt32
unsigned char OdUInt8
OdSmartPtr< OdTrVecResourceSharingProvider > OdTrVecResourceSharingProviderPtr
virtual OdDrawOrderMetafileBase & resourceBitSet()=0
virtual TypeOfResource resourceType() const =0
OdGsDevice * gsDevice(OdTrVecDevice *pRequestFor) const
OdTrVisRenderClient * renderClient(OdTrVecDevice *pRequestFor) const
virtual void closeResourceSharing(OdTrVecDevice *pDevice, bool bTemporaryDisconnect=false)
void mtLockMetafilesPool(OdTrVecDevice *pDevice)
OdRxObject * serverMetafilesPool(OdTrVecDevice *pDevice)
OdTrVecLayerContainer * layersCache(OdTrVecDevice *pDevice)
void broadcastFunction(const OdDrawOrderMetafileBase &bitSet, broadcastProc pProc, void *pArg) const
OdTrVecVisualStyleContainer * m_pVSCache
OdTrVecDevice * findUsage(const OdDrawOrderMetafileBase &bitSet, OdTrVecDevice *pStartFrom=NULL) const
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)
OdTrVisRendition * rendition(OdTrVecDevice *pRequestFor) const
OdTrVecTtfFontsCache * ttfFontsCache(OdTrVecDevice *pDevice)
virtual bool shareGroup(OdTrVecDevice *pRequestedFor, OdDrawOrderMetafileBase &bitSet, OdTrVisGroupId groupId, void *pInternalDataPtr, void *pOriginatorPtr)
OdTrVecVisualStyleContainer * visualStylesCache(OdTrVecDevice *pDevice)
virtual bool shareGroup(OdTrVecDevice *pRequestedFor, OdTrVecDevice *pRequestedFrom, OdTrVisGroupId groupId, void *pInternalDataPtr, void *pOriginatorPtr)
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)
void mtUnlockMetafilesPool(OdTrVecDevice *pDevice)
void(* broadcastProc)(OdDrawOrderBaseDevice *pDevice, void *pData)
const OdTrVisRendition::ClientSettings & clientSettings(const OdTrVecDevice *pRequestFor) const
OdTrVisMetafilesPool * metafilesPool(OdTrVecDevice *pDevice)
bool isResourceSharingOpened(OdTrVecDevice *pDevice) const
static OdSmartPtr< OdTrVecResourceSharingProvider > createObject()
void setServerMetafilesPool(OdTrVecDevice *pDevice, OdRxObject *pMfPool)
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
@ kDeleted
@ kConnected