aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrGlyph.h
diff options
context:
space:
mode:
authorGravatar djsollen <djsollen@google.com>2014-11-13 12:52:35 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-13 12:52:35 -0800
commit0b17d6cb343cb71a3f548a02f0952c3592fc8c87 (patch)
tree0a5577be50cfbd238db7008c7d73f7cc7b9e58a6 /src/gpu/GrGlyph.h
parent04f7e14b385118b8caa3ad7fcb30d64f4c32e677 (diff)
Cleanup public includes directory.
This CL updates various files in the includes directory to ensure that (1) they do not depend on headers in /src and (2) that they minimize their dependence on external headers. To ensure that we don't regress this behavior a new build target has been added to build a single cpp file that contains all* public includes and is compiled with only those directories in the include path. * The exception is those includes that depend on OS specific headers BUG=skia:2941 NOTRY=true Review URL: https://codereview.chromium.org/721903002
Diffstat (limited to 'src/gpu/GrGlyph.h')
-rw-r--r--src/gpu/GrGlyph.h90
1 files changed, 90 insertions, 0 deletions
diff --git a/src/gpu/GrGlyph.h b/src/gpu/GrGlyph.h
new file mode 100644
index 0000000000..0e534d694a
--- /dev/null
+++ b/src/gpu/GrGlyph.h
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrGlyph_DEFINED
+#define GrGlyph_DEFINED
+
+#include "GrRect.h"
+#include "GrTypes.h"
+
+#include "SkChecksum.h"
+#include "SkPath.h"
+
+class GrPlot;
+
+/* Need this to be quad-state:
+ - complete w/ image
+ - just metrics
+ - failed to get image, but has metrics
+ - failed to get metrics
+ */
+struct GrGlyph {
+ typedef uint32_t PackedID;
+
+ GrPlot* fPlot;
+ SkPath* fPath;
+ PackedID fPackedID;
+ GrMaskFormat fMaskFormat;
+ GrIRect16 fBounds;
+ SkIPoint16 fAtlasLocation;
+
+ void init(GrGlyph::PackedID packed, const SkIRect& bounds, GrMaskFormat format) {
+ fPlot = NULL;
+ fPath = NULL;
+ fPackedID = packed;
+ fBounds.set(bounds);
+ fMaskFormat = format;
+ fAtlasLocation.set(0, 0);
+ }
+
+ void free() {
+ if (fPath) {
+ delete fPath;
+ fPath = NULL;
+ }
+ }
+
+ int width() const { return fBounds.width(); }
+ int height() const { return fBounds.height(); }
+ bool isEmpty() const { return fBounds.isEmpty(); }
+ uint16_t glyphID() const { return UnpackID(fPackedID); }
+
+ ///////////////////////////////////////////////////////////////////////////
+
+ static inline unsigned ExtractSubPixelBitsFromFixed(SkFixed pos) {
+ // two most significant fraction bits from fixed-point
+ return (pos >> 14) & 3;
+ }
+
+ static inline PackedID Pack(uint16_t glyphID, SkFixed x, SkFixed y) {
+ x = ExtractSubPixelBitsFromFixed(x);
+ y = ExtractSubPixelBitsFromFixed(y);
+ return (x << 18) | (y << 16) | glyphID;
+ }
+
+ static inline SkFixed UnpackFixedX(PackedID packed) {
+ return ((packed >> 18) & 3) << 14;
+ }
+
+ static inline SkFixed UnpackFixedY(PackedID packed) {
+ return ((packed >> 16) & 3) << 14;
+ }
+
+ static inline uint16_t UnpackID(PackedID packed) {
+ return (uint16_t)packed;
+ }
+
+ static inline const GrGlyph::PackedID& GetKey(const GrGlyph& glyph) {
+ return glyph.fPackedID;
+ }
+
+ static inline uint32_t Hash(GrGlyph::PackedID key) {
+ return SkChecksum::Murmur3(&key, sizeof(key));
+ }
+};
+
+#endif