CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
TrVisTexture.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 textures
24
25#ifndef ODTRVISTEXTURE
26#define ODTRVISTEXTURE
27
28#include "TD_PackPush.h"
29
30#include "TrVisDefs.h"
31
37{
38protected:
42
44
45public:
49 enum Format
50 { // Basic 8 bit formats
59
60 //Depth/Stencil
63 kDepth24Stencil8,//Most used depth format. getColor() returns only depth value. For stencil data use textureData() function
65
66 //16 bit
71
72 //Float
79
80 //Signed normalized
89
91 };
99 {
101 float floatRGBA[ 4 ];
102 };
107 {
109 {
110 kNone = 0,
113 };
115
116 void prepareContext( const OdTrVisTexture* pSrc, const OdTrVisTexture* pDst );
117
122 double scalesMult[ 4 ];
123 };
124
126
127 // non-virtual part of OdTrVisTexture inline interface.
128
129 // Typical data accessors
134
135 const OdUInt8 *textureData() const { return (const OdUInt8*)m_pTextureData; }
137
138 // Part of virtual OdTrVisTexture interface
139
140 // Some types of texture formats can have limitation (for example S3TC - DXT formats require consists from 4x4 blocks, so texture size must be divideable by 4).
141 virtual OdUInt32 subDivLimit() const = 0;
142
143 // Typically textures store data as integers, but may as floats. So we require ability to access texture pixels similarly for all texture sub-types.
144 virtual bool isFPImage() const = 0;
145
146 virtual void getColor(OdUInt32 nX, OdUInt32 nY, TextureColor &color) const = 0;
147 virtual void setColor( OdUInt32 nX, OdUInt32 nY, const TextureColor &color ) = 0;
148
149 // This is also can be helpful for algorithms optimization to have accessors for entire scanlines
150 virtual void getScanline(OdUInt32 startLine, OdUInt32 linesCount, TextureColor *pScanline) const
151 {
152 for( OdUInt32 i = 0; i < linesCount; ++i )
153 {
155 for( OdUInt32 j = 0; j < getTextureWidth(); ++j )
156 {
157 getColor( j, startLine + i, pScanline[ j + offset ] );
158 }
159 }
160 }
161
162 virtual void setScanline(OdUInt32 startLine, OdUInt32 linesCount, const TextureColor *pScanline)
163 {
164 for( OdUInt32 i = 0; i < linesCount; ++i )
165 {
167 for( OdUInt32 j = 0; j < getTextureWidth(); ++j )
168 {
169 setColor( j, startLine + i, pScanline[ j + offset ] );
170 }
171 }
172 }
173
174 // Probably we will require color setters or etc.
175
176 // Textures in Lut format contain color indexes. Color palette can be stored simply as another 1D texture.
177 virtual void setPalette(const OdTrVisTexture *pTexture) = 0;
178 virtual OdTrVisTexture *palette() = 0;
179 virtual const OdTrVisTexture *palette() const = 0;
180
181 // We can't rescale indexed textures with bilinear interpolation
182 virtual bool isSmoothResampleSupported() const = 0;
183
184 virtual Format format() const = 0;
185
189 virtual OdUInt32 pixelSize() const = 0;
190
194 virtual TextureColor getMaxValues() const = 0;
198 virtual TextureColor getMinValues() const;
202 static void prepareTextureColors( TextureColor* colors, OdUInt32 size, const TextureColorContext& context );
206 virtual void beginEditing() = 0;
207 virtual void endEditing() = 0;
208};
209
211
216{
217public:
219 {
222 };
223public:
231 static OdTrVisTexturePtr convert( OdTrVisTexture::Format fmt, const OdTrVisTexture* pTexture, OdUInt32 nNewAlign = 0, const OdTrVisTexture* pPalette = NULL );
235 static OdTrVisTexturePtr convert( OdTrVisTexture *pTextureTo, const OdTrVisTexture* pTextureFrom, Resampler method = kNearest );
239 static void negateTexture(OdTrVisTexture* pTexture);
243 static OdTrVisTexturePtr negate(const OdTrVisTexture* pTexture);
247 static void grayscaleTexture(OdTrVisTexture* pTexture, OdUInt32 nApplyComponent = 7);
251 static OdTrVisTexturePtr grayscale(const OdTrVisTexture* pTexture, OdUInt32 nApplyComponent = 7);
255 static void blurTexture(OdTrVisTexture* pTexture, OdUInt32 nSizeKernel = 3, float fKernelMultiplier = 1.0f);
259 static OdTrVisTexturePtr blur(const OdTrVisTexture* pTexture, OdUInt32 nSizeKernel = 3, float fKernelMultiplier = 1.0f);
263 static void sphereMapTexture(OdTrVisTexture *pTexture, const OdTrVisTexture *pRightTexture, const OdTrVisTexture *pLeftTexture,
264 const OdTrVisTexture *pTopTexture, const OdTrVisTexture *pBottomTexture, const OdTrVisTexture *pFrontTexture,
265 const OdTrVisTexture *pBackTexture, int antiAliasLevel = 1, bool bSineCorrection = false);
269 static OdTrVisTexturePtr sphereMap(const OdTrVisTexture *pRightTexture, const OdTrVisTexture *pLeftTexture, const OdTrVisTexture *pTopTexture,
270 const OdTrVisTexture *pBottomTexture, const OdTrVisTexture *pFrontTexture, const OdTrVisTexture *pBackTexture,
271 int antiAliasLevel = 1, bool bSineCorrection = false);
276 { float m_coef[4];
277 ChannelMapping &set(float redMap, float greenMap, float blueMap, float alphaMap)
278 { m_coef[0] = redMap; m_coef[1] = greenMap; m_coef[2] = blueMap; m_coef[3] = alphaMap; return *this; }
279 explicit ChannelMapping(float redMap = 0.0f, float greenMap = 0.0f, float blueMap = 0.0, float alphaMap = 0.0)
280 { set(redMap, greenMap, blueMap, alphaMap); } };
284 static void remapTextureChannels(OdTrVisTexture* pTexture, const ChannelMapping &redMap = ChannelMapping(1.0f),
285 const ChannelMapping &greenMap = ChannelMapping(0.0f, 1.0f), const ChannelMapping &blueMap = ChannelMapping(0.0f, 0.0f, 1.0f),
286 const ChannelMapping &alphaMap = ChannelMapping(0.0f, 0.0f, 0.0f, 1.0f));
290 static OdTrVisTexturePtr mapChannels(const OdTrVisTexture* pTexture, const ChannelMapping &redMap = ChannelMapping(1.0f),
291 const ChannelMapping &greenMap = ChannelMapping(0.0f, 1.0f), const ChannelMapping &blueMap = ChannelMapping(0.0f, 0.0f, 1.0f),
292 const ChannelMapping &alphaMap = ChannelMapping(0.0f, 0.0f, 0.0f, 1.0f));
296 static OdTrVisTexturePtr clone(const OdTrVisTexture* pTexture);
300 static OdTrVisTexturePtr resample( Resampler method, OdUInt32 newWidth, OdUInt32 newHeight, const OdTrVisTexture* pTexture );
304 static OdTrVisTexturePtr convertAndResample( OdTrVisTexture::Format fmt, Resampler method, OdUInt32 newWidth, OdUInt32 newHeight, const OdTrVisTexture* pTexture, OdUInt32 nNewAlign = 0, const OdTrVisTexture* pPalette = NULL );
308 static OdTrVisTexturePtr resamplePow2(Resampler method, bool bRequirePow2, const OdTrVisTexture *pTexture, OdUInt32 nMaxSize);
313 OdTrVisTexture::Format bufferFmt, OdUInt32 bufferWidth, OdUInt32 bufferHeight, OdUInt32 bufferAlign, const void* buffer, Resampler method, const OdTrVisTexture* pPalette = NULL );
314
318 static OdTrVisTexturePtr createPow2TextureFrom( OdTrVisTexture::Format fmt, bool bRequirePow2, OdUInt32 nMaxSize, OdUInt32 nAlign,
319 OdTrVisTexture::Format bufferFmt, OdUInt32 bufferWidth, OdUInt32 bufferHeight, OdUInt32 bufferAlign, const void* buffer, Resampler method, const OdTrVisTexture* pPalette = NULL );
320
324 static OdTrVisTexturePtr createTextureFrom( OdTrVisTexture::Format fmt, OdUInt32 nWidth, OdUInt32 nHeight, OdUInt32 nAlign, const void* buffer, const OdTrVisTexture* pPalette = NULL,
325 bool bOwnExistBuffer = false );
329 static bool pow2ResampleDimensions( OdUInt32 &nResultWidth, OdUInt32 &nResultHeight, OdUInt32 nInWidth, OdUInt32 nInHeight, bool bRequirePow2, OdUInt32 nMaxSize );
333 static bool save(const OdTrVisTexture *pTexture, const OdString &fileName);
334
335};
336
337
338#include "TD_PackPop.h"
339
340#endif
unsigned int OdUInt32
unsigned char OdUInt8
OdSmartPtr< OdTrVisTexture > OdTrVisTexturePtr
Definition: TrVisTexture.h:210
static void prepareTextureColors(TextureColor *colors, OdUInt32 size, const TextureColorContext &context)
OdUInt8 * textureData()
Definition: TrVisTexture.h:136
OdUInt32 m_nWidth
Definition: TrVisTexture.h:39
virtual void endEditing()=0
virtual void beginEditing()=0
virtual const OdTrVisTexture * palette() const =0
virtual TextureColor getMaxValues() const =0
virtual void getColor(OdUInt32 nX, OdUInt32 nY, TextureColor &color) const =0
virtual void setScanline(OdUInt32 startLine, OdUInt32 linesCount, const TextureColor *pScanline)
Definition: TrVisTexture.h:162
OdUInt32 m_nAlignment
Definition: TrVisTexture.h:40
virtual OdTrVisTexture * palette()=0
virtual void setColor(OdUInt32 nX, OdUInt32 nY, const TextureColor &color)=0
virtual TextureColor getMinValues() const
OdUInt32 getScanlineLength() const
Definition: TrVisTexture.h:132
virtual OdUInt32 subDivLimit() const =0
OdUInt32 m_nScanLength
Definition: TrVisTexture.h:40
void * m_pTextureData
Definition: TrVisTexture.h:41
virtual OdUInt32 pixelSize() const =0
virtual bool isSmoothResampleSupported() const =0
virtual ~OdTrVisTexture()
virtual void getScanline(OdUInt32 startLine, OdUInt32 linesCount, TextureColor *pScanline) const
Definition: TrVisTexture.h:150
const OdUInt8 * textureData() const
Definition: TrVisTexture.h:135
virtual Format format() const =0
OdUInt32 getDataAlignment() const
Definition: TrVisTexture.h:133
virtual void setPalette(const OdTrVisTexture *pTexture)=0
virtual bool isFPImage() const =0
OdUInt32 m_nHeight
Definition: TrVisTexture.h:39
OdUInt32 getTextureHeight() const
Definition: TrVisTexture.h:131
OdUInt32 getTextureWidth() const
Definition: TrVisTexture.h:130
static bool save(const OdTrVisTexture *pTexture, const OdString &fileName)
static OdTrVisTexturePtr convert(OdTrVisTexture *pTextureTo, const OdTrVisTexture *pTextureFrom, Resampler method=kNearest)
static OdTrVisTexturePtr blur(const OdTrVisTexture *pTexture, OdUInt32 nSizeKernel=3, float fKernelMultiplier=1.0f)
static OdTrVisTexturePtr convertAndResample(OdTrVisTexture::Format fmt, Resampler method, OdUInt32 newWidth, OdUInt32 newHeight, const OdTrVisTexture *pTexture, OdUInt32 nNewAlign=0, const OdTrVisTexture *pPalette=NULL)
static OdTrVisTexturePtr createTextureFrom(OdTrVisTexture::Format fmt, OdUInt32 nWidth, OdUInt32 nHeight, OdUInt32 nAlign, OdTrVisTexture::Format bufferFmt, OdUInt32 bufferWidth, OdUInt32 bufferHeight, OdUInt32 bufferAlign, const void *buffer, Resampler method, const OdTrVisTexture *pPalette=NULL)
static OdTrVisTexturePtr mapChannels(const OdTrVisTexture *pTexture, const ChannelMapping &redMap=ChannelMapping(1.0f), const ChannelMapping &greenMap=ChannelMapping(0.0f, 1.0f), const ChannelMapping &blueMap=ChannelMapping(0.0f, 0.0f, 1.0f), const ChannelMapping &alphaMap=ChannelMapping(0.0f, 0.0f, 0.0f, 1.0f))
static OdTrVisTexturePtr createTextureFrom(OdTrVisTexture::Format fmt, OdUInt32 nWidth, OdUInt32 nHeight, OdUInt32 nAlign, const void *buffer, const OdTrVisTexture *pPalette=NULL, bool bOwnExistBuffer=false)
static void grayscaleTexture(OdTrVisTexture *pTexture, OdUInt32 nApplyComponent=7)
static void remapTextureChannels(OdTrVisTexture *pTexture, const ChannelMapping &redMap=ChannelMapping(1.0f), const ChannelMapping &greenMap=ChannelMapping(0.0f, 1.0f), const ChannelMapping &blueMap=ChannelMapping(0.0f, 0.0f, 1.0f), const ChannelMapping &alphaMap=ChannelMapping(0.0f, 0.0f, 0.0f, 1.0f))
static void blurTexture(OdTrVisTexture *pTexture, OdUInt32 nSizeKernel=3, float fKernelMultiplier=1.0f)
static bool pow2ResampleDimensions(OdUInt32 &nResultWidth, OdUInt32 &nResultHeight, OdUInt32 nInWidth, OdUInt32 nInHeight, bool bRequirePow2, OdUInt32 nMaxSize)
static void sphereMapTexture(OdTrVisTexture *pTexture, const OdTrVisTexture *pRightTexture, const OdTrVisTexture *pLeftTexture, const OdTrVisTexture *pTopTexture, const OdTrVisTexture *pBottomTexture, const OdTrVisTexture *pFrontTexture, const OdTrVisTexture *pBackTexture, int antiAliasLevel=1, bool bSineCorrection=false)
static OdTrVisTexturePtr createTexture(OdTrVisTexture::Format fmt, OdUInt32 nWidth, OdUInt32 nHeight, OdUInt32 nAlign=4)
static OdTrVisTexturePtr sphereMap(const OdTrVisTexture *pRightTexture, const OdTrVisTexture *pLeftTexture, const OdTrVisTexture *pTopTexture, const OdTrVisTexture *pBottomTexture, const OdTrVisTexture *pFrontTexture, const OdTrVisTexture *pBackTexture, int antiAliasLevel=1, bool bSineCorrection=false)
static OdTrVisTexturePtr grayscale(const OdTrVisTexture *pTexture, OdUInt32 nApplyComponent=7)
static OdTrVisTexturePtr negate(const OdTrVisTexture *pTexture)
static OdTrVisTexturePtr convert(OdTrVisTexture::Format fmt, const OdTrVisTexture *pTexture, OdUInt32 nNewAlign=0, const OdTrVisTexture *pPalette=NULL)
static OdTrVisTexturePtr createPow2TextureFrom(OdTrVisTexture::Format fmt, bool bRequirePow2, OdUInt32 nMaxSize, OdUInt32 nAlign, OdTrVisTexture::Format bufferFmt, OdUInt32 bufferWidth, OdUInt32 bufferHeight, OdUInt32 bufferAlign, const void *buffer, Resampler method, const OdTrVisTexture *pPalette=NULL)
static OdTrVisTexturePtr resamplePow2(Resampler method, bool bRequirePow2, const OdTrVisTexture *pTexture, OdUInt32 nMaxSize)
static OdTrVisTexturePtr resample(Resampler method, OdUInt32 newWidth, OdUInt32 newHeight, const OdTrVisTexture *pTexture)
static void negateTexture(OdTrVisTexture *pTexture)
static OdTrVisTexturePtr clone(const OdTrVisTexture *pTexture)
GLuint buffer
Definition: gles2_ext.h:178
GLsizeiptr size
Definition: gles2_ext.h:182
GLintptr offset
Definition: gles2_ext.h:183
void prepareContext(const OdTrVisTexture *pSrc, const OdTrVisTexture *pDst)
ChannelMapping(float redMap=0.0f, float greenMap=0.0f, float blueMap=0.0, float alphaMap=0.0)
Definition: TrVisTexture.h:279
ChannelMapping & set(float redMap, float greenMap, float blueMap, float alphaMap)
Definition: TrVisTexture.h:277