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