2012-11-18 12:04:49 +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
|
|
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2014-03-15 17:38:46 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
2020-02-29 20:51:14 +00:00
|
|
|
|
2020-10-04 21:24:14 +00:00
|
|
|
#include "Common/Render/TextureAtlas.h"
|
2020-02-29 20:51:14 +00:00
|
|
|
|
2013-12-30 09:17:11 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2012-11-18 12:04:49 +00:00
|
|
|
|
2013-02-04 04:31:46 +00:00
|
|
|
class PointerWrap;
|
|
|
|
|
2012-11-18 12:04:49 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// PPGeDraw: Super simple internal drawing API for 2D overlays like sceUtility messageboxes
|
2020-12-20 11:11:02 +00:00
|
|
|
// etc. Goes through the Ge emulation so that it doesn't need to care about backends.
|
|
|
|
//
|
|
|
|
// It does need a thin3d Draw-context but only for text rendering.
|
|
|
|
|
|
|
|
namespace Draw {
|
|
|
|
class DrawContext;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PPGeSetDrawContext(Draw::DrawContext *draw);
|
2012-11-18 12:04:49 +00:00
|
|
|
|
|
|
|
// Uploads the necessary texture atlas and other data to kernel RAM, and reserves
|
|
|
|
// space for the display list. The PSP must be inited.
|
|
|
|
void __PPGeInit();
|
|
|
|
|
2012-12-28 07:00:04 +00:00
|
|
|
// Saves to and restores from savestates (kernel RAM pointers, etc.)
|
|
|
|
void __PPGeDoState(PointerWrap &p);
|
|
|
|
|
2012-11-18 12:04:49 +00:00
|
|
|
// Just frees up the allocated kernel memory.
|
|
|
|
void __PPGeShutdown();
|
|
|
|
|
|
|
|
// Save and restore the Ge context. PPGeEnd() kicks off the generated display list.
|
|
|
|
void PPGeBegin();
|
|
|
|
void PPGeEnd();
|
|
|
|
|
2020-05-24 02:59:56 +00:00
|
|
|
enum class PPGeAlign {
|
|
|
|
BOX_LEFT = 0x00,
|
|
|
|
BOX_RIGHT = 0x01,
|
|
|
|
BOX_HCENTER = 0x02,
|
|
|
|
|
|
|
|
BOX_TOP = 0x00,
|
|
|
|
BOX_BOTTOM = 0x10,
|
|
|
|
BOX_VCENTER = 0x20,
|
|
|
|
|
|
|
|
BOX_CENTER = 0x22,
|
|
|
|
|
|
|
|
ANY = 0xFF,
|
2012-11-18 12:04:49 +00:00
|
|
|
};
|
2021-01-03 22:42:29 +00:00
|
|
|
ENUM_CLASS_BITOPS(PPGeAlign);
|
2012-11-18 12:04:49 +00:00
|
|
|
|
2013-06-10 05:48:35 +00:00
|
|
|
enum {
|
2014-03-03 16:16:53 +00:00
|
|
|
PPGE_LINE_NONE = 0,
|
2013-06-10 05:48:35 +00:00
|
|
|
PPGE_LINE_USE_ELLIPSIS = 1, // use ellipses in too long words
|
2014-03-03 16:16:53 +00:00
|
|
|
PPGE_LINE_WRAP_WORD = 2,
|
|
|
|
PPGE_LINE_WRAP_CHAR = 4,
|
2013-06-10 05:48:35 +00:00
|
|
|
};
|
|
|
|
|
2020-05-24 04:21:16 +00:00
|
|
|
struct PPGeStyle {
|
|
|
|
PPGeAlign align = PPGeAlign::BOX_LEFT;
|
|
|
|
float scale = 1.0f;
|
|
|
|
uint32_t color = 0xFFFFFFFF;
|
|
|
|
bool hasShadow = false;
|
|
|
|
uint32_t shadowColor = 0x80000000;
|
|
|
|
};
|
|
|
|
|
2021-01-03 22:42:29 +00:00
|
|
|
struct PPGeImageStyle {
|
|
|
|
uint32_t color = 0xFFFFFFFF;
|
|
|
|
};
|
|
|
|
|
2013-06-10 12:37:30 +00:00
|
|
|
// Get the metrics of the bounding box of the text without changing the buffer or state.
|
2020-03-24 01:23:35 +00:00
|
|
|
void PPGeMeasureText(float *w, float *h, const char *text, float scale, int WrapType = PPGE_LINE_NONE, int wrapWidth = 0);
|
2013-06-10 12:37:30 +00:00
|
|
|
|
2012-11-18 12:04:49 +00:00
|
|
|
// Draws some text using the one font we have.
|
2013-06-10 12:37:30 +00:00
|
|
|
// Clears the text buffer when done.
|
2020-05-24 04:21:16 +00:00
|
|
|
void PPGeDrawText(const char *text, float x, float y, const PPGeStyle &style);
|
|
|
|
void PPGeDrawTextWrapped(const char *text, float x, float y, float wrapWidth, float wrapHeight, const PPGeStyle &style);
|
2012-11-18 12:04:49 +00:00
|
|
|
|
2013-06-10 12:37:30 +00:00
|
|
|
// Draws a "4-patch" for button-like things that can be resized.
|
2020-02-29 20:51:14 +00:00
|
|
|
void PPGeDraw4Patch(ImageID atlasImage, float x, float y, float w, float h, u32 color = 0xFFFFFFFF);
|
2012-11-18 12:04:49 +00:00
|
|
|
|
|
|
|
// Just blits an image to the screen, multiplied with the color.
|
2020-05-24 04:21:16 +00:00
|
|
|
void PPGeDrawImage(ImageID atlasImage, float x, float y, const PPGeStyle &style);
|
|
|
|
void PPGeDrawImage(ImageID atlasImage, float x, float y, float w, float h, const PPGeStyle &style);
|
2021-01-03 22:42:29 +00:00
|
|
|
void PPGeDrawImage(float x, float y, float w, float h, float u1, float v1, float u2, float v2, int tw, int th, const PPGeImageStyle &style);
|
2012-12-13 21:06:45 +00:00
|
|
|
|
2020-05-24 05:38:02 +00:00
|
|
|
// Note: x2/y2 are exclusive.
|
|
|
|
void PPGeScissor(int x1, int y1, int x2, int y2);
|
|
|
|
void PPGeScissorReset();
|
|
|
|
|
2020-03-11 00:53:30 +00:00
|
|
|
void PPGeNotifyFrame();
|
|
|
|
|
2013-12-08 19:06:18 +00:00
|
|
|
class PPGeImage {
|
|
|
|
public:
|
|
|
|
PPGeImage(const std::string &pspFilename);
|
|
|
|
PPGeImage(u32 pngPointer, size_t pngSize);
|
|
|
|
~PPGeImage();
|
|
|
|
|
|
|
|
void SetTexture();
|
|
|
|
|
|
|
|
// Does not normally need to be called (except to force preloading.)
|
|
|
|
bool Load();
|
|
|
|
void Free();
|
|
|
|
|
|
|
|
void DoState(PointerWrap &p);
|
|
|
|
|
|
|
|
// Do not use, only for savestate upgrading.
|
|
|
|
void CompatLoad(u32 texture, int width, int height);
|
|
|
|
|
2014-12-03 20:16:11 +00:00
|
|
|
int Width() const {
|
2013-12-08 19:06:18 +00:00
|
|
|
return width_;
|
|
|
|
}
|
|
|
|
|
2014-12-03 20:16:11 +00:00
|
|
|
int Height() const {
|
2013-12-08 19:06:18 +00:00
|
|
|
return height_;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void Decimate();
|
2020-03-11 00:53:30 +00:00
|
|
|
|
|
|
|
private:
|
2013-12-08 19:06:18 +00:00
|
|
|
static std::vector<PPGeImage *> loadedTextures_;
|
|
|
|
|
|
|
|
std::string filename_;
|
|
|
|
|
|
|
|
// Only valid if filename_.empty().
|
|
|
|
u32 png_;
|
|
|
|
size_t size_;
|
|
|
|
|
|
|
|
u32 texture_;
|
|
|
|
int width_;
|
|
|
|
int height_;
|
|
|
|
|
|
|
|
int lastFrame_;
|
|
|
|
};
|
|
|
|
|
2013-01-06 22:23:36 +00:00
|
|
|
void PPGeDrawRect(float x1, float y1, float x2, float y2, u32 color);
|
|
|
|
|
2012-12-13 21:06:45 +00:00
|
|
|
void PPGeSetDefaultTexture();
|
|
|
|
void PPGeDisableTexture();
|
2012-11-18 12:04:49 +00:00
|
|
|
|