summaryrefslogtreecommitdiffstats
path: root/thirdparty/etcpak/DataProvider.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2021-04-14 16:45:14 +0200
committerRémi Verschelde <rverschelde@gmail.com>2021-04-14 16:50:02 +0200
commit638cfec853cfdbc95b5ccc67477afbaa3a53bc33 (patch)
tree68e408f59de168080efbb5e4ecdb2fca4bf7a1c9 /thirdparty/etcpak/DataProvider.cpp
parent8ce0fb0a946455ed6a7bc8a54fcf90a9d5a9ae4d (diff)
downloadredot-engine-638cfec853cfdbc95b5ccc67477afbaa3a53bc33.tar.gz
etcpak: We only need the compression code, remove rest of etcpak app
We do our own image loading, threading, and memory management in Godot already, so the only components we need from etcpak (at least as of now) are the `Compress*` methods defined in `ProcessDxtc.cpp` and `ProcessRGB.cpp`. So we don't need to compile or vendor the rest.
Diffstat (limited to 'thirdparty/etcpak/DataProvider.cpp')
-rw-r--r--thirdparty/etcpak/DataProvider.cpp77
1 files changed, 0 insertions, 77 deletions
diff --git a/thirdparty/etcpak/DataProvider.cpp b/thirdparty/etcpak/DataProvider.cpp
deleted file mode 100644
index 6bd4b105ed..0000000000
--- a/thirdparty/etcpak/DataProvider.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-#include <assert.h>
-#include <utility>
-
-#include "BitmapDownsampled.hpp"
-#include "DataProvider.hpp"
-#include "MipMap.hpp"
-
-DataProvider::DataProvider( const char* fn, bool mipmap, bool bgr )
- : m_offset( 0 )
- , m_mipmap( mipmap )
- , m_done( false )
- , m_lines( 32 )
-{
- m_bmp.emplace_back( new Bitmap( fn, m_lines, bgr ) );
- m_current = m_bmp[0].get();
-}
-
-DataProvider::~DataProvider()
-{
-}
-
-unsigned int DataProvider::NumberOfParts() const
-{
- unsigned int parts = ( ( m_bmp[0]->Size().y / 4 ) + m_lines - 1 ) / m_lines;
-
- if( m_mipmap )
- {
- v2i current = m_bmp[0]->Size();
- int levels = NumberOfMipLevels( current );
- unsigned int lines = m_lines;
- for( int i=1; i<levels; i++ )
- {
- assert( current.x != 1 || current.y != 1 );
- current.x = std::max( 1, current.x / 2 );
- current.y = std::max( 1, current.y / 2 );
- lines *= 2;
- parts += ( ( std::max( 4, current.y ) / 4 ) + lines - 1 ) / lines;
- }
- assert( current.x == 1 && current.y == 1 );
- }
-
- return parts;
-}
-
-DataPart DataProvider::NextPart()
-{
- assert( !m_done );
-
- unsigned int lines = m_lines;
- bool done;
-
- const auto ptr = m_current->NextBlock( lines, done );
- DataPart ret = {
- ptr,
- std::max<unsigned int>( 4, m_current->Size().x ),
- lines,
- m_offset
- };
-
- m_offset += m_current->Size().x / 4 * lines;
-
- if( done )
- {
- if( m_mipmap && ( m_current->Size().x != 1 || m_current->Size().y != 1 ) )
- {
- m_lines *= 2;
- m_bmp.emplace_back( new BitmapDownsampled( *m_current, m_lines ) );
- m_current = m_bmp[m_bmp.size()-1].get();
- }
- else
- {
- m_done = true;
- }
- }
-
- return ret;
-}