• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2     Copyright 2011 Google Inc.
3 
4     Licensed under the Apache License, Version 2.0 (the "License");
5     you may not use this file except in compliance with the License.
6     You may obtain a copy of the License at
7 
8     http://www.apache.org/licenses/LICENSE-2.0
9 
10     Unless required by applicable law or agreed to in writing, software
11     distributed under the License is distributed on an "AS IS" BASIS,
12     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13     See the License for the specific language governing permissions and
14     limitations under the License.
15  */
16 
17 #ifndef SkClampRange_DEFINED
18 #define SkClampRange_DEFINED
19 
20 #include "SkFixed.h"
21 
22 /**
23  *  Iteration fixed fx by dx, clamping as you go to [0..0xFFFF], this class
24  *  computes the (up to) 3 spans there are:
25  *
26  *  range0: use constant value V0
27  *  range1: iterate as usual fx += dx
28  *  range2: use constant value V1
29  */
30 struct SkClampRange {
31     int fCount0;    // count for fV0
32     int fCount1;    // count for interpolating (fV0...fV1)
33     int fCount2;    // count for fV1
34     SkFixed fFx1;   // initial fx value for the fCount1 range.
35                     // only valid if fCount1 > 0
36     int fV0, fV1;
37     bool fOverflowed;   // true if we had to clamp due to numerical overflow
38 
39     void init(SkFixed fx, SkFixed dx, int count, int v0, int v1);
40 
41 private:
42     void initFor1(SkFixed fx);
43 };
44 
45 #endif
46 
47