1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/core/SkDeviceProfile.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,98 @@ 1.4 +/* 1.5 + * Copyright 2012 Google Inc. 1.6 + * 1.7 + * Use of this source code is governed by a BSD-style license that can be 1.8 + * found in the LICENSE file. 1.9 + */ 1.10 + 1.11 +#ifndef SkDeviceProfile_DEFINED 1.12 +#define SkDeviceProfile_DEFINED 1.13 + 1.14 +#include "SkRefCnt.h" 1.15 + 1.16 +class SkDeviceProfile : public SkRefCnt { 1.17 +public: 1.18 + SK_DECLARE_INST_COUNT(SkDeviceProfile) 1.19 + 1.20 + enum LCDConfig { 1.21 + kNone_LCDConfig, // disables LCD text rendering, uses A8 instead 1.22 + kRGB_Horizontal_LCDConfig, 1.23 + kBGR_Horizontal_LCDConfig, 1.24 + kRGB_Vertical_LCDConfig, 1.25 + kBGR_Vertical_LCDConfig 1.26 + }; 1.27 + 1.28 + enum FontHintLevel { 1.29 + kNone_FontHintLevel, 1.30 + kSlight_FontHintLevel, 1.31 + kNormal_FontHintLevel, 1.32 + kFull_FontHintLevel, 1.33 + kAuto_FontHintLevel 1.34 + }; 1.35 + 1.36 + /** 1.37 + * gammaExp is typically between 1.0 and 2.2. For no gamma adjustment, 1.38 + * specify 1.0 1.39 + * 1.40 + * contrastScale will be pinned between 0.0 and 1.0. For no contrast 1.41 + * adjustment, specify 0.0 1.42 + * 1.43 + * @param config Describes the LCD layout for this device. If this is set 1.44 + * to kNone, then all requests for LCD text will be 1.45 + * devolved to A8 antialiasing. 1.46 + * 1.47 + * @param level The hinting level to be used, IF the paint specifies 1.48 + * "default". Otherwise the paint's hinting level will be 1.49 + * respected. 1.50 + */ 1.51 + static SkDeviceProfile* Create(float gammaExp, 1.52 + float contrastScale, 1.53 + LCDConfig, 1.54 + FontHintLevel); 1.55 + 1.56 + /** 1.57 + * Returns the global default profile, that is used if no global profile is 1.58 + * specified with SetGlobal(), or if NULL is specified to SetGlobal(). 1.59 + * The references count is *not* incremented, and the caller should not 1.60 + * call unref(). 1.61 + */ 1.62 + static SkDeviceProfile* GetDefault(); 1.63 + 1.64 + /** 1.65 + * Return the current global profile (or the default if no global had yet 1.66 + * been set) and increment its reference count. The call *must* call unref() 1.67 + * when it is done using it. 1.68 + */ 1.69 + static SkDeviceProfile* RefGlobal(); 1.70 + 1.71 + /** 1.72 + * Make the specified profile be the global value for all subsequently 1.73 + * instantiated devices. Does not affect any existing devices. 1.74 + * Increments the reference count on the profile. 1.75 + * Specify NULL for the "identity" profile (where there is no gamma or 1.76 + * contrast correction). 1.77 + */ 1.78 + static void SetGlobal(SkDeviceProfile*); 1.79 + 1.80 + float getFontGammaExponent() const { return fGammaExponent; } 1.81 + float getFontContrastScale() const { return fContrastScale; } 1.82 + 1.83 + /** 1.84 + * Given a luminance byte (0 for black, 0xFF for white), generate a table 1.85 + * that applies the gamma/contrast settings to linear coverage values. 1.86 + */ 1.87 + void generateTableForLuminanceByte(U8CPU lumByte, uint8_t table[256]) const; 1.88 + 1.89 +private: 1.90 + SkDeviceProfile(float gammaExp, float contrastScale, LCDConfig, 1.91 + FontHintLevel); 1.92 + 1.93 + float fGammaExponent; 1.94 + float fContrastScale; 1.95 + LCDConfig fLCDConfig; 1.96 + FontHintLevel fFontHintLevel; 1.97 + 1.98 + typedef SkRefCnt INHERITED; 1.99 +}; 1.100 + 1.101 +#endif