| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 | 8 |
| 9 #include "SkDeviceProfile.h" | 9 #include "SkDeviceProfile.h" |
| 10 #include "SkThread.h" |
| 10 | 11 |
| 11 SK_DEFINE_INST_COUNT(SkDeviceProfile) | 12 SK_DEFINE_INST_COUNT(SkDeviceProfile) |
| 12 | 13 |
| 13 #define DEFAULT_GAMMAEXP 2.2f | 14 #define DEFAULT_GAMMAEXP 2.2f |
| 14 #define DEFAULT_CONTRASTSCALE 0.5f | 15 #define DEFAULT_CONTRASTSCALE 0.5f |
| 15 #define DEFAULT_LCDCONFIG SkDeviceProfile::kNone_LCDConfig | 16 #define DEFAULT_LCDCONFIG SkDeviceProfile::kNone_LCDConfig |
| 16 #define DEFAULT_FONTHINTLEVEL SkDeviceProfile::kSlight_FontHintLevel | 17 #define DEFAULT_FONTHINTLEVEL SkDeviceProfile::kSlight_FontHintLevel |
| 17 | 18 |
| 18 static float pin(float value, float min, float max) { | 19 static float pin(float value, float min, float max) { |
| 19 if (value < min) { | 20 if (value < min) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 38 | 39 |
| 39 /////////////////////////////////////////////////////////////////////////////// | 40 /////////////////////////////////////////////////////////////////////////////// |
| 40 | 41 |
| 41 SkDeviceProfile* SkDeviceProfile::Create(float gammaExp, | 42 SkDeviceProfile* SkDeviceProfile::Create(float gammaExp, |
| 42 float contrast, | 43 float contrast, |
| 43 LCDConfig config, | 44 LCDConfig config, |
| 44 FontHintLevel level) { | 45 FontHintLevel level) { |
| 45 return SkNEW_ARGS(SkDeviceProfile, (gammaExp, contrast, config, level)); | 46 return SkNEW_ARGS(SkDeviceProfile, (gammaExp, contrast, config, level)); |
| 46 } | 47 } |
| 47 | 48 |
| 48 static SkMutex gMutex; | 49 SK_DECLARE_STATIC_MUTEX(gMutex); |
| 49 static SkDeviceProfile* gDefaultProfile; | 50 static SkDeviceProfile* gDefaultProfile; |
| 50 static SkDeviceProfile* gGlobalProfile; | 51 static SkDeviceProfile* gGlobalProfile; |
| 51 | 52 |
| 52 SkDeviceProfile* SkDeviceProfile::GetDefault() { | 53 SkDeviceProfile* SkDeviceProfile::GetDefault() { |
| 53 SkAutoMutexAcquire amc(gMutex); | 54 SkAutoMutexAcquire amc(gMutex); |
| 54 | 55 |
| 55 if (NULL == gDefaultProfile) { | 56 if (NULL == gDefaultProfile) { |
| 56 gDefaultProfile = SkDeviceProfile::Create(DEFAULT_GAMMAEXP, | 57 gDefaultProfile = SkDeviceProfile::Create(DEFAULT_GAMMAEXP, |
| 57 DEFAULT_CONTRASTSCALE, | 58 DEFAULT_CONTRASTSCALE, |
| 58 DEFAULT_LCDCONFIG, | 59 DEFAULT_LCDCONFIG, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 69 } | 70 } |
| 70 gGlobalProfile->ref(); | 71 gGlobalProfile->ref(); |
| 71 return gGlobalProfile; | 72 return gGlobalProfile; |
| 72 } | 73 } |
| 73 | 74 |
| 74 void SkDeviceProfile::SetGlobal(SkDeviceProfile* profile) { | 75 void SkDeviceProfile::SetGlobal(SkDeviceProfile* profile) { |
| 75 SkAutoMutexAcquire amc(gMutex); | 76 SkAutoMutexAcquire amc(gMutex); |
| 76 | 77 |
| 77 SkRefCnt_SafeAssign(gGlobalProfile, profile); | 78 SkRefCnt_SafeAssign(gGlobalProfile, profile); |
| 78 } | 79 } |
| OLD | NEW |