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 @@ ...@@ -14,6 +14,7 @@
#include <stddef.h> #include <stddef.h>
#include <string> #include <string>
#include <set> #include <set>
#include <sstream>
// A macro to disallow the copy constructor and operator= functions // A macro to disallow the copy constructor and operator= functions
// This must be used in the private: declarations for a class // This must be used in the private: declarations for a class
...@@ -115,6 +116,31 @@ inline const char* MakeStaticString(const std::string &str) ...@@ -115,6 +116,31 @@ inline const char* MakeStaticString(const std::string &str)
return strings.insert(str).first->c_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) #if defined(_MSC_VER)
#define snprintf _snprintf #define snprintf _snprintf
#endif #endif
......
...@@ -17,12 +17,8 @@ ...@@ -17,12 +17,8 @@
#include "libGLESv2/formatutils.h" #include "libGLESv2/formatutils.h"
#include "common/blocklayout.h" #include "common/blocklayout.h"
static std::string Str(int i) // For use with ArrayString, see angleutils.h
{ META_ASSERT(GL_INVALID_INDEX == UINT_MAX);
char buffer[20];
snprintf(buffer, sizeof(buffer), "%d", i);
return buffer;
}
namespace gl_d3d namespace gl_d3d
{ {
...@@ -77,11 +73,6 @@ std::string HLSLTypeString(GLenum type) ...@@ -77,11 +73,6 @@ std::string HLSLTypeString(GLenum type)
namespace gl 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 VERTEX_ATTRIBUTE_STUB_STRING = "@@ VERTEX ATTRIBUTES @@";
const std::string PIXEL_OUTPUT_STUB_STRING = "@@ PIXEL OUTPUT @@"; const std::string PIXEL_OUTPUT_STUB_STRING = "@@ PIXEL OUTPUT @@";
......
...@@ -91,9 +91,6 @@ class DynamicHLSL ...@@ -91,9 +91,6 @@ class DynamicHLSL
std::string generateAttributeConversionHLSL(const VertexFormat &vertexFormat, const sh::ShaderVariable &shaderAttrib) const; 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_ #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