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

Side by Side Diff: include/gpu/GrGlyph.h

Issue 721903002: Cleanup public includes directory. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: &^%%$# Created 6 years, 1 month 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 | « include/gpu/GrFontScaler.h ('k') | include/views/android/AndroidKeyToSkKey.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2010 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
8 #ifndef GrGlyph_DEFINED
9 #define GrGlyph_DEFINED
10
11 #include "GrRect.h"
12 #include "GrTypes.h"
13
14 #include "SkChecksum.h"
15 #include "SkPath.h"
16
17 class GrPlot;
18
19 /* Need this to be quad-state:
20 - complete w/ image
21 - just metrics
22 - failed to get image, but has metrics
23 - failed to get metrics
24 */
25 struct GrGlyph {
26 typedef uint32_t PackedID;
27
28 GrPlot* fPlot;
29 SkPath* fPath;
30 PackedID fPackedID;
31 GrMaskFormat fMaskFormat;
32 GrIRect16 fBounds;
33 SkIPoint16 fAtlasLocation;
34
35 void init(GrGlyph::PackedID packed, const SkIRect& bounds, GrMaskFormat form at) {
36 fPlot = NULL;
37 fPath = NULL;
38 fPackedID = packed;
39 fBounds.set(bounds);
40 fMaskFormat = format;
41 fAtlasLocation.set(0, 0);
42 }
43
44 void free() {
45 if (fPath) {
46 delete fPath;
47 fPath = NULL;
48 }
49 }
50
51 int width() const { return fBounds.width(); }
52 int height() const { return fBounds.height(); }
53 bool isEmpty() const { return fBounds.isEmpty(); }
54 uint16_t glyphID() const { return UnpackID(fPackedID); }
55
56 ///////////////////////////////////////////////////////////////////////////
57
58 static inline unsigned ExtractSubPixelBitsFromFixed(SkFixed pos) {
59 // two most significant fraction bits from fixed-point
60 return (pos >> 14) & 3;
61 }
62
63 static inline PackedID Pack(uint16_t glyphID, SkFixed x, SkFixed y) {
64 x = ExtractSubPixelBitsFromFixed(x);
65 y = ExtractSubPixelBitsFromFixed(y);
66 return (x << 18) | (y << 16) | glyphID;
67 }
68
69 static inline SkFixed UnpackFixedX(PackedID packed) {
70 return ((packed >> 18) & 3) << 14;
71 }
72
73 static inline SkFixed UnpackFixedY(PackedID packed) {
74 return ((packed >> 16) & 3) << 14;
75 }
76
77 static inline uint16_t UnpackID(PackedID packed) {
78 return (uint16_t)packed;
79 }
80
81 static inline const GrGlyph::PackedID& GetKey(const GrGlyph& glyph) {
82 return glyph.fPackedID;
83 }
84
85 static inline uint32_t Hash(GrGlyph::PackedID key) {
86 return SkChecksum::Murmur3(&key, sizeof(key));
87 }
88 };
89
90 #endif
OLDNEW
« no previous file with comments | « include/gpu/GrFontScaler.h ('k') | include/views/android/AndroidKeyToSkKey.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698