Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Side by Side Diff: src/core/SkDeviceProperties.h

Issue 551463004: introduce Props to surface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix no-gpu after rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #ifndef SkDeviceProperties_DEFINED 1 #ifndef SkDeviceProperties_DEFINED
2 #define SkDeviceProperties_DEFINED 2 #define SkDeviceProperties_DEFINED
3 3
4 //TODO: get everyone to stop using SkFontLCDConfig::SetSubpixel* and remove this import. 4 #include "SkSurfaceProps.h"
5 #include "SkFontLCDConfig.h"
6 5
7 struct SkDeviceProperties { 6 struct SkDeviceProperties {
8 struct Geometry { 7 enum InitType {
9 /** The orientation of the pixel specifies the interpretation of the 8 kLegacyLCD_InitType
10 * layout. If the orientation is horizontal, the layout is interpreted a s 9 };
11 * left to right. It the orientation is vertical, the layout is 10 SkDeviceProperties(InitType);
bungeman-skia 2014/09/19 18:29:51 If this is only ever supposed to be passed the one
reed1 2014/09/19 19:16:34 I want to not have a default constructor, so I can
12 * interpreted top to bottom (rotated 90deg cw from horizontal). 11 SkDeviceProperties(SkPixelGeometry geo) : fPixelGeometry(geo) {}
13 */
14 enum Orientation {
15 kUnknown_Orientation = 0x0,
16 kKnown_Orientation = 0x2,
17 12
18 kHorizontal_Orientation = 0x2, //!< this is the default 13 SkPixelGeometry fPixelGeometry;
19 kVertical_Orientation = 0x3,
20 14
21 kOrientationMask = 0x3, 15 bool useBGR() const {
22 }; 16 return kBGR_H_SkPixelGeometry == fPixelGeometry || kBGR_V_SkPixelGeometr y == fPixelGeometry;
23
24 /** The layout of the pixel specifies its subpixel geometry.
25 *
26 * kUnknown_Layout means that the subpixel elements are not spatially
27 * separated in any known or usable fashion.
28 */
29 enum Layout {
30 kUnknown_Layout = 0x0,
31 kKnown_Layout = 0x8,
32
33 kRGB_Layout = 0x8, //!< this is the default
34 kBGR_Layout = 0xC,
35
36 kLayoutMask = 0xC,
37 };
38
39 Orientation getOrientation() {
40 return static_cast<Orientation>(fGeometry & kOrientationMask);
41 }
42 Layout getLayout() {
43 return static_cast<Layout>(fGeometry & kLayoutMask);
44 }
45
46 bool isOrientationKnown() {
47 return SkToBool(fGeometry & kKnown_Orientation);
48 }
49 bool isLayoutKnown() {
50 return SkToBool(fGeometry & kKnown_Layout);
51 }
52
53 private:
54 //TODO: get everyone to stop using SkFontLCDConfig::SetSubpixel* and rep lace these calls with constants.
55 static Orientation fromOldOrientation(SkFontLCDConfig::LCDOrientation or ientation) {
56 switch (orientation) {
57 case SkFontLCDConfig::kHorizontal_LCDOrientation: return kHorizontal _Orientation;
58 case SkFontLCDConfig::kVertical_LCDOrientation: return kVertical_Ori entation;
59 default: return kUnknown_Orientation;
60 }
61 }
62 static Layout fromOldLayout(SkFontLCDConfig::LCDOrder order) {
63 switch (order) {
64 case SkFontLCDConfig::kRGB_LCDOrder: return kRGB_Layout;
65 case SkFontLCDConfig::kBGR_LCDOrder: return kBGR_Layout;
66 default: return kUnknown_Layout;
67 }
68 }
69 public:
70 static Geometry MakeDefault() {
71 Orientation orientation = fromOldOrientation(SkFontLCDConfig::GetSub pixelOrientation()); //kHorizontal_Orientation
72 Layout layout = fromOldLayout(SkFontLCDConfig::GetSubpixelOrder()); //kRGB_Layout
73 Geometry ret = { SkToU8(orientation | layout) };
74 return ret;
75 }
76
77 static Geometry Make(Orientation orientation, Layout layout) {
78 Geometry ret = { SkToU8(orientation | layout) };
79 return ret;
80 }
81
82 uint8_t fGeometry;
83 };
84
85 static SkDeviceProperties MakeDefault() {
86 SkDeviceProperties ret = { Geometry::MakeDefault(), SK_GAMMA_EXPONENT };
87 return ret;
88 } 17 }
89 18
90 static SkDeviceProperties Make(Geometry geometry, SkScalar gamma) { 19 float getGamma() const { return SK_GAMMA_EXPONENT; }
91 SkDeviceProperties ret = { geometry, gamma };
92 return ret;
93 }
94
95 /** Each pixel of an image will have some number of channels.
96 * Can the layout of those channels be exploited? */
97 Geometry fGeometry;
98
99 /** Represents the color space of the image. This is a woefully inadequate b eginning. */
100 SkScalar fGamma;
101 }; 20 };
102 21
103 #endif 22 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698