gfx/skia/trunk/include/core/SkPaintOptionsAndroid.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 /*
michael@0 3 * Copyright 2012 The Android Open Source Project
michael@0 4 *
michael@0 5 * Use of this source code is governed by a BSD-style license that can be
michael@0 6 * found in the LICENSE file.
michael@0 7 */
michael@0 8
michael@0 9
michael@0 10 #ifndef SkPaintOptionsAndroid_DEFINED
michael@0 11 #define SkPaintOptionsAndroid_DEFINED
michael@0 12
michael@0 13 #include "SkTypes.h"
michael@0 14 #include "SkString.h"
michael@0 15
michael@0 16 class SkReadBuffer;
michael@0 17 class SkWriteBuffer;
michael@0 18
michael@0 19 /** \class SkLanguage
michael@0 20
michael@0 21 The SkLanguage class represents a human written language, and is used by
michael@0 22 text draw operations to determine which glyph to draw when drawing
michael@0 23 characters with variants (ie Han-derived characters).
michael@0 24 */
michael@0 25 class SkLanguage {
michael@0 26 public:
michael@0 27 SkLanguage() { }
michael@0 28 SkLanguage(const SkString& tag) : fTag(tag) { }
michael@0 29 SkLanguage(const char* tag) : fTag(tag) { }
michael@0 30 SkLanguage(const char* tag, size_t len) : fTag(tag, len) { }
michael@0 31 SkLanguage(const SkLanguage& b) : fTag(b.fTag) { }
michael@0 32
michael@0 33 /** Gets a BCP 47 language identifier for this SkLanguage.
michael@0 34 @return a BCP 47 language identifier representing this language
michael@0 35 */
michael@0 36 const SkString& getTag() const { return fTag; }
michael@0 37
michael@0 38 /** Performs BCP 47 fallback to return an SkLanguage one step more general.
michael@0 39 @return an SkLanguage one step more general
michael@0 40 */
michael@0 41 SkLanguage getParent() const;
michael@0 42
michael@0 43 bool operator==(const SkLanguage& b) const {
michael@0 44 return fTag == b.fTag;
michael@0 45 }
michael@0 46 bool operator!=(const SkLanguage& b) const {
michael@0 47 return fTag != b.fTag;
michael@0 48 }
michael@0 49 SkLanguage& operator=(const SkLanguage& b) {
michael@0 50 fTag = b.fTag;
michael@0 51 return *this;
michael@0 52 }
michael@0 53
michael@0 54 private:
michael@0 55 //! BCP 47 language identifier
michael@0 56 SkString fTag;
michael@0 57 };
michael@0 58
michael@0 59 class SkPaintOptionsAndroid {
michael@0 60 public:
michael@0 61 SkPaintOptionsAndroid() {
michael@0 62 fFontVariant = kDefault_Variant;
michael@0 63 fUseFontFallbacks = false;
michael@0 64 }
michael@0 65
michael@0 66 SkPaintOptionsAndroid& operator=(const SkPaintOptionsAndroid& b) {
michael@0 67 fLanguage = b.fLanguage;
michael@0 68 fFontVariant = b.fFontVariant;
michael@0 69 fUseFontFallbacks = b.fUseFontFallbacks;
michael@0 70 return *this;
michael@0 71 }
michael@0 72
michael@0 73 bool operator==(const SkPaintOptionsAndroid& b) const {
michael@0 74 return !(*this != b);
michael@0 75 }
michael@0 76
michael@0 77 bool operator!=(const SkPaintOptionsAndroid& b) const {
michael@0 78 return fLanguage != b.fLanguage ||
michael@0 79 fFontVariant != b.fFontVariant ||
michael@0 80 fUseFontFallbacks != b.fUseFontFallbacks;
michael@0 81 }
michael@0 82
michael@0 83 void flatten(SkWriteBuffer&) const;
michael@0 84 void unflatten(SkReadBuffer&);
michael@0 85
michael@0 86 /** Return the paint's language value used for drawing text.
michael@0 87 @return the paint's language value used for drawing text.
michael@0 88 */
michael@0 89 const SkLanguage& getLanguage() const { return fLanguage; }
michael@0 90
michael@0 91 /** Set the paint's language value used for drawing text.
michael@0 92 @param language set the paint's language value for drawing text.
michael@0 93 */
michael@0 94 void setLanguage(const SkLanguage& language) { fLanguage = language; }
michael@0 95 void setLanguage(const char* languageTag) { fLanguage = SkLanguage(languageTag); }
michael@0 96
michael@0 97
michael@0 98 enum FontVariant {
michael@0 99 kDefault_Variant = 0x01,
michael@0 100 kCompact_Variant = 0x02,
michael@0 101 kElegant_Variant = 0x04,
michael@0 102 kLast_Variant = kElegant_Variant,
michael@0 103 };
michael@0 104
michael@0 105 /** Return the font variant
michael@0 106 @return the font variant used by this paint object
michael@0 107 */
michael@0 108 FontVariant getFontVariant() const { return fFontVariant; }
michael@0 109
michael@0 110 /** Set the font variant
michael@0 111 @param fontVariant set the paint's font variant for choosing fonts
michael@0 112 */
michael@0 113 void setFontVariant(FontVariant fontVariant) {
michael@0 114 SkASSERT((unsigned)fontVariant <= kLast_Variant);
michael@0 115 fFontVariant = fontVariant;
michael@0 116 }
michael@0 117
michael@0 118 bool isUsingFontFallbacks() const { return fUseFontFallbacks; }
michael@0 119
michael@0 120 void setUseFontFallbacks(bool useFontFallbacks) {
michael@0 121 fUseFontFallbacks = useFontFallbacks;
michael@0 122 }
michael@0 123
michael@0 124 private:
michael@0 125 SkLanguage fLanguage;
michael@0 126 FontVariant fFontVariant;
michael@0 127 bool fUseFontFallbacks;
michael@0 128 };
michael@0 129
michael@0 130 #endif // #ifndef SkPaintOptionsAndroid_DEFINED

mercurial