updated to latest mobile-common (0cf55b7da58e), removed libtiff, libpng, libmng, devil, jasper, jpeg-8d, added libturbo-jpeg

This commit is contained in:
fysx
2014-08-27 23:19:11 +02:00
parent aba2f47b31
commit abb819335b
1910 changed files with 78167 additions and 922995 deletions
+62 -64
View File
@@ -451,15 +451,15 @@ static void getStrategy()
}
}
Canvas::Canvas(int width, int height, Format format, int fsaa)
Canvas::Canvas(int width, int height, Format format, int msaa)
: fbo(0)
, resolve_fbo(0)
, texture(0)
, fsaa_buffer(0)
, msaa_buffer(0)
, depth_stencil(0)
, format(format)
, fsaa_samples(fsaa)
, fsaa_dirty(false)
, msaa_samples(msaa)
, msaa_dirty(false)
{
this->width = width;
this->height = height;
@@ -501,7 +501,7 @@ Canvas::~Canvas()
unloadVolatile();
}
bool Canvas::createFSAAFBO(GLenum internalformat)
bool Canvas::createMSAAFBO(GLenum internalformat)
{
// Create our FBO without a texture.
status = strategy->createFBO(fbo, 0);
@@ -516,7 +516,7 @@ bool Canvas::createFSAAFBO(GLenum internalformat)
}
// Create and attach the MSAA buffer for our FBO.
if (strategy->createMSAABuffer(width, height, fsaa_samples, internalformat, fsaa_buffer))
if (strategy->createMSAABuffer(width, height, msaa_samples, internalformat, msaa_buffer))
status = GL_FRAMEBUFFER_COMPLETE;
else
status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
@@ -528,10 +528,10 @@ bool Canvas::createFSAAFBO(GLenum internalformat)
if (status != GL_FRAMEBUFFER_COMPLETE)
{
// Clean up.
strategy->deleteFBO(fbo, 0, fsaa_buffer);
strategy->deleteFBO(fbo, 0, msaa_buffer);
strategy->deleteFBO(resolve_fbo, 0, 0);
fbo = fsaa_buffer = resolve_fbo = 0;
fsaa_samples = 0;
fbo = msaa_buffer = resolve_fbo = 0;
msaa_samples = 0;
}
if (current != this)
@@ -543,7 +543,7 @@ bool Canvas::createFSAAFBO(GLenum internalformat)
bool Canvas::loadVolatile()
{
fbo = depth_stencil = texture = 0;
resolve_fbo = fsaa_buffer = 0;
resolve_fbo = msaa_buffer = 0;
status = GL_FRAMEBUFFER_COMPLETE;
// glTexImage2D is guaranteed to error in this case.
@@ -597,16 +597,16 @@ bool Canvas::loadVolatile()
glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
}
if (fsaa_samples > max_samples)
fsaa_samples = max_samples;
if (msaa_samples > max_samples)
msaa_samples = max_samples;
// Try to create a FSAA FBO if requested.
bool fsaasuccess = false;
if (fsaa_samples > 1)
fsaasuccess = createFSAAFBO(internalformat);
// Try to create a MSAA FBO if requested.
bool msaasuccess = false;
if (msaa_samples > 1)
msaasuccess = createMSAAFBO(internalformat);
// On failure (or no requested FSAA), fall back to a regular FBO.
if (!fsaasuccess)
// On failure (or no requested MSAA), fall back to a regular FBO.
if (!msaasuccess)
status = strategy->createFBO(fbo, texture);
if (status != GL_FRAMEBUFFER_COMPLETE)
@@ -614,31 +614,28 @@ bool Canvas::loadVolatile()
clear(Color(0, 0, 0, 0));
fsaa_dirty = (fsaa_buffer != 0);
msaa_dirty = (msaa_buffer != 0);
return true;
}
void Canvas::unloadVolatile()
{
strategy->deleteFBO(fbo, depth_stencil, fsaa_buffer);
strategy->deleteFBO(fbo, depth_stencil, msaa_buffer);
strategy->deleteFBO(resolve_fbo, 0, 0);
gl.deleteTexture(texture);
fbo = depth_stencil = texture = 0;
resolve_fbo = fsaa_buffer = 0;
for (size_t i = 0; i < attachedCanvases.size(); i++)
attachedCanvases[i]->release();
resolve_fbo = msaa_buffer = 0;
attachedCanvases.clear();
}
void Canvas::drawv(const Matrix &t, const Vertex *v)
{
gl.matrices.transform.push(gl.matrices.transform.top());
gl.matrices.transform.top() *= t;
OpenGL::TempTransform transform(gl);
transform.get() *= t;
gl.prepareDraw();
@@ -656,8 +653,6 @@ void Canvas::drawv(const Matrix &t, const Vertex *v)
gl.disableVertexAttribArray(OpenGL::ATTRIB_TEXCOORD);
postdraw();
gl.matrices.transform.pop();
}
void Canvas::draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
@@ -684,11 +679,24 @@ void Canvas::setFilter(const Texture::Filter &f)
gl.setTextureFilter(filter);
}
void Canvas::setWrap(const Texture::Wrap &w)
bool Canvas::setWrap(const Texture::Wrap &w)
{
bool success = true;
wrap = w;
if (hasLimitedNpot() && (width != next_p2(width) || height != next_p2(height)))
{
if (wrap.s != WRAP_CLAMP || wrap.t != WRAP_CLAMP)
success = false;
// If we only have limited NPOT support then the wrap mode must be CLAMP.
wrap.s = wrap.t = WRAP_CLAMP;
}
gl.bindTexture(texture);
gl.setTextureWrap(wrap);
return success;
}
GLuint Canvas::getGLTexture() const
@@ -727,8 +735,8 @@ void Canvas::setupGrab()
strategy->bindFBO(fbo);
gl.setViewport(OpenGL::Viewport(0, 0, width, height));
// Set up orthographic view (no depth)
gl.matrices.projection.push(Matrix::ortho(0.0, width, 0.0, height));
// Set up the projection matrix
gl.matrices.projection.push_back(Matrix::ortho(0.0, width, 0.0, height));
// Make sure the correct sRGB setting is used when drawing to the canvas.
if (GLAD_VERSION_1_1 || GLAD_EXT_sRGB_write_control)
@@ -739,8 +747,8 @@ void Canvas::setupGrab()
glDisable(GL_FRAMEBUFFER_SRGB);
}
if (fsaa_buffer != 0)
fsaa_dirty = true;
if (msaa_buffer != 0)
msaa_dirty = true;
}
void Canvas::startGrab(const std::vector<Canvas *> &canvases)
@@ -757,8 +765,8 @@ void Canvas::startGrab(const std::vector<Canvas *> &canvases)
if ((int) canvases.size() + 1 > gl.getMaxRenderTargets())
throw love::Exception("This system can't simultaniously render to %d canvases.", canvases.size()+1);
if (fsaa_samples != 0)
throw love::Exception("Multi-canvas rendering is not supported with FSAA.");
if (msaa_samples != 0)
throw love::Exception("Multi-canvas rendering is not supported with MSAA.");
}
for (size_t i = 0; i < canvases.size(); i++)
@@ -769,8 +777,8 @@ void Canvas::startGrab(const std::vector<Canvas *> &canvases)
if (canvases[i]->getTextureFormat() != format)
throw love::Exception("All canvas arguments must have the same texture format.");
if (canvases[i]->getFSAA() != 0)
throw love::Exception("Multi-canvas rendering is not supported with FSAA.");
if (canvases[i]->getMSAA() != 0)
throw love::Exception("Multi-canvas rendering is not supported with MSAA.");
if (!canvaseschanged && canvases[i] != attachedCanvases[i])
canvaseschanged = true;
@@ -785,11 +793,8 @@ void Canvas::startGrab(const std::vector<Canvas *> &canvases)
// Attach the canvas textures to the active FBO and set up MRTs.
strategy->setAttachments(canvases);
for (size_t i = 0; i < canvases.size(); i++)
canvases[i]->retain();
for (size_t i = 0; i < attachedCanvases.size(); i++)
attachedCanvases[i]->release();
// We want to avoid reference cycles, so we don't retain the attached
// Canvases here. The code in Graphics::setCanvas retains them.
attachedCanvases = canvases;
}
@@ -804,10 +809,6 @@ void Canvas::startGrab()
// make sure the FBO is only using a single canvas
strategy->setAttachments();
// release any previously attached canvases
for (size_t i = 0; i < attachedCanvases.size(); i++)
attachedCanvases[i]->release();
attachedCanvases.clear();
}
@@ -824,6 +825,8 @@ void Canvas::stopGrab(bool switchingToOtherCanvas)
glDiscardFramebufferEXT(GL_FRAMEBUFFER, 2, attachments);
}
gl.matrices.projection.pop_back();
if (switchingToOtherCanvas)
{
if (GLAD_VERSION_1_1 || GLAD_EXT_sRGB_write_control)
@@ -847,8 +850,6 @@ void Canvas::stopGrab(bool switchingToOtherCanvas)
glEnable(GL_FRAMEBUFFER_SRGB);
}
}
gl.matrices.projection.pop();
}
void Canvas::clear(Color c)
@@ -902,8 +903,8 @@ void Canvas::clear(Color c)
if (current != this)
strategy->bindFBO(previous);
if (fsaa_buffer != 0)
fsaa_dirty = true;
if (msaa_buffer != 0)
msaa_dirty = true;
}
bool Canvas::checkCreateStencil()
@@ -915,7 +916,7 @@ bool Canvas::checkCreateStencil()
if (current != this)
strategy->bindFBO(fbo);
bool success = strategy->createStencil(width, height, fsaa_samples, depth_stencil);
bool success = strategy->createStencil(width, height, msaa_samples, depth_stencil);
if (current && current != this)
strategy->bindFBO(current->fbo);
@@ -934,9 +935,9 @@ love::image::ImageData *Canvas::getImageData(love::image::Image *image)
GLubyte *pixels = new GLubyte[size];
// Our texture is attached to 'resolve_fbo' when we use MSAA.
if (fsaa_samples > 1 && (GLAD_VERSION_3_0 || GLAD_ARB_framebuffer_object))
if (msaa_samples > 1 && (GLAD_VERSION_3_0 || GLAD_ARB_framebuffer_object))
glBindFramebuffer(GL_READ_FRAMEBUFFER, resolve_fbo);
else if (fsaa_samples > 1 && GLAD_EXT_framebuffer_multisample)
else if (msaa_samples > 1 && GLAD_EXT_framebuffer_multisample)
glBindFramebufferEXT(GL_READ_FRAMEBUFFER, resolve_fbo);
else
strategy->bindFBO(fbo);
@@ -955,12 +956,15 @@ love::image::ImageData *Canvas::getImageData(love::image::Image *image)
void Canvas::getPixel(unsigned char* pixel_rgba, int x, int y)
{
if (x < 0 || x >= width || y < 0 || y >= width)
throw love::Exception("Attempt to get out-of-range pixel (%d,%d)!", x, y);
resolveMSAA();
// Our texture is attached to 'resolve_fbo' when we use MSAA.
if (fsaa_samples > 1 && (GLAD_VERSION_3_0 || GLAD_ARB_framebuffer_object))
if (msaa_samples > 1 && (GLAD_VERSION_3_0 || GLAD_ARB_framebuffer_object))
glBindFramebuffer(GL_READ_FRAMEBUFFER, resolve_fbo);
else if (fsaa_samples > 1 && GLAD_EXT_framebuffer_multisample)
else if (msaa_samples > 1 && GLAD_EXT_framebuffer_multisample)
glBindFramebufferEXT(GL_READ_FRAMEBUFFER, resolve_fbo);
else if (current != this)
strategy->bindFBO(fbo);
@@ -975,10 +979,10 @@ void Canvas::getPixel(unsigned char* pixel_rgba, int x, int y)
bool Canvas::resolveMSAA()
{
if (resolve_fbo == 0 || fsaa_buffer == 0)
if (resolve_fbo == 0 || msaa_buffer == 0)
return false;
if (!fsaa_dirty)
if (!msaa_dirty)
return true;
GLuint previous = 0;
@@ -1006,7 +1010,7 @@ bool Canvas::resolveMSAA()
strategy->bindFBO(previous);
if (current != this)
fsaa_dirty = false;
msaa_dirty = false;
return true;
}
@@ -1203,12 +1207,6 @@ bool Canvas::isFormatSupported(Canvas::Format format)
return supported;
}
void Canvas::bindDefaultCanvas()
{
if (current != nullptr)
current->stopGrab();
}
bool Canvas::getConstant(const char *in, Format &out)
{
return formats.find(in, out);