mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-13 07:57:52 +00:00
- code cleanup
This commit is contained in:
parent
afecb1ca0f
commit
ccd39d6df7
13 changed files with 60 additions and 33 deletions
|
@ -422,7 +422,7 @@ void FFont::ReadSheetFont(std::vector<FileSys::FolderEntry> &folderdata, int wid
|
|||
|
||||
FBitmap* sheetimg = &sheetBitmaps[sheetBitmaps.Reserve(1)];
|
||||
sheetimg->Create(tex->GetTexelWidth(), tex->GetTexelHeight());
|
||||
tex->GetTexture()->GetImage()->CopyPixels(sheetimg, FImageSource::normal);
|
||||
tex->GetTexture()->GetImage()->CopyPixels(sheetimg, FImageSource::normal, 0);
|
||||
|
||||
for (int y = 0; y < numtex_y; y++)
|
||||
{
|
||||
|
|
|
@ -35,5 +35,3 @@ extern TArray<TranslationMap> TranslationLookup;
|
|||
extern TArray<PalEntry> TranslationColors;
|
||||
|
||||
class FImageSource;
|
||||
|
||||
void RecordTextureColors (FImageSource *pic, uint32_t *usedcolors);
|
||||
|
|
|
@ -25,9 +25,9 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
|
|||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
#include <string.h>
|
||||
#include "animlib.h"
|
||||
#include "m_swap.h"
|
||||
#include "m_alloc.h"
|
||||
|
||||
//****************************************************************************
|
||||
//
|
||||
|
|
|
@ -118,7 +118,7 @@ void iCopyColors(uint8_t *pout, const uint8_t *pin, int count, int step, FCopyIn
|
|||
a = TSrc::A(pin, tr, tg, tb);
|
||||
if (TBlend::ProcessAlpha0() || a)
|
||||
{
|
||||
int gray = clamp<int>(TSrc::Gray(pin),0,255);
|
||||
int gray = std::clamp<int>(TSrc::Gray(pin),0,255);
|
||||
|
||||
PalEntry pe = cm->GrayscaleToColor[gray];
|
||||
TBlend::OpC(pout[TDest::RED], pe.r , a, inf);
|
||||
|
|
|
@ -36,8 +36,6 @@
|
|||
#ifndef __BITMAP_H__
|
||||
#define __BITMAP_H__
|
||||
|
||||
#include "basics.h"
|
||||
|
||||
#include "palentry.h"
|
||||
|
||||
struct FCopyInfo;
|
||||
|
@ -320,9 +318,9 @@ struct cCMYK
|
|||
|
||||
struct cYCbCr
|
||||
{
|
||||
static __forceinline unsigned char R(const unsigned char * p) { return clamp((int)(p[0] + 1.40200 * (int(p[2]) - 0x80)), 0, 255); }
|
||||
static __forceinline unsigned char G(const unsigned char * p) { return clamp((int)(p[0] - 0.34414 * (int(p[1] - 0x80)) - 0.71414 * (int(p[2]) - 0x80)), 0, 255); }
|
||||
static __forceinline unsigned char B(const unsigned char * p) { return clamp((int)(p[0] + 1.77200 * (int(p[1]) - 0x80)), 0, 255); }
|
||||
static __forceinline unsigned char R(const unsigned char * p) { return std::clamp((int)(p[0] + 1.40200 * (int(p[2]) - 0x80)), 0, 255); }
|
||||
static __forceinline unsigned char G(const unsigned char * p) { return std::clamp((int)(p[0] - 0.34414 * (int(p[1] - 0x80)) - 0.71414 * (int(p[2]) - 0x80)), 0, 255); }
|
||||
static __forceinline unsigned char B(const unsigned char * p) { return std::clamp((int)(p[0] + 1.77200 * (int(p[1]) - 0x80)), 0, 255); }
|
||||
static __forceinline unsigned char A(const unsigned char * p, uint8_t x, uint8_t y, uint8_t z) { return 255; }
|
||||
static __forceinline int Gray(const unsigned char * p) { return (R(p) * 77 + G(p) * 143 + B(p) * 36) >> 8; }
|
||||
};
|
||||
|
@ -470,7 +468,7 @@ struct bCopyAlpha
|
|||
struct bOverlay
|
||||
{
|
||||
static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = (s*a + d*(255-a))/255; }
|
||||
static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = max(s,d); }
|
||||
static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = std::max(s,d); }
|
||||
static __forceinline bool ProcessAlpha0() { return false; }
|
||||
};
|
||||
|
||||
|
@ -483,21 +481,21 @@ struct bBlend
|
|||
|
||||
struct bAdd
|
||||
{
|
||||
static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = min<int>((d*BLENDUNIT + s*i->alpha) >> BLENDBITS, 255); }
|
||||
static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = std::min<int>((d*BLENDUNIT + s*i->alpha) >> BLENDBITS, 255); }
|
||||
static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = s; }
|
||||
static __forceinline bool ProcessAlpha0() { return false; }
|
||||
};
|
||||
|
||||
struct bSubtract
|
||||
{
|
||||
static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = max<int>((d*BLENDUNIT - s*i->alpha) >> BLENDBITS, 0); }
|
||||
static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = std::max<int>((d*BLENDUNIT - s*i->alpha) >> BLENDBITS, 0); }
|
||||
static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = s; }
|
||||
static __forceinline bool ProcessAlpha0() { return false; }
|
||||
};
|
||||
|
||||
struct bReverseSubtract
|
||||
{
|
||||
static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = max<int>((-d*BLENDUNIT + s*i->alpha) >> BLENDBITS, 0); }
|
||||
static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = std::max<int>((-d*BLENDUNIT + s*i->alpha) >> BLENDBITS, 0); }
|
||||
static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = s; }
|
||||
static __forceinline bool ProcessAlpha0() { return false; }
|
||||
};
|
||||
|
|
|
@ -67,7 +67,7 @@ FBrightmapTexture::FBrightmapTexture (FImageSource *source)
|
|||
|
||||
int FBrightmapTexture::CopyPixels(FBitmap *bmp, int conversion, int frame)
|
||||
{
|
||||
SourcePic->CopyTranslatedPixels(bmp, GPalette.GlobalBrightmap.Palette);
|
||||
SourcePic->CopyTranslatedPixels(bmp, GPalette.GlobalBrightmap.Palette, frame);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@ PalettedPixels FIMGZTexture::CreatePalettedPixels(int conversion, int frame)
|
|||
|
||||
int FIMGZTexture::CopyPixels(FBitmap *bmp, int conversion, int frame)
|
||||
{
|
||||
if (!isalpha) return FImageSource::CopyPixels(bmp, conversion);
|
||||
else return CopyTranslatedPixels(bmp, GPalette.GrayscaleMap.Palette);
|
||||
if (!isalpha) return FImageSource::CopyPixels(bmp, conversion, frame);
|
||||
else return CopyTranslatedPixels(bmp, GPalette.GrayscaleMap.Palette, frame);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,17 @@
|
|||
#include "m_swap.h"
|
||||
|
||||
|
||||
// Doom patch format header
|
||||
struct patch_t
|
||||
{
|
||||
int16_t width; // bounding box size
|
||||
int16_t height;
|
||||
int16_t leftoffset; // pixels to the left of origin
|
||||
int16_t topoffset; // pixels below the origin
|
||||
uint32_t columnofs[1]; // only [width] used
|
||||
};
|
||||
|
||||
|
||||
// posts are runs of non masked source pixels
|
||||
struct column_t
|
||||
{
|
||||
|
@ -266,8 +277,8 @@ PalettedPixels FPatchTexture::CreatePalettedPixels(int conversion, int frame)
|
|||
|
||||
int FPatchTexture::CopyPixels(FBitmap *bmp, int conversion, int frame)
|
||||
{
|
||||
if (!isalpha) return FImageSource::CopyPixels(bmp, conversion);
|
||||
else return CopyTranslatedPixels(bmp, GPalette.GrayscaleMap.Palette);
|
||||
if (!isalpha) return FImageSource::CopyPixels(bmp, conversion, frame);
|
||||
else return CopyTranslatedPixels(bmp, GPalette.GrayscaleMap.Palette, frame);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -40,6 +40,16 @@
|
|||
#include "image.h"
|
||||
#include "m_swap.h"
|
||||
|
||||
// Doom patch format header
|
||||
struct patch_t
|
||||
{
|
||||
int16_t width; // bounding box size
|
||||
int16_t height;
|
||||
int16_t leftoffset; // pixels to the left of origin
|
||||
int16_t topoffset; // pixels below the origin
|
||||
uint32_t columnofs[1]; // only [width] used
|
||||
};
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
@ -201,7 +211,7 @@ PalettedPixels FRawPageTexture::CreatePalettedPixels(int conversion, int frame)
|
|||
|
||||
int FRawPageTexture::CopyPixels(FBitmap *bmp, int conversion, int frame)
|
||||
{
|
||||
if (mPaletteLump < 0) return FImageSource::CopyPixels(bmp, conversion);
|
||||
if (mPaletteLump < 0) return FImageSource::CopyPixels(bmp, conversion, frame);
|
||||
else
|
||||
{
|
||||
auto lump = fileSystem.ReadFile(SourceLump);
|
||||
|
|
|
@ -5,20 +5,24 @@
|
|||
#include "bitmap.h"
|
||||
#include "memarena.h"
|
||||
|
||||
#ifndef MAKE_ID
|
||||
#ifndef __BIG_ENDIAN__
|
||||
#define MAKE_ID(a,b,c,d) ((uint32_t)((a)|((b)<<8)|((c)<<16)|((d)<<24)))
|
||||
#else
|
||||
#define MAKE_ID(a,b,c,d) ((uint32_t)((d)|((c)<<8)|((b)<<16)|((a)<<24)))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
using std::min;
|
||||
using std::max;
|
||||
using std::clamp;
|
||||
|
||||
|
||||
class FImageSource;
|
||||
using PrecacheInfo = TMap<int, std::pair<int, int>>;
|
||||
extern FMemArena ImageArena;
|
||||
|
||||
// Doom patch format header
|
||||
struct patch_t
|
||||
{
|
||||
int16_t width; // bounding box size
|
||||
int16_t height;
|
||||
int16_t leftoffset; // pixels to the left of origin
|
||||
int16_t topoffset; // pixels below the origin
|
||||
uint32_t columnofs[1]; // only [width] used
|
||||
};
|
||||
|
||||
// Pixel store wrapper that can either own the pixels itself or refer to an external store.
|
||||
struct PalettedPixels
|
||||
{
|
||||
friend class FImageSource;
|
||||
|
|
|
@ -42,11 +42,13 @@
|
|||
#include <malloc.h> // for alloca()
|
||||
#endif
|
||||
|
||||
#include "basics.h"
|
||||
#include "m_crc32.h"
|
||||
#include "m_swap.h"
|
||||
#if __has_include("c_cvars.h")
|
||||
#include "c_cvars.h"
|
||||
#endif
|
||||
#include "m_png.h"
|
||||
#include "basics.h"
|
||||
|
||||
|
||||
// MACROS ------------------------------------------------------------------
|
||||
|
@ -103,6 +105,8 @@ static void UnpackPixels (int width, int bytesPerRow, int bitdepth, const uint8_
|
|||
|
||||
// PUBLIC DATA DEFINITIONS -------------------------------------------------
|
||||
|
||||
// allow this to compile without CVARs.
|
||||
#if __has_include("c_cvars.h")
|
||||
CUSTOM_CVAR(Int, png_level, 5, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (self < 0)
|
||||
|
@ -111,6 +115,10 @@ CUSTOM_CVAR(Int, png_level, 5, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
|||
self = 9;
|
||||
}
|
||||
CVAR(Float, png_gamma, 0.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
#else
|
||||
const int png_level = 5;
|
||||
const float png_gamma = 0;
|
||||
#endif
|
||||
|
||||
// PRIVATE DATA DEFINITIONS ------------------------------------------------
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
#include "zstring.h"
|
||||
#include "files.h"
|
||||
#include "palentry.h"
|
||||
#include "basics.h"
|
||||
|
||||
// Screenshot buffer image data types
|
||||
enum ESSType
|
||||
|
|
|
@ -45,7 +45,6 @@
|
|||
#include "floatrect.h"
|
||||
#include "refcounted.h"
|
||||
|
||||
typedef TMap<int, bool> SpriteHits;
|
||||
class FImageSource;
|
||||
class FGameTexture;
|
||||
class IHardwareTexture;
|
||||
|
|
Loading…
Reference in a new issue