Home | History | Annotate | Download | only in gpu
      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 GrFontScaler_DEFINED
      9 #define GrFontScaler_DEFINED
     10 
     11 #include "GrGlyph.h"
     12 #include "GrKey.h"
     13 
     14 class SkPath;
     15 
     16 /**
     17  *  This is a virtual base class which Gr's interface to the host platform's
     18  *  font scaler.
     19  *
     20  *  The client is responsible for subclassing, and instantiating this. The
     21  *  instance is created for a specific font+size+matrix.
     22  */
     23 class GrFontScaler : public SkRefCnt {
     24 public:
     25     SK_DECLARE_INST_COUNT(GrFontScaler)
     26 
     27     virtual const GrKey* getKey() = 0;
     28     virtual GrMaskFormat getMaskFormat() = 0;
     29     virtual bool getPackedGlyphBounds(GrGlyph::PackedID, SkIRect* bounds) = 0;
     30     virtual bool getPackedGlyphImage(GrGlyph::PackedID, int width, int height,
     31                                      int rowBytes, void* image) = 0;
     32     // get bounds for distance field associated with packed ID
     33     virtual bool getPackedGlyphDFBounds(GrGlyph::PackedID, SkIRect* bounds) = 0;
     34     // copies distance field bytes into pre-allocated dfImage
     35     // (should be width*height bytes in size)
     36     virtual bool getPackedGlyphDFImage(GrGlyph::PackedID, int width, int height,
     37                                        void* dfImage) = 0;
     38     virtual bool getGlyphPath(uint16_t glyphID, SkPath*) = 0;
     39 
     40 private:
     41     typedef SkRefCnt INHERITED;
     42 };
     43 
     44 #endif
     45