diff options
author | reed <reed@google.com> | 2014-09-22 07:29:03 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-22 07:29:03 -0700 |
commit | 4a8126e7f81384526629b1e21bf89b632ea13cd9 (patch) | |
tree | 9ee0776304de9dc98e48efc4943dd0fdc45db453 /include/core/SkSurfaceProps.h | |
parent | a29b5d8430ada72bc73b1e6e1b8f09e4b046b2ff (diff) |
Introduce Props to surface (patchset #27 id:520001 of https://codereview.chromium.org/551463004/)"
This reverts commit 29c857d0f3a1cb837f73406eeb6ba9771879b5e7.
TBR=
Author: reed@google.com
Review URL: https://codereview.chromium.org/588143004
Diffstat (limited to 'include/core/SkSurfaceProps.h')
-rw-r--r-- | include/core/SkSurfaceProps.h | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/include/core/SkSurfaceProps.h b/include/core/SkSurfaceProps.h new file mode 100644 index 0000000000..0154473914 --- /dev/null +++ b/include/core/SkSurfaceProps.h @@ -0,0 +1,80 @@ +/* + * Copyright 2014 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef SkSurfaceProps_DEFINED +#define SkSurfaceProps_DEFINED + +#include "SkTypes.h" + +/** + * Description of how the LCD strips are arranged for each pixel. If this is unknown, or the + * pixels are meant to be "portable" and/or transformed before showing (e.g. rotated, scaled) + * then use kUnknown_SkPixelGeometry. + */ +enum SkPixelGeometry { + kUnknown_SkPixelGeometry, + kRGB_H_SkPixelGeometry, + kBGR_H_SkPixelGeometry, + kRGB_V_SkPixelGeometry, + kBGR_V_SkPixelGeometry, +}; + +// Returns true iff geo is a known geometry and is RGB. +static inline bool SkPixelGeometryIsRGB(SkPixelGeometry geo) { + return kRGB_H_SkPixelGeometry == geo || kRGB_V_SkPixelGeometry == geo; +} + +// Returns true iff geo is a known geometry and is BGR. +static inline bool SkPixelGeometryIsBGR(SkPixelGeometry geo) { + return kBGR_H_SkPixelGeometry == geo || kBGR_V_SkPixelGeometry == geo; +} + +// Returns true iff geo is a known geometry and is horizontal. +static inline bool SkPixelGeometryIsH(SkPixelGeometry geo) { + return kRGB_H_SkPixelGeometry == geo || kBGR_H_SkPixelGeometry == geo; +} + +// Returns true iff geo is a known geometry and is vertical. +static inline bool SkPixelGeometryIsV(SkPixelGeometry geo) { + return kRGB_V_SkPixelGeometry == geo || kBGR_V_SkPixelGeometry == geo; +} + +/** + * Describes properties and constraints of a given SkSurface. The rendering engine can parse these + * during drawing, and can sometimes optimize its performance (e.g. disabling an expensive + * feature). + */ +class SkSurfaceProps { +public: + enum Flags { + kDisallowAntiAlias_Flag = 1 << 0, + kDisallowDither_Flag = 1 << 1, + kUseDistanceFieldFonts_Flag = 1 << 2, + }; + SkSurfaceProps(uint32_t flags, SkPixelGeometry); + + enum InitType { + kLegacyFontHost_InitType + }; + SkSurfaceProps(InitType); + SkSurfaceProps(uint32_t flags, InitType); + + uint32_t flags() const { return fFlags; } + SkPixelGeometry pixelGeometry() const { return fPixelGeometry; } + + bool isDisallowAA() const { return SkToBool(fFlags & kDisallowAntiAlias_Flag); } + bool isDisallowDither() const { return SkToBool(fFlags & kDisallowDither_Flag); } + bool isUseDistanceFieldFonts() const { return SkToBool(fFlags & kUseDistanceFieldFonts_Flag); } + +private: + SkSurfaceProps(); + + uint32_t fFlags; + SkPixelGeometry fPixelGeometry; +}; + +#endif |