changeset 1425:4d66b8cbe5a9 image-CompressedData

Removed an unused graphics Image method
author Alex Szpakowski <slime73@gmail.com>
date Mon, 08 Apr 2013 21:58:20 -0300
parents 4d201f99aed3
children a5e46f43e3d6
files src/modules/graphics/opengl/Graphics.cpp src/modules/graphics/opengl/Image.cpp src/modules/graphics/opengl/Image.h src/modules/image/CompressedData.h src/modules/image/magpie/CompressedData.cpp src/modules/image/magpie/CompressedData.h src/modules/image/magpie/DevilHandler.cpp src/modules/image/magpie/DevilHandler.h src/modules/image/magpie/FormatHandler.h src/modules/image/magpie/ddsHandler.h
diffstat 10 files changed, 24 insertions(+), 68 deletions(-) [+]
line wrap: on
line diff
--- a/src/modules/graphics/opengl/Graphics.cpp	Sun Apr 07 23:11:11 2013 -0300
+++ b/src/modules/graphics/opengl/Graphics.cpp	Mon Apr 08 21:58:20 2013 -0300
@@ -224,11 +224,10 @@
 
 void Graphics::setIcon(Image *image)
 {
-	love::image::ImageData *data = image->getData();
-	if (data)
-		currentWindow->setIcon(data);
-	else
+	if (image->isCompressed())
 		throw love::Exception("Cannot use compressed image data to set an icon.");
+
+	currentWindow->setIcon(image->getData());
 }
 
 void Graphics::setCaption(const char *caption)
@@ -334,9 +333,11 @@
 
 void Graphics::defineStencil()
 {
+	// Disable color writes but don't save the mask values.
 	glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
+
+	glClear(GL_STENCIL_BUFFER_BIT);
 	glEnable(GL_STENCIL_TEST);
-	glClear(GL_STENCIL_BUFFER_BIT);
 	glStencilFunc(GL_ALWAYS, 1, 1);
 	glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
 }
--- a/src/modules/graphics/opengl/Image.cpp	Sun Apr 07 23:11:11 2013 -0300
+++ b/src/modules/graphics/opengl/Image.cpp	Mon Apr 08 21:58:20 2013 -0300
@@ -93,40 +93,6 @@
 	return data;
 }
 
