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

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: add new file 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
« no previous file with comments | « src/core/SkDevice.cpp ('k') | src/core/SkPaint.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
1 #ifndef SkDeviceProperties_DEFINED 8 #ifndef SkDeviceProperties_DEFINED
2 #define SkDeviceProperties_DEFINED 9 #define SkDeviceProperties_DEFINED
3 10
4 //TODO: get everyone to stop using SkFontLCDConfig::SetSubpixel* and remove this import. 11 #include "SkSurfacePriv.h"
5 #include "SkFontLCDConfig.h"
6 12
7 struct SkDeviceProperties { 13 struct SkDeviceProperties {
8 struct Geometry { 14 enum InitType {
9 /** The orientation of the pixel specifies the interpretation of the 15 kLegacyLCD_InitType
10 * layout. If the orientation is horizontal, the layout is interpreted a s 16 };
11 * left to right. It the orientation is vertical, the layout is 17 SkDeviceProperties(InitType) : fPixelGeometry(SkSurfacePropsDefaultPixelGeom etry()) {}
12 * interpreted top to bottom (rotated 90deg cw from horizontal). 18 SkDeviceProperties(SkPixelGeometry geo) : fPixelGeometry(geo) {}
13 */
14 enum Orientation {
15 kUnknown_Orientation = 0x0,
16 kKnown_Orientation = 0x2,
17 19
18 kHorizontal_Orientation = 0x2, //!< this is the default 20 SkPixelGeometry fPixelGeometry;
19 kVertical_Orientation = 0x3,
20 21
21 kOrientationMask = 0x3, 22 // read-only attribute -- until we actually store a value (future CL)
22 }; 23 float getGamma() const { return SK_GAMMA_EXPONENT; }
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 }
89
90 static SkDeviceProperties Make(Geometry geometry, SkScalar gamma) {
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 }; 24 };
102 25
103 #endif 26 #endif
OLDNEW
« no previous file with comments | « src/core/SkDevice.cpp ('k') | src/core/SkPaint.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698