LCOV - code coverage report
Current view: top level - gfx/skia/skia/src/gpu - GrGlyph.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 35 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 12 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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 "GrDrawOpAtlas.h"
      12             : #include "GrRect.h"
      13             : #include "GrTypes.h"
      14             : 
      15             : #include "SkChecksum.h"
      16             : #include "SkFixed.h"
      17             : #include "SkPath.h"
      18             : 
      19             : class GrPlot;
      20             : 
      21             : /*  Need this to be quad-state:
      22             :     - complete w/ image
      23             :     - just metrics
      24             :     - failed to get image, but has metrics
      25             :     - failed to get metrics
      26             :  */
      27             : struct GrGlyph {
      28             :     enum MaskStyle {
      29             :         kCoverage_MaskStyle,
      30             :         kDistance_MaskStyle
      31             :     };
      32             : 
      33             :     typedef uint32_t PackedID;
      34             : 
      35             :     GrDrawOpAtlas::AtlasID fID;
      36             :     SkPath*               fPath;
      37             :     PackedID              fPackedID;
      38             :     GrMaskFormat          fMaskFormat;
      39             :     GrIRect16             fBounds;
      40             :     SkIPoint16            fAtlasLocation;
      41             :     bool                  fTooLargeForAtlas;
      42             : 
      43           0 :     void init(GrGlyph::PackedID packed, const SkIRect& bounds, GrMaskFormat format) {
      44           0 :         fID = GrDrawOpAtlas::kInvalidAtlasID;
      45           0 :         fPath = nullptr;
      46           0 :         fPackedID = packed;
      47           0 :         fBounds.set(bounds);
      48           0 :         fMaskFormat = format;
      49           0 :         fAtlasLocation.set(0, 0);
      50           0 :         fTooLargeForAtlas = GrDrawOpAtlas::GlyphTooLargeForAtlas(bounds.width(), bounds.height());
      51           0 :     }
      52             : 
      53           0 :     void reset() {
      54           0 :         if (fPath) {
      55           0 :             delete fPath;
      56           0 :             fPath = nullptr;
      57             :         }
      58           0 :     }
      59             : 
      60           0 :     int width() const { return fBounds.width(); }
      61           0 :     int height() const { return fBounds.height(); }
      62             :     bool isEmpty() const { return fBounds.isEmpty(); }
      63             :     uint16_t glyphID() const { return UnpackID(fPackedID); }
      64             : 
      65             :     ///////////////////////////////////////////////////////////////////////////
      66             : 
      67           0 :     static inline unsigned ExtractSubPixelBitsFromFixed(SkFixed pos) {
      68             :         // two most significant fraction bits from fixed-point
      69           0 :         return (pos >> 14) & 3;
      70             :     }
      71             : 
      72           0 :     static inline PackedID Pack(uint16_t glyphID, SkFixed x, SkFixed y, MaskStyle ms) {
      73           0 :         x = ExtractSubPixelBitsFromFixed(x);
      74           0 :         y = ExtractSubPixelBitsFromFixed(y);
      75           0 :         int dfFlag = (ms == kDistance_MaskStyle) ? 0x1 : 0x0;
      76           0 :         return (dfFlag << 20) | (x << 18) | (y << 16) | glyphID;
      77             :     }
      78             : 
      79           0 :     static inline SkFixed UnpackFixedX(PackedID packed) {
      80           0 :         return ((packed >> 18) & 3) << 14;
      81             :     }
      82             : 
      83           0 :     static inline SkFixed UnpackFixedY(PackedID packed) {
      84           0 :         return ((packed >> 16) & 3) << 14;
      85             :     }
      86             : 
      87           0 :     static inline MaskStyle UnpackMaskStyle(PackedID packed) {
      88           0 :         return ((packed >> 20) & 1) ? kDistance_MaskStyle : kCoverage_MaskStyle;
      89             :     }
      90             : 
      91           0 :     static inline uint16_t UnpackID(PackedID packed) {
      92           0 :         return (uint16_t)packed;
      93             :     }
      94             : 
      95           0 :     static inline const GrGlyph::PackedID& GetKey(const GrGlyph& glyph) {
      96           0 :         return glyph.fPackedID;
      97             :     }
      98             : 
      99           0 :     static inline uint32_t Hash(GrGlyph::PackedID key) {
     100           0 :         return SkChecksum::Mix(key);
     101             :     }
     102             : };
     103             : 
     104             : #endif

Generated by: LCOV version 1.13