The load and save dialog decoded the save's JPEG screenshot with osgDB and built the osg::Texture2D for it, so mwgui needed the OSG image codec and texture setup for one thumbnail. The decode and texture setup move into MyGUIPlatform::createTextureFromJpeg, next to the OSGTexture it returns, which logs why a JPEG could not be decoded while the dialog logs which save's screenshot that was and keeps only the MyGUI::ITexture; savegamedialog no longer includes anything from OSG, and the encoding side already moved out of mwstate earlier.
81 lines
2.2 KiB
C++
81 lines
2.2 KiB
C++
#ifndef OPENMW_COMPONENTS_MYGUIPLATFORM_MYGUITEXTURE_H
|
|
#define OPENMW_COMPONENTS_MYGUIPLATFORM_MYGUITEXTURE_H
|
|
|
|
#include <memory>
|
|
#include <span>
|
|
|
|
#include <MyGUI_ITexture.h>
|
|
|
|
#include <osg/ref_ptr>
|
|
|
|
namespace osg
|
|
{
|
|
class Image;
|
|
class Texture2D;
|
|
class StateSet;
|
|
}
|
|
|
|
namespace Resource
|
|
{
|
|
class ImageManager;
|
|
}
|
|
|
|
namespace MyGUIPlatform
|
|
{
|
|
|
|
class OSGTexture final : public MyGUI::ITexture
|
|
{
|
|
std::string mName;
|
|
Resource::ImageManager* mImageManager;
|
|
|
|
osg::ref_ptr<osg::Image> mLockedImage;
|
|
osg::ref_ptr<osg::Texture2D> mTexture;
|
|
osg::ref_ptr<osg::StateSet> mInjectState;
|
|
MyGUI::PixelFormat mFormat;
|
|
MyGUI::TextureUsage mUsage;
|
|
size_t mNumElemBytes;
|
|
|
|
int mWidth;
|
|
int mHeight;
|
|
|
|
public:
|
|
OSGTexture(const std::string& name, Resource::ImageManager* imageManager);
|
|
OSGTexture(osg::Texture2D* texture, osg::StateSet* injectState = nullptr);
|
|
~OSGTexture() override;
|
|
|
|
osg::StateSet* getInjectState() { return mInjectState; }
|
|
|
|
const std::string& getName() const override { return mName; }
|
|
|
|
void createManual(int width, int height, MyGUI::TextureUsage usage, MyGUI::PixelFormat format) override;
|
|
void loadFromFile(const std::string& fname) override;
|
|
void saveToFile(const std::string& fname) override;
|
|
|
|
void destroy() override;
|
|
|
|
void* lock(MyGUI::TextureUsage access) override;
|
|
void unlock() override;
|
|
bool isLocked() const override { return mLockedImage.valid(); }
|
|
|
|
int getWidth() const override { return mWidth; }
|
|
int getHeight() const override { return mHeight; }
|
|
|
|
MyGUI::PixelFormat getFormat() const override { return mFormat; }
|
|
MyGUI::TextureUsage getUsage() const override { return mUsage; }
|
|
size_t getNumElemBytes() const override { return mNumElemBytes; }
|
|
|
|
MyGUI::IRenderTarget* getRenderTarget() override;
|
|
|
|
void setShader(const std::string& shaderName) override;
|
|
|
|
/*internal:*/
|
|
osg::Texture2D* getTexture() const { return mTexture.get(); }
|
|
};
|
|
|
|
// Rows stay in the decoder's bottom-up order.
|
|
std::unique_ptr<MyGUI::ITexture> createTextureFromJpeg(std::span<const char> data);
|
|
|
|
}
|
|
|
|
#endif
|