Browse Source

Move Canvas:getMSAA to Texture:getMSAA.

Alex Szpakowski 5 years ago
parent
commit
fc0d60a96d

+ 1 - 5
src/modules/graphics/Canvas.cpp

@@ -35,6 +35,7 @@ Canvas::Canvas(const Settings &settings)
 
 	renderTarget = true;
 	sRGB = false;
+	requestedMSAA = settings.msaa;
 
 	width = settings.width;
 	height = settings.height;
@@ -106,11 +107,6 @@ Canvas::MipmapMode Canvas::getMipmapMode() const
 	return settings.mipmaps;
 }
 
-int Canvas::getRequestedMSAA() const
-{
-	return settings.msaa;
-}
-
 love::image::ImageData *Canvas::newImageData(love::image::Image *module, int slice, int mipmap, const Rect &r)
 {
 	if (!isReadable())

+ 0 - 4
src/modules/graphics/Canvas.h

@@ -78,13 +78,9 @@ public:
 	virtual ~Canvas();
 
 	MipmapMode getMipmapMode() const;
-	int getRequestedMSAA() const;
 
 	virtual love::image::ImageData *newImageData(love::image::Image *module, int slice, int mipmap, const Rect &rect);
 
-	virtual int getMSAA() const = 0;
-	virtual ptrdiff_t getRenderTargetHandle() const = 0;
-
 	static bool getConstant(const char *in, MipmapMode &out);
 	static bool getConstant(MipmapMode in, const char *&out);
 	static std::vector<std::string> getConstants(MipmapMode);

+ 6 - 0
src/modules/graphics/Texture.cpp

@@ -172,6 +172,7 @@ Texture::Texture(TextureType texType)
 	, mipmapCount(1)
 	, pixelWidth(0)
 	, pixelHeight(0)
+	, requestedMSAA(1)
 	, samplerState()
 	, graphicsMemorySize(0)
 {
@@ -397,6 +398,11 @@ float Texture::getDPIScale() const
 	return (float) pixelHeight / (float) height;
 }
 
+int Texture::getRequestedMSAA() const
+{
+	return requestedMSAA;
+}
+
 void Texture::setSamplerState(const SamplerState &s)
 {
 	if (s.depthSampleMode.hasValue && (!readable || !isPixelFormatDepthStencil(format)))

+ 7 - 0
src/modules/graphics/Texture.h

@@ -181,6 +181,8 @@ public:
 	void drawLayer(Graphics *gfx, int layer, const Matrix4 &m);
 	void drawLayer(Graphics *gfx, int layer, Quad *quad, const Matrix4 &m);
 
+	virtual ptrdiff_t getRenderTargetHandle() const = 0;
+
 	TextureType getTextureType() const;
 	PixelFormat getPixelFormat() const;
 
@@ -203,6 +205,9 @@ public:
 
 	float getDPIScale() const;
 
+	int getRequestedMSAA() const;
+	virtual int getMSAA() const = 0;
+
 	virtual void setSamplerState(const SamplerState &s);
 	const SamplerState &getSamplerState() const;
 
@@ -242,6 +247,8 @@ protected:
 	int pixelWidth;
 	int pixelHeight;
 
+	int requestedMSAA;
+
 	SamplerState samplerState;
 
 	StrongRef<Quad> quad;

+ 2 - 0
src/modules/graphics/opengl/Image.h

@@ -48,7 +48,9 @@ public:
 	void unloadVolatile() override;
 
 	ptrdiff_t getHandle() const override;
+	ptrdiff_t getRenderTargetHandle() const override { return 0; }
 
+	int getMSAA() const override { return 1; }
 	void setSamplerState(const SamplerState &s) override;
 	void generateMipmaps() override;
 

+ 0 - 8
src/modules/graphics/wrap_Canvas.cpp

@@ -31,13 +31,6 @@ Canvas *luax_checkcanvas(lua_State *L, int idx)
 	return luax_checktype<Canvas>(L, idx);
 }
 
-int w_Canvas_getMSAA(lua_State *L)
-{
-	Canvas *canvas = luax_checkcanvas(L, 1);
-	lua_pushinteger(L, canvas->getMSAA());
-	return 1;
-}
-
 int w_Canvas_renderTo(lua_State *L)
 {
 	Graphics::RenderTarget rt(luax_checkcanvas(L, 1));
@@ -135,7 +128,6 @@ int w_Canvas_getMipmapMode(lua_State *L)
 
 static const luaL_Reg w_Canvas_functions[] =
 {
-	{ "getMSAA", w_Canvas_getMSAA },
 	{ "renderTo", w_Canvas_renderTo },
 	{ "newImageData", w_Canvas_newImageData },
 	{ "generateMipmaps", w_Canvas_generateMipmaps },

+ 8 - 0
src/modules/graphics/wrap_Texture.cpp

@@ -143,6 +143,13 @@ int w_Texture_isCompressed(lua_State *L)
 	return 1;
 }
 
+int w_Texture_getMSAA(lua_State *L)
+{
+	Texture *t = luax_checktexture(L, 1);
+	lua_pushinteger(L, t->getMSAA());
+	return 1;
+}
+
 int w_Texture_setFilter(lua_State *L)
 {
 	Texture *t = luax_checktexture(L, 1);
@@ -330,6 +337,7 @@ const luaL_Reg w_Texture_functions[] =
 	{ "getDPIScale", w_Texture_getDPIScale },
 	{ "isFormatLinear", w_Texture_isFormatLinear },
 	{ "isCompressed", w_Texture_isCompressed },
+	{ "getMSAA", w_Texture_getMSAA },
 	{ "setFilter", w_Texture_setFilter },
 	{ "getFilter", w_Texture_getFilter },
 	{ "setMipmapFilter", w_Texture_setMipmapFilter },