javauis/lcdui_akn/lcdgd/src/lcdgdrvutil.cpp
branchRCL_3
changeset 14 04becd199f91
equal deleted inserted replaced
13:f5050f1da672 14:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <e32std.h>
       
    20 #include "lcdgdrvutil.h"
       
    21 
       
    22 /**
       
    23  * Calculate rational increment stepping in positive y direction.
       
    24  *
       
    25  *@param aDx difference in x coordinates of edge end points
       
    26  *@param aDy difference in y coordinates of edge end points, always positive (y sorted vertices)
       
    27  *@return aIx integer increment
       
    28  *@return aIf positive fractional increment with denominator aDy
       
    29  *
       
    30  */
       
    31 void Increment(TInt& aIx, TInt& aIf, TInt aDx, TInt aDy)
       
    32 {
       
    33     ASSERT(aDy > 0);
       
    34 
       
    35     TInt ip = aDx / aDy;
       
    36     TInt fp = aDx % aDy;
       
    37 
       
    38     if (fp < 0)
       
    39     {
       
    40         aIx = ip - 1;
       
    41         aIf = fp + aDy;
       
    42     }
       
    43     else
       
    44     {
       
    45         aIx = ip;
       
    46         aIf = fp;
       
    47     }
       
    48 }
       
    49 
       
    50 void Increment(TInt64& aIx, TInt64& aIf, TInt64 aDx, TInt64 aDy)
       
    51 {
       
    52     ASSERT(aDy > 0);
       
    53 
       
    54     TInt64 ip = aDx / aDy;
       
    55     TInt64 fp = aDx % aDy;
       
    56 
       
    57     if (fp < 0)
       
    58     {
       
    59         aIx = ip - 1;
       
    60         aIf = fp + aDy;
       
    61     }
       
    62     else
       
    63     {
       
    64         aIx = ip;
       
    65         aIf = fp;
       
    66     }
       
    67 }
       
    68