2013-04-30 19:44:34 +00:00
|
|
|
// Copyright (c) 2012- PPSSPP Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official git repository and contact information can be found at
|
2015-01-22 18:53:32 +00:00
|
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
2013-07-25 22:34:55 +00:00
|
|
|
|
2015-01-22 18:53:32 +00:00
|
|
|
// On Visual Studio 2012, include this before anything else so
|
|
|
|
// _VARIADIC_MAX gets set to 10, to avoid std::bind compile errors.
|
|
|
|
// See header file for reasons why.
|
|
|
|
#if defined(_WIN32) && _MSC_VER == 1700
|
2013-09-17 14:16:18 +00:00
|
|
|
#include "../native/base/basictypes.h"
|
|
|
|
#endif
|
|
|
|
|
2014-07-01 07:26:22 +00:00
|
|
|
#include <algorithm>
|
2013-04-30 19:44:34 +00:00
|
|
|
|
2015-04-07 22:16:22 +00:00
|
|
|
#include "Common/ColorConv.h"
|
2013-05-03 06:31:53 +00:00
|
|
|
#include "Common/ThreadPools.h"
|
2015-04-08 18:52:35 +00:00
|
|
|
#include "GPU/Common/TextureScalerCommon.h"
|
|
|
|
#include "GPU/Directx9/TextureScalerDX9.h"
|
|
|
|
#include "GPU/Directx9/GPU_DX9.h"
|
2013-05-01 12:08:33 +00:00
|
|
|
|
2015-01-22 18:53:32 +00:00
|
|
|
namespace DX9 {
|
|
|
|
|
2015-04-08 18:52:35 +00:00
|
|
|
int TextureScalerDX9::BytesPerPixel(u32 format) {
|
|
|
|
return format == D3DFMT_A8R8G8B8 ? 4 : 2;
|
2013-05-01 21:55:34 +00:00
|
|
|
}
|
|
|
|
|
2015-04-08 18:52:35 +00:00
|
|
|
u32 TextureScalerDX9::Get8888Format() {
|
|
|
|
return D3DFMT_A8R8G8B8;
|
2013-05-03 14:21:46 +00:00
|
|
|
}
|
|
|
|
|
2015-01-22 18:53:32 +00:00
|
|
|
void TextureScalerDX9::ConvertTo8888(u32 format, u32* source, u32* &dest, int width, int height) {
|
2013-05-01 21:55:34 +00:00
|
|
|
switch(format) {
|
2015-01-22 18:53:32 +00:00
|
|
|
case D3DFMT_A8R8G8B8:
|
2013-05-01 21:55:34 +00:00
|
|
|
dest = source; // already fine
|
|
|
|
break;
|
|
|
|
|
2015-01-22 18:53:32 +00:00
|
|
|
case D3DFMT_A4R4G4B4:
|
2015-04-07 22:33:12 +00:00
|
|
|
GlobalThreadPool::Loop(std::bind(&convert4444_dx9, (u16*)source, dest, width, placeholder::_1, placeholder::_2), 0, height);
|
2013-05-01 21:55:34 +00:00
|
|
|
break;
|
|
|
|
|
2015-01-22 18:53:32 +00:00
|
|
|
case D3DFMT_R5G6B5:
|
2015-04-07 22:33:12 +00:00
|
|
|
GlobalThreadPool::Loop(std::bind(&convert565_dx9, (u16*)source, dest, width, placeholder::_1, placeholder::_2), 0, height);
|
2013-05-01 21:55:34 +00:00
|
|
|
break;
|
|
|
|
|
2015-01-22 18:53:32 +00:00
|
|
|
case D3DFMT_A1R5G5B5:
|
2015-04-07 22:33:12 +00:00
|
|
|
GlobalThreadPool::Loop(std::bind(&convert5551_dx9, (u16*)source, dest, width, placeholder::_1, placeholder::_2), 0, height);
|
2013-05-01 21:55:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
dest = source;
|
|
|
|
ERROR_LOG(G3D, "iXBRZTexScaling: unsupported texture format");
|
|
|
|
}
|
|
|
|
}
|
2015-01-22 18:53:32 +00:00
|
|
|
|
2015-04-08 18:52:35 +00:00
|
|
|
} // namespace
|