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

Unified Diff: include/core/SkSurfaceProps.h

Issue 551463004: introduce Props to surface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: deprecate non-prop versions of surfaces 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 side-by-side diff with in-line comments
Download patch
Index: include/core/SkSurfaceProps.h
diff --git a/include/core/SkSurfaceProps.h b/include/core/SkSurfaceProps.h
new file mode 100644
index 0000000000000000000000000000000000000000..799bf49e9b159e7adedc88b9158b91b773864d69
--- /dev/null
+++ b/include/core/SkSurfaceProps.h
@@ -0,0 +1,67 @@
+/*
+ * 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 "SkPoint.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,
+};
+
+/**
+ * Describes properties and constraints of a given SkSurface. The rendering engine can parse these
+ * during drawing, and can sometimes optimized 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,
+ };
+private:
+ SkSurfaceProps();
+public:
+ enum InitType {
+ kLegacyFontHost_InitType
+ };
+ SkSurfaceProps(InitType);
+ SkSurfaceProps(uint32_t flags, InitType);
+
+ // pixel geometry cannot be kLegacyLCD_SkPixelGeometry
+ SkSurfaceProps(uint32_t flags, SkPixelGeometry);
+
+ uint32_t flags() const { return fFlags; }
+ SkPixelGeometry pixelGeometry() const { return fPixelGeometry; }
+
+ bool disallowAA() const { return SkToBool(fFlags & kDisallowAntiAlias_Flag); }
+ bool disallowDither() const { return SkToBool(fFlags & kDisallowDither_Flag); }
+ bool useDistanceFieldFonts() const { return SkToBool(fFlags & kUseDistanceFieldFonts_Flag); }
+
+ // Returns a copy of the specified props, or the legacy version if props is NULL.
+ static SkSurfaceProps CopyOrLegacy(const SkSurfaceProps* props) {
+ return props ? *props : SkSurfaceProps(kLegacyFontHost_InitType);
+ }
+
+private:
+ uint32_t fFlags;
+ SkPixelGeometry fPixelGeometry;
+};
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698