Skip to content

Commit

Permalink
XP3Filter: add filename filter
Browse files Browse the repository at this point in the history
fix mixed Gray/RGBA character caused texture error
fix volume/pan value out of OpenAL standard
  • Loading branch information
ZeaS committed Dec 25, 2016
1 parent 157e8c3 commit 0b8a337
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 913 deletions.
16 changes: 16 additions & 0 deletions src/core/base/XP3Archive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ void TVPSetXP3ArchiveExtractionFilter(tTVPXP3ArchiveExtractionFilter filter)
}
//---------------------------------------------------------------------------

static tTVPXP3ArchiveContentFilter TVPXP3ArchiveContentFilter = nullptr;
void TVPSetXP3ArchiveContentFilter(tTVPXP3ArchiveContentFilter filter)
{
TVPXP3ArchiveContentFilter = filter;
}


//---------------------------------------------------------------------------
Expand Down Expand Up @@ -572,6 +577,17 @@ tTJSBinaryStream * tTVPXP3Archive::CreateStreamByIndex(tjs_uint idx)
{
out = new tTVPXP3ArchiveStream(this, idx, &(item.Segments), stream,
item.OrgSize);
if (TVPXP3ArchiveContentFilter) {
tjs_int result = TVPXP3ArchiveContentFilter(item.Name, Name, item.OrgSize);
#define XP3_CONTENT_FILTER_FETCH_FULLDATA 1
if (result == XP3_CONTENT_FILTER_FETCH_FULLDATA) {
tTVPMemoryStream *memstr = new tTVPMemoryStream();
memstr->SetSize(item.OrgSize);
out->ReadBuffer(memstr->GetInternalBuffer(), item.OrgSize);
delete out;
out = memstr;
}
}
}
catch(...)
{
Expand Down
4 changes: 3 additions & 1 deletion src/core/base/XP3Archive.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ struct tTVPXP3ExtractionFilterInfo

typedef void (TVP_tTVPXP3ArchiveExtractionFilter_CONVENTION *
tTVPXP3ArchiveExtractionFilter)(tTVPXP3ExtractionFilterInfo *info);

typedef tjs_int (TVP_tTVPXP3ArchiveExtractionFilter_CONVENTION *
tTVPXP3ArchiveContentFilter)(const ttstr &filepath, const ttstr &archivename, tjs_uint64 filesize);

/*]*/
//---------------------------------------------------------------------------
TJS_EXP_FUNC_DEF(void, TVPSetXP3ArchiveExtractionFilter, (tTVPXP3ArchiveExtractionFilter filter));
TJS_EXP_FUNC_DEF(void, TVPSetXP3ArchiveContentFilter, (tTVPXP3ArchiveContentFilter filter));
//---------------------------------------------------------------------------


Expand Down
2 changes: 1 addition & 1 deletion src/core/msg/MsgIntfInc.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ TVP_MSG_DEFINE(TVPInsufficientMemory, "Insufficient memory")
TVP_MSG_DEFINE(TVPUncompressionFailed,"Unpompression failed")
TVP_MSG_DEFINE(TVPCompressionFailed, "Compression failed")
TVP_MSG_DEFINE(TVPCannotWriteToArchive, "Cannot write to archive")
TVP_MSG_DEFINE(TVPUnsupportedCipherMode, "%1 is unsupported cipger mode")
TVP_MSG_DEFINE(TVPUnsupportedCipherMode, "%1 is unsupported cipher mode")
TVP_MSG_DEFINE(TVPUnsupportedEncoding, "%1 is unsupported encoding")
TVP_MSG_DEFINE(TVPUnsupportedModeString, "%1 is unsupported mode string")
TVP_MSG_DEFINE(TVPUnknownGraphicFormat, "Unknown graphic format %1")
Expand Down
4 changes: 2 additions & 2 deletions src/core/sound/win32/WaveImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3234,12 +3234,12 @@ void tTJSNI_WaveSoundBuffer::SetVolumeToSoundBuffer()
v = (Volume / 10) * (Volume2 / 10) / 1000;
v = (v / 10) * (GlobalVolume / 10) / 1000;
v = (v / 10) * (mutevol / 10) / 1000;
SoundBuffer->SetVolume(TVPVolumeToDSAttenuate(v));
SoundBuffer->SetVolume(/*TVPVolumeToDSAttenuate*/(v / 100000.0f));

if(BufferCanControlPan)
{
// set pan
SoundBuffer->SetPan(TVPPanToDSAttenuate(Pan));
SoundBuffer->SetPan(/*TVPPanToDSAttenuate*/(Pan / 100000.0f));
}
}
}
Expand Down
97 changes: 0 additions & 97 deletions src/core/tjs2/tjspp.tab.h

This file was deleted.

28 changes: 16 additions & 12 deletions src/core/visual/win32/LayerBitmapImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ struct tTVPDrawTextData
tTVPBBBltMethod bltmode;
};

static iTVPTexture2D *_CharacterTexture = NULL;
static iTVPTexture2D *_CharacterTexture = nullptr, *_CharacterTextureRGBA = nullptr;

bool tTVPNativeBaseBitmap::InternalBlendText(
tTVPCharacterData *data, tTVPDrawTextData *dtdata, tjs_uint32 color, const tTVPRect &srect, tTVPRect &drect)
Expand All @@ -844,6 +844,7 @@ bool tTVPNativeBaseBitmap::InternalBlendText(
static bool fastGPURoute = !TVPIsSoftwareRenderManager()
&& !IndividualConfigManager::GetInstance()->GetValueBool("ogl_accurate_render", false);

iTVPTexture2D *pTexSrc;
if (fastGPURoute && dtdata->bltmode == bmAlphaOnAlpha && dtdata->opa > 0) {
// convert to addalpha bitmap
tTVPBitmap* tmp = new tTVPBitmap(w, h, 32);
Expand All @@ -859,25 +860,26 @@ bool tTVPNativeBaseBitmap::InternalBlendText(
dst += dpitch;
src += spitch;
}
if (_CharacterTexture) {
if (_CharacterTexture->GetFormat() != TVPTextureFormat::RGBA) {
_CharacterTexture->Release();
_CharacterTexture = nullptr;
if (_CharacterTextureRGBA) {
if (_CharacterTextureRGBA->GetFormat() != TVPTextureFormat::RGBA) {
_CharacterTextureRGBA->Release();
_CharacterTextureRGBA = nullptr;
}
}
if (!_CharacterTexture) {
_CharacterTexture = GetRenderManager()->CreateTexture2D(tmp->GetBits(), dpitch, w, h, TVPTextureFormat::RGBA);
} else if (_CharacterTexture->GetInternalWidth() < w || _CharacterTexture->GetInternalHeight() < h) {
_CharacterTexture->Release();
_CharacterTexture = GetRenderManager()->CreateTexture2D(tmp->GetBits(), dpitch, w, h, TVPTextureFormat::RGBA);
if (!_CharacterTextureRGBA) {
_CharacterTextureRGBA = GetRenderManager()->CreateTexture2D(tmp->GetBits(), dpitch, w, h, TVPTextureFormat::RGBA);
} else if (_CharacterTextureRGBA->GetInternalWidth() < w || _CharacterTextureRGBA->GetInternalHeight() < h) {
_CharacterTextureRGBA->Release();
_CharacterTextureRGBA = GetRenderManager()->CreateTexture2D(tmp->GetBits(), dpitch, w, h, TVPTextureFormat::RGBA);
} else {
_CharacterTexture->Update(tmp->GetBits(), TVPTextureFormat::RGBA, dpitch, tTVPRect(0, 0, w, h));
_CharacterTextureRGBA->Update(tmp->GetBits(), TVPTextureFormat::RGBA, dpitch, tTVPRect(0, 0, w, h));
}

tmp->Release();

GEMTHOD_OPA_CLR(AlphaBlend_a);
method->SetParameterOpa(opa_id, dtdata->opa);
pTexSrc = _CharacterTextureRGBA;
} else {
if (dtdata->bltmode == bmAlphaOnAlpha) {
if (dtdata->opa > 0) {
Expand All @@ -904,6 +906,8 @@ bool tTVPNativeBaseBitmap::InternalBlendText(

method->SetParameterOpa(opa_id, dtdata->opa);
method->SetParameterColor4B(clr_id, color);

pTexSrc = _CharacterTexture;
}
#if 0
if (pShader->isBlendEnabled() || !IsIndependent()) {
Expand All @@ -929,7 +933,7 @@ bool tTVPNativeBaseBitmap::InternalBlendText(
}
#endif
tRenderTexRectArray::Element src_tex[] = {
tRenderTexRectArray::Element(_CharacterTexture, tTVPRect(0, 0, w, h))
tRenderTexRectArray::Element(pTexSrc, tTVPRect(0, 0, w, h))
};
TVPGetRenderManager()->OperateRect(method,
GetTextureForRender(method->IsBlendTarget(), &drect), nullptr, drect,
Expand Down
Loading

0 comments on commit 0b8a337

Please sign in to comment.