Rename some internal functionality to better match what it actually is.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2017-08-25 22:42:03 -03:00
parent 25afd740b4
commit 0b68c92570
6 changed files with 81 additions and 81 deletions
+6 -6
View File
@@ -624,13 +624,13 @@ void Font::printv(graphics::Graphics *gfx, const Matrix4 &t, const std::vector<D
for (const DrawCommand &cmd : drawcommands)
{
Graphics::StreamDrawRequest req;
req.formats[0] = vertexFormat;
req.indexMode = vertex::TriangleIndexMode::QUADS;
req.vertexCount = cmd.vertexcount;
req.texture = cmd.texture;
Graphics::StreamDrawCommand streamcmd;
streamcmd.formats[0] = vertexFormat;
streamcmd.indexMode = vertex::TriangleIndexMode::QUADS;
streamcmd.vertexCount = cmd.vertexcount;
streamcmd.texture = cmd.texture;
Graphics::StreamVertexData data = gfx->requestStreamDraw(req);
Graphics::StreamVertexData data = gfx->requestStreamDraw(streamcmd);
GlyphVertex *vertexdata = (GlyphVertex *) data.stream[0];
memcpy(vertexdata, &vertices[cmd.startvertex], sizeof(GlyphVertex) * cmd.vertexcount);
+44 -44
View File
@@ -755,7 +755,7 @@ void Graphics::captureScreenshot(const ScreenshotInfo &info)
pendingScreenshotCallbacks.push_back(info);
}
Graphics::StreamVertexData Graphics::requestStreamDraw(const StreamDrawRequest &req)
Graphics::StreamVertexData Graphics::requestStreamDraw(const StreamDrawCommand &cmd)
{
using namespace vertex;
@@ -764,22 +764,22 @@ Graphics::StreamVertexData Graphics::requestStreamDraw(const StreamDrawRequest &
bool shouldflush = false;
bool shouldresize = false;
if (req.primitiveMode != state.primitiveMode
|| req.formats[0] != state.formats[0] || req.formats[1] != state.formats[1]
|| ((req.indexMode != TriangleIndexMode::NONE) != (state.indexCount > 0))
|| req.texture != state.texture
|| req.standardShaderType != state.standardShaderType)
if (cmd.primitiveMode != state.primitiveMode
|| cmd.formats[0] != state.formats[0] || cmd.formats[1] != state.formats[1]
|| ((cmd.indexMode != TriangleIndexMode::NONE) != (state.indexCount > 0))
|| cmd.texture != state.texture
|| cmd.standardShaderType != state.standardShaderType)
{
shouldflush = true;
}
int totalvertices = state.vertexCount + req.vertexCount;
int totalvertices = state.vertexCount + cmd.vertexCount;
// We only support uint16 index buffers for now.
if (totalvertices > LOVE_UINT16_MAX && req.indexMode != TriangleIndexMode::NONE)
if (totalvertices > LOVE_UINT16_MAX && cmd.indexMode != TriangleIndexMode::NONE)
shouldflush = true;
int reqIndexCount = getIndexCount(req.indexMode, req.vertexCount);
int reqIndexCount = getIndexCount(cmd.indexMode, cmd.vertexCount);
size_t reqIndexSize = reqIndexCount * sizeof(uint16);
size_t newdatasizes[2] = {0, 0};
@@ -787,10 +787,10 @@ Graphics::StreamVertexData Graphics::requestStreamDraw(const StreamDrawRequest &
for (int i = 0; i < 2; i++)
{
if (req.formats[i] == CommonFormat::NONE)
if (cmd.formats[i] == CommonFormat::NONE)
continue;
size_t stride = getFormatStride(req.formats[i]);
size_t stride = getFormatStride(cmd.formats[i]);
size_t datasize = stride * totalvertices;
if (state.vbMap[i].data != nullptr && datasize > state.vbMap[i].size)
@@ -802,10 +802,10 @@ Graphics::StreamVertexData Graphics::requestStreamDraw(const StreamDrawRequest &
shouldresize = true;
}
newdatasizes[i] = stride * req.vertexCount;
newdatasizes[i] = stride * cmd.vertexCount;
}
if (req.indexMode != TriangleIndexMode::NONE)
if (cmd.indexMode != TriangleIndexMode::NONE)
{
size_t datasize = (state.indexCount + reqIndexCount) * sizeof(uint16);
@@ -823,18 +823,18 @@ Graphics::StreamVertexData Graphics::requestStreamDraw(const StreamDrawRequest &
{
flushStreamDraws();
state.primitiveMode = req.primitiveMode;
state.formats[0] = req.formats[0];
state.formats[1] = req.formats[1];
state.texture = req.texture;
state.standardShaderType = req.standardShaderType;
state.primitiveMode = cmd.primitiveMode;
state.formats[0] = cmd.formats[0];
state.formats[1] = cmd.formats[1];
state.texture = cmd.texture;
state.standardShaderType = cmd.standardShaderType;
}
if (state.vertexCount == 0 && Shader::isDefaultActive())
Shader::attachDefault(state.standardShaderType);
if (state.vertexCount == 0 && Shader::current != nullptr && req.texture != nullptr)
Shader::current->checkMainTexture(req.texture);
if (state.vertexCount == 0 && Shader::current != nullptr && cmd.texture != nullptr)
Shader::current->checkMainTexture(cmd.texture);
if (shouldresize)
{
@@ -854,13 +854,13 @@ Graphics::StreamVertexData Graphics::requestStreamDraw(const StreamDrawRequest &
}
}
if (req.indexMode != TriangleIndexMode::NONE)
if (cmd.indexMode != TriangleIndexMode::NONE)
{
if (state.indexBufferMap.data == nullptr)
state.indexBufferMap = state.indexBuffer->map(reqIndexSize);
uint16 *indices = (uint16 *) state.indexBufferMap.data;
fillIndices(req.indexMode, state.vertexCount, req.vertexCount, indices);
fillIndices(cmd.indexMode, state.vertexCount, cmd.vertexCount, indices);
state.indexBufferMap.data += reqIndexSize;
}
@@ -883,7 +883,7 @@ Graphics::StreamVertexData Graphics::requestStreamDraw(const StreamDrawRequest &
if (state.vertexCount > 0)
drawCallsBatched++;
state.vertexCount += req.vertexCount;
state.vertexCount += cmd.vertexCount;
state.indexCount += reqIndexCount;
return d;
@@ -960,18 +960,18 @@ void Graphics::points(const Vector2 *positions, const Colorf *colors, size_t num
const Matrix4 &t = getTransform();
bool is2D = t.isAffine2DTransform();
StreamDrawRequest req;
req.primitiveMode = vertex::PrimitiveMode::POINTS;
req.formats[0] = vertex::getSinglePositionFormat(is2D);
req.formats[1] = vertex::CommonFormat::RGBAub;
req.vertexCount = (int) numpoints;
StreamDrawCommand cmd;
cmd.primitiveMode = vertex::PrimitiveMode::POINTS;
cmd.formats[0] = vertex::getSinglePositionFormat(is2D);
cmd.formats[1] = vertex::CommonFormat::RGBAub;
cmd.vertexCount = (int) numpoints;
StreamVertexData data = requestStreamDraw(req);
StreamVertexData data = requestStreamDraw(cmd);
if (is2D)
t.transformXY((Vector2 *) data.stream[0], positions, req.vertexCount);
t.transformXY((Vector2 *) data.stream[0], positions, cmd.vertexCount);
else
t.transformXY0((Vector3 *) data.stream[0], positions, req.vertexCount);
t.transformXY0((Vector3 *) data.stream[0], positions, cmd.vertexCount);
Color *colordata = (Color *) data.stream[1];
@@ -982,7 +982,7 @@ void Graphics::points(const Vector2 *positions, const Colorf *colors, size_t num
if (isGammaCorrect())
{
for (int i = 0; i < req.vertexCount; i++)
for (int i = 0; i < cmd.vertexCount; i++)
{
Colorf ci = colors[i];
gammaCorrectColor(ci);
@@ -993,7 +993,7 @@ void Graphics::points(const Vector2 *positions, const Colorf *colors, size_t num
}
else
{
for (int i = 0; i < req.vertexCount; i++)
for (int i = 0; i < cmd.vertexCount; i++)
colordata[i] = toColor(nc * colors[i]);
}
}
@@ -1001,7 +1001,7 @@ void Graphics::points(const Vector2 *positions, const Colorf *colors, size_t num
{
Color c = toColor(getColor());
for (int i = 0; i < req.vertexCount; i++)
for (int i = 0; i < cmd.vertexCount; i++)
colordata[i] = c;
}
}
@@ -1242,22 +1242,22 @@ void Graphics::polygon(DrawMode mode, const Vector2 *coords, size_t count)
const Matrix4 &t = getTransform();
bool is2D = t.isAffine2DTransform();
StreamDrawRequest req;
req.formats[0] = vertex::getSinglePositionFormat(is2D);
req.formats[1] = vertex::CommonFormat::RGBAub;
req.indexMode = vertex::TriangleIndexMode::FAN;
req.vertexCount = (int)count - 1;
StreamDrawCommand cmd;
cmd.formats[0] = vertex::getSinglePositionFormat(is2D);
cmd.formats[1] = vertex::CommonFormat::RGBAub;
cmd.indexMode = vertex::TriangleIndexMode::FAN;
cmd.vertexCount = (int)count - 1;
StreamVertexData data = requestStreamDraw(req);
StreamVertexData data = requestStreamDraw(cmd);
if (is2D)
t.transformXY((Vector2 *) data.stream[0], coords, req.vertexCount);
t.transformXY((Vector2 *) data.stream[0], coords, cmd.vertexCount);
else
t.transformXY0((Vector3 *) data.stream[0], coords, req.vertexCount);
t.transformXY0((Vector3 *) data.stream[0], coords, cmd.vertexCount);
Color c = toColor(getColor());
Color *colordata = (Color *) data.stream[1];
for (int i = 0; i < req.vertexCount; i++)
for (int i = 0; i < cmd.vertexCount; i++)
colordata[i] = c;
}
}
+3 -3
View File
@@ -248,7 +248,7 @@ public:
}
};
struct StreamDrawRequest
struct StreamDrawCommand
{
vertex::PrimitiveMode primitiveMode = vertex::PrimitiveMode::TRIANGLES;
vertex::CommonFormat formats[2];
@@ -257,7 +257,7 @@ public:
Texture *texture = nullptr;
Shader::StandardShader standardShaderType = Shader::STANDARD_DEFAULT;
StreamDrawRequest()
StreamDrawCommand()
{
// VS2013 can't initialize arrays in the above manner...
formats[1] = formats[0] = vertex::CommonFormat::NONE;
@@ -750,7 +750,7 @@ public:
Vector2 inverseTransformPoint(Vector2 point);
virtual void flushStreamDraws() = 0;
StreamVertexData requestStreamDraw(const StreamDrawRequest &request);
StreamVertexData requestStreamDraw(const StreamDrawCommand &command);
static void flushStreamDrawsGlobal();
+6 -6
View File
@@ -374,13 +374,13 @@ void Polyline::draw(love::graphics::Graphics *gfx)
const Matrix4 &t = gfx->getTransform();
bool is2D = t.isAffine2DTransform();
Graphics::StreamDrawRequest req;
req.formats[0] = vertex::getSinglePositionFormat(is2D);
req.formats[1] = vertex::CommonFormat::RGBAub;
req.indexMode = triangle_mode;
req.vertexCount = total_vertex_count;
Graphics::StreamDrawCommand cmd;
cmd.formats[0] = vertex::getSinglePositionFormat(is2D);
cmd.formats[1] = vertex::CommonFormat::RGBAub;
cmd.indexMode = triangle_mode;
cmd.vertexCount = total_vertex_count;
Graphics::StreamVertexData data = gfx->requestStreamDraw(req);
Graphics::StreamVertexData data = gfx->requestStreamDraw(cmd);
if (is2D)
t.transformXY((Vector2 *) data.stream[0], vertices, total_vertex_count);
+15 -15
View File
@@ -123,14 +123,14 @@ void Texture::draw(Graphics *gfx, Quad *q, const Matrix4 &localTransform)
const Matrix4 &tm = gfx->getTransform();
bool is2D = tm.isAffine2DTransform();
Graphics::StreamDrawRequest req;
req.formats[0] = vertex::getSinglePositionFormat(is2D);
req.formats[1] = CommonFormat::STf_RGBAub;
req.indexMode = TriangleIndexMode::QUADS;
req.vertexCount = 4;
req.texture = this;
Graphics::StreamDrawCommand cmd;
cmd.formats[0] = vertex::getSinglePositionFormat(is2D);
cmd.formats[1] = CommonFormat::STf_RGBAub;
cmd.indexMode = TriangleIndexMode::QUADS;
cmd.vertexCount = 4;
cmd.texture = this;
Graphics::StreamVertexData data = gfx->requestStreamDraw(req);
Graphics::StreamVertexData data = gfx->requestStreamDraw(cmd);
Matrix4 t(tm, localTransform);
@@ -177,15 +177,15 @@ void Texture::drawLayer(Graphics *gfx, int layer, Quad *q, const Matrix4 &m)
Matrix4 t(tm, m);
Graphics::StreamDrawRequest req;
req.formats[0] = vertex::getSinglePositionFormat(is2D);
req.formats[1] = CommonFormat::STPf_RGBAub;
req.indexMode = TriangleIndexMode::QUADS;
req.vertexCount = 4;
req.texture = this;
req.standardShaderType = Shader::STANDARD_ARRAY;
Graphics::StreamDrawCommand cmd;
cmd.formats[0] = vertex::getSinglePositionFormat(is2D);
cmd.formats[1] = CommonFormat::STPf_RGBAub;
cmd.indexMode = TriangleIndexMode::QUADS;
cmd.vertexCount = 4;
cmd.texture = this;
cmd.standardShaderType = Shader::STANDARD_ARRAY;
Graphics::StreamVertexData data = gfx->requestStreamDraw(req);
Graphics::StreamVertexData data = gfx->requestStreamDraw(cmd);
if (is2D)
t.transformXY((Vector2 *) data.stream[0], q->getVertexPositions(), 4);
+7 -7
View File
@@ -112,14 +112,14 @@ void Video::draw(Graphics *gfx, const Matrix4 &m)
Matrix4 t(tm, m);
Graphics::StreamDrawRequest req;
req.formats[0] = vertex::getSinglePositionFormat(is2D);
req.formats[1] = vertex::CommonFormat::STf_RGBAub;
req.indexMode = vertex::TriangleIndexMode::QUADS;
req.vertexCount = 4;
req.standardShaderType = Shader::STANDARD_VIDEO;
Graphics::StreamDrawCommand cmd;
cmd.formats[0] = vertex::getSinglePositionFormat(is2D);
cmd.formats[1] = vertex::CommonFormat::STf_RGBAub;
cmd.indexMode = vertex::TriangleIndexMode::QUADS;
cmd.vertexCount = 4;
cmd.standardShaderType = Shader::STANDARD_VIDEO;
Graphics::StreamVertexData data = gfx->requestStreamDraw(req);
Graphics::StreamVertexData data = gfx->requestStreamDraw(cmd);
if (is2D)
t.transformXY((Vector2 *) data.stream[0], vertices, 4);