Implement automatic batching for points, lines, shapes, and images/quads.

The above are batched together into a single draw call when called without other drawing calls in between, as long as the following criteria are met:

- The texture is the same.
- The primitive type is the same (points cannot be batched with non-points).
- The love.graphics state is the same (aside from the current color - i.e. setColor - and the transform state).
- The active shader’s uniform values are the same.

You can examine the ‘drawcalls’ field of love.graphics.getStats() to help determine if your code is allowing for optimum batching.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2016-12-27 21:02:58 -04:00
parent f98b7ce1ed
commit 0d2e08baff
43 changed files with 1245 additions and 511 deletions
+11 -2
View File
@@ -27,6 +27,10 @@
#include "common/pixelformat.h"
#include "Drawable.h"
#include "Quad.h"
#include "vertex.h"
// C
#include <stddef.h>
namespace love
{
@@ -77,10 +81,13 @@ public:
Texture();
virtual ~Texture();
// Drawable.
void draw(Graphics *gfx, const Matrix4 &m) override;
/**
* Draws the texture using the specified transformation with a Quad applied.
**/
virtual void drawq(Quad *quad, const Matrix4 &m) = 0;
void drawq(Graphics *gfx, Quad *quad, const Matrix4 &m);
PixelFormat getPixelFormat() const;
@@ -95,7 +102,7 @@ public:
virtual const Vertex *getVertices() const;
virtual const void *getHandle() const = 0;
virtual ptrdiff_t getHandle() const = 0;
// The default filter.
static void setDefaultFilter(const Filter &f);
@@ -111,6 +118,8 @@ public:
protected:
virtual void drawv(Graphics *gfx, const Matrix4 &localTransform, const Vertex *v);
PixelFormat format;
int width;