CFx SDK Documentation 2026 SP0
Loading...
Searching...
No Matches
TrVisRenderClient.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2024, 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-2024 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 "TrVisSelectionStyle.h"
33#include "RxVariantValue.h"
34
36
41{
42 public:
43 virtual bool beginMeasurement() = 0;
44 virtual bool checkMeasurement() const = 0;
45 virtual bool releaseMeasurement() = 0;
46 virtual bool isMeasurementStarted() const = 0;
47
48 virtual bool pauseMeasurement( bool bPause ) = 0;
49};
50
55{
56 public:
58 {
59 kAntiAliasDisabled = 0, // Anti-aliasing disabled.
60 kAntiAliasLines = (1 << 0), // Lines anti-aliasing.
61 kAntiAliasLines3d = (1 << 1) // Lines anti-aliasing in 3d.
62 };
64 {
65 kBlendingAlphaDefault = 0, // Alpha blending without sorting (default transparency behavior).
66 kBlendingAlphaSorting, // Alpha blending with sorting from back to front using second rendering pass.
67 kBlendingMultiPassOIT, // Weighted Blended Order-Independed Transparency using multiple rendering passes.
68 kBlendingSinglePassOIT // Weighted Blended Order-Independed Transparency using multiple draw buffers.
69 };
71 {
72 kRBufFmtRGBA = 0, // RGBA direct render buffer
73 kRBufFmtRGB, // RGB direct render buffer
74 kRBufFmtBGRA, // BGRA direct render buffer
75 kRBufFmtBGR // BGR direct render buffer
76 };
77 public:
79
80 // Properties accessibility
81 virtual bool hasProperty(const OdChar *pPropName) const = 0;
82 virtual OdRxVariantValue getProperty(const OdChar *pPropName) const = 0;
83 virtual OdRxObjectPtr getPropertyObject(const OdChar *pPropName) const = 0;
84 virtual void setProperty(const OdChar *pPropName, OdRxVariantValue pValue) = 0;
85 virtual void setPropertyObject(const OdChar *pPropName, OdRxObjectPtr pValue) = 0;
86
87 // Elementary properties
88 virtual bool usePartialUpdate() const
89 { // This property isn't currently configurable through properties dictionary.
90 // It is comes from device specifics (on-screen devices prefer partial update availability,
91 // off-screen devices typically prefer work w/o partial updates).
92 //if (hasProperty(OD_T("UsePartialUpdate")))
93 // return getProperty(OD_T("UsePartialUpdate"))->getBool();
94 //if (hasProperty(OD_T("ForcePartialUpdate")))
95 // return getProperty(OD_T("ForcePartialUpdate"))->getBool();
96 return false;
97 }
98 virtual bool useCompositeMetafiles() const
99 {
100 if (hasProperty(OD_T("UseCompositeMetafiles")))
101 return getProperty(OD_T("UseCompositeMetafiles"))->getBool();
102 return false;
103 }
104 virtual bool useVisualStyles() const
105 {
106 if (hasProperty(OD_T("UseVisualStyles")))
107 return getProperty(OD_T("UseVisualStyles"))->getBool();
108 return false;
109 }
110 virtual bool useOverlays() const
111 {
112 if (hasProperty(OD_T("UseOverlays")))
113 return getProperty(OD_T("UseOverlays"))->getBool();
114 return false;
115 }
116 virtual bool useSceneGraph() const
117 {
118 if (hasProperty(OD_T("UseSceneGraph")))
119 return getProperty(OD_T("UseSceneGraph"))->getBool();
120 return false;
121 }
123 { // Configurable through GiContext.
124 return kAntiAliasDisabled;
125 }
126 virtual OdUInt32 blendingMode() const
127 {
128 if (hasProperty(OD_T("BlendingMode")))
129 return getProperty(OD_T("BlendingMode"))->getUInt32();
131 }
132 virtual bool rasterImageContentsHighlight() const
133 { // Configurable through GiContext.
134 return false;
135 }
136
137 // Output window size
138 virtual int outputWindowWidth() const = 0;
139 virtual int outputWindowHeight() const = 0;
140
141 // Direct render buffer accessibility
142 virtual bool hasDirectRenderBuffer(bool* /*bTransparent*/ = NULL) const { return false; }
143 virtual OdUInt8 *getDirectRenderBuffer(OdUInt32* /*pWidth*/, OdUInt32* /*pHeight*/, OdUInt32* /*pFormat*/ = NULL, OdUInt32* /*pAlignment*/ = NULL) { return NULL; }
144
145 // Selection/highlighting styles
146 virtual OdUInt32 getSelectionStyle(OdUInt32 nStyle, OdTrVisSelectionStyle &style) const { style.setForStippling(); return (nStyle < 1) ? 1 : 0; }
147
148 // TrueType fonts cache
149 virtual const OdTrVisTtfFontsCacheClient *ttfFontsCache() const { return NULL; }
150 virtual const OdTrVisSharingProviderClient *sharingProvider() const { return NULL; }
151
152 // Rendering process handlers
153 virtual void emitError(const char *pError) = 0;
154 virtual void emitWarning(const char *pWarn) = 0;
155
157 bool /*bAutoStart*/ = false) { return NULL; }
158};
159
164{
165 protected:
166 struct DicPair
167 {
170
172 DicPair(const OdChar *pPropName, OdRxObjectPtr pValue)
173 : m_propName(pPropName), m_pValue(pValue) { }
174 };
177 public:
179
180 OdUInt32 findProp(const OdChar *pPropName) const
181 {
182 OdUInt32 nSearchBase = 0, nSearchCur;
183 OdUInt32 nSearchLimit = m_dic.size();
184 const DicPair *pDic = m_dic.getPtr();
185 for ( ; nSearchLimit != 0; nSearchLimit >>= 1)
186 {
187 nSearchCur = nSearchBase + (nSearchLimit >> 1);
188 int nCmp = pDic[nSearchCur].m_propName.compare(pPropName);
189 if (!nCmp) return nSearchCur;
190 if (nCmp > 0) { nSearchBase = nSearchCur + 1; nSearchLimit--; }
191 }
192 return 0xFFFFFFFF;
193 }
194 OdUInt32 numProps() const { return m_dic.size(); }
195 OdRxObjectPtr getPropAt(OdUInt32 nProp) const { return m_dic[nProp].m_pValue; }
196 void setPropAt(OdUInt32 nProp, OdRxObjectPtr pValue) { m_dic[nProp].m_pValue = pValue; }
197 void killPropAt(OdUInt32 nProp) { m_dic.removeAt(nProp); }
198 bool isEmpty() { return m_dic.isEmpty(); }
199 void clear() { m_dic.clear(); }
200
201 bool hasProp(const OdChar *pPropName) const { return findProp(pPropName) != 0xFFFFFFFF; }
202 void setProp(const OdChar *pPropName, OdRxObjectPtr pValue)
203 {
204 if (m_dic.isEmpty())
205 m_dic.push_back(DicPair(pPropName, pValue));
206 else
207 {
208 OdUInt32 nSearchBase = 0, nSearchCur = 0;
209 OdUInt32 nSearchLimit = m_dic.size();
210 const DicPair *pDic = m_dic.getPtr();
211 for ( ; nSearchLimit != 0; nSearchLimit >>= 1)
212 {
213 nSearchCur = nSearchBase + (nSearchLimit >> 1);
214 int nCmp = pDic[nSearchCur].m_propName.compare(pPropName);
215 if (!nCmp) { m_dic[nSearchCur].m_pValue = pValue; return; }
216 if (nCmp > 0) { nSearchBase = nSearchCur + 1; nSearchLimit--; }
217 }
218 if (!(pDic[nSearchCur].m_propName.compare(pPropName) < 0))
219 nSearchCur++;
220 m_dic.insertAt(nSearchCur, DicPair(pPropName, pValue));
221 }
222 }
223 OdRxObjectPtr getProp(const OdChar *pPropName) const
224 {
225 OdUInt32 nProp = findProp(pPropName);
226 if (nProp == 0xFFFFFFFF) return OdRxObjectPtr();
227 return m_dic.getPtr()[nProp].m_pValue;
228 }
229 void killProp(const OdChar *pPropName)
230 {
231 OdUInt32 nProp = findProp(pPropName);
232 if (nProp != 0xFFFFFFFF) killPropAt(nProp);
233 }
234};
235
240{
241 protected:
243 public:
244 // Properties accessibility
245 virtual bool hasProperty(const OdChar *pPropName) const
246 {
247 return m_props.hasProp(pPropName);
248 }
249 virtual OdRxVariantValue getProperty(const OdChar *pPropName) const
250 {
251 return m_props.getProp(pPropName).get();
252 }
253 virtual OdRxObjectPtr getPropertyObject(const OdChar *pPropName) const
254 {
255 return m_props.getProp(pPropName);
256 }
257 virtual void setProperty(const OdChar *pPropName, OdRxVariantValue pValue)
258 {
259 m_props.setProp(pPropName, pValue);
260 }
261 virtual void setPropertyObject(const OdChar *pPropName, OdRxObjectPtr pValue)
262 {
263 m_props.setProp(pPropName, pValue);
264 }
265};
266
270template <typename RCInterface = OdTrVisRenderClient>
271class OdTrVisRenderClientWrapper : public RCInterface
272{
273 protected:
275 public:
276 OdTrVisRenderClientWrapper(OdTrVisRenderClient *pRedirection = NULL) : m_pRedirection(pRedirection) { }
277
278 bool hasRedirection() const { return m_pRedirection != NULL; }
279 void setRedirection(OdTrVisRenderClient *pRedirection) { m_pRedirection = pRedirection; }
282
283 // Properties accessibility
284 virtual bool hasProperty(const OdChar *pPropName) const
285 {
286 if (hasRedirection())
287 return redirection()->hasProperty(pPropName);
288 return false;
289 }
290 virtual OdRxVariantValue getProperty(const OdChar *pPropName) const
291 {
292 if (hasRedirection())
293 return redirection()->getProperty(pPropName);
294 return OdRxVariantValue(false);
295 }
296 virtual OdRxObjectPtr getPropertyObject(const OdChar *pPropName) const
297 {
298 if (hasRedirection())
299 return redirection()->getPropertyObject(pPropName);
300 return OdRxObjectPtr();
301 }
302 virtual void setProperty(const OdChar *pPropName, OdRxVariantValue pValue)
303 {
304 if (hasRedirection())
305 redirection()->setProperty(pPropName, pValue);
306 }
307 virtual void setPropertyObject(const OdChar *pPropName, OdRxObjectPtr pValue)
308 {
309 if (hasRedirection())
310 redirection()->setPropertyObject(pPropName, pValue);
311 }
312
313 // Elementary properties
314 virtual bool usePartialUpdate() const
315 {
316 if (hasRedirection())
317 return redirection()->usePartialUpdate();
318 return false;
319 }
320 virtual bool useCompositeMetafiles() const
321 {
322 if (hasRedirection())
324 return false;
325 }
326 virtual bool useVisualStyles() const
327 {
328 if (hasRedirection())
329 return redirection()->useVisualStyles();
330 return false;
331 }
332 virtual bool useOverlays() const
333 {
334 if (hasRedirection())
335 return redirection()->useOverlays();
336 return false;
337 }
338 virtual bool useSceneGraph() const
339 {
340 if (hasRedirection())
341 return redirection()->useSceneGraph();
342 return false;
343 }
345 {
346 if (hasRedirection())
347 return redirection()->antiAliasingMode();
349 }
350 virtual OdUInt32 blendingMode() const
351 {
352 if (hasRedirection())
353 return redirection()->blendingMode();
355 }
356 virtual bool rasterImageContentsHighlight() const
357 {
358 if (hasRedirection())
360 return false;
361 }
362
363 // Output window size
364 virtual int outputWindowWidth() const
365 {
366 if (hasRedirection())
367 return redirection()->outputWindowWidth();
368 return 0;
369 }
370 virtual int outputWindowHeight() const
371 {
372 if (hasRedirection())
374 return 0;
375 }
376
377 // Direct render buffer accessibility
378 virtual bool hasDirectRenderBuffer(bool *bTransparent = NULL) const
379 {
380 if (hasRedirection())
381 return redirection()->hasDirectRenderBuffer(bTransparent);
382 return false;
383 }
384 virtual OdUInt8 *getDirectRenderBuffer(OdUInt32* pWidth, OdUInt32* pHeight, OdUInt32* pFormat = NULL, OdUInt32* pAlignment = NULL)
385 {
386 if (hasRedirection())
387 return redirection()->getDirectRenderBuffer(pWidth, pHeight, pFormat, pAlignment);
388 return NULL;
389 }
390
391 // Selection/highlighting styles
393 {
394 if (hasRedirection())
395 return redirection()->getSelectionStyle(nStyle, style);
396 return RCInterface::getSelectionStyle(nStyle, style);
397 }
398
399 // TrueType fonts cache
401 {
402 if (hasRedirection())
403 return redirection()->ttfFontsCache();
404 return NULL;
405 }
407 {
408 if (hasRedirection())
409 return redirection()->sharingProvider();
410 return NULL;
411 }
412
413 // Rendering process handlers
414 virtual void emitError(const char *pError)
415 {
416 if (hasRedirection())
417 redirection()->emitError(pError);
418 }
419 virtual void emitWarning(const char *pWarn)
420 {
421 if (hasRedirection())
422 redirection()->emitWarning(pWarn);
423 }
424};
425
426#include "TD_PackPop.h"
427
428#endif // ODTRVISRENDERCLIENT
#define OD_T(x)
unsigned int OdUInt32
unsigned char OdUInt8
wchar_t OdChar
int compare(const OdChar *otherString) const
Definition OdString.h:328
virtual bool releaseMeasurement()=0
virtual bool isMeasurementStarted() const =0
virtual bool checkMeasurement() const =0
virtual bool beginMeasurement()=0
virtual bool pauseMeasurement(bool bPause)=0
virtual bool hasProperty(const OdChar *pPropName) const =0
virtual bool useSceneGraph() const
virtual bool hasDirectRenderBuffer(bool *=NULL) const
virtual OdTrVisRenderAbort * queryRenderAbort(const OdTrVisDirectRenderPartialUpdateInvocation *, bool=false)
virtual bool useVisualStyles() const
virtual const OdTrVisTtfFontsCacheClient * ttfFontsCache() const
virtual bool useCompositeMetafiles() const
virtual bool usePartialUpdate() const
virtual const OdTrVisSharingProviderClient * sharingProvider() const
virtual OdUInt32 antiAliasingMode() const
virtual void emitWarning(const char *pWarn)=0
virtual bool rasterImageContentsHighlight() const
virtual int outputWindowWidth() const =0
virtual OdUInt8 * getDirectRenderBuffer(OdUInt32 *, OdUInt32 *, OdUInt32 *=NULL, OdUInt32 *=NULL)
virtual OdUInt32 blendingMode() const
virtual OdRxVariantValue getProperty(const OdChar *pPropName) const =0
virtual OdUInt32 getSelectionStyle(OdUInt32 nStyle, OdTrVisSelectionStyle &style) const
virtual void setPropertyObject(const OdChar *pPropName, OdRxObjectPtr pValue)=0
virtual OdRxObjectPtr getPropertyObject(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 void setPropertyObject(const OdChar *pPropName, OdRxObjectPtr pValue)
virtual bool hasProperty(const OdChar *pPropName) const
virtual OdRxObjectPtr getPropertyObject(const OdChar *pPropName) const
virtual OdRxVariantValue getProperty(const OdChar *pPropName) const
OdRxObjectPtr getProp(const OdChar *pPropName) const
OdVector< DicPair > DicPairsArray
void setPropAt(OdUInt32 nProp, OdRxObjectPtr pValue)
void killPropAt(OdUInt32 nProp)
void setProp(const OdChar *pPropName, OdRxObjectPtr pValue)
OdRxObjectPtr getPropAt(OdUInt32 nProp) const
void killProp(const OdChar *pPropName)
bool hasProp(const OdChar *pPropName) const
OdUInt32 findProp(const OdChar *pPropName) const
virtual int outputWindowWidth() const
virtual bool useVisualStyles() const
virtual OdUInt32 getSelectionStyle(OdUInt32 nStyle, OdTrVisSelectionStyle &style) const
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 void setPropertyObject(const OdChar *pPropName, OdRxObjectPtr pValue)
virtual bool useOverlays() const
OdTrVisRenderClient * redirection() const
virtual bool rasterImageContentsHighlight() const
virtual int outputWindowHeight() const
virtual void emitError(const char *pError)
virtual const OdTrVisSharingProviderClient * sharingProvider() const
virtual OdUInt32 blendingMode() const
virtual bool useSceneGraph() const
virtual OdUInt8 * getDirectRenderBuffer(OdUInt32 *pWidth, OdUInt32 *pHeight, OdUInt32 *pFormat=NULL, OdUInt32 *pAlignment=NULL)
virtual OdRxObjectPtr getPropertyObject(const OdChar *pPropName) const
virtual bool hasDirectRenderBuffer(bool *bTransparent=NULL) const
void setRedirection(OdTrVisRenderClient *pRedirection)
OdTrVisRenderClient * m_pRedirection
virtual OdUInt32 antiAliasingMode() const
virtual const OdTrVisTtfFontsCacheClient * ttfFontsCache() const
virtual bool useCompositeMetafiles() const
DicPair(const OdChar *pPropName, OdRxObjectPtr pValue)