Commit 53cb14dc by Jamie Madill

Share ArrayString and Str helper methods.

Placing these string helper methods allows us to re-use them in the relevant place of the shader translator. BUG=angle:466 Change-Id: Idd638542027d3b1035bc79fc941e80bf436c82af Reviewed-on: https://chromium-review.googlesource.com/206567Reviewed-by: 's avatarNicolas Capens <capn@chromium.org> Reviewed-by: 's avatarZhenyao Mo <zmo@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent b23375fe
......@@ -14,6 +14,7 @@
#include <stddef.h>
#include <string>
#include <set>
#include <sstream>
// A macro to disallow the copy constructor and operator= functions
// This must be used in the private: declarations for a class
......@@ -115,6 +116,31 @@ inline const char* MakeStaticString(const std::string &str)
return strings.insert(str).first->c_str();
}
inline std::string ArrayString(unsigned int i)
{
// We assume UINT_MAX and GL_INVALID_INDEX are equal
// See DynamicHLSL.cpp
if (i == UINT_MAX)
{
return "";
}
std::stringstream strstr;
strstr << "[";
strstr << i;
strstr << "]";
return strstr.str();
}
inline std::string Str(int i)
{
std::stringstream strstr;
strstr << i;
return strstr.str();
}
#if defined(_MSC_VER)
#define snprintf _snprintf
#endif
......
......@@ -17,12 +17,8 @@
#include "libGLESv2/formatutils.h"
#include "common/blocklayout.h"
static std::string Str(int i)
{
char buffer[20];
snprintf(buffer, sizeof(buffer), "%d", i);
return buffer;
}
// For use with ArrayString, see angleutils.h
META_ASSERT(GL_INVALID_INDEX == UINT_MAX);
namespace gl_d3d
{
......@@ -77,11 +73,6 @@ std::string HLSLTypeString(GLenum type)
namespace gl
{
std::string ArrayString(unsigned int i)
{
return (i == GL_INVALID_INDEX ? "" : "[" + Str(i) + "]");
}
const std::string VERTEX_ATTRIBUTE_STUB_STRING = "@@ VERTEX ATTRIBUTES @@";
const std::string PIXEL_OUTPUT_STUB_STRING = "@@ PIXEL OUTPUT @@";
......
......@@ -91,9 +91,6 @@ class DynamicHLSL
std::string generateAttributeConversionHLSL(const VertexFormat &vertexFormat, const sh::ShaderVariable &shaderAttrib) const;
};
// Utility method shared between ProgramBinary and DynamicHLSL
std::string ArrayString(unsigned int i);
}
#endif // LIBGLESV2_DYNAMIC_HLSL_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment