CFx SDK Documentation  2023 SP0
TrVisRenderClient.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 render client
24 
25 #ifndef ODTRVISRENDERCLIENT
26 #define ODTRVISRENDERCLIENT
27 
28 #include "TD_PackPush.h"
29 
30 #include "TrVisDefs.h"
31 #include "TrVisRendition.h"
32 #include "RxVariantValue.h"
33 
35 
40 {
41  public:
43  {
44  kAntiAliasDisabled = 0, // Anti-aliasing disabled.
45  kAntiAliasLines = (1 << 0) // Lines anti-aliasing.
46  };
48  {
49  kBlendingAlphaDefault = 0, // Alpha blending without sorting (default transparency behavior).
50  kBlendingAlphaSorting, // Alpha blending with sorting from back to front using second rendering pass.
51  kBlendingMultiPassOIT, // Weighted Blended Order-Independed Transparency using multiple rendering passes.
52  kBlendingSinglePassOIT // Weighted Blended Order-Independed Transparency using multiple draw buffers.
53  };
55  {
56  kRBufFmtRGBA = 0, // RGBA direct render buffer
57  kRBufFmtRGB, // RGB direct render buffer
58  kRBufFmtBGRA, // BGRA direct render buffer
59  kRBufFmtBGR // BGR direct render buffer
60  };
61  public:
62  // Properties accessibility
63  virtual bool hasProperty(const OdChar *pPropName) const = 0;
64  virtual OdRxVariantValue getProperty(const OdChar *pPropName) const = 0;
65  virtual void setProperty(const OdChar *pPropName, OdRxVariantValue pValue) = 0;
66 
67  // Elementary properties
68  virtual bool usePartialUpdate() const
69  { // This property isn't currently configurable through properties dictionary.
70  // It is comes from device specifics (on-screen devices prefer partial update availability,
71  // off-screen devices typically prefer work w/o partial updates).
72  //if (hasProperty(OD_T("UsePartialUpdate")))
73  // return getProperty(OD_T("UsePartialUpdate"))->getBool();
74  //if (hasProperty(OD_T("ForcePartialUpdate")))
75  // return getProperty(OD_T("ForcePartialUpdate"))->getBool();
76  return false;
77  }
78  virtual bool useCompositeMetafiles() const
79  {
80  if (hasProperty(OD_T("UseCompositeMetafiles")))
81  return getProperty(OD_T("UseCompositeMetafiles"))->getBool();
82  return false;
83  }
84  virtual bool useVisualStyles() const
85  {
86  if (hasProperty(OD_T("UseVisualStyles")))
87  return getProperty(OD_T("UseVisualStyles"))->getBool();
88  return false;
89  }
90  virtual bool useOverlays() const
91  {
92  if (hasProperty(OD_T("UseOverlays")))
93  return getProperty(OD_T("UseOverlays"))->getBool();
94  return false;
95  }
96  virtual bool useSceneGraph() const
97  {
98  if (hasProperty(OD_T("UseSceneGraph")))
99  return getProperty(OD_T("UseSceneGraph"))->getBool();
100  return false;
101  }
102  virtual OdUInt32 antiAliasingMode() const
103  { // Configurable through GiContext.
104  return kAntiAliasDisabled;
105  }
106  virtual OdUInt32 blendingMode() const
107  {
108  if (hasProperty(OD_T("BlendingMode")))
109  return getProperty(OD_T("BlendingMode"))->getUInt32();
110  return kBlendingAlphaDefault;
111  }
112 
113  // Output window size
114  virtual int outputWindowWidth() const = 0;
115  virtual int outputWindowHeight() const = 0;
116 
117  // Direct render buffer accessibility
118  virtual bool hasDirectRenderBuffer() const { return false; }
119  virtual OdUInt8 *getDirectRenderBuffer(OdUInt32* /*pWidth*/, OdUInt32* /*pHeight*/, OdUInt32* /*pFormat*/ = NULL, OdUInt32* /*pAlignment*/ = NULL) { return NULL; }
120 
121  // TrueType fonts cache
122  virtual const OdTrVisTtfFontsCacheClient *ttfFontsCache() const { return NULL; }
123  virtual const OdTrVisSharingProviderClient *sharingProvider() const { return NULL; }
124 
125  // Rendering process handlers
126  virtual void emitError(const char *pError) = 0;
127  virtual void emitWarning(const char *pWarn) = 0;
128 
129  virtual ~OdTrVisRenderClient() {}
130 };
131 
136 {
137  protected:
138  struct DicPair
139  {
142 
144  DicPair(const OdChar *pPropName, OdRxVariantValue pValue)
145  : m_propName(pPropName), m_pValue(pValue) { }
146  };
149  public:
151 
152  OdUInt32 findProp(const OdChar *pPropName) const
153  {
154  OdUInt32 nSearchBase = 0, nSearchCur;
155  OdUInt32 nSearchLimit = m_dic.size();
156  const DicPair *pDic = m_dic.getPtr();
157  for ( ; nSearchLimit != 0; nSearchLimit >>= 1)
158  {
159  nSearchCur = nSearchBase + (nSearchLimit >> 1);
160  int nCmp = pDic[nSearchCur].m_propName.compare(pPropName);
161  if (!nCmp) return nSearchCur;
162  if (nCmp > 0) { nSearchBase = nSearchCur + 1; nSearchLimit--; }
163  }
164  return 0xFFFFFFFF;
165  }
166  OdUInt32 numProps() const { return m_dic.size(); }
167  OdRxVariantValue getPropAt(OdUInt32 nProp) const { return m_dic[nProp].m_pValue; }
168  void setPropAt(OdUInt32 nProp, OdRxVariantValue pValue) { m_dic[nProp].m_pValue = pValue; }
169  void killPropAt(OdUInt32 nProp) { m_dic.removeAt(nProp); }
170  bool isEmpty() { return m_dic.isEmpty(); }
171  void clear() { m_dic.clear(); }
172 
173  bool hasProp(const OdChar *pPropName) const { return findProp(pPropName) != 0xFFFFFFFF; }
174  void setProp(const OdChar *pPropName, OdRxVariantValue pValue)
175  {
176  if (m_dic.isEmpty())
177  m_dic.push_back(DicPair(pPropName, pValue));
178  else
179  {
180  OdUInt32 nSearchBase = 0, nSearchCur = 0;
181  OdUInt32 nSearchLimit = m_dic.size();
182  const DicPair *pDic = m_dic.getPtr();
183  for ( ; nSearchLimit != 0; nSearchLimit >>= 1)
184  {
185  nSearchCur = nSearchBase + (nSearchLimit >> 1);
186  int nCmp = pDic[nSearchCur].m_propName.compare(pPropName);
187  if (!nCmp) { m_dic[nSearchCur].m_pValue = pValue; return; }
188  if (nCmp > 0) { nSearchBase = nSearchCur + 1; nSearchLimit--; }
189  }
190  if (!(pDic[nSearchCur].m_propName.compare(pPropName) < 0))
191  nSearchCur++;
192  m_dic.insertAt(nSearchCur, DicPair(pPropName, pValue));
193  }
194  }
195  OdRxVariantValue getProp(const OdChar *pPropName) const
196  {
197  OdUInt32 nProp = findProp(pPropName);
198  if (nProp == 0xFFFFFFFF) return OdRxVariantValue(false);
199  return m_dic.getPtr()[nProp].m_pValue;
200  }
201  void killProp(const OdChar *pPropName)
202  {
203  OdUInt32 nProp = findProp(pPropName);
204  if (nProp != 0xFFFFFFFF) killPropAt(nProp);
205  }
206 };
207 
212 {
213  protected:
215  public:
216  // Properties accessibility
217  virtual bool hasProperty(const OdChar *pPropName) const
218  {
219  return m_props.hasProp(pPropName);
220  }
221  virtual OdRxVariantValue getProperty(const OdChar *pPropName) const
222  {
223  return m_props.getProp(pPropName);
224  }
225  virtual void setProperty(const OdChar *pPropName, OdRxVariantValue pValue)
226  {
227  m_props.setProp(pPropName, pValue);
228  }
229 };
230 
234 template <typename RCInterface = OdTrVisRenderClient>
235 class OdTrVisRenderClientWrapper : public RCInterface
236 {
237  protected:
239  public:
241 
242  bool hasRedirection() const { return m_pRedirection != NULL; }
243  void setRedirection(OdTrVisRenderClient *pRedirection) { m_pRedirection = pRedirection; }
246 
247  // Properties accessibility
248  virtual bool hasProperty(const OdChar *pPropName) const
249  {
250  if (hasRedirection())
251  return redirection()->hasProperty(pPropName);
252  return false;
253  }
254  virtual OdRxVariantValue getProperty(const OdChar *pPropName) const
255  {
256  if (hasRedirection())
257  return redirection()->getProperty(pPropName);
258  return OdRxVariantValue(false);
259  }
260  virtual void setProperty(const OdChar *pPropName, OdRxVariantValue pValue)
261  {
262  if (hasRedirection())
263  redirection()->setProperty(pPropName, pValue);
264  }
265 
266  // Elementary properties
267  virtual bool usePartialUpdate() const
268  {
269  if (hasRedirection())
270  return redirection()->usePartialUpdate();
271  return false;
272  }
273  virtual bool useCompositeMetafiles() const
274  {
275  if (hasRedirection())
277  return false;
278  }
279  virtual bool useVisualStyles() const
280  {
281  if (hasRedirection())
282  return redirection()->useVisualStyles();
283  return false;
284  }
285  virtual bool useOverlays() const
286  {
287  if (hasRedirection())
288  return redirection()->useOverlays();
289  return false;
290  }
291  virtual bool useSceneGraph() const
292  {
293  if (hasRedirection())
294  return redirection()->useSceneGraph();
295  return false;
296  }
297  virtual OdUInt32 antiAliasingMode() const
298  {
299  if (hasRedirection())
300  return redirection()->antiAliasingMode();
302  }
303  virtual OdUInt32 blendingMode() const
304  {
305  if (hasRedirection())
306  return redirection()->blendingMode();
308  }
309 
310  // Output window size
311  virtual int outputWindowWidth() const
312  {
313  if (hasRedirection())
314  return redirection()->outputWindowWidth();
315  return 0;
316  }
317  virtual int outputWindowHeight() const
318  {
319  if (hasRedirection())
320  return redirection()->outputWindowHeight();
321  return 0;
322  }
323 
324  // Direct render buffer accessibility
325  virtual bool hasDirectRenderBuffer() const
326  {
327  if (hasRedirection())
329  return false;
330  }
331  virtual OdUInt8 *getDirectRenderBuffer(OdUInt32* pWidth, OdUInt32* pHeight, OdUInt32* pFormat = NULL, OdUInt32* pAlignment = NULL)
332  {
333  if (hasRedirection())
334  return redirection()->getDirectRenderBuffer(pWidth, pHeight, pFormat, pAlignment);
335  return NULL;
336  }
337 
338  // TrueType fonts cache
340  {
341  if (hasRedirection())
342  return redirection()->ttfFontsCache();
343  return NULL;
344  }
346  {
347  if (hasRedirection())
348  return redirection()->sharingProvider();
349  return NULL;
350  }
351 
352  // Rendering process handlers
353  virtual void emitError(const char *pError)
354  {
355  if (hasRedirection())
356  redirection()->emitError(pError);
357  }
358  virtual void emitWarning(const char *pWarn)
359  {
360  if (hasRedirection())
361  redirection()->emitWarning(pWarn);
362  }
363 };
364 
365 
366 #include "TD_PackPop.h"
367 
368 #endif // ODTRVISRENDERCLIENT
false
Definition: DimVarDefs.h:165
#define NULL
Definition: GsProperties.h:177
#define OD_T(x)
unsigned int OdUInt32
unsigned char OdUInt8
wchar_t OdChar
int compare(const OdChar *otherString) const
Definition: OdString.h:319
virtual bool hasProperty(const OdChar *pPropName) const =0
virtual bool useSceneGraph() const
virtual bool hasDirectRenderBuffer() const
virtual bool useVisualStyles() const
virtual OdUInt8 * getDirectRenderBuffer(OdUInt32 *, OdUInt32 *, OdUInt32 *=NULL, OdUInt32 *=NULL)
virtual bool useCompositeMetafiles() const
virtual bool usePartialUpdate() const
virtual OdUInt32 antiAliasingMode() const
virtual const OdTrVisSharingProviderClient * sharingProvider() const
virtual const OdTrVisTtfFontsCacheClient * ttfFontsCache() const
virtual void emitWarning(const char *pWarn)=0
virtual int outputWindowWidth() const =0
virtual OdUInt32 blendingMode() const
virtual OdRxVariantValue getProperty(const OdChar *pPropName) const =0
virtual bool useOverlays() const
virtual int outputWindowHeight() const =0
virtual void emitError(const char *pError)=0
virtual void setProperty(const OdChar *pPropName, OdRxVariantValue pValue)=0
virtual void setProperty(const OdChar *pPropName, OdRxVariantValue pValue)
OdTrVisRenderClientPropsDic m_props
virtual bool hasProperty(const OdChar *pPropName) const
virtual OdRxVariantValue getProperty(const OdChar *pPropName) const
OdRxVariantValue getPropAt(OdUInt32 nProp) const
void setProp(const OdChar *pPropName, OdRxVariantValue pValue)
OdVector< DicPair > DicPairsArray
OdRxVariantValue getProp(const OdChar *pPropName) const
void killPropAt(OdUInt32 nProp)
void killProp(const OdChar *pPropName)
bool hasProp(const OdChar *pPropName) const
OdUInt32 findProp(const OdChar *pPropName) const
void setPropAt(OdUInt32 nProp, OdRxVariantValue pValue)
virtual int outputWindowWidth() const
virtual bool useVisualStyles() const
virtual OdUInt8 * getDirectRenderBuffer(OdUInt32 *pWidth, OdUInt32 *pHeight, OdUInt32 *pFormat=NULL, OdUInt32 *pAlignment=NULL)
virtual void emitWarning(const char *pWarn)
virtual void setProperty(const OdChar *pPropName, OdRxVariantValue pValue)
OdTrVisRenderClientWrapper(OdTrVisRenderClient *pRedirection=NULL)
virtual bool usePartialUpdate() const
virtual bool hasProperty(const OdChar *pPropName) const
virtual OdRxVariantValue getProperty(const OdChar *pPropName) const
virtual const OdTrVisTtfFontsCacheClient * ttfFontsCache() const
virtual bool useOverlays() const
virtual int outputWindowHeight() const
virtual void emitError(const char *pError)
virtual OdUInt32 blendingMode() const
virtual bool useSceneGraph() const
virtual bool hasDirectRenderBuffer() const
void setRedirection(OdTrVisRenderClient *pRedirection)
OdTrVisRenderClient * m_pRedirection
OdTrVisRenderClient * redirection() const
virtual OdUInt32 antiAliasingMode() const
virtual const OdTrVisSharingProviderClient * sharingProvider() const
virtual bool useCompositeMetafiles() const
void clear()
Definition: OdVector.h:920
void push_back(const T &value)
Definition: OdVector.h:926
OdVector & insertAt(size_type index, const T &value)
Definition: OdVector.h:750
size_type size() const
Definition: OdVector.h:866
const T * getPtr() const
Definition: OdVector.h:976
bool isEmpty() const
Definition: OdVector.h:946
OdVector & removeAt(size_type index)
Definition: OdVector.h:779
DicPair(const OdChar *pPropName, OdRxVariantValue pValue)