michael@0: /* michael@0: * Copyright 2012 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: #ifndef SkDeviceProfile_DEFINED michael@0: #define SkDeviceProfile_DEFINED michael@0: michael@0: #include "SkRefCnt.h" michael@0: michael@0: class SkDeviceProfile : public SkRefCnt { michael@0: public: michael@0: SK_DECLARE_INST_COUNT(SkDeviceProfile) michael@0: michael@0: enum LCDConfig { michael@0: kNone_LCDConfig, // disables LCD text rendering, uses A8 instead michael@0: kRGB_Horizontal_LCDConfig, michael@0: kBGR_Horizontal_LCDConfig, michael@0: kRGB_Vertical_LCDConfig, michael@0: kBGR_Vertical_LCDConfig michael@0: }; michael@0: michael@0: enum FontHintLevel { michael@0: kNone_FontHintLevel, michael@0: kSlight_FontHintLevel, michael@0: kNormal_FontHintLevel, michael@0: kFull_FontHintLevel, michael@0: kAuto_FontHintLevel michael@0: }; michael@0: michael@0: /** michael@0: * gammaExp is typically between 1.0 and 2.2. For no gamma adjustment, michael@0: * specify 1.0 michael@0: * michael@0: * contrastScale will be pinned between 0.0 and 1.0. For no contrast michael@0: * adjustment, specify 0.0 michael@0: * michael@0: * @param config Describes the LCD layout for this device. If this is set michael@0: * to kNone, then all requests for LCD text will be michael@0: * devolved to A8 antialiasing. michael@0: * michael@0: * @param level The hinting level to be used, IF the paint specifies michael@0: * "default". Otherwise the paint's hinting level will be michael@0: * respected. michael@0: */ michael@0: static SkDeviceProfile* Create(float gammaExp, michael@0: float contrastScale, michael@0: LCDConfig, michael@0: FontHintLevel); michael@0: michael@0: /** michael@0: * Returns the global default profile, that is used if no global profile is michael@0: * specified with SetGlobal(), or if NULL is specified to SetGlobal(). michael@0: * The references count is *not* incremented, and the caller should not michael@0: * call unref(). michael@0: */ michael@0: static SkDeviceProfile* GetDefault(); michael@0: michael@0: /** michael@0: * Return the current global profile (or the default if no global had yet michael@0: * been set) and increment its reference count. The call *must* call unref() michael@0: * when it is done using it. michael@0: */ michael@0: static SkDeviceProfile* RefGlobal(); michael@0: michael@0: /** michael@0: * Make the specified profile be the global value for all subsequently michael@0: * instantiated devices. Does not affect any existing devices. michael@0: * Increments the reference count on the profile. michael@0: * Specify NULL for the "identity" profile (where there is no gamma or michael@0: * contrast correction). michael@0: */ michael@0: static void SetGlobal(SkDeviceProfile*); michael@0: michael@0: float getFontGammaExponent() const { return fGammaExponent; } michael@0: float getFontContrastScale() const { return fContrastScale; } michael@0: michael@0: /** michael@0: * Given a luminance byte (0 for black, 0xFF for white), generate a table michael@0: * that applies the gamma/contrast settings to linear coverage values. michael@0: */ michael@0: void generateTableForLuminanceByte(U8CPU lumByte, uint8_t table[256]) const; michael@0: michael@0: private: michael@0: SkDeviceProfile(float gammaExp, float contrastScale, LCDConfig, michael@0: FontHintLevel); michael@0: michael@0: float fGammaExponent; michael@0: float fContrastScale; michael@0: LCDConfig fLCDConfig; michael@0: FontHintLevel fFontHintLevel; michael@0: michael@0: typedef SkRefCnt INHERITED; michael@0: }; michael@0: michael@0: #endif