Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / skia / src / core / SkScalerContext.h
index f18d217..337b2e0 100644 (file)
 #include "SkPaint.h"
 #include "SkTypeface.h"
 
-#ifdef SK_BUILD_FOR_ANDROID
-    #include "SkPaintOptionsAndroid.h"
-#endif
-
 struct SkGlyph;
 class SkDescriptor;
 class SkMaskFilter;
@@ -29,7 +25,6 @@ class SkRasterizer;
  *  than a nested struct inside SkScalerContext (where it started).
  */
 struct SkScalerContextRec {
-    uint32_t    fOrigFontID;
     uint32_t    fFontID;
     SkScalar    fTextSize, fPreScaleX, fPreSkewX;
     SkScalar    fPost2x2[2][2];
@@ -160,9 +155,8 @@ public:
         return SkToBool(fRec.fFlags & kSubpixelPositioning_Flag);
     }
 
-    // remember our glyph offset/base
-    void setBaseGlyphCount(unsigned baseGlyphCount) {
-        fBaseGlyphCount = baseGlyphCount;
+    bool isVertical() const {
+        return SkToBool(fRec.fFlags & kVertical_Flag);
     }
 
     /** Return the corresponding glyph for the specified unichar. Since contexts
@@ -170,12 +164,16 @@ public:
         fact correspond to a different font/context. In that case, we use the
         base-glyph-count to know how to translate back into local glyph space.
      */
-    uint16_t charToGlyphID(SkUnichar uni);
+    uint16_t charToGlyphID(SkUnichar uni) {
+        return generateCharToGlyph(uni);
+    }
 
     /** Map the glyphID to its glyph index, and then to its char code. Unmapped
         glyphs return zero.
     */
-    SkUnichar glyphIDToChar(uint16_t glyphID);
+    SkUnichar glyphIDToChar(uint16_t glyphID) {
+        return (glyphID < getGlyphCount()) ? generateGlyphToChar(glyphID) : 0;
+    }
 
     unsigned    getGlyphCount() { return this->generateGlyphCount(); }
     void        getAdvance(SkGlyph*);
@@ -184,13 +182,16 @@ public:
     void        getPath(const SkGlyph&, SkPath*);
     void        getFontMetrics(SkPaint::FontMetrics*);
 
-#ifdef SK_BUILD_FOR_ANDROID
-    unsigned getBaseGlyphCount(SkUnichar charCode);
+    /** Return the size in bytes of the associated gamma lookup table
+     */
+    static size_t GetGammaLUTSize(SkScalar contrast, SkScalar paintGamma, SkScalar deviceGamma,
+                                  int* width, int* height);
 
-    // This function must be public for SkTypeface_android.h, but should not be
-    // called by other callers
-    SkFontID findTypefaceIdForChar(SkUnichar uni);
-#endif
+    /** Get the associated gamma lookup table. The 'data' pointer must point to pre-allocated
+        memory, with size in bytes greater than or equal to the return value of getGammaLUTSize().
+     */
+    static void   GetGammaLUTData(SkScalar contrast, SkScalar paintGamma, SkScalar deviceGamma,
+                                  void* data);
 
     static void MakeRec(const SkPaint&, const SkDeviceProperties* deviceProperties,
                         const SkMatrix*, Rec* rec);
@@ -200,7 +201,6 @@ public:
 
 protected:
     Rec         fRec;
-    unsigned    fBaseGlyphCount;
 
     /** Generates the contents of glyph.fAdvanceX and glyph.fAdvanceY.
      *  May call getMetrics if that would be just as fast.
@@ -234,11 +234,8 @@ protected:
      */
     virtual void generatePath(const SkGlyph& glyph, SkPath* path) = 0;
 
-    /** Retrieves font metrics.
-     *  TODO: there is now a vertical bit, no need for two parameters.
-     */
-    virtual void generateFontMetrics(SkPaint::FontMetrics* mX,
-                                     SkPaint::FontMetrics* mY) = 0;
+    /** Retrieves font metrics. */
+    virtual void generateFontMetrics(SkPaint::FontMetrics*) = 0;
 
     /** Returns the number of glyphs in the font. */
     virtual unsigned generateGlyphCount() = 0;
@@ -260,10 +257,6 @@ private:
     // never null
     SkAutoTUnref<SkTypeface> fTypeface;
 
-#ifdef SK_BUILD_FOR_ANDROID
-    SkPaintOptionsAndroid fPaintOptionsAndroid;
-#endif
-
     // optional object, which may be null
     SkPathEffect*   fPathEffect;
     SkMaskFilter*   fMaskFilter;
@@ -276,25 +269,11 @@ private:
     void internalGetPath(const SkGlyph& glyph, SkPath* fillPath,
                          SkPath* devPath, SkMatrix* fillToDevMatrix);
 
-    // Return the context associated with the next logical typeface, or NULL if
-    // there are no more entries in the fallback chain.
-    SkScalerContext* allocNextContext() const;
-
-    // return the next context, treating fNextContext as a cache of the answer
-    SkScalerContext* getNextContext();
-
-    // returns the right context from our link-list for this glyph. If no match
-    // is found, just returns the original context (this)
-    SkScalerContext* getGlyphContext(const SkGlyph& glyph);
-
     // returns the right context from our link-list for this char. If no match
     // is found it returns NULL. If a match is found then the glyphID param is
     // set to the glyphID that maps to the provided char.
     SkScalerContext* getContextFromChar(SkUnichar uni, uint16_t* glyphID);
 
-    // link-list of context, to handle missing chars. null-terminated.
-    SkScalerContext* fNextContext;
-
     // SkMaskGamma::PreBlend converts linear masks to gamma correcting masks.
 protected:
     // Visible to subclasses so that generateImage can apply the pre-blend directly.
@@ -309,9 +288,6 @@ private:
 #define kPathEffect_SkDescriptorTag     SkSetFourByteTag('p', 't', 'h', 'e')
 #define kMaskFilter_SkDescriptorTag     SkSetFourByteTag('m', 's', 'k', 'f')
 #define kRasterizer_SkDescriptorTag     SkSetFourByteTag('r', 'a', 's', 't')
-#ifdef SK_BUILD_FOR_ANDROID
-#define kAndroidOpts_SkDescriptorTag    SkSetFourByteTag('a', 'n', 'd', 'r')
-#endif
 
 ///////////////////////////////////////////////////////////////////////////////