-void Image::getRectangleVertices(int x, int y, int w, int h, vertex *vertices) const
-{
-	// Check upper.
-	x = (x+w > (int)width) ? (int)width-w : x;
-	y = (y+h > (int)height) ? (int)height-h : y;
-
-	// Check lower.
-	x = (x < 0) ? 0 : x;
-	y = (y < 0) ? 0 : y;
-
-	vertices[0].x = 0;
-	vertices[0].y = 0;
-	vertices[1].x = 0;
-	vertices[1].y = (float)h;
-	vertices[2].x = (float)w;
-	vertices[2].y = (float)h;
-	vertices[3].x = (float)w;
-	vertices[3].y = 0;
-
-	float tx = (float)x/width;
-	float ty = (float)y/height;
-	float tw = (float)w/width;
-	float th = (float)h/height;
-
-	vertices[0].s = tx;
-	vertices[0].t = ty;
-	vertices[1].s = tx;
-	vertices[1].t = ty+th;
-	vertices[2].s = tx+tw;
-	vertices[2].t = ty+th;
-	vertices[3].s = tx+tw;
-	vertices[3].t = ty;
-}
-
 void Image::draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const
 {
 	static Matrix t;
--- a/src/modules/graphics/opengl/Image.h	Sun Apr 07 23:11:11 2013 -0300
+++ b/src/modules/graphics/opengl/Image.h	Mon Apr 08 21:58:20 2013 -0300
@@ -77,20 +77,6 @@
 	love::image::ImageData *getData() const;
 
 	/**
-	 * Generate vertices according to a subimage.
-	 *
-	 * Note: out-of-range values will be clamped.
-	 * Note: the vertex colors will not be changed.
-	 *
-	 * @param x The top-left corner of the subimage along the x-axis.
-	 * @param y The top-left corner of the subimage along the y-axis.
-	 * @param w The width of the subimage.
-	 * @param h The height of the subimage.
-	 * @param vertices A vertex array of size four.
-	 **/
-	void getRectangleVertices(int x, int y, int w, int h, vertex *vertices) const;
-
-	/**
 	 * @copydoc Drawable::draw()
 	 **/
 	void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const;
--- a/src/modules/image/CompressedData.h	Sun Apr 07 23:11:11 2013 -0300
+++ b/src/modules/image/CompressedData.h	Mon Apr 08 21:58:20 2013 -0300
@@ -81,22 +81,22 @@
 	int getNumMipmaps() const;
 
 	/**
-	 * Gets the size in bytes of the sub-image at the specified mipmap level.
+	 * Gets the size in bytes of a sub-image at the specified mipmap level.
 	 **/
 	int getSize(int miplevel) const;
 
 	/**
-	 * Gets the byte data of the sub-image at the specified mipmap level.
+	 * Gets the byte data of a sub-image at the specified mipmap level.
 	 **/
 	void *getData(int miplevel) const;
 
 	/**
-	 * Gets the width of the sub-image at the specified mipmap level.
+	 * Gets the width of a sub-image at the specified mipmap level.
 	 **/
 	int getWidth(int miplevel) const;
 
 	/**
-	 * Gets the height of the sub-image at the specified mipmap level.
+	 * Gets the height of a sub-image at the specified mipmap level.
 	 **/
 	int getHeight(int miplevel) const;
 
--- a/src/modules/image/magpie/CompressedData.cpp	Sun Apr 07 23:11:11 2013 -0300
+++ b/src/modules/image/magpie/CompressedData.cpp	Mon Apr 08 21:58:20 2013 -0300
@@ -40,16 +40,20 @@
 
 void CompressedData::load(love::filesystem::FileData *data)
 {
-	std::vector<SubImage> parsedImages;
+	// SubImage vector will be populated by a parser.
+	std::vector<SubImage> parsedimages;
 	TextureType textype = TYPE_UNKNOWN;
 
 	if (ddsHandler::canParse(data))
-		textype = ddsHandler::parse(data, parsedImages);
+		textype = ddsHandler::parse(data, parsedimages);
 
 	if (textype == TYPE_UNKNOWN)
-		throw (love::Exception("Could not parse compressed data: Unknown format."));
+		throw love::Exception("Could not parse compressed data: Unknown format.");
 
-	dataImages = parsedImages;
+	if (parsedimages.size() == 0)
+		throw love::Exception("Could not parse compressed data: No valid data?");
+
+	dataImages = parsedimages;
 	type = textype;
 }
 
--- a/src/modules/image/magpie/CompressedData.h	Sun Apr 07 23:11:11 2013 -0300
+++ b/src/modules/image/magpie/CompressedData.h	Mon Apr 08 21:58:20 2013 -0300
@@ -22,7 +22,7 @@
 #define LOVE_IMAGE_MAGPIE_COMPRESSED_DATA_H
 
 // LOVE
-#include "filesystem/File.h"
+#include "filesystem/FileData.h"
 #include "image/CompressedData.h"
 
 namespace love
--- a/src/modules/image/magpie/DevilHandler.cpp	Sun Apr 07 23:11:11 2013 -0300
+++ b/src/modules/image/magpie/DevilHandler.cpp	Mon Apr 08 21:58:20 2013 -0300
@@ -23,7 +23,6 @@
 // LOVE
 #include "common/Exception.h"
 #include "common/math.h"
-#include "filesystem/File.h"
 #include "thread/threads.h"
 
 // DevIL
--- a/src/modules/image/magpie/DevilHandler.h	Sun Apr 07 23:11:11 2013 -0300
+++ b/src/modules/image/magpie/DevilHandler.h	Mon Apr 08 21:58:20 2013 -0300
@@ -22,7 +22,7 @@
 #define LOVE_IMAGE_MAGPIE_DEVIL_HANDLER_H
 
 // LOVE
-#include "filesystem/File.h"
+#include "filesystem/FileData.h"
 #include "FormatHandler.h"
 
 namespace love
--- a/src/modules/image/magpie/FormatHandler.h	Sun Apr 07 23:11:11 2013 -0300
+++ b/src/modules/image/magpie/FormatHandler.h	Mon Apr 08 21:58:20 2013 -0300
@@ -23,7 +23,7 @@
 
 // LOVE
 #include "image/ImageData.h"
-#include "filesystem/File.h"
+#include "filesystem/FileData.h"
 
 namespace love
 {
--- a/src/modules/image/magpie/ddsHandler.h	Sun Apr 07 23:11:11 2013 -0300
+++ b/src/modules/image/magpie/ddsHandler.h	Mon Apr 08 21:58:20 2013 -0300
@@ -22,7 +22,7 @@
 #define LOVE_IMAGE_MAGPIE_DDS_HANDLER_H
 
 // LOVE
-#include "filesystem/File.h"
+#include "filesystem/FileData.h"
 #include "image/CompressedData.h"
 
 // dds parser
@@ -55,8 +55,8 @@
 	/**
 	 * Parses Compressed image data into a list of sub-images.
 	 * @param[in]  data The data to parse.
-	 * @param[out] images The list of sub-images (including byte data for each),
-	 *             created by the parser.
+	 * @param[out] images The list of sub-images (including byte data for each)
+	 *             parsed from the file data.
 	 * @return The type of CompressedData.
 	 **/
 	static CompressedData::TextureType parse(filesystem::FileData *data, std::vector<CompressedData::SubImage> &images);