From 0017f9c77dce9371b7fa7f5e7275054084ec1b9e Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Tue, 4 Feb 2020 22:15:18 -0400 Subject: [PATCH] Remove a redundant internal Texture method --- src/modules/graphics/Texture.cpp | 113 ++++++++++++------------- src/modules/graphics/Texture.h | 1 - src/modules/graphics/opengl/Canvas.cpp | 1 - 3 files changed, 54 insertions(+), 61 deletions(-) diff --git a/src/modules/graphics/Texture.cpp b/src/modules/graphics/Texture.cpp index 3a7e73061..8d8f21121 100644 --- a/src/modules/graphics/Texture.cpp +++ b/src/modules/graphics/Texture.cpp @@ -273,7 +273,8 @@ Texture::Texture(const Settings &settings, const Slices *slices) samplerState = gfx->getDefaultSamplerState(); - initQuad(); + Quad::Viewport v = {0, 0, (double) width, (double) height}; + quad.set(new Quad(v, width, height), Acquire::NORETAIN); ++textureCount; } @@ -284,12 +285,6 @@ Texture::~Texture() setGraphicsMemorySize(0); } -void Texture::initQuad() -{ - Quad::Viewport v = {0, 0, (double) width, (double) height}; - quad.set(new Quad(v, width, height), Acquire::NORETAIN); -} - void Texture::setGraphicsMemorySize(int64 bytes) { totalGraphicsMemory = std::max(totalGraphicsMemory - graphicsMemorySize, (int64) 0); @@ -299,58 +294,6 @@ void Texture::setGraphicsMemorySize(int64 bytes) totalGraphicsMemory += bytes; } -TextureType Texture::getTextureType() const -{ - return texType; -} - -PixelFormat Texture::getPixelFormat() const -{ - return format; -} - -Texture::MipmapsMode Texture::getMipmapsMode() const -{ - return mipmapsMode; -} - -bool Texture::isRenderTarget() const -{ - return renderTarget; -} - -bool Texture::isReadable() const -{ - return readable; -} - -bool Texture::isCompressed() const -{ - return isPixelFormatCompressed(format); -} - -bool Texture::isFormatLinear() const -{ - return isGammaCorrect() && !sRGB && format != PIXELFORMAT_sRGBA8_UNORM; -} - -bool Texture::isValidSlice(int slice) const -{ - if (slice < 0) - return false; - - if (texType == TEXTURE_CUBE) - return slice < 6; - else if (texType == TEXTURE_VOLUME) - return slice < depth; - else if (texType == TEXTURE_2D_ARRAY) - return slice < layers; - else if (slice > 0) - return false; - - return true; -} - void Texture::draw(Graphics *gfx, const Matrix4 &m) { draw(gfx, quad, m); @@ -577,6 +520,58 @@ love::image::ImageData *Texture::newImageData(love::image::Image *module, int sl return module->newImageData(r.w, r.h, dataformat); } +TextureType Texture::getTextureType() const +{ + return texType; +} + +PixelFormat Texture::getPixelFormat() const +{ + return format; +} + +Texture::MipmapsMode Texture::getMipmapsMode() const +{ + return mipmapsMode; +} + +bool Texture::isRenderTarget() const +{ + return renderTarget; +} + +bool Texture::isReadable() const +{ + return readable; +} + +bool Texture::isCompressed() const +{ + return isPixelFormatCompressed(format); +} + +bool Texture::isFormatLinear() const +{ + return isGammaCorrect() && !sRGB && format != PIXELFORMAT_sRGBA8_UNORM; +} + +bool Texture::isValidSlice(int slice) const +{ + if (slice < 0) + return false; + + if (texType == TEXTURE_CUBE) + return slice < 6; + else if (texType == TEXTURE_VOLUME) + return slice < depth; + else if (texType == TEXTURE_2D_ARRAY) + return slice < layers; + else if (slice > 0) + return false; + + return true; +} + int Texture::getWidth(int mip) const { return std::max(width >> mip, 1); diff --git a/src/modules/graphics/Texture.h b/src/modules/graphics/Texture.h index 1b583be8d..ec2d7cc68 100644 --- a/src/modules/graphics/Texture.h +++ b/src/modules/graphics/Texture.h @@ -273,7 +273,6 @@ public: protected: - void initQuad(); void setGraphicsMemorySize(int64 size); void uploadImageData(love::image::ImageDataBase *d, int level, int slice, int x, int y); diff --git a/src/modules/graphics/opengl/Canvas.cpp b/src/modules/graphics/opengl/Canvas.cpp index 6f5b46881..4b77c06f4 100644 --- a/src/modules/graphics/opengl/Canvas.cpp +++ b/src/modules/graphics/opengl/Canvas.cpp @@ -193,7 +193,6 @@ Canvas::Canvas(const Settings &settings) if (gfx != nullptr) format = gfx->getSizedFormat(format, renderTarget, readable, sRGB); - initQuad(); loadVolatile(); if (status != GL_FRAMEBUFFER_COMPLETE)