180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/*
380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Copyright 2011 Google Inc.
480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru *
580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Use of this source code is governed by a BSD-style license that can be
680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * found in the LICENSE file.
780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */
880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef SkClampRange_DEFINED
1180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#define SkClampRange_DEFINED
1280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkFixed.h"
1480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/**
1680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru *  Iteration fixed fx by dx, clamping as you go to [0..0xFFFF], this class
1780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru *  computes the (up to) 3 spans there are:
1880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru *
1980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru *  range0: use constant value V0
2080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru *  range1: iterate as usual fx += dx
2180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru *  range2: use constant value V1
2280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */
2380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querustruct SkClampRange {
2480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    int fCount0;    // count for fV0
2580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    int fCount1;    // count for interpolating (fV0...fV1)
2680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    int fCount2;    // count for fV1
2780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkFixed fFx1;   // initial fx value for the fCount1 range.
2880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                    // only valid if fCount1 > 0
2980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    int fV0, fV1;
3080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool fOverflowed;   // true if we had to clamp due to numerical overflow
3180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
3280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void init(SkFixed fx, SkFixed dx, int count, int v0, int v1);
3380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
3480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprivate:
3580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void initFor1(SkFixed fx);
3680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru};
3780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
3880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif
39