1 #ifndef SkDeviceProperties_DEFINED
2 #define SkDeviceProperties_DEFINED
4 //TODO: get everyone to stop using SkFontLCDConfig::SetSubpixel* and remove this import.
5 #include "SkFontLCDConfig.h"
7 struct SkDeviceProperties {
9 /** The orientation of the pixel specifies the interpretation of the
10 * layout. If the orientation is horizontal, the layout is interpreted as
11 * left to right. It the orientation is vertical, the layout is
12 * interpreted top to bottom (rotated 90deg cw from horizontal).
15 kUnknown_Orientation = 0x0,
16 kKnown_Orientation = 0x2,
18 kHorizontal_Orientation = 0x2, //!< this is the default
19 kVertical_Orientation = 0x3,
21 kOrientationMask = 0x3,
24 /** The layout of the pixel specifies its subpixel geometry.
26 * kUnknown_Layout means that the subpixel elements are not spatially
27 * separated in any known or usable fashion.
30 kUnknown_Layout = 0x0,
33 kRGB_Layout = 0x8, //!< this is the default
39 Orientation getOrientation() {
40 return static_cast<Orientation>(fGeometry & kOrientationMask);
43 return static_cast<Layout>(fGeometry & kLayoutMask);
46 bool isOrientationKnown() {
47 return SkToBool(fGeometry & kKnown_Orientation);
49 bool isLayoutKnown() {
50 return SkToBool(fGeometry & kKnown_Layout);
54 //TODO: get everyone to stop using SkFontLCDConfig::SetSubpixel* and replace these calls with constants.
55 static Orientation fromOldOrientation(SkFontLCDConfig::LCDOrientation orientation) {
56 switch (orientation) {
57 case SkFontLCDConfig::kHorizontal_LCDOrientation: return kHorizontal_Orientation;
58 case SkFontLCDConfig::kVertical_LCDOrientation: return kVertical_Orientation;
59 default: return kUnknown_Orientation;
62 static Layout fromOldLayout(SkFontLCDConfig::LCDOrder order) {
64 case SkFontLCDConfig::kRGB_LCDOrder: return kRGB_Layout;
65 case SkFontLCDConfig::kBGR_LCDOrder: return kBGR_Layout;
66 default: return kUnknown_Layout;
70 static Geometry MakeDefault() {
71 Orientation orientation = fromOldOrientation(SkFontLCDConfig::GetSubpixelOrientation()); //kHorizontal_Orientation
72 Layout layout = fromOldLayout(SkFontLCDConfig::GetSubpixelOrder()); //kRGB_Layout
73 Geometry ret = { SkToU8(orientation | layout) };
77 static Geometry Make(Orientation orientation, Layout layout) {
78 Geometry ret = { SkToU8(orientation | layout) };
85 static SkDeviceProperties MakeDefault() {
86 SkDeviceProperties ret = { Geometry::MakeDefault(), SK_GAMMA_EXPONENT };
90 static SkDeviceProperties Make(Geometry geometry, SkScalar gamma) {
91 SkDeviceProperties ret = { geometry, gamma };
95 /** Each pixel of an image will have some number of channels.
96 * Can the layout of those channels be exploited? */
99 /** Represents the color space of the image. This is a woefully inadequate beginning. */