1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/thebes/gfxPrefs.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,88 @@ 1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- 1.5 + * This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "gfxPrefs.h" 1.10 + 1.11 +#include "mozilla/Preferences.h" 1.12 +#include "MainThreadUtils.h" 1.13 + 1.14 +using namespace mozilla; 1.15 + 1.16 +gfxPrefs* gfxPrefs::sInstance = nullptr; 1.17 + 1.18 +void 1.19 +gfxPrefs::DestroySingleton() 1.20 +{ 1.21 + if (sInstance) { 1.22 + delete sInstance; 1.23 + sInstance = nullptr; 1.24 + } 1.25 +} 1.26 + 1.27 +bool 1.28 +gfxPrefs::SingletonExists() 1.29 +{ 1.30 + return sInstance != nullptr; 1.31 +} 1.32 + 1.33 +gfxPrefs::gfxPrefs() 1.34 +{ 1.35 + // Needs to be created on the main thread. 1.36 + MOZ_ASSERT(NS_IsMainThread(), "must be constructed on the main thread"); 1.37 +} 1.38 + 1.39 +gfxPrefs::~gfxPrefs() 1.40 +{ 1.41 + MOZ_ASSERT(NS_IsMainThread(), "must be destructed on the main thread"); 1.42 +} 1.43 + 1.44 +void gfxPrefs::PrefAddVarCache(bool* aVariable, 1.45 + const char* aPref, 1.46 + bool aDefault) 1.47 +{ 1.48 + Preferences::AddBoolVarCache(aVariable, aPref, aDefault); 1.49 +} 1.50 + 1.51 +void gfxPrefs::PrefAddVarCache(int32_t* aVariable, 1.52 + const char* aPref, 1.53 + int32_t aDefault) 1.54 +{ 1.55 + Preferences::AddIntVarCache(aVariable, aPref, aDefault); 1.56 +} 1.57 + 1.58 +void gfxPrefs::PrefAddVarCache(uint32_t* aVariable, 1.59 + const char* aPref, 1.60 + uint32_t aDefault) 1.61 +{ 1.62 + Preferences::AddUintVarCache(aVariable, aPref, aDefault); 1.63 +} 1.64 + 1.65 +void gfxPrefs::PrefAddVarCache(float* aVariable, 1.66 + const char* aPref, 1.67 + float aDefault) 1.68 +{ 1.69 + Preferences::AddFloatVarCache(aVariable, aPref, aDefault); 1.70 +} 1.71 + 1.72 +bool gfxPrefs::PrefGet(const char* aPref, bool aDefault) 1.73 +{ 1.74 + return Preferences::GetBool(aPref, aDefault); 1.75 +} 1.76 + 1.77 +int32_t gfxPrefs::PrefGet(const char* aPref, int32_t aDefault) 1.78 +{ 1.79 + return Preferences::GetInt(aPref, aDefault); 1.80 +} 1.81 + 1.82 +uint32_t gfxPrefs::PrefGet(const char* aPref, uint32_t aDefault) 1.83 +{ 1.84 + return Preferences::GetUint(aPref, aDefault); 1.85 +} 1.86 + 1.87 +float gfxPrefs::PrefGet(const char* aPref, float aDefault) 1.88 +{ 1.89 + return Preferences::GetFloat(aPref, aDefault); 1.90 +} 1.91 +