diff options
| author | 2014-04-08 19:25:03 -0400 | |
|---|---|---|
| committer | 2014-04-08 19:25:03 -0400 | |
| commit | 63e46abdb8764bc97e91bae862c8d461e61b1965 (patch) | |
| tree | e73f4aa25d7b4015a265e7bbfb6004dab7561027 /src/video_core/utils.h | |
| parent | fixed some license headers that I missed (diff) | |
| download | yuzu-63e46abdb8764bc97e91bae862c8d461e61b1965.tar.gz yuzu-63e46abdb8764bc97e91bae862c8d461e61b1965.tar.xz yuzu-63e46abdb8764bc97e91bae862c8d461e61b1965.zip | |
got rid of 'src' folders in each sub-project
Diffstat (limited to 'src/video_core/utils.h')
| -rw-r--r-- | src/video_core/utils.h | 64 |
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 000000000..c417342e1 --- /dev/null +++ b/src/video_core/utils.h | |||
| @@ -0,0 +1,64 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <string> | ||
| 8 | |||
| 9 | #include "common_types.h" | ||
| 10 | |||
| 11 | namespace FormatPrecision { | ||
| 12 | |||
| 13 | /// Adjust RGBA8 color with RGBA6 precision | ||
| 14 | static inline u32 rgba8_with_rgba6(u32 src) { | ||
| 15 | u32 color = src; | ||
| 16 | color &= 0xFCFCFCFC; | ||
| 17 | color |= (color >> 6) & 0x03030303; | ||
| 18 | return color; | ||
| 19 | } | ||
| 20 | |||
| 21 | /// Adjust RGBA8 color with RGB565 precision | ||
| 22 | static inline u32 rgba8_with_rgb565(u32 src) { | ||
| 23 | u32 color = (src & 0xF8FCF8); | ||
| 24 | color |= (color >> 5) & 0x070007; | ||
| 25 | color |= (color >> 6) & 0x000300; | ||
| 26 | color |= 0xFF000000; | ||
| 27 | return color; | ||
| 28 | } | ||
| 29 | |||
| 30 | /// Adjust Z24 depth value with Z16 precision | ||
| 31 | static inline u32 z24_with_z16(u32 src) { | ||
| 32 | return (src & 0xFFFF00) | (src >> 16); | ||
| 33 | } | ||
| 34 | |||
| 35 | } // namespace | ||
| 36 | |||
| 37 | namespace VideoCore { | ||
| 38 | |||
| 39 | /// Structure for the TGA texture format (for dumping) | ||
| 40 | struct TGAHeader { | ||
| 41 | char idlength; | ||
| 42 | char colourmaptype; | ||
| 43 | char datatypecode; | ||
| 44 | short int colourmaporigin; | ||
| 45 | short int colourmaplength; | ||
| 46 | short int x_origin; | ||
| 47 | short int y_origin; | ||
| 48 | short width; | ||
| 49 | short height; | ||
| 50 | char bitsperpixel; | ||
| 51 | char imagedescriptor; | ||
| 52 | }; | ||
| 53 | |||
| 54 | /** | ||
| 55 | * Dumps a texture to TGA | ||
| 56 | * @param filename String filename to dump texture to | ||
| 57 | * @param width Width of texture in pixels | ||
| 58 | * @param height Height of texture in pixels | ||
| 59 | * @param raw_data Raw RGBA8 texture data to dump | ||
| 60 | * @todo This should be moved to some general purpose/common code | ||
| 61 | */ | ||
| 62 | void DumpTGA(std::string filename, int width, int height, u8* raw_data); | ||
| 63 | |||
| 64 | } // namespace | ||