CFx SDK Documentation  2022 SP0
TrVisTexture.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 device textures
24 
25 #ifndef ODTRVISTEXTURE
26 #define ODTRVISTEXTURE
27 
28 #include "TD_PackPush.h"
29 
30 #include "TrVisDefs.h"
31 
36 class OdTrVisTexture : public OdRxObject
37 {
38 protected:
42 
44 
45 public:
49  enum Format
50  {
61  };
69  {
71  float floatRGBA[ 4 ];
72  };
77  {
79  {
80  kNone = 0,
83  };
85 
86  void prepareContext( const OdTrVisTexture* pSrc, const OdTrVisTexture* pDst );
87 
88  bool isSrcInt;
89  bool isDstInt;
92  double scalesMult[ 4 ];
93  };
94 
95  virtual ~OdTrVisTexture();
96 
97  // non-virtual part of OdTrVisTexture inline interface.
98 
99  // Typical data accessors
100  OdUInt32 getTextureWidth() const { return m_nWidth; }
101  OdUInt32 getTextureHeight() const { return m_nHeight; }
104 
105  const OdUInt8 *textureData() const { return (const OdUInt8*)m_pTextureData; }
107 
108  // Part of virtual OdTrVisTexture interface
109 
110  // 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).
111  virtual OdUInt32 subDivLimit() const = 0;
112 
113  // Typically textures store data as integers, but may as floats. So we require ability to access texture pixels similarly for all texture sub-types.
114  virtual bool isFPImage() const = 0;
115 
116  virtual void getColor(OdUInt32 nX, OdUInt32 nY, TextureColor &color) const = 0;
117  virtual void setColor( OdUInt32 nX, OdUInt32 nY, const TextureColor &color ) = 0;
118 
119  // This is also can be helpful for algorithms optimization to have accessors for entire scanlines
120  virtual void getScanline(OdUInt32 startLine, OdUInt32 linesCount, TextureColor *pScanline) const
121  {
122  for( OdUInt32 i = 0; i < linesCount; ++i )
123  {
125  for( OdUInt32 j = 0; j < getTextureWidth(); ++j )
126  {
127  getColor( j, startLine + i, pScanline[ j + offset ] );
128  }
129  }
130  }
131 
132  virtual void setScanline(OdUInt32 startLine, OdUInt32 linesCount, const TextureColor *pScanline)
133  {
134  for( OdUInt32 i = 0; i < linesCount; ++i )
135  {
137  for( OdUInt32 j = 0; j < getTextureWidth(); ++j )
138  {
139  setColor( j, startLine + i, pScanline[ j + offset ] );
140  }
141  }
142  }
143 
144  // Probably we will require color setters or etc.
145 
146  // Textures in Lut format contain color indexes. Color palette can be stored simply as another 1D texture.
147  virtual void setPalette(OdTrVisTexture *pTexture) = 0;
148  virtual OdTrVisTexture *palette() = 0;
149  virtual const OdTrVisTexture *palette() const = 0;
150 
151  // We can't rescale indexed textures with bilinear interpolation
152  virtual bool isSmoothResampleSupported() const = 0;
153 
154  virtual Format format() const = 0;
158  virtual TextureColor getMaxValues() const = 0;
162  static void prepareTextureColors( TextureColor* colors, OdUInt32 size, const TextureColorContext& context );
166  virtual void beginEditing() = 0;
167  virtual void endEditing() = 0;
168 };
169 
171 
176 {
177 public:
179  {
181  kBilinear
182  };
183 public:
191  static OdTrVisTexturePtr convert( OdTrVisTexture::Format fmt, OdTrVisTexture* pTexture, OdUInt32 nNewAlign = 0, OdTrVisTexture* pPalette = NULL );
195  static OdTrVisTexturePtr convert( OdTrVisTexture *pTextureTo, const OdTrVisTexture* pTextureFrom, Resampler method = kNearest );
199  static OdTrVisTexturePtr resample( Resampler method, OdUInt32 newWidth, OdUInt32 newHeight, OdTrVisTexture* pTexture );
203  static OdTrVisTexturePtr convertAndResample( OdTrVisTexture::Format fmt, Resampler method, OdUInt32 newWidth, OdUInt32 newHeight, OdTrVisTexture* pTexture, OdUInt32 nNewAlign = 0, OdTrVisTexture* pPalette = NULL );
207  static OdTrVisTexturePtr resamplePow2(Resampler method, bool bRequirePow2, OdTrVisTexture *pTexture, OdUInt32 nMaxSize);
212  OdTrVisTexture::Format bufferFmt, OdUInt32 bufferWidth, OdUInt32 bufferHeight, OdUInt32 bufferAlign, void* buffer, Resampler method, OdTrVisTexture* pPalette = NULL );
213 
217  static OdTrVisTexturePtr createPow2TextureFrom( OdTrVisTexture::Format fmt, bool bRequirePow2, OdUInt32 nMaxSize, OdUInt32 nAlign,
218  OdTrVisTexture::Format bufferFmt, OdUInt32 bufferWidth, OdUInt32 bufferHeight, OdUInt32 bufferAlign, void* buffer, Resampler method, OdTrVisTexture* pPalette = NULL );
219 
224  bool bOwnExistBuffer = false );
228  static bool save(OdTrVisTexture *pTexture, const OdString &fileName);
229 
230 };
231 
232 
233 #include "TD_PackPop.h"
234 
235 #endif
#define NULL
Definition: GsProperties.h:177
unsigned int OdUInt32
unsigned char OdUInt8
OdSmartPtr< OdTrVisTexture > OdTrVisTexturePtr
Definition: TrVisTexture.h:170
static void prepareTextureColors(TextureColor *colors, OdUInt32 size, const TextureColorContext &context)
OdUInt32 m_nWidth
Definition: TrVisTexture.h:39
virtual OdTrVisTexture * palette()=0
virtual void endEditing()=0
virtual void beginEditing()=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:132
OdUInt32 m_nAlignment
Definition: TrVisTexture.h:40
virtual void setColor(OdUInt32 nX, OdUInt32 nY, const TextureColor &color)=0
OdUInt32 getScanlineLength() const
Definition: TrVisTexture.h:102
virtual OdUInt32 subDivLimit() const =0
OdUInt32 m_nScanLength
Definition: TrVisTexture.h:40
void * m_pTextureData
Definition: TrVisTexture.h:41
virtual const OdTrVisTexture * palette() const =0
virtual bool isSmoothResampleSupported() const =0
const OdUInt8 * textureData() const
Definition: TrVisTexture.h:105
virtual ~OdTrVisTexture()
virtual void getScanline(OdUInt32 startLine, OdUInt32 linesCount, TextureColor *pScanline) const
Definition: TrVisTexture.h:120
OdUInt8 * textureData()
Definition: TrVisTexture.h:106
virtual Format format() const =0
OdUInt32 getDataAlignment() const
Definition: TrVisTexture.h:103
virtual bool isFPImage() const =0
OdUInt32 m_nHeight
Definition: TrVisTexture.h:39
virtual void setPalette(OdTrVisTexture *pTexture)=0
OdUInt32 getTextureHeight() const
Definition: TrVisTexture.h:101
OdUInt32 getTextureWidth() const
Definition: TrVisTexture.h:100
static bool save(OdTrVisTexture *pTexture, const OdString &fileName)
static OdTrVisTexturePtr convert(OdTrVisTexture *pTextureTo, const OdTrVisTexture *pTextureFrom, Resampler method=kNearest)
static OdTrVisTexturePtr createTextureFrom(OdTrVisTexture::Format fmt, OdUInt32 nWidth, OdUInt32 nHeight, OdUInt32 nAlign, OdTrVisTexture::Format bufferFmt, OdUInt32 bufferWidth, OdUInt32 bufferHeight, OdUInt32 bufferAlign, void *buffer, Resampler method, OdTrVisTexture *pPalette=NULL)
static OdTrVisTexturePtr resamplePow2(Resampler method, bool bRequirePow2, OdTrVisTexture *pTexture, OdUInt32 nMaxSize)
static OdTrVisTexturePtr resample(Resampler method, OdUInt32 newWidth, OdUInt32 newHeight, OdTrVisTexture *pTexture)
static OdTrVisTexturePtr createPow2TextureFrom(OdTrVisTexture::Format fmt, bool bRequirePow2, OdUInt32 nMaxSize, OdUInt32 nAlign, OdTrVisTexture::Format bufferFmt, OdUInt32 bufferWidth, OdUInt32 bufferHeight, OdUInt32 bufferAlign, void *buffer, Resampler method, OdTrVisTexture *pPalette=NULL)
static OdTrVisTexturePtr createTexture(OdTrVisTexture::Format fmt, OdUInt32 nWidth, OdUInt32 nHeight, OdUInt32 nAlign=4)
static OdTrVisTexturePtr convertAndResample(OdTrVisTexture::Format fmt, Resampler method, OdUInt32 newWidth, OdUInt32 newHeight, OdTrVisTexture *pTexture, OdUInt32 nNewAlign=0, OdTrVisTexture *pPalette=NULL)
static OdTrVisTexturePtr convert(OdTrVisTexture::Format fmt, OdTrVisTexture *pTexture, OdUInt32 nNewAlign=0, OdTrVisTexture *pPalette=NULL)
static OdTrVisTexturePtr createTextureFrom(OdTrVisTexture::Format fmt, OdUInt32 nWidth, OdUInt32 nHeight, OdUInt32 nAlign, void *buffer, OdTrVisTexture *pPalette=NULL, bool bOwnExistBuffer=false)
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)