aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/video_core/utils.h
diff options
context:
space:
mode:
authorGravatar bunnei <ericbunnie@gmail.com>2014-04-08 19:25:03 -0400
committerGravatar bunnei <ericbunnie@gmail.com>2014-04-08 19:25:03 -0400
commit63e46abdb8764bc97e91bae862c8d461e61b1965 (patch)
treee73f4aa25d7b4015a265e7bbfb6004dab7561027 /src/video_core/utils.h
parent03c245345e1f319da5007c15019ed54432029fb8 (diff)
got rid of 'src' folders in each sub-project
Diffstat (limited to 'src/video_core/utils.h')
-rw-r--r--src/video_core/utils.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/video_core/utils.h b/src/video_core/utils.h
new file mode 100644
index 00000000..c417342e
--- /dev/null
+++ b/src/video_core/utils.h
@@ -0,0 +1,64 @@
+// Copyright 2014 Citra Emulator Project
+// Licensed under GPLv2
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include <string>
+
+#include "common_types.h"
+
+namespace FormatPrecision {
+
+/// Adjust RGBA8 color with RGBA6 precision
+static inline u32 rgba8_with_rgba6(u32 src) {
+ u32 color = src;
+ color &= 0xFCFCFCFC;
+ color |= (color >> 6) & 0x03030303;
+ return color;
+}
+
+/// Adjust RGBA8 color with RGB565 precision
+static inline u32 rgba8_with_rgb565(u32 src) {
+ u32 color = (src & 0xF8FCF8);
+ color |= (color >> 5) & 0x070007;
+ color |= (color >> 6) & 0x000300;
+ color |= 0xFF000000;
+ return color;
+}
+
+/// Adjust Z24 depth value with Z16 precision
+static inline u32 z24_with_z16(u32 src) {
+ return (src & 0xFFFF00) | (src >> 16);
+}
+
+} // namespace
+
+namespace VideoCore {
+
+/// Structure for the TGA texture format (for dumping)
+struct TGAHeader {
+ char idlength;
+ char colourmaptype;
+ char datatypecode;
+ short int colourmaporigin;
+ short int colourmaplength;
+ short int x_origin;
+ short int y_origin;
+ short width;
+ short height;
+ char bitsperpixel;
+ char imagedescriptor;
+};
+
+/**
+ * Dumps a texture to TGA
+ * @param filename String filename to dump texture to
+ * @param width Width of texture in pixels
+ * @param height Height of texture in pixels
+ * @param raw_data Raw RGBA8 texture data to dump
+ * @todo This should be moved to some general purpose/common code
+ */
+void DumpTGA(std::string filename, int width, int height, u8* raw_data);
+
+} // namespace