| 148 | } |
| 149 | |
| 150 | static 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 | |
| 197 | CachedTexture * CachedTexture::Create( const TextureInfo & ti ) |
| 198 | { |
no test coverage detected