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

          Line data    Source code
       1             : /*
       2             :  * Copyright 2014 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 SkTextMapStateProc_DEFINED
       9             : #define SkTextMapStateProc_DEFINED
      10             : 
      11             : #include "SkPoint.h"
      12             : #include "SkMatrix.h"
      13             : 
      14             : class SkTextMapStateProc {
      15             : public:
      16           0 :     SkTextMapStateProc(const SkMatrix& matrix, const SkPoint& offset, int scalarsPerPosition)
      17           0 :         : fMatrix(matrix)
      18           0 :         , fProc(matrix.getMapXYProc())
      19             :         , fOffset(offset)
      20           0 :         , fScaleX(fMatrix.getScaleX()) {
      21           0 :         SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition);
      22           0 :         if (1 == scalarsPerPosition) {
      23           0 :             unsigned mtype = fMatrix.getType();
      24           0 :             if (mtype & (SkMatrix::kAffine_Mask | SkMatrix::kPerspective_Mask)) {
      25           0 :                 fMapCase = kX;
      26             :             } else {
      27             :                 // Bake the matrix scale/translation components into fOffset,
      28             :                 // to expedite proc computations.
      29           0 :                 fOffset.set(offset.x() * fMatrix.getScaleX() + fMatrix.getTranslateX(),
      30           0 :                             offset.y() * fMatrix.getScaleY() + fMatrix.getTranslateY());
      31             : 
      32           0 :                 if (mtype & SkMatrix::kScale_Mask) {
      33           0 :                     fMapCase = kOnlyScaleX;
      34             :                 } else {
      35           0 :                     fMapCase = kOnlyTransX;
      36             :                 }
      37             :             }
      38             :         } else {
      39           0 :             fMapCase = kXY;
      40             :         }
      41           0 :     }
      42             : 
      43             :     void operator()(const SkScalar pos[], SkPoint* loc) const;
      44             : 
      45             : private:
      46             :     const SkMatrix& fMatrix;
      47             :     enum {
      48             :         kXY,
      49             :         kOnlyScaleX,
      50             :         kOnlyTransX,
      51             :         kX
      52             :     } fMapCase;
      53             :     const SkMatrix::MapXYProc fProc;
      54             :     SkPoint  fOffset; // In kOnly* mode, this includes the matrix translation component.
      55             :     SkScalar fScaleX; // This is only used by kOnly... cases.
      56             : };
      57             : 
      58           0 : inline void SkTextMapStateProc::operator()(const SkScalar pos[], SkPoint* loc) const {
      59           0 :     switch(fMapCase) {
      60             :     case kXY:
      61           0 :         fProc(fMatrix, pos[0] + fOffset.x(), pos[1] + fOffset.y(), loc);
      62           0 :         break;
      63             :     case kOnlyScaleX:
      64           0 :         loc->set(fScaleX * *pos + fOffset.x(), fOffset.y());
      65           0 :         break;
      66             :     case kOnlyTransX:
      67           0 :         loc->set(*pos + fOffset.x(), fOffset.y());
      68           0 :         break;
      69             :     default:
      70           0 :         SkASSERT(false);
      71             :     case kX:
      72           0 :         fProc(fMatrix, *pos + fOffset.x(), fOffset.y(), loc);
      73           0 :         break;
      74             :     }
      75           0 : }
      76             : 
      77             : #endif

Generated by: LCOV version 1.13