Skip to content

Commit

Permalink
LibGfx: Add support for DDS images
Browse files Browse the repository at this point in the history
  • Loading branch information
stelar7 authored and linusg committed May 18, 2021
1 parent 9f42ccd commit 24c5b0e
Show file tree
Hide file tree
Showing 18 changed files with 1,375 additions and 11 deletions.
4 changes: 4 additions & 0 deletions AK/Debug.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
#cmakedefine01 CURSOR_TOOL_DEBUG
#endif

#ifndef DDS_DEBUG
#cmakedefine01 DDS_DEBUG
#endif

#ifndef DEFERRED_INVOKE_DEBUG
#cmakedefine01 DEFERRED_INVOKE_DEBUG
#endif
Expand Down
1 change: 1 addition & 0 deletions Base/home/anon/.config/LaunchServer.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[FileType]
dds=/bin/ImageViewer
pbm=/bin/ImageViewer
pgm=/bin/ImageViewer
png=/bin/ImageViewer
Expand Down
2 changes: 1 addition & 1 deletion Base/res/apps/ImageViewer.af
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Executable=/bin/ImageViewer
Category=Graphics

[Launcher]
FileTypes=pbm,pgm,png,ppm,gif,jpg,jpeg
FileTypes=pbm,pgm,png,ppm,gif,jpg,jpeg,dds
35 changes: 35 additions & 0 deletions Base/res/html/misc/ddssuite.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<html>
<head><title>DDS test suite</title></head>
<body>
<table border="1" width="100%">
<tr>
<th>Type</th>
<th>Image</th>
</tr>
<tr>
<td align="center">DXT1</td>
<td align="center"><img src="ddssuite_files/DXT1.dds"></td>
</tr>
<tr>
<td align="center">DXT3</td>
<td align="center"><img src="ddssuite_files/DXT3.dds"></td>
</tr>
<tr>
<td align="center">DXT5</td>
<td align="center"><img src="ddssuite_files/DXT5.dds"></td>
</tr>
<tr>
<td align="center">DXT3 - alpha</td>
<td align="center"><img src="ddssuite_files/DXT3-alpha.dds"></td>
</tr>
<tr>
<td align="center">DXT5 - alpha</td>
<td align="center"><img src="ddssuite_files/DXT5-alpha.dds"></td>
</tr>
<tr>
<td align="center">DXT1 - mipmap</td>
<td align="center"><img src="ddssuite_files/DXT1-mipmap.dds"></td>
</tr>
</table>
</body>
</html>
Binary file added Base/res/html/misc/ddssuite_files/DXT1-mipmap.dds
Binary file not shown.
Binary file added Base/res/html/misc/ddssuite_files/DXT1.dds
Binary file not shown.
Binary file added Base/res/html/misc/ddssuite_files/DXT3-alpha.dds
Binary file not shown.
Binary file added Base/res/html/misc/ddssuite_files/DXT3.dds
Binary file not shown.
Binary file added Base/res/html/misc/ddssuite_files/DXT5-alpha.dds
Binary file not shown.
Binary file added Base/res/html/misc/ddssuite_files/DXT5.dds
Binary file not shown.
1 change: 1 addition & 0 deletions Base/res/html/misc/welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ <h1>Welcome to the Serenity Browser!</h1>
<p>This page loaded in <b><span id="loadtime"></span></b> ms</p>
<p>Some small test pages:</p>
<ul>
<li><a href="ddssuite.html">DDS test suite</a></li>
<li><a href="websocket.html">WebSocket API Test</a></li>
<li><a href="cookie.html">document.cookie</a></li>
<li><a href="last-of-type.html">CSS :last-of-type selector</a></li>
Expand Down
1 change: 1 addition & 0 deletions Meta/CMake/all_the_debug_macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ set(WASM_BINPARSER_DEBUG ON)
set(WASM_TRACE_DEBUG ON)
set(PDF_DEBUG ON)
set(SOLITAIRE_DEBUG ON)
set(DDS_DEBUG ON)

# False positive: DEBUG is a flag but it works differently.
# set(DEBUG ON)
Expand Down
1 change: 1 addition & 0 deletions Userland/Libraries/LibGfx/Bitmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <AK/String.h>
#include <LibGfx/BMPLoader.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/DDSLoader.h>
#include <LibGfx/GIFLoader.h>
#include <LibGfx/ICOLoader.h>
#include <LibGfx/JPGLoader.h>
Expand Down
21 changes: 11 additions & 10 deletions Userland/Libraries/LibGfx/Bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@
#include <LibGfx/Forward.h>
#include <LibGfx/Rect.h>

#define ENUMERATE_IMAGE_FORMATS \
__ENUMERATE_IMAGE_FORMAT(pbm, ".pbm") \
__ENUMERATE_IMAGE_FORMAT(pgm, ".pgm") \
__ENUMERATE_IMAGE_FORMAT(png, ".png") \
__ENUMERATE_IMAGE_FORMAT(ppm, ".ppm") \
__ENUMERATE_IMAGE_FORMAT(gif, ".gif") \
__ENUMERATE_IMAGE_FORMAT(bmp, ".bmp") \
__ENUMERATE_IMAGE_FORMAT(ico, ".ico") \
__ENUMERATE_IMAGE_FORMAT(jpg, ".jpg") \
__ENUMERATE_IMAGE_FORMAT(jpg, ".jpeg")
#define ENUMERATE_IMAGE_FORMATS \
__ENUMERATE_IMAGE_FORMAT(pbm, ".pbm") \
__ENUMERATE_IMAGE_FORMAT(pgm, ".pgm") \
__ENUMERATE_IMAGE_FORMAT(png, ".png") \
__ENUMERATE_IMAGE_FORMAT(ppm, ".ppm") \
__ENUMERATE_IMAGE_FORMAT(gif, ".gif") \
__ENUMERATE_IMAGE_FORMAT(bmp, ".bmp") \
__ENUMERATE_IMAGE_FORMAT(ico, ".ico") \
__ENUMERATE_IMAGE_FORMAT(jpg, ".jpg") \
__ENUMERATE_IMAGE_FORMAT(jpg, ".jpeg") \
__ENUMERATE_IMAGE_FORMAT(dds, ".dds")

namespace Gfx {

Expand Down
1 change: 1 addition & 0 deletions Userland/Libraries/LibGfx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ set(SOURCES
ClassicStylePainter.cpp
ClassicWindowTheme.cpp
Color.cpp
DDSLoader.cpp
DisjointRectSet.cpp
Emoji.cpp
FontDatabase.cpp
Expand Down
Loading

0 comments on commit 24c5b0e

Please sign in to comment.