gfx/skia/trunk/include/gpu/GrGlyph.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /*
michael@0 2 * Copyright 2010 Google Inc.
michael@0 3 *
michael@0 4 * Use of this source code is governed by a BSD-style license that can be
michael@0 5 * found in the LICENSE file.
michael@0 6 */
michael@0 7
michael@0 8 #ifndef GrGlyph_DEFINED
michael@0 9 #define GrGlyph_DEFINED
michael@0 10
michael@0 11 #include "GrRect.h"
michael@0 12 #include "SkPath.h"
michael@0 13
michael@0 14 class GrPlot;
michael@0 15
michael@0 16 /* Need this to be quad-state:
michael@0 17 - complete w/ image
michael@0 18 - just metrics
michael@0 19 - failed to get image, but has metrics
michael@0 20 - failed to get metrics
michael@0 21 */
michael@0 22 struct GrGlyph {
michael@0 23 typedef uint32_t PackedID;
michael@0 24
michael@0 25 GrPlot* fPlot;
michael@0 26 SkPath* fPath;
michael@0 27 PackedID fPackedID;
michael@0 28 GrIRect16 fBounds;
michael@0 29 GrIPoint16 fAtlasLocation;
michael@0 30
michael@0 31 void init(GrGlyph::PackedID packed, const SkIRect& bounds) {
michael@0 32 fPlot = NULL;
michael@0 33 fPath = NULL;
michael@0 34 fPackedID = packed;
michael@0 35 fBounds.set(bounds);
michael@0 36 fAtlasLocation.set(0, 0);
michael@0 37 }
michael@0 38
michael@0 39 void free() {
michael@0 40 if (fPath) {
michael@0 41 delete fPath;
michael@0 42 fPath = NULL;
michael@0 43 }
michael@0 44 }
michael@0 45
michael@0 46 int width() const { return fBounds.width(); }
michael@0 47 int height() const { return fBounds.height(); }
michael@0 48 bool isEmpty() const { return fBounds.isEmpty(); }
michael@0 49 uint16_t glyphID() const { return UnpackID(fPackedID); }
michael@0 50
michael@0 51 ///////////////////////////////////////////////////////////////////////////
michael@0 52
michael@0 53 static inline unsigned ExtractSubPixelBitsFromFixed(GrFixed pos) {
michael@0 54 // two most significant fraction bits from fixed-point
michael@0 55 return (pos >> 14) & 3;
michael@0 56 }
michael@0 57
michael@0 58 static inline PackedID Pack(uint16_t glyphID, GrFixed x, GrFixed y) {
michael@0 59 x = ExtractSubPixelBitsFromFixed(x);
michael@0 60 y = ExtractSubPixelBitsFromFixed(y);
michael@0 61 return (x << 18) | (y << 16) | glyphID;
michael@0 62 }
michael@0 63
michael@0 64 static inline GrFixed UnpackFixedX(PackedID packed) {
michael@0 65 return ((packed >> 18) & 3) << 14;
michael@0 66 }
michael@0 67
michael@0 68 static inline GrFixed UnpackFixedY(PackedID packed) {
michael@0 69 return ((packed >> 16) & 3) << 14;
michael@0 70 }
michael@0 71
michael@0 72 static inline uint16_t UnpackID(PackedID packed) {
michael@0 73 return (uint16_t)packed;
michael@0 74 }
michael@0 75 };
michael@0 76
michael@0 77
michael@0 78 #endif

mercurial