SkSurfaceProps.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. #ifndef SkSurfaceProps_DEFINED
  8. #define SkSurfaceProps_DEFINED
  9. #include "SkTypes.h"
  10. /**
  11. * Description of how the LCD strips are arranged for each pixel. If this is unknown, or the
  12. * pixels are meant to be "portable" and/or transformed before showing (e.g. rotated, scaled)
  13. * then use kUnknown_SkPixelGeometry.
  14. */
  15. enum SkPixelGeometry {
  16. kUnknown_SkPixelGeometry,
  17. kRGB_H_SkPixelGeometry,
  18. kBGR_H_SkPixelGeometry,
  19. kRGB_V_SkPixelGeometry,
  20. kBGR_V_SkPixelGeometry,
  21. };
  22. // Returns true iff geo is a known geometry and is RGB.
  23. static inline bool SkPixelGeometryIsRGB(SkPixelGeometry geo) {
  24. return kRGB_H_SkPixelGeometry == geo || kRGB_V_SkPixelGeometry == geo;
  25. }
  26. // Returns true iff geo is a known geometry and is BGR.
  27. static inline bool SkPixelGeometryIsBGR(SkPixelGeometry geo) {
  28. return kBGR_H_SkPixelGeometry == geo || kBGR_V_SkPixelGeometry == geo;
  29. }
  30. // Returns true iff geo is a known geometry and is horizontal.
  31. static inline bool SkPixelGeometryIsH(SkPixelGeometry geo) {
  32. return kRGB_H_SkPixelGeometry == geo || kBGR_H_SkPixelGeometry == geo;
  33. }
  34. // Returns true iff geo is a known geometry and is vertical.
  35. static inline bool SkPixelGeometryIsV(SkPixelGeometry geo) {
  36. return kRGB_V_SkPixelGeometry == geo || kBGR_V_SkPixelGeometry == geo;
  37. }
  38. /**
  39. * Describes properties and constraints of a given SkSurface. The rendering engine can parse these
  40. * during drawing, and can sometimes optimize its performance (e.g. disabling an expensive
  41. * feature).
  42. */
  43. class SK_API SkSurfaceProps {
  44. public:
  45. enum Flags {
  46. kUseDeviceIndependentFonts_Flag = 1 << 0,
  47. };
  48. /** Deprecated alias used by Chromium. Will be removed. */
  49. static const Flags kUseDistanceFieldFonts_Flag = kUseDeviceIndependentFonts_Flag;
  50. SkSurfaceProps(uint32_t flags, SkPixelGeometry);
  51. enum InitType {
  52. kLegacyFontHost_InitType
  53. };
  54. SkSurfaceProps(InitType);
  55. SkSurfaceProps(uint32_t flags, InitType);
  56. SkSurfaceProps(const SkSurfaceProps& other);
  57. uint32_t flags() const { return fFlags; }
  58. SkPixelGeometry pixelGeometry() const { return fPixelGeometry; }
  59. bool isUseDeviceIndependentFonts() const {
  60. return SkToBool(fFlags & kUseDeviceIndependentFonts_Flag);
  61. }
  62. bool operator==(const SkSurfaceProps& that) const {
  63. return fFlags == that.fFlags && fPixelGeometry == that.fPixelGeometry;
  64. }
  65. private:
  66. SkSurfaceProps();
  67. uint32_t fFlags;
  68. SkPixelGeometry fPixelGeometry;
  69. };
  70. #endif