Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(628)

Side by Side Diff: src/gpu/GrAutoLocaleSetter.h

Issue 1002623004: Move GrAutoLocaleSetter to new file and fix issue with null locale (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove extra newline Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/gpu/GrTypesPriv.h ('k') | src/gpu/gl/builders/GrGLProgramBuilder.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef GrAutoLocaleSetter_DEFINED
9 #define GrAutoLocaleSetter_DEFINED
10
11 #include "GrTypes.h"
12
13 #if !defined(SK_BUILD_FOR_ANDROID)
14 #include <locale.h>
15 #endif
16
17 #if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
18 #include <xlocale.h>
19 #endif
20
21 /**
22 * Helper class for ensuring that we don't use the wrong locale when building sh aders. Android
23 * doesn't support locale in the NDK, so this is a no-op there.
24 */
25 class GrAutoLocaleSetter {
26 public:
27 GrAutoLocaleSetter (const char* name) {
28 #if defined(SK_BUILD_FOR_WIN)
29 fOldPerThreadLocale = _configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
30 fOldLocale = setlocale(LC_ALL, name);
31 #elif !defined(SK_BUILD_FOR_ANDROID)
32 fLocale = newlocale(LC_ALL, name, 0);
33 if (fLocale) {
34 fOldLocale = uselocale(fLocale);
35 }
36 #else
37 (void) name; // suppress unused param warning.
38 #endif
39 }
40
41 ~GrAutoLocaleSetter () {
42 #if defined(SK_BUILD_FOR_WIN)
43 setlocale(LC_ALL, fOldLocale);
44 _configthreadlocale(fOldPerThreadLocale);
45 #elif !defined(SK_BUILD_FOR_ANDROID)
46 if (fLocale) {
47 uselocale(fOldLocale);
48 freelocale(fLocale);
49 }
50 #endif
51 }
52
53 private:
54 #if defined(SK_BUILD_FOR_WIN)
55 int fOldPerThreadLocale;
56 const char* fOldLocale;
57 #elif !defined(SK_BUILD_FOR_ANDROID)
58 locale_t fOldLocale;
59 locale_t fLocale;
60 #endif
61 };
62
63 #endif
64
OLDNEW
« no previous file with comments | « include/gpu/GrTypesPriv.h ('k') | src/gpu/gl/builders/GrGLProgramBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698