diff --git a/Common/GraphicsContext.h b/Common/GraphicsContext.h index f0f419cb1e..365c4faeaa 100644 --- a/Common/GraphicsContext.h +++ b/Common/GraphicsContext.h @@ -25,7 +25,7 @@ public: // Needs casting to the appropriate type, unfortunately. Should find a better solution.. virtual void *GetAPIContext() { return nullptr; } - virtual Thin3DContext *CreateThin3DContext() = 0; + virtual Draw::Thin3DContext *CreateThin3DContext() = 0; }; class DummyGraphicsContext : public GraphicsContext { @@ -35,5 +35,5 @@ public: void SwapBuffers() override {} void Resize() override {} - Thin3DContext *CreateThin3DContext() override { return nullptr; } + Draw::Thin3DContext *CreateThin3DContext() override { return nullptr; } }; \ No newline at end of file diff --git a/Core/CoreParameter.h b/Core/CoreParameter.h index c9351443c7..a5cae73bb7 100644 --- a/Core/CoreParameter.h +++ b/Core/CoreParameter.h @@ -34,7 +34,9 @@ enum GPUCore { class FileLoader; class GraphicsContext; -class Thin3DContext; +namespace Draw { + class Thin3DContext; +} // PSP_CoreParameter() struct CoreParameter { @@ -44,7 +46,7 @@ struct CoreParameter { GPUCore gpuCore; GraphicsContext *graphicsContext; // TODO: Find a better place. - Thin3DContext *thin3d; + Draw::Thin3DContext *thin3d; bool enableSound; // there aren't multiple sound cores. std::string fileToStart; diff --git a/GPU/Directx9/GPU_DX9.cpp b/GPU/Directx9/GPU_DX9.cpp index cbec9370e3..191105d967 100644 --- a/GPU/Directx9/GPU_DX9.cpp +++ b/GPU/Directx9/GPU_DX9.cpp @@ -512,6 +512,7 @@ GPU_DX9::~GPU_DX9() { // Needs to be called on GPU thread, not reporting thread. void GPU_DX9::BuildReportingInfo() { + using namespace Draw; Thin3DContext *thin3d = gfxCtx_->CreateThin3DContext(); reportingPrimaryInfo_ = thin3d->GetInfoString(T3DInfo::VENDORSTRING); diff --git a/GPU/GPU.cpp b/GPU/GPU.cpp index cc91b1e512..49555ecac4 100644 --- a/GPU/GPU.cpp +++ b/GPU/GPU.cpp @@ -46,7 +46,7 @@ static void SetGPU(T *obj) { #undef new #endif -bool GPU_Init(GraphicsContext *ctx, Thin3DContext *thin3d) { +bool GPU_Init(GraphicsContext *ctx, Draw::Thin3DContext *thin3d) { switch (PSP_CoreParameter().gpuCore) { case GPUCORE_NULL: SetGPU(new NullGPU()); diff --git a/GPU/GPU.h b/GPU/GPU.h index f48fc940ea..43dd2a8064 100644 --- a/GPU/GPU.h +++ b/GPU/GPU.h @@ -98,7 +98,9 @@ extern GPUStatistics gpuStats; extern GPUInterface *gpu; extern GPUDebugInterface *gpuDebug; -class Thin3DContext; +namespace Draw { + class Thin3DContext; +} -bool GPU_Init(GraphicsContext *ctx, Thin3DContext *thin3d); +bool GPU_Init(GraphicsContext *ctx, Draw::Thin3DContext *thin3d); void GPU_Shutdown(); diff --git a/GPU/Software/SoftGpu.cpp b/GPU/Software/SoftGpu.cpp index 14be8bdac0..d0ccabc656 100644 --- a/GPU/Software/SoftGpu.cpp +++ b/GPU/Software/SoftGpu.cpp @@ -42,18 +42,19 @@ FormatBuffer fb; FormatBuffer depthbuf; u32 clut[4096]; -static Thin3DVertexFormat *vformat = nullptr; -static Thin3DDepthStencilState *depth = nullptr; -static Thin3DRasterState *rasterNoCull = nullptr; -static Thin3DBlendState *blendstateOff = nullptr; -static Thin3DSamplerState *samplerNearest = nullptr; -static Thin3DSamplerState *samplerLinear = nullptr; -static Thin3DBuffer *vdata = nullptr; -static Thin3DBuffer *idata = nullptr; +static Draw::Thin3DVertexFormat *vformat = nullptr; +static Draw::Thin3DDepthStencilState *depth = nullptr; +static Draw::Thin3DRasterState *rasterNoCull = nullptr; +static Draw::Thin3DBlendState *blendstateOff = nullptr; +static Draw::Thin3DSamplerState *samplerNearest = nullptr; +static Draw::Thin3DSamplerState *samplerLinear = nullptr; +static Draw::Thin3DBuffer *vdata = nullptr; +static Draw::Thin3DBuffer *idata = nullptr; -SoftGPU::SoftGPU(GraphicsContext *gfxCtx, Thin3DContext *_thin3D) +SoftGPU::SoftGPU(GraphicsContext *gfxCtx, Draw::Thin3DContext *_thin3D) : gfxCtx_(gfxCtx), thin3d(_thin3D) { + using namespace Draw; fbTex = thin3d->CreateTexture(LINEAR2D, T3DDataFormat::R8A8G8B8_UNORM, 480, 272, 1, 1); std::vector components; @@ -124,6 +125,8 @@ void SoftGPU::SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat for // Copies RGBA8 data from RAM to the currently bound render target. void SoftGPU::CopyToCurrentFboFromDisplayRam(int srcwidth, int srcheight) { + using namespace Draw; + if (!thin3d) return; float dstwidth = (float)PSP_CoreParameter().pixelWidth; diff --git a/GPU/Software/SoftGpu.h b/GPU/Software/SoftGpu.h index cd958bbb66..0fd68708db 100644 --- a/GPU/Software/SoftGpu.h +++ b/GPU/Software/SoftGpu.h @@ -45,12 +45,14 @@ typedef struct { } FormatBuffer; class ShaderManager; -class Thin3DContext; -class Thin3DTexture; +namespace Draw { + class Thin3DContext; + class Thin3DTexture; +} class SoftGPU : public GPUCommon { public: - SoftGPU(GraphicsContext *gfxCtx, Thin3DContext *_thin3D); + SoftGPU(GraphicsContext *gfxCtx, Draw::Thin3DContext *_thin3D); ~SoftGPU(); void InitClear() override {} void ExecuteOp(u32 op, u32 diff) override; @@ -105,7 +107,7 @@ private: GEBufferFormat displayFormat_; GraphicsContext *gfxCtx_; - Thin3DTexture *fbTex; - Thin3DContext *thin3d; + Draw::Thin3DTexture *fbTex; + Draw::Thin3DContext *thin3d; std::vector fbTexBuffer; }; diff --git a/UI/DevScreens.cpp b/UI/DevScreens.cpp index 3262176875..2f8ccc06f7 100644 --- a/UI/DevScreens.cpp +++ b/UI/DevScreens.cpp @@ -314,6 +314,8 @@ const char *GetCompilerABI() { } void SystemInfoScreen::CreateViews() { + using namespace Draw; + // NOTE: Do not translate this section. It will change a lot and will be impossible to keep up. I18NCategory *di = GetI18NCategory("Dialog"); diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 1a1b630aa0..2f70342c89 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -968,6 +968,8 @@ static void DrawFPS(DrawBuffer *draw2d, const Bounds &bounds) { } void EmuScreen::render() { + using namespace Draw; + if (invalid_) { // It's possible this might be set outside PSP_RunLoopFor(). // In this case, we need to double check it here. diff --git a/UI/GameInfoCache.cpp b/UI/GameInfoCache.cpp index f9fc5a527a..19cbaa6124 100644 --- a/UI/GameInfoCache.cpp +++ b/UI/GameInfoCache.cpp @@ -730,7 +730,7 @@ void GameInfoCache::WaitUntilDone(GameInfo *info) { // Runs on the main thread. -GameInfo *GameInfoCache::GetInfo(Thin3DContext *thin3d, const std::string &gamePath, int wantFlags) { +GameInfo *GameInfoCache::GetInfo(Draw::Thin3DContext *thin3d, const std::string &gamePath, int wantFlags) { GameInfo *info = 0; auto iter = info_.find(gamePath); @@ -781,7 +781,8 @@ again: return info; } -void GameInfoCache::SetupTexture(GameInfo *info, std::string &textureData, Thin3DContext *thin3d, Thin3DTexture *&tex, double &loadTime) { +void GameInfoCache::SetupTexture(GameInfo *info, std::string &textureData, Draw::Thin3DContext *thin3d, Draw::Thin3DTexture *&tex, double &loadTime) { + using namespace Draw; if (textureData.size()) { if (!tex) { tex = thin3d->CreateTextureFromFileData((const uint8_t *)textureData.data(), (int)textureData.size(), T3DImageType::DETECT); diff --git a/UI/GameInfoCache.h b/UI/GameInfoCache.h index a741fb02a8..9152d72fe3 100644 --- a/UI/GameInfoCache.h +++ b/UI/GameInfoCache.h @@ -25,8 +25,10 @@ #include "Core/ELF/ParamSFO.h" #include "Core/Loaders.h" -class Thin3DContext; -class Thin3DTexture; +namespace Draw { + class Thin3DContext; + class Thin3DTexture; +} class PrioritizedWorkQueue; // A GameInfo holds information about a game, and also lets you do things that the VSH @@ -140,11 +142,11 @@ public: // Pre read the data, create a texture the next time (GL thread..) std::string iconTextureData; - Thin3DTexture *iconTexture; + Draw::Thin3DTexture *iconTexture; std::string pic0TextureData; - Thin3DTexture *pic0Texture; + Draw::Thin3DTexture *pic0Texture; std::string pic1TextureData; - Thin3DTexture *pic1Texture; + Draw::Thin3DTexture *pic1Texture; std::string sndFileData; @@ -190,7 +192,7 @@ public: // but filled in later asynchronously in the background. So keep calling this, // redrawing the UI often. Only set flags to GAMEINFO_WANTBG or WANTSND if you really want them // because they're big. bgTextures and sound may be discarded over time as well. - GameInfo *GetInfo(Thin3DContext *thin3d, const std::string &gamePath, int wantFlags); + GameInfo *GetInfo(Draw::Thin3DContext *thin3d, const std::string &gamePath, int wantFlags); void FlushBGs(); // Gets rid of all BG textures. Also gets rid of bg sounds. PrioritizedWorkQueue *WorkQueue() { return gameInfoWQ_; } @@ -200,7 +202,7 @@ public: private: void Init(); void Shutdown(); - void SetupTexture(GameInfo *info, std::string &textureData, Thin3DContext *thin3d, Thin3DTexture *&tex, double &loadTime); + void SetupTexture(GameInfo *info, std::string &textureData, Draw::Thin3DContext *thin3d, Draw::Thin3DTexture *&tex, double &loadTime); // Maps ISO path to info. std::map info_; diff --git a/UI/GameScreen.cpp b/UI/GameScreen.cpp index 142f090c43..86140dc413 100644 --- a/UI/GameScreen.cpp +++ b/UI/GameScreen.cpp @@ -185,7 +185,7 @@ void GameScreen::update(InputState &input) { I18NCategory *ga = GetI18NCategory("Game"); - Thin3DContext *thin3d = screenManager()->getThin3DContext(); + Draw::Thin3DContext *thin3d = screenManager()->getThin3DContext(); GameInfo *info = g_gameInfoCache->GetInfo(thin3d, gamePath_, GAMEINFO_WANTBG | GAMEINFO_WANTSIZE); diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index f2a2a8891f..2960a9c4ec 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -174,7 +174,7 @@ private: void GameButton::Draw(UIContext &dc) { GameInfo *ginfo = g_gameInfoCache->GetInfo(dc.GetThin3DContext(), gamePath_, 0); - Thin3DTexture *texture = 0; + Draw::Thin3DTexture *texture = 0; u32 color = 0, shadowColor = 0; using namespace UI; diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index e13986496d..c2425c3f2f 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -432,6 +432,8 @@ bool LogoScreen::key(const KeyInput &key) { } void LogoScreen::render() { + using namespace Draw; + UIScreen::render(); UIContext &dc = *screenManager()->getUIContext(); diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 32203d9efc..14c2009bb4 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -117,7 +117,7 @@ static UI::Theme ui_theme; #include "android/android-ndk-profiler/prof.h" #endif -Thin3DTexture *uiTexture; +Draw::Thin3DTexture *uiTexture; ScreenManager *screenManager; std::string config_filename; @@ -139,7 +139,7 @@ struct PendingMessage { static recursive_mutex pendingMutex; static std::vector pendingMessages; -static Thin3DContext *thin3d; +static Draw::Thin3DContext *thin3d; static UIContext *uiContext; static std::vector inputboxValue; @@ -147,7 +147,7 @@ static std::vector inputboxValue; WindowsAudioBackend *winAudioBackend; #endif -Thin3DContext *GetThin3D() { +Draw::Thin3DContext *GetThin3D() { return thin3d; } @@ -524,6 +524,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch } void NativeInitGraphics(GraphicsContext *graphicsContext) { + using namespace Draw; Core_SetGraphicsContext(graphicsContext); thin3d = graphicsContext->CreateThin3DContext(); diff --git a/UI/PauseScreen.cpp b/UI/PauseScreen.cpp index 444d32f24b..10c2b221e6 100644 --- a/UI/PauseScreen.cpp +++ b/UI/PauseScreen.cpp @@ -76,6 +76,7 @@ void AsyncImageFileView::SetFilename(std::string filename) { } void AsyncImageFileView::Draw(UIContext &dc) { + using namespace Draw; if (!texture_ && !textureFailed_ && !filename_.empty()) { texture_ = dc.GetThin3DContext()->CreateTextureFromFile(filename_.c_str(), DETECT); if (!texture_) diff --git a/UI/PauseScreen.h b/UI/PauseScreen.h index b25e669e93..4589c41984 100644 --- a/UI/PauseScreen.h +++ b/UI/PauseScreen.h @@ -95,7 +95,7 @@ private: uint32_t color_; UI::ImageSizeMode sizeMode_; - Thin3DTexture *texture_; + Draw::Thin3DTexture *texture_; bool textureFailed_; bool textureAutoGen_; float fixedSizeW_; diff --git a/UI/SavedataScreen.cpp b/UI/SavedataScreen.cpp index 83c44c61f8..874fd36b4d 100644 --- a/UI/SavedataScreen.cpp +++ b/UI/SavedataScreen.cpp @@ -154,7 +154,7 @@ static std::string CleanSaveString(std::string str) { void SavedataButton::Draw(UIContext &dc) { GameInfo *ginfo = g_gameInfoCache->GetInfo(dc.GetThin3DContext(), savePath_, GAMEINFO_WANTSIZE); - Thin3DTexture *texture = 0; + Draw::Thin3DTexture *texture = 0; u32 color = 0, shadowColor = 0; using namespace UI; diff --git a/UI/Store.cpp b/UI/Store.cpp index a96d113e43..0d258e8197 100644 --- a/UI/Store.cpp +++ b/UI/Store.cpp @@ -84,7 +84,7 @@ private: std::shared_ptr download_; std::string textureData_; - Thin3DTexture *texture_; + Draw::Thin3DTexture *texture_; bool textureFailed_; float fixedSizeW_; float fixedSizeH_; @@ -135,6 +135,7 @@ void HttpImageFileView::DownloadCompletedCallback(http::Download &download) { } void HttpImageFileView::Draw(UIContext &dc) { + using namespace Draw; if (!texture_ && !textureFailed_ && !path_.empty() && !download_) { download_ = downloader_->StartDownloadWithCallback(path_, "", std::bind(&HttpImageFileView::DownloadCompletedCallback, this, std::placeholders::_1)); download_->SetHidden(true); diff --git a/Windows/GPU/D3D11Context.cpp b/Windows/GPU/D3D11Context.cpp index 0cd93bb11c..6a075b81a5 100644 --- a/Windows/GPU/D3D11Context.cpp +++ b/Windows/GPU/D3D11Context.cpp @@ -15,8 +15,8 @@ void D3D11Context::SwapBuffers() { swapChain_->Present(0, 0); } -Thin3DContext *D3D11Context::CreateThin3DContext() { - return T3DCreateD3D11Context(); // device_, context_); +Draw::Thin3DContext *D3D11Context::CreateThin3DContext() { + return Draw::T3DCreateD3D11Context(); // device_, context_); } static void GetRes(HWND hWnd, int &xres, int &yres) { diff --git a/Windows/GPU/D3D11Context.h b/Windows/GPU/D3D11Context.h index 58183dd759..d89aee1e4c 100644 --- a/Windows/GPU/D3D11Context.h +++ b/Windows/GPU/D3D11Context.h @@ -37,7 +37,7 @@ public: void Resize() override; - Thin3DContext *CreateThin3DContext() override; + Draw::Thin3DContext *CreateThin3DContext() override; private: ID3D11Device *device_; diff --git a/Windows/GPU/D3D9Context.cpp b/Windows/GPU/D3D9Context.cpp index cee3e8413a..516ae82f4a 100644 --- a/Windows/GPU/D3D9Context.cpp +++ b/Windows/GPU/D3D9Context.cpp @@ -27,8 +27,8 @@ void D3D9Context::SwapBuffers() { } } -Thin3DContext *D3D9Context::CreateThin3DContext() { - return T3DCreateDX9Context(d3d, d3dEx, adapterId, device, deviceEx); +Draw::Thin3DContext *D3D9Context::CreateThin3DContext() { + return Draw::T3DCreateDX9Context(d3d, d3dEx, adapterId, device, deviceEx); } typedef HRESULT (__stdcall *DIRECT3DCREATE9EX)(UINT, IDirect3D9Ex**); diff --git a/Windows/GPU/D3D9Context.h b/Windows/GPU/D3D9Context.h index 6c43ce4cf0..6bf4d9ddc2 100644 --- a/Windows/GPU/D3D9Context.h +++ b/Windows/GPU/D3D9Context.h @@ -23,7 +23,9 @@ #include "Windows/GPU/WindowsGraphicsContext.h" #include -class Thin3DContext; +namespace Draw { + class Thin3DContext; +} class D3D9Context : public WindowsGraphicsContext { public: @@ -37,7 +39,7 @@ public: void Resize() override; - Thin3DContext *CreateThin3DContext() override; + Draw::Thin3DContext *CreateThin3DContext() override; private: bool has9Ex; diff --git a/Windows/GPU/WindowsGLContext.cpp b/Windows/GPU/WindowsGLContext.cpp index 65881c6eaf..7089e4652a 100644 --- a/Windows/GPU/WindowsGLContext.cpp +++ b/Windows/GPU/WindowsGLContext.cpp @@ -400,8 +400,7 @@ void WindowsGLContext::Shutdown() { void WindowsGLContext::Resize() { } -Thin3DContext *WindowsGLContext::CreateThin3DContext() { +Draw::Thin3DContext *WindowsGLContext::CreateThin3DContext() { CheckGLExtensions(); - Thin3DContext *ctx = T3DCreateGLContext(); - return ctx; + return Draw::T3DCreateGLContext(); } diff --git a/Windows/GPU/WindowsGLContext.h b/Windows/GPU/WindowsGLContext.h index 54289c9efe..a7a8e7e152 100644 --- a/Windows/GPU/WindowsGLContext.h +++ b/Windows/GPU/WindowsGLContext.h @@ -3,7 +3,9 @@ #include "Common/CommonWindows.h" #include "Windows/GPU/WindowsGraphicsContext.h" -class Thin3DContext; +namespace Draw { + class Thin3DContext; +} class WindowsGLContext : public WindowsGraphicsContext { public: @@ -19,7 +21,7 @@ public: void Resize() override; - Thin3DContext *CreateThin3DContext() override; + Draw::Thin3DContext *CreateThin3DContext() override; private: HDC hDC; // Private GDI Device Context diff --git a/Windows/GPU/WindowsVulkanContext.cpp b/Windows/GPU/WindowsVulkanContext.cpp index c6af516ee8..8ca56d0cb5 100644 --- a/Windows/GPU/WindowsVulkanContext.cpp +++ b/Windows/GPU/WindowsVulkanContext.cpp @@ -206,8 +206,8 @@ void WindowsVulkanContext::Shutdown() { finalize_glslang(); } -Thin3DContext *WindowsVulkanContext::CreateThin3DContext() { - return T3DCreateVulkanContext(g_Vulkan); +Draw::Thin3DContext *WindowsVulkanContext::CreateThin3DContext() { + return Draw::T3DCreateVulkanContext(g_Vulkan); } void WindowsVulkanContext::SwapBuffers() { diff --git a/Windows/GPU/WindowsVulkanContext.h b/Windows/GPU/WindowsVulkanContext.h index 0aad7d92c3..d49f1654a7 100644 --- a/Windows/GPU/WindowsVulkanContext.h +++ b/Windows/GPU/WindowsVulkanContext.h @@ -31,6 +31,6 @@ public: void *GetAPIContext(); - Thin3DContext *CreateThin3DContext() override; + Draw::Thin3DContext *CreateThin3DContext() override; }; diff --git a/ext/native/gfx_es2/draw_buffer.cpp b/ext/native/gfx_es2/draw_buffer.cpp index e38ac1dd21..e5af9e81f0 100644 --- a/ext/native/gfx_es2/draw_buffer.cpp +++ b/ext/native/gfx_es2/draw_buffer.cpp @@ -32,7 +32,9 @@ DrawBuffer::~DrawBuffer() { delete [] verts_; } -void DrawBuffer::Init(Thin3DContext *t3d) { +void DrawBuffer::Init(Draw::Thin3DContext *t3d) { + using namespace Draw; + if (inited_) return; @@ -63,7 +65,7 @@ void DrawBuffer::Shutdown() { inited_ = false; } -void DrawBuffer::Begin(Thin3DShaderSet *program, DrawBufferPrimitiveMode dbmode) { +void DrawBuffer::Begin(Draw::Thin3DShaderSet *program, DrawBufferPrimitiveMode dbmode) { shaderSet_ = program; count_ = 0; mode_ = dbmode; @@ -74,6 +76,7 @@ void DrawBuffer::End() { } void DrawBuffer::Flush(bool set_blend_state) { + using namespace Draw; if (!shaderSet_) { ELOG("No program set!"); return; diff --git a/ext/native/gfx_es2/draw_buffer.h b/ext/native/gfx_es2/draw_buffer.h index 32658f1bf4..58070429ab 100644 --- a/ext/native/gfx_es2/draw_buffer.h +++ b/ext/native/gfx_es2/draw_buffer.h @@ -42,7 +42,9 @@ enum { FLAG_WRAP_TEXT = 8192, }; -class Thin3DShaderSet; +namespace Draw { + class Thin3DShaderSet; +} enum DrawBufferPrimitiveMode { DBMODE_NORMAL = 0, @@ -61,11 +63,11 @@ public: DrawBuffer(); ~DrawBuffer(); - void Begin(Thin3DShaderSet *shaders, DrawBufferPrimitiveMode mode = DBMODE_NORMAL); + void Begin(Draw::Thin3DShaderSet *shaders, DrawBufferPrimitiveMode mode = DBMODE_NORMAL); void End(); // TODO: Enforce these. Now Init is autocalled and shutdown not called. - void Init(Thin3DContext *t3d); + void Init(Draw::Thin3DContext *t3d); void Shutdown(); int Count() const { return count_; } @@ -155,10 +157,10 @@ private: Matrix4x4 drawMatrix_; - Thin3DContext *t3d_; - Thin3DBuffer *vbuf_; - Thin3DVertexFormat *vformat_; - Thin3DShaderSet *shaderSet_; + Draw::Thin3DContext *t3d_; + Draw::Thin3DBuffer *vbuf_; + Draw::Thin3DVertexFormat *vformat_; + Draw::Thin3DShaderSet *shaderSet_; Vertex *verts_; int count_; diff --git a/ext/native/gfx_es2/draw_text.cpp b/ext/native/gfx_es2/draw_text.cpp index d552db263b..d732c5e531 100644 --- a/ext/native/gfx_es2/draw_text.cpp +++ b/ext/native/gfx_es2/draw_text.cpp @@ -50,7 +50,7 @@ struct TextDrawerContext { int *pBitmapBits; }; -TextDrawer::TextDrawer(Thin3DContext *thin3d) : thin3d_(thin3d), ctx_(NULL) { +TextDrawer::TextDrawer(Draw::Thin3DContext *thin3d) : thin3d_(thin3d), ctx_(nullptr) { fontScaleX_ = 1.0f; fontScaleY_ = 1.0f; @@ -215,6 +215,7 @@ void TextDrawer::MeasureStringRect(const char *str, size_t len, const Bounds &bo } void TextDrawer::DrawString(DrawBuffer &target, const char *str, float x, float y, uint32_t color, int align) { + using namespace Draw; if (!strlen(str)) return; diff --git a/ext/native/gfx_es2/draw_text.h b/ext/native/gfx_es2/draw_text.h index 4b68702a4c..7cce92f748 100644 --- a/ext/native/gfx_es2/draw_text.h +++ b/ext/native/gfx_es2/draw_text.h @@ -13,15 +13,17 @@ #include "base/basictypes.h" #include "gfx_es2/draw_buffer.h" -class Thin3DContext; -class Thin3DTexture; +namespace Draw { + class Thin3DContext; + class Thin3DTexture; +} #ifdef USING_QT_UI #include #endif struct TextStringEntry { - Thin3DTexture *texture; + Draw::Thin3DTexture *texture; int width; int height; int bmWidth; @@ -47,7 +49,7 @@ struct TextDrawerFontContext; class TextDrawer { public: - TextDrawer(Thin3DContext *thin3d); + TextDrawer(Draw::Thin3DContext *thin3d); ~TextDrawer(); uint32_t SetFont(const char *fontName, int size, int flags); @@ -63,7 +65,7 @@ public: void OncePerFrame(); private: - Thin3DContext *thin3d_; + Draw::Thin3DContext *thin3d_; void WrapString(std::string &out, const char *str, float maxWidth); diff --git a/ext/native/thin3d/thin3d.cpp b/ext/native/thin3d/thin3d.cpp index 6e237b15b1..a515ad59b1 100644 --- a/ext/native/thin3d/thin3d.cpp +++ b/ext/native/thin3d/thin3d.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include "base/logging.h" @@ -7,6 +7,8 @@ #include "file/vfs.h" #include "ext/jpge/jpgd.h" +namespace Draw { + // ================================== PIXEL/FRAGMENT SHADERS // The Vulkan ones can be re-used with modern GL later if desired, as they're just GLSL. @@ -320,3 +322,5 @@ Thin3DTexture *Thin3DContext::CreateTextureFromFileData(const uint8_t *data, int tex->Finalize(zim_flags); return tex; } + +} // namespace Draw \ No newline at end of file diff --git a/ext/native/thin3d/thin3d.h b/ext/native/thin3d/thin3d.h index 644bc49a33..05d765b866 100644 --- a/ext/native/thin3d/thin3d.h +++ b/ext/native/thin3d/thin3d.h @@ -15,6 +15,19 @@ class Matrix4x4; +#ifdef _WIN32 + +struct IDirect3DDevice9; +struct IDirect3D9; +struct IDirect3DDevice9Ex; +struct IDirect3D9Ex; + +#endif + +class VulkanContext; + +namespace Draw { + enum T3DBlendEquation : int { ADD, SUBTRACT, @@ -414,14 +427,10 @@ private: Thin3DContext *T3DCreateGLContext(); #ifdef _WIN32 -struct IDirect3DDevice9; -struct IDirect3D9; -struct IDirect3DDevice9Ex; -struct IDirect3D9Ex; Thin3DContext *T3DCreateDX9Context(IDirect3D9 *d3d, IDirect3D9Ex *d3dEx, int adapterId, IDirect3DDevice9 *device, IDirect3DDevice9Ex *deviceEx); #endif -class VulkanContext; - Thin3DContext *T3DCreateVulkanContext(VulkanContext *context); -Thin3DContext *T3DCreateD3D11Context(); \ No newline at end of file +Thin3DContext *T3DCreateD3D11Context(); + +} // namespace Draw \ No newline at end of file diff --git a/ext/native/thin3d/thin3d_d3d11.cpp b/ext/native/thin3d/thin3d_d3d11.cpp index 64e17ef9af..62b321a6d3 100644 --- a/ext/native/thin3d/thin3d_d3d11.cpp +++ b/ext/native/thin3d/thin3d_d3d11.cpp @@ -1,5 +1,9 @@ #include "thin3d/thin3d.h" +namespace Draw { + Thin3DContext *T3DCreateD3D11Context() { return nullptr; -} \ No newline at end of file +} + +} // namespace Draw \ No newline at end of file diff --git a/ext/native/thin3d/thin3d_d3d9.cpp b/ext/native/thin3d/thin3d_d3d9.cpp index 732069edf8..338cbecfd6 100644 --- a/ext/native/thin3d/thin3d_d3d9.cpp +++ b/ext/native/thin3d/thin3d_d3d9.cpp @@ -1,6 +1,6 @@ #include -#include -#include +#include +#include #ifdef _DEBUG #define D3D_DEBUG_INFO @@ -20,6 +20,8 @@ #include "thin3d/thin3d.h" #include "thin3d/d3dx9_loader.h" +namespace Draw { + // Could be declared as u8 static const D3DCMPFUNC compareToD3D9[] = { D3DCMP_NEVER, @@ -502,7 +504,8 @@ private: char shadeLangVersion_[64]; }; -Thin3DDX9Context::Thin3DDX9Context(IDirect3D9 *d3d, IDirect3D9Ex *d3dEx, int adapterId, IDirect3DDevice9 *device, IDirect3DDevice9Ex *deviceEx) : d3d_(d3d), d3dEx_(d3dEx), adapterId_(adapterId), device_(device), deviceEx_(deviceEx) { +Thin3DDX9Context::Thin3DDX9Context(IDirect3D9 *d3d, IDirect3D9Ex *d3dEx, int adapterId, IDirect3DDevice9 *device, IDirect3DDevice9Ex *deviceEx) + : d3d_(d3d), d3dEx_(d3dEx), adapterId_(adapterId), device_(device), deviceEx_(deviceEx) { CreatePresets(); d3d->GetAdapterIdentifier(adapterId, 0, &identifier_); if (!FAILED(device->GetDeviceCaps(&caps_))) { @@ -820,3 +823,5 @@ Thin3DContext *T3DCreateDX9Context(IDirect3D9 *d3d, IDirect3D9Ex *d3dEx, int ada } return new Thin3DDX9Context(d3d, d3dEx, adapterId, device, deviceEx); } + +} // namespace Draw \ No newline at end of file diff --git a/ext/native/thin3d/thin3d_gl.cpp b/ext/native/thin3d/thin3d_gl.cpp index 094bfcf00c..f56ae018d5 100644 --- a/ext/native/thin3d/thin3d_gl.cpp +++ b/ext/native/thin3d/thin3d_gl.cpp @@ -12,6 +12,8 @@ #include "gfx_es2/gpu_features.h" #include "gfx/gl_lost_manager.h" +namespace Draw { + static const unsigned short compToGL[] = { GL_NEVER, GL_LESS, @@ -1039,3 +1041,5 @@ void Thin3DGLVertexFormat::Unapply() { glBindVertexArray(0); } } + +} // namespace Draw \ No newline at end of file diff --git a/ext/native/thin3d/thin3d_vulkan.cpp b/ext/native/thin3d/thin3d_vulkan.cpp index 3a05755572..f2ff7faf8f 100644 --- a/ext/native/thin3d/thin3d_vulkan.cpp +++ b/ext/native/thin3d/thin3d_vulkan.cpp @@ -15,7 +15,7 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. -#include +#include #include #include #include @@ -43,6 +43,8 @@ #include "Common/Vulkan/VulkanLoader.h" +namespace Draw { + // This can actually be replaced with a cast as the values are in the right order. static const VkCompareOp compToVK[] = { VK_COMPARE_OP_NEVER, @@ -1192,3 +1194,5 @@ std::vector Thin3DVKContext::GetFeatureList() { return features; } + +} // namespace Draw \ No newline at end of file diff --git a/ext/native/ui/screen.h b/ext/native/ui/screen.h index f8f7282c9e..362f35cb00 100644 --- a/ext/native/ui/screen.h +++ b/ext/native/ui/screen.h @@ -36,7 +36,10 @@ enum DialogResult { class ScreenManager; class UIContext; -class Thin3DContext; + +namespace Draw { + class Thin3DContext; +} class Screen { public: @@ -99,8 +102,8 @@ public: void setUIContext(UIContext *context) { uiContext_ = context; } UIContext *getUIContext() { return uiContext_; } - void setThin3DContext(Thin3DContext *context) { thin3DContext_ = context; } - Thin3DContext *getThin3DContext() { return thin3DContext_; } + void setThin3DContext(Draw::Thin3DContext *context) { thin3DContext_ = context; } + Draw::Thin3DContext *getThin3DContext() { return thin3DContext_; } void render(); void resized(); @@ -136,7 +139,7 @@ private: Screen *nextScreen_; UIContext *uiContext_; - Thin3DContext *thin3DContext_; + Draw::Thin3DContext *thin3DContext_; const Screen *dialogFinished_; DialogResult dialogResult_; diff --git a/ext/native/ui/ui.cpp b/ext/native/ui/ui.cpp index 67aa9db0aa..72729558e7 100644 --- a/ext/native/ui/ui.cpp +++ b/ext/native/ui/ui.cpp @@ -15,7 +15,7 @@ DrawBuffer ui_draw2d; DrawBuffer ui_draw2d_front; -void UIBegin(Thin3DShaderSet *shaderSet) { +void UIBegin(Draw::Thin3DShaderSet *shaderSet) { ui_draw2d.Begin(shaderSet); ui_draw2d_front.Begin(shaderSet); } diff --git a/ext/native/ui/ui.h b/ext/native/ui/ui.h index 5e495cc507..8c8b4a0339 100644 --- a/ext/native/ui/ui.h +++ b/ext/native/ui/ui.h @@ -61,7 +61,7 @@ private: // Call at start of frame -void UIBegin(Thin3DShaderSet *shaderSet); +void UIBegin(Draw::Thin3DShaderSet *shaderSet); // Call at end of frame. diff --git a/ext/native/ui/ui_context.cpp b/ext/native/ui/ui_context.cpp index 5941bfbfd9..4bd670e5d7 100644 --- a/ext/native/ui/ui_context.cpp +++ b/ext/native/ui/ui_context.cpp @@ -23,7 +23,8 @@ UIContext::~UIContext() { blendNormal_->Release(); } -void UIContext::Init(Thin3DContext *thin3d, Thin3DShaderSet *uishader, Thin3DShaderSet *uishadernotex, Thin3DTexture *uitexture, DrawBuffer *uidrawbuffer, DrawBuffer *uidrawbufferTop) { +void UIContext::Init(Draw::Thin3DContext *thin3d, Draw::Thin3DShaderSet *uishader, Draw::Thin3DShaderSet *uishadernotex, Draw::Thin3DTexture *uitexture, DrawBuffer *uidrawbuffer, DrawBuffer *uidrawbufferTop) { + using namespace Draw; thin3d_ = thin3d; blendNormal_ = thin3d_->CreateBlendState({ true, T3DBlendFactor::SRC_ALPHA, T3DBlendFactor::ONE_MINUS_SRC_ALPHA }); sampler_ = thin3d_->CreateSamplerState({ T3DTextureFilter::LINEAR, T3DTextureFilter::LINEAR,T3DTextureFilter::LINEAR }); diff --git a/ext/native/ui/ui_context.h b/ext/native/ui/ui_context.h index 78e18201bb..9b1af40439 100644 --- a/ext/native/ui/ui_context.h +++ b/ext/native/ui/ui_context.h @@ -9,13 +9,16 @@ // Everything you need to draw a UI collected into a single unit that can be passed around. // Everything forward declared so this header is safe everywhere. -class Thin3DContext; -class Thin3DShaderSet; -class Thin3DDepthStencilState; -class Thin3DTexture; -class Thin3DBlendState; -class Thin3DSamplerState; -class Thin3DRasterState; +namespace Draw { + class Thin3DContext; + class Thin3DShaderSet; + class Thin3DDepthStencilState; + class Thin3DTexture; + class Thin3DBlendState; + class Thin3DSamplerState; + class Thin3DRasterState; +} + class Texture; class DrawBuffer; class TextDrawer; @@ -33,7 +36,7 @@ public: UIContext(); ~UIContext(); - void Init(Thin3DContext *thin3d, Thin3DShaderSet *uiShaderTex, Thin3DShaderSet *uiShaderNoTex, Thin3DTexture *uitexture, DrawBuffer *uidrawbuffer, DrawBuffer *uidrawbufferTop); + void Init(Draw::Thin3DContext *thin3d, Draw::Thin3DShaderSet *uiShaderTex, Draw::Thin3DShaderSet *uiShaderNoTex, Draw::Thin3DTexture *uitexture, DrawBuffer *uidrawbuffer, DrawBuffer *uidrawbufferTop); void Begin(); void BeginNoTex(); @@ -71,10 +74,10 @@ public: // in dps, like dp_xres and dp_yres void SetBounds(const Bounds &b) { bounds_ = b; } const Bounds &GetBounds() const { return bounds_; } - Thin3DContext *GetThin3DContext() { return thin3d_; } + Draw::Thin3DContext *GetThin3DContext() { return thin3d_; } private: - Thin3DContext *thin3d_; + Draw::Thin3DContext *thin3d_; Bounds bounds_; float fontScaleX_; @@ -82,14 +85,14 @@ private: UI::FontStyle *fontStyle_; TextDrawer *textDrawer_; - Thin3DContext *thin3D_; - Thin3DDepthStencilState *depth_; - Thin3DSamplerState *sampler_; - Thin3DRasterState *rasterNoCull_; - Thin3DBlendState *blendNormal_; - Thin3DShaderSet *uishader_; - Thin3DShaderSet *uishadernotex_; - Thin3DTexture *uitexture_; + Draw::Thin3DContext *thin3D_; + Draw::Thin3DDepthStencilState *depth_; + Draw::Thin3DSamplerState *sampler_; + Draw::Thin3DRasterState *rasterNoCull_; + Draw::Thin3DBlendState *blendNormal_; + Draw::Thin3DShaderSet *uishader_; + Draw::Thin3DShaderSet *uishadernotex_; + Draw::Thin3DTexture *uitexture_; DrawBuffer *uidrawbuffer_; DrawBuffer *uidrawbufferTop_; diff --git a/ext/native/ui/ui_screen.cpp b/ext/native/ui/ui_screen.cpp index 0580d608b1..2bbac86287 100644 --- a/ext/native/ui/ui_screen.cpp +++ b/ext/native/ui/ui_screen.cpp @@ -59,13 +59,13 @@ void UIScreen::update(InputState &input) { } void UIScreen::preRender() { - Thin3DContext *thin3d = screenManager()->getThin3DContext(); + Draw::Thin3DContext *thin3d = screenManager()->getThin3DContext(); if (!thin3d) { return; } thin3d->Begin(true, 0xFF000000, 0.0f, 0); - T3DViewport viewport; + Draw::T3DViewport viewport; viewport.TopLeftX = 0; viewport.TopLeftY = 0; viewport.Width = pixel_xres; @@ -77,7 +77,7 @@ void UIScreen::preRender() { } void UIScreen::postRender() { - Thin3DContext *thin3d = screenManager()->getThin3DContext(); + auto thin3d = screenManager()->getThin3DContext(); if (!thin3d) { return; } diff --git a/ext/native/ui/ui_screen.h b/ext/native/ui/ui_screen.h index 18bb5fe6ec..e756469a16 100644 --- a/ext/native/ui/ui_screen.h +++ b/ext/native/ui/ui_screen.h @@ -6,7 +6,9 @@ #include "ui/viewgroup.h" class I18NCategory; -class Thin3DContext; +namespace Draw { + class Thin3DContext; +} class UIScreen : public Screen { public: diff --git a/ext/native/ui/view.h b/ext/native/ui/view.h index 3696f2d66f..9b45d7a987 100644 --- a/ext/native/ui/view.h +++ b/ext/native/ui/view.h @@ -34,7 +34,9 @@ class DrawBuffer; class Texture; class UIContext; -class Thin3DTexture; +namespace Draw { + class Thin3DTexture; +} // I don't generally like namespaces but I think we do need one for UI, so many potentially-clashing names. @@ -825,17 +827,17 @@ private: // of the view. class Thin3DTextureView : public InertView { public: - Thin3DTextureView(Thin3DTexture *texture, ImageSizeMode sizeMode, LayoutParams *layoutParams = 0) + Thin3DTextureView(Draw::Thin3DTexture *texture, ImageSizeMode sizeMode, LayoutParams *layoutParams = 0) : InertView(layoutParams), texture_(texture), color_(0xFFFFFFFF), sizeMode_(sizeMode) {} void GetContentDimensions(const UIContext &dc, float &w, float &h) const override; void Draw(UIContext &dc) override; - void SetTexture(Thin3DTexture *texture) { texture_ = texture; } + void SetTexture(Draw::Thin3DTexture *texture) { texture_ = texture; } void SetColor(uint32_t color) { color_ = color; } private: - Thin3DTexture *texture_; + Draw::Thin3DTexture *texture_; uint32_t color_; ImageSizeMode sizeMode_; };