Home | History | Annotate | Download | only in core
      1 
      2 /*
      3  * Copyright 2011 Google Inc.
      4  *
      5  * Use of this source code is governed by a BSD-style license that can be
      6  * found in the LICENSE file.
      7  */
      8 
      9 
     10 #ifndef SkClampRange_DEFINED
     11 #define SkClampRange_DEFINED
     12 
     13 #include "SkFixed.h"
     14 
     15 /**
     16  *  Iteration fixed fx by dx, clamping as you go to [0..0xFFFF], this class
     17  *  computes the (up to) 3 spans there are:
     18  *
     19  *  range0: use constant value V0
     20  *  range1: iterate as usual fx += dx
     21  *  range2: use constant value V1
     22  */
     23 struct SkClampRange {
     24     int fCount0;    // count for fV0
     25     int fCount1;    // count for interpolating (fV0...fV1)
     26     int fCount2;    // count for fV1
     27     SkFixed fFx1;   // initial fx value for the fCount1 range.
     28                     // only valid if fCount1 > 0
     29     int fV0, fV1;
     30     bool fOverflowed;   // true if we had to clamp due to numerical overflow
     31 
     32     void init(SkFixed fx, SkFixed dx, int count, int v0, int v1);
     33 
     34 private:
     35     void initFor1(SkFixed fx);
     36 };
     37 
     38 #endif
     39 
     40