MCPcopy Create free account
hub / github.com/DaedalusX64/daedalus / UpdateTexture

Function UpdateTexture

Source/HLEGraphics/CachedTexture.cpp:150–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148}
149
150static void UpdateTexture( const TextureInfo & ti, CNativeTexture * texture )
151{
152 #ifdef DAEDALUS_PROFILE
153 DAEDALUS_PROFILE( "Texture Conversion" );
154 #endif
155 #ifdef DAEDALUS_ENABLE_ASSERTS
156 DAEDALUS_ASSERT( texture != nullptr, "No texture" );
157 #endif
158 if ( texture != nullptr && texture->HasData() )
159 {
160 ETextureFormat format = texture->GetFormat();
161 u32 stride {texture->GetStride()};
162
163 void * texels;
164 void * palette;
165 if( GenerateTexels( &texels, &palette, ti, format, stride, texture->GetBytesRequired() ) )
166 {
167 //
168 // Recolour the texels
169 //
170 if( ti.GetWhite() )
171 {
172 Recolour( texels, palette, ti.GetWidth(), ti.GetHeight(), stride, format, c32::White );
173 }
174
175 //
176 // Clamp edges. We do this so that non power-of-2 textures whose whose width/height
177 // is less than the mask value clamp correctly. It still doesn't fix those
178 // textures with a width which is greater than the power-of-2 size.
179 //
180 ClampTexels( texels, ti.GetWidth(), ti.GetHeight(), texture->GetCorrectedWidth(), texture->GetCorrectedHeight(), stride, format );
181
182 //
183 // Mirror the texels if required (in-place)
184 //
185 bool mirror_s {ti.GetEmulateMirrorS()};
186 bool mirror_t {ti.GetEmulateMirrorT()};
187 if( mirror_s || mirror_t )
188 {
189 MirrorTexels( mirror_s, mirror_t, texels, stride, texels, stride, format, ti.GetWidth(), ti.GetHeight() );
190 }
191
192 texture->SetData( texels, palette );
193 }
194 }
195}
196
197CachedTexture * CachedTexture::Create( const TextureInfo & ti )
198{

Callers 2

InitialiseMethod · 0.85
UpdateIfNecessaryMethod · 0.85

Calls 15

GenerateTexelsFunction · 0.85
RecolourFunction · 0.85
ClampTexelsFunction · 0.85
MirrorTexelsFunction · 0.85
GetWhiteMethod · 0.80
GetCorrectedWidthMethod · 0.80
GetCorrectedHeightMethod · 0.80
GetEmulateMirrorSMethod · 0.80
GetEmulateMirrorTMethod · 0.80
HasDataMethod · 0.45
GetFormatMethod · 0.45
GetStrideMethod · 0.45

Tested by

no test coverage detected