Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't hardlink texture atlas metadata into the executable #12656

Merged
merged 5 commits into from
Mar 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ Windows/ARM64
Windows/ipch
Windows/bin-release
Windows/win-version.h
ui_atlas.zim.png
ui_atlas_high.zim.png
android/assets
ext/_Output
android/lint.xml
Expand Down Expand Up @@ -87,9 +85,9 @@ __testfinish.txt
__testfailure.bmp
GameLogNotes.txt
screenshots
android/ui_atlas.zim
android/assets/lang
android/assets/flash0
ui_atlas.zim.png
ppge_atlas.zim.png
local.properties
r.sh
Expand Down
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,6 @@ list(APPEND NativeAppSource
UI/CwCheatScreen.cpp
UI/InstallZipScreen.cpp
UI/ProfilerDraw.cpp
UI/ui_atlas.cpp
UI/TextureUtil.cpp
UI/ComboKeyMappingScreen.cpp
)
Expand Down Expand Up @@ -1754,8 +1753,6 @@ add_library(${CoreLibName} ${CoreLinkType}
Core/Util/BlockAllocator.h
Core/Util/PPGeDraw.cpp
Core/Util/PPGeDraw.h
Core/Util/ppge_atlas.cpp
Core/Util/ppge_atlas.h
${CORE_NEON}
${GPU_SOURCES}
ext/disarm.cpp
Expand Down Expand Up @@ -1927,6 +1924,7 @@ endif()

set(NativeAssets
android/assets/ui_atlas.zim
android/assets/ui_atlas.meta
assets/lang
assets/shaders
assets/Roboto-Condensed.ttf
Expand All @@ -1935,6 +1933,7 @@ set(NativeAssets
assets/gamecontrollerdb.txt
assets/langregion.ini
assets/ppge_atlas.zim
assets/ppge_atlas.meta
assets/rargray.png
assets/unknown.png
assets/zip.png
Expand Down
3 changes: 0 additions & 3 deletions Core/Core.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\Windows\fix_2017.props" />
</ImportGroup>

<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
Expand Down Expand Up @@ -834,7 +833,6 @@
<ClCompile Include="Util\DisArm64.cpp" />
<ClCompile Include="Util\GameManager.cpp" />
<ClCompile Include="Util\PPGeDraw.cpp" />
<ClCompile Include="Util\ppge_atlas.cpp" />
<ClCompile Include="..\ext\xxhash.c">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">MaxSpeed</Optimization>
<IntrinsicFunctions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</IntrinsicFunctions>
Expand Down Expand Up @@ -1166,7 +1164,6 @@
<ClInclude Include="Util\DisArm64.h" />
<ClInclude Include="Util\GameManager.h" />
<ClInclude Include="Util\PPGeDraw.h" />
<ClInclude Include="Util\ppge_atlas.h" />
<ClInclude Include="..\ext\xxhash.h" />
<ClInclude Include="WaveFile.h" />
<ClInclude Include="WebServer.h" />
Expand Down
6 changes: 0 additions & 6 deletions Core/Core.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,6 @@
<ClCompile Include="Util\PPGeDraw.cpp">
<Filter>Util</Filter>
</ClCompile>
<ClCompile Include="Util\ppge_atlas.cpp">
<Filter>Util</Filter>
</ClCompile>
<ClCompile Include="HLE\sceFont.cpp">
<Filter>HLE\Libraries</Filter>
</ClCompile>
Expand Down Expand Up @@ -1000,9 +997,6 @@
<ClInclude Include="Util\PPGeDraw.h">
<Filter>Util</Filter>
</ClInclude>
<ClInclude Include="Util\ppge_atlas.h">
<Filter>Util</Filter>
</ClInclude>
<ClInclude Include="HLE\sceFont.h">
<Filter>HLE\Libraries</Filter>
</ClInclude>
Expand Down
5 changes: 5 additions & 0 deletions Core/Dialog/PSPDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,13 @@ void PSPDialog::DoState(PointerWrap &p)
p.Do(isFading);
p.Do(fadeIn);
p.Do(fadeValue);

// I don't think we should save these two... Let's just ignore them for now for compat.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, as long as we restore them properly per messageDialog.common.buttonSwap / param.GetPspParam()->common.buttonSwap? I guess it should correct on next Update.

-[Unknown]

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it was always wrong to store IDs as part of a save state here that depend on what values the texture atlas compiler assigned.

I think it should indeed be enough to wait for the next update.

int okButtonImg = 0;
p.Do(okButtonImg);
int cancelButtonImg = 0;
p.Do(cancelButtonImg);

p.Do(okButtonFlag);
p.Do(cancelButtonFlag);

Expand Down
6 changes: 4 additions & 2 deletions Core/Dialog/PSPDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#pragma once

#include "gfx/texture_atlas.h"

#include "Common/Common.h"
#include "Common/CommonTypes.h"
#include "Common/Swap.h"
Expand Down Expand Up @@ -112,8 +114,8 @@ class PSPDialog
bool fadeIn;
u32 fadeValue;

int okButtonImg;
int cancelButtonImg;
ImageID okButtonImg;
ImageID cancelButtonImg;
int okButtonFlag;
int cancelButtonFlag;
};
8 changes: 4 additions & 4 deletions Core/Dialog/PSPMsgDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,14 @@ int PSPMsgDialog::Update(int animSpeed) {
UpdateButtons();
UpdateFade(animSpeed);

okButtonImg = I_CIRCLE;
cancelButtonImg = I_CROSS;
okButtonImg = ImageID("I_CIRCLE");
cancelButtonImg = ImageID("I_CROSS");
okButtonFlag = CTRL_CIRCLE;
cancelButtonFlag = CTRL_CROSS;
if (messageDialog.common.buttonSwap == 1)
{
okButtonImg = I_CROSS;
cancelButtonImg = I_CIRCLE;
okButtonImg = ImageID("I_CROSS");
cancelButtonImg = ImageID("I_CIRCLE");
okButtonFlag = CTRL_CROSS;
cancelButtonFlag = CTRL_CIRCLE;
}
Expand Down
2 changes: 1 addition & 1 deletion Core/Dialog/PSPNetconfDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ int PSPNetconfDialog::Update(int animSpeed) {
auto di = GetI18NCategory("Dialog");
auto err = GetI18NCategory("Error");
const float WRAP_WIDTH = 254.0f;
const int confirmBtnImage = g_Config.iButtonPreference == PSP_SYSTEMPARAM_BUTTON_CROSS ? I_CROSS : I_CIRCLE;
const ImageID confirmBtnImage = g_Config.iButtonPreference == PSP_SYSTEMPARAM_BUTTON_CROSS ? ImageID("I_CROSS") : ImageID("I_CIRCLE");
const int confirmBtn = g_Config.iButtonPreference == PSP_SYSTEMPARAM_BUTTON_CROSS ? CTRL_CROSS : CTRL_CIRCLE;

if (status == SCE_UTILITY_STATUS_INITIALIZE) {
Expand Down
10 changes: 5 additions & 5 deletions Core/Dialog/PSPOskDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -919,15 +919,15 @@ int PSPOskDialog::Update(int animSpeed) {

auto di = GetI18NCategory("Dialog");

PPGeDrawImage(I_SQUARE, 365, 222, 16, 16, 0, CalcFadedColor(0xFFFFFFFF));
PPGeDrawImage(ImageID("I_SQUARE"), 365, 222, 16, 16, 0, CalcFadedColor(0xFFFFFFFF));
PPGeDrawText(di->T("Space"), 390, 222, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));

if (g_Config.iButtonPreference != PSP_SYSTEMPARAM_BUTTON_CIRCLE) {
PPGeDrawImage(I_CROSS, 45, 222, 16, 16, 0, CalcFadedColor(0xFFFFFFFF));
PPGeDrawImage(I_CIRCLE, 45, 247, 16, 16, 0, CalcFadedColor(0xFFFFFFFF));
PPGeDrawImage(ImageID("I_CROSS"), 45, 222, 16, 16, 0, CalcFadedColor(0xFFFFFFFF));
PPGeDrawImage(ImageID("I_CIRCLE"), 45, 247, 16, 16, 0, CalcFadedColor(0xFFFFFFFF));
} else {
PPGeDrawImage(I_CIRCLE, 45, 222, 16, 16, 0, CalcFadedColor(0xFFFFFFFF));
PPGeDrawImage(I_CROSS, 45, 247, 16, 16, 0, CalcFadedColor(0xFFFFFFFF));
PPGeDrawImage(ImageID("I_CIRCLE"), 45, 222, 16, 16, 0, CalcFadedColor(0xFFFFFFFF));
PPGeDrawImage(ImageID("I_CROSS"), 45, 247, 16, 16, 0, CalcFadedColor(0xFFFFFFFF));
}

PPGeDrawText(di->T("Select"), 75, 222, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
Expand Down
8 changes: 4 additions & 4 deletions Core/Dialog/PSPSaveDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,13 +610,13 @@ int PSPSaveDialog::Update(int animSpeed)
UpdateButtons();
UpdateFade(animSpeed);

okButtonImg = I_CIRCLE;
cancelButtonImg = I_CROSS;
okButtonImg = ImageID("I_CIRCLE");
cancelButtonImg = ImageID("I_CROSS");
okButtonFlag = CTRL_CIRCLE;
cancelButtonFlag = CTRL_CROSS;
if (param.GetPspParam()->common.buttonSwap == 1) {
okButtonImg = I_CROSS;
cancelButtonImg = I_CIRCLE;
okButtonImg = ImageID("I_CROSS");
cancelButtonImg = ImageID("I_CIRCLE");
okButtonFlag = CTRL_CROSS;
cancelButtonFlag = CTRL_CIRCLE;
}
Expand Down
56 changes: 35 additions & 21 deletions Core/Util/PPGeDraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include <algorithm>

#include "base/stringutil.h"
#include "file/vfs.h"
#include "gfx/texture_atlas.h"
#include "image/zim_load.h"
#include "image/png_load.h"
#include "util/text/utf8.h"
Expand All @@ -36,6 +38,8 @@
#include "Core/MemMapHelpers.h"
#include "Core/System.h"

Atlas g_ppge_atlas;

static u32 atlasPtr;
static int atlasWidth;
static int atlasHeight;
Expand Down Expand Up @@ -190,6 +194,13 @@ void __PPGeInit()
return;
}

size_t atlas_data_size;
uint8_t *atlas_data;
if (!g_ppge_atlas.IsMetadataLoaded()) {
atlas_data = VFSReadFile("ppge_atlas.meta", &atlas_data_size);
g_ppge_atlas.Load(atlas_data, atlas_data_size);
delete[] atlas_data;
}
u32 atlasSize = height[0] * width[0] / 2; // it's a 4-bit paletted texture in ram
atlasWidth = width[0];
atlasHeight = height[0];
Expand Down Expand Up @@ -617,7 +628,7 @@ static AtlasTextMetrics BreakLines(const char *text, const AtlasFont &atlasfont,
void PPGeMeasureText(float *w, float *h, int *n,
const char *text, float scale, int WrapType, int wrapWidth)
{
const AtlasFont &atlasfont = *ppge_atlas.fonts[0];
const AtlasFont &atlasfont = g_ppge_atlas.fonts[0];
AtlasTextMetrics metrics = BreakLines(text, atlasfont, 0, 0, 0, scale, scale, WrapType, wrapWidth, true);
if (w) *w = metrics.maxWidth;
if (h) *h = metrics.lineHeight;
Expand All @@ -626,7 +637,7 @@ void PPGeMeasureText(float *w, float *h, int *n,

void PPGePrepareText(const char *text, float x, float y, int align, float scale, float lineHeightScale, int WrapType, int wrapWidth)
{
const AtlasFont &atlasfont = *ppge_atlas.fonts[0];
const AtlasFont &atlasfont = g_ppge_atlas.fonts[0];
char_lines_metrics = BreakLines(text, atlasfont, x, y, align, scale, lineHeightScale, WrapType, wrapWidth, false);
}

Expand Down Expand Up @@ -731,15 +742,16 @@ void PPGeDrawTextWrapped(const char *text, float x, float y, float wrapWidth, fl
}

// Draws a "4-patch" for button-like things that can be resized
void PPGeDraw4Patch(int atlasImage, float x, float y, float w, float h, u32 color)
{
void PPGeDraw4Patch(ImageID atlasImage, float x, float y, float w, float h, u32 color) {
if (!dlPtr)
return;
const AtlasImage &img = ppge_images[atlasImage];
float borderx = img.w / 20;
float bordery = img.h / 20;
float u1 = img.u1, uhalf = (img.u1 + img.u2) / 2, u2 = img.u2;
float v1 = img.v1, vhalf = (img.v1 + img.v2) / 2, v2 = img.v2;
const AtlasImage *img = g_ppge_atlas.getImage(atlasImage);
if (!img)
return;
float borderx = img->w / 20;
float bordery = img->h / 20;
float u1 = img->u1, uhalf = (img->u1 + img->u2) / 2, u2 = img->u2;
float v1 = img->v1, vhalf = (img->v1 + img->v2) / 2, v2 = img->v2;
float xmid1 = x + borderx;
float xmid2 = x + w - borderx;
float ymid1 = y + bordery;
Expand Down Expand Up @@ -771,8 +783,7 @@ void PPGeDraw4Patch(int atlasImage, float x, float y, float w, float h, u32 colo
EndVertexDataAndDraw(GE_PRIM_RECTANGLES);
}

void PPGeDrawRect(float x1, float y1, float x2, float y2, u32 color)
{
void PPGeDrawRect(float x1, float y1, float x2, float y2, u32 color) {
if (!dlPtr)
return;

Expand All @@ -787,29 +798,32 @@ void PPGeDrawRect(float x1, float y1, float x2, float y2, u32 color)
}

// Just blits an image to the screen, multiplied with the color.
void PPGeDrawImage(int atlasImage, float x, float y, int align, u32 color)
void PPGeDrawImage(ImageID atlasImage, float x, float y, int align, u32 color)
{
if (!dlPtr)
return;

const AtlasImage &img = ppge_atlas.images[atlasImage];
float w = img.w;
float h = img.h;
const AtlasImage *img = g_ppge_atlas.getImage(atlasImage);
if (!img) {
return;
}
float w = img->w;
float h = img->h;
BeginVertexData();
Vertex(x, y, img.u1, img.v1, atlasWidth, atlasHeight, color);
Vertex(x + w, y + h, img.u2, img.v2, atlasWidth, atlasHeight, color);
Vertex(x, y, img->u1, img->v1, atlasWidth, atlasHeight, color);
Vertex(x + w, y + h, img->u2, img->v2, atlasWidth, atlasHeight, color);
EndVertexDataAndDraw(GE_PRIM_RECTANGLES);
}

void PPGeDrawImage(int atlasImage, float x, float y, float w, float h, int align, u32 color)
void PPGeDrawImage(ImageID atlasImage, float x, float y, float w, float h, int align, u32 color)
{
if (!dlPtr)
return;

const AtlasImage &img = ppge_atlas.images[atlasImage];
const AtlasImage *img = g_ppge_atlas.getImage(atlasImage);
BeginVertexData();
Vertex(x, y, img.u1, img.v1, atlasWidth, atlasHeight, color);
Vertex(x + w, y + h, img.u2, img.v2, atlasWidth, atlasHeight, color);
Vertex(x, y, img->u1, img->v1, atlasWidth, atlasHeight, color);
Vertex(x + w, y + h, img->u2, img->v2, atlasWidth, atlasHeight, color);
EndVertexDataAndDraw(GE_PRIM_RECTANGLES);
}

Expand Down
10 changes: 6 additions & 4 deletions Core/Util/PPGeDraw.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@

#include <vector>
#include <string>
#include "ppge_atlas.h"

#include "gfx/texture_atlas.h"

#include "Common/CommonTypes.h"

class PointerWrap;
Expand Down Expand Up @@ -98,11 +100,11 @@ void PPGeDrawText(const char *text, float x, float y, int align, float scale = 1
void PPGeDrawTextWrapped(const char *text, float x, float y, float wrapWidth, float wrapHeight, int align, float scale = 1.0f, u32 color = 0xFFFFFFFF);

// Draws a "4-patch" for button-like things that can be resized.
void PPGeDraw4Patch(int atlasImage, float x, float y, float w, float h, u32 color = 0xFFFFFFFF);
void PPGeDraw4Patch(ImageID atlasImage, float x, float y, float w, float h, u32 color = 0xFFFFFFFF);

// Just blits an image to the screen, multiplied with the color.
void PPGeDrawImage(int atlasImage, float x, float y, int align, u32 color = 0xFFFFFFFF);
void PPGeDrawImage(int atlasImage, float x, float y, float w, float h, int align, u32 color = 0xFFFFFFFF);
void PPGeDrawImage(ImageID atlasImage, float x, float y, int align, u32 color = 0xFFFFFFFF);
void PPGeDrawImage(ImageID atlasImage, float x, float y, float w, float h, int align, u32 color = 0xFFFFFFFF);
void PPGeDrawImage(float x, float y, float w, float h, float u1, float v1, float u2, float v2, int tw, int th, u32 color);

class PPGeImage {
Expand Down
Loading