2 Commits
Author SHA1 Message Date
SSimco 93b2c73e0c Fixed folder deletion 2024-09-27 02:01:55 +03:00
SSimco 0c05c3e87f Fix bc5 decoding 2024-09-27 01:41:35 +03:00
3 changed files with 42 additions and 18 deletions
+4 -3
View File
@@ -46,6 +46,7 @@ void decodeBC3Block_UNORM(uint8* inputData, float* imageRGBA);
void decodeBC4Block_UNORM(uint8* blockStorage, float* rOutput);
void decodeBC5Block_UNORM(uint8* blockStorage, float* rgOutput);
void decodeBC5Block_SNORM(uint8* blockStorage, float* rgOutput);
using decodingFn = void (uint8 *, float *);
inline void BC1_GetPixel(uint8* inputData, sint32 x, sint32 y, uint8 rgba[4])
{
@@ -2171,8 +2172,8 @@ public:
*(outputPixel + 3) = 255;
}
};
class TextureDecoder_BC5_To_R8G8 : public TextureDecoder, public SingletonClass<TextureDecoder_BC5_To_R8G8>
template<decodingFn fn>
class TextureDecoder_BC5_To_R8G8 : public TextureDecoder, public SingletonClass<TextureDecoder_BC5_To_R8G8<fn>>
{
public:
@@ -2192,7 +2193,7 @@ public:
sint32 blockSizeY = (std::min)(4, textureLoader->height - y);
// decode 4x4 pixels at once
float rgBlock[4 * 4 * 2];
decodeBC5Block_UNORM(blockData, rgBlock);
fn(blockData, rgBlock);
for (sint32 py = 0; py < blockSizeY; py++)
{
@@ -2579,7 +2579,7 @@ void VulkanRenderer::GetTextureFormatInfoVK(Latte::E_GX2SURFFMT format, bool isD
else
{
formatInfoOut->vkImageFormat = VK_FORMAT_R8G8_UNORM;
formatInfoOut->decoder = TextureDecoder_BC5_To_R8G8::getInstance();
formatInfoOut->decoder = TextureDecoder_BC5_To_R8G8<decodeBC5Block_UNORM>::getInstance();
}
break;
case Latte::E_GX2SURFFMT::BC5_SNORM:
@@ -2591,7 +2591,7 @@ void VulkanRenderer::GetTextureFormatInfoVK(Latte::E_GX2SURFFMT format, bool isD
else
{
formatInfoOut->vkImageFormat = VK_FORMAT_R8G8_SNORM;
formatInfoOut->decoder = TextureDecoder_BC5_To_R8G8::getInstance();
formatInfoOut->decoder = TextureDecoder_BC5_To_R8G8<decodeBC5Block_SNORM>::getInstance();
}
break;
case Latte::E_GX2SURFFMT::R24_X8_UNORM:
@@ -112,8 +112,29 @@ public class DocumentsProvider extends android.provider.DocumentsProvider {
@Override
public void deleteDocument(String documentId) throws FileNotFoundException {
var file = getFile(documentId);
if (file.isDirectory()) {
deleteFolder(file);
return;
}
if (!file.delete())
throw new FileNotFoundException("Couldn't delete document with ID '$documentId'");
throw new FileNotFoundException("Couldn't delete document with ID " + documentId);
}
private void deleteFolder(File dirFile) throws FileNotFoundException {
if (!dirFile.isDirectory())
return;
var files = dirFile.listFiles();
if (files == null) return;
for (var file : files) {
if (file.isDirectory()) {
deleteFolder(file);
continue;
}
if (!file.delete())
throw new FileNotFoundException("Couldn't delete file " + file.getPath());
}
if (!dirFile.delete())
throw new FileNotFoundException("Couldn't delete file " + dirFile.getPath());
}
@Override
@@ -121,30 +142,32 @@ public class DocumentsProvider extends android.provider.DocumentsProvider {
var parent = getFile(parentDocumentId);
var file = getFile(documentId);
if (parent.equals(file) || file.getParentFile() == null || file.getParentFile().equals(parent)) {
if (!file.delete())
throw new FileNotFoundException("Couldn't delete document with ID '$documentId'");
} else {
throw new FileNotFoundException("Couldn't delete document with ID '$documentId'");
if (!(parent.equals(file) || file.getParentFile() == null || file.getParentFile().equals(parent)))
throw new FileNotFoundException("Couldn't delete document with ID " + documentId);
if (file.isDirectory()) {
deleteFolder(file);
return;
}
if (!file.delete())
throw new FileNotFoundException("Couldn't delete document with ID " + documentId);
}
@Override
public String renameDocument(String documentId, String displayName) throws FileNotFoundException {
if (displayName == null)
throw new FileNotFoundException("Couldn't rename document '$documentId' as the new name is null");
throw new FileNotFoundException("Couldn't rename document " + documentId + " as the new name is null");
var sourceFile = getFile(documentId);
var sourceParentFile = sourceFile.getParentFile();
if (sourceParentFile == null)
throw new FileNotFoundException("Couldn't rename document '$documentId' as it has no parent");
throw new FileNotFoundException("Couldn't rename document '" + documentId + "' as it has no parent");
var destFile = resolve(sourceParentFile, displayName);
try {
if (!sourceFile.renameTo(destFile))
throw new FileNotFoundException("Couldn't rename document from '${sourceFile.name}' to '${destFile.name}'");
throw new FileNotFoundException("Couldn't rename document from '" + sourceFile.getName() + "' to '" + destFile.getName() + "'");
} catch (Exception exception) {
throw new FileNotFoundException("Couldn't rename document from '${sourceFile.name}' to '${destFile.name}': ${e.message}");
throw new FileNotFoundException("Couldn't rename document from '" + sourceFile.getName() + "' to '" + destFile.getName() + "':" + exception.getMessage());
}
return getDocumentId(destFile);
@@ -167,7 +190,7 @@ public class DocumentsProvider extends android.provider.DocumentsProvider {
}
}
} catch (IOException exception) {
throw new FileNotFoundException("Couldn't copy document '$sourceDocumentId': ${e.message}");
throw new FileNotFoundException("Couldn't copy document '" + sourceDocumentId + "': " + exception.getMessage());
}
return getDocumentId(newFile);
}
@@ -179,7 +202,7 @@ public class DocumentsProvider extends android.provider.DocumentsProvider {
removeDocument(sourceDocumentId, sourceParentDocumentId);
return newDocumentId;
} catch (FileNotFoundException e) {
throw new FileNotFoundException("Couldn't move document '$sourceDocumentId'");
throw new FileNotFoundException("Couldn't move document '" + sourceDocumentId + "'");
}
}
@@ -208,7 +231,7 @@ public class DocumentsProvider extends android.provider.DocumentsProvider {
private String copyDocument(String sourceDocumentId, String sourceParentDocumentId, String targetParentDocumentId) throws FileNotFoundException {
if (!isChildDocument(sourceParentDocumentId, sourceDocumentId))
throw new FileNotFoundException("Couldn't copy document '$sourceDocumentId' as its parent is not '$sourceParentDocumentId'");
throw new FileNotFoundException("Couldn't copy document '" + sourceDocumentId + "' as its parent is not '" + sourceParentDocumentId + "'");
return copyDocument(sourceDocumentId, targetParentDocumentId);
}