Replace internal C++ newImage and newCanvas methods with newTexture

This commit is contained in:
Alex Szpakowski
2020-02-05 20:39:55 -04:00
parent 0017f9c77d
commit 17f77407bb
7 changed files with 13 additions and 17 deletions
+1 -1
View File
@@ -154,7 +154,7 @@ void Font::createTexture()
settings.format = pixelFormat;
settings.width = size.width;
settings.height = size.height;
texture = gfx->newImage(settings, nullptr);
texture = gfx->newTexture(settings, nullptr);
texture->setSamplerState(samplerState);
{
+2 -1
View File
@@ -821,12 +821,13 @@ Texture *Graphics::getTemporaryTexture(PixelFormat format, int w, int h, int sam
if (texture == nullptr)
{
Texture::Settings settings;
settings.renderTarget = true;
settings.format = format;
settings.width = w;
settings.height = h;
settings.msaa = samples;
texture = newCanvas(settings);
texture = newTexture(settings);
temporaryTextures.emplace_back(texture);
}
+1 -3
View File
@@ -426,7 +426,7 @@ public:
// Implements Module.
virtual ModuleType getModuleType() const { return M_GRAPHICS; }
virtual Texture *newImage(const Texture::Settings &settings, const Texture::Slices *data) = 0;
virtual Texture *newTexture(const Texture::Settings &settings, const Texture::Slices *data = nullptr) = 0;
Quad *newQuad(Quad::Viewport v, double sw, double sh);
Font *newFont(love::font::Rasterizer *data);
@@ -436,8 +436,6 @@ public:
SpriteBatch *newSpriteBatch(Texture *texture, int size, vertex::Usage usage);
ParticleSystem *newParticleSystem(Texture *texture, int size);
virtual Texture *newCanvas(const Texture::Settings &settings) = 0;
ShaderStage *newShaderStage(ShaderStage::StageType stage, const std::string &source);
Shader *newShader(const std::string &vertex, const std::string &pixel);
+1 -1
View File
@@ -86,7 +86,7 @@ Video::Video(Graphics *gfx, love::video::VideoStream *stream, float dpiscale)
settings.width = widths[i];
settings.height = heights[i];
settings.format = PIXELFORMAT_R8_UNORM;
Texture *tex = gfx->newImage(settings, nullptr);
Texture *tex = gfx->newTexture(settings, nullptr);
tex->setSamplerState(samplerState);
+5 -7
View File
@@ -130,14 +130,12 @@ love::graphics::StreamBuffer *Graphics::newStreamBuffer(BufferType type, size_t
return CreateStreamBuffer(type, size);
}
love::graphics::Texture *Graphics::newImage(const Texture::Settings &settings, const Texture::Slices *data)
love::graphics::Texture *Graphics::newTexture(const Texture::Settings &settings, const Texture::Slices *data)
{
return new Image(settings, data);
}
love::graphics::Texture *Graphics::newCanvas(const Texture::Settings &settings)
{
return new Canvas(settings);
if (settings.renderTarget)
return new Canvas(settings);
else
return new Image(settings, data);
}
love::graphics::ShaderStage *Graphics::newShaderStageInternal(ShaderStage::StageType stage, const std::string &cachekey, const std::string &source, bool gles)
+1 -2
View File
@@ -60,8 +60,7 @@ public:
// Implements Module.
const char *getName() const override;
love::graphics::Texture *newImage(const Texture::Settings &settings, const Texture::Slices *data) override;
love::graphics::Texture *newCanvas(const Texture::Settings &settings) override;
love::graphics::Texture *newTexture(const Texture::Settings &settings, const Texture::Slices *data = nullptr) override;
love::graphics::Buffer *newBuffer(size_t size, const void *data, BufferType type, vertex::Usage usage, uint32 mapflags) override;
void setViewportSize(int width, int height, int pixelwidth, int pixelheight) override;
+2 -2
View File
@@ -761,7 +761,7 @@ static int w__pushNewImage(lua_State *L, Texture::Slices &slices, const Texture:
{
StrongRef<Texture> i;
luax_catchexcept(L,
[&]() { i.set(instance()->newImage(settings, &slices), Acquire::NORETAIN); },
[&]() { i.set(instance()->newTexture(settings, &slices), Acquire::NORETAIN); },
[&](bool) { slices.clear(); }
);
@@ -1248,7 +1248,7 @@ int w_newCanvas(lua_State *L)
}
Texture *texture = nullptr;
luax_catchexcept(L, [&](){ texture = instance()->newCanvas(settings); });
luax_catchexcept(L, [&](){ texture = instance()->newTexture(settings); });
luax_pushtype(L, texture);
texture->release();