SkIRect fRect;
};
+
+/**
+ * Helper class for ensuring that we don't use the wrong locale when building shaders. Android
+ * doesn't support locale in the NDK, so this is a no-op there.
+ */
+#if !defined(SK_BUILD_FOR_ANDROID)
+#include <locale.h>
+#endif
+
+#if defined(SK_BUILD_FOR_MAC)
+#include <xlocale.h>
+#endif
+
+class GrAutoLocaleSetter {
+public:
+ GrAutoLocaleSetter (const char* name) {
+#if defined(SK_BUILD_FOR_WIN)
+ fOldPerThreadLocale = _configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
+ fOldLocale = setlocale(LC_ALL, name);
+#elif !defined(SK_BUILD_FOR_ANDROID)
+ fLocale = newlocale(LC_ALL, name, 0);
+ fOldLocale = uselocale(fLocale);
+#else
+ (void) name; // suppress unused param warning.
+#endif
+ }
+
+ ~GrAutoLocaleSetter () {
+#if defined(SK_BUILD_FOR_WIN)
+ setlocale(LC_ALL, fOldLocale);
+ _configthreadlocale(fOldPerThreadLocale);
+#elif !defined(SK_BUILD_FOR_ANDROID)
+ SkASSERT(uselocale(fOldLocale) == fLocale);
+ freelocale(fLocale);
+#endif
+ }
+
+private:
+#if defined(SK_BUILD_FOR_WIN)
+ int fOldPerThreadLocale;
+ const char* fOldLocale;
+#elif !defined(SK_BUILD_FOR_ANDROID)
+ locale_t fOldLocale;
+ locale_t fLocale;
+#endif
+};
+
#endif
const int GrGLProgramBuilder::kVarsPerBlock = 8;
GrGLProgram* GrGLProgramBuilder::CreateProgram(const DrawArgs& args, GrGLGpu* gpu) {
+ GrAutoLocaleSetter als("C");
+
// create a builder. This will be handed off to effects so they can use it to add
// uniforms, varyings, textures, etc
SkAutoTDelete<GrGLProgramBuilder> builder(CreateProgramBuilder(args, gpu));
}
DEF_GPUTEST(GLPrograms, reporter, factory) {
+ // Set a locale that would cause shader compilation to fail because of , as decimal separator.
+ // skbug 3330
+#ifdef SK_BUILD_FOR_WIN
+ GrAutoLocaleSetter als("sv-SE");
+#else
+ GrAutoLocaleSetter als("sv_SE.UTF-8");
+#endif
+
for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
GrContext* context = factory->get(static_cast<GrContextFactory::GLContextType>(type));
if (context) {