blob: 376dc93b4bda9d88ab2fba961c357ef9f28f0777 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
mike@reedtribe.org676d69b2011-04-15 03:43:23 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * 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.
mike@reedtribe.org676d69b2011-04-15 03:43:23 +00007 */
8
epoger@google.comec3ed6a2011-07-28 14:26:00 +00009
mike@reedtribe.org676d69b2011-04-15 03:43:23 +000010#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 */
23struct SkClampRange {
24 int fCount0; // count for fV0
25 int fCount1; // count for interpolating (fV0...fV1)
26 int fCount2; // count for fV1
reed@google.com63c1ad82011-04-18 14:15:36 +000027 SkFixed fFx1; // initial fx value for the fCount1 range.
28 // only valid if fCount1 > 0
mike@reedtribe.org676d69b2011-04-15 03:43:23 +000029 int fV0, fV1;
reed@google.com63c1ad82011-04-18 14:15:36 +000030 bool fOverflowed; // true if we had to clamp due to numerical overflow
mike@reedtribe.org676d69b2011-04-15 03:43:23 +000031
32 void init(SkFixed fx, SkFixed dx, int count, int v0, int v1);
reed@google.com13659f12011-04-18 19:59:38 +000033
34private:
35 void initFor1(SkFixed fx);
mike@reedtribe.org676d69b2011-04-15 03:43:23 +000036};
37
38#endif