Changeset 664


Ignore:
Timestamp:
May 15, 2011, 5:32:46 PM (9 years ago)
Author:
Sam Hocevar
Message:

starting GetClip? refactoring

Location:
abuse/trunk/src/imlib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/imlib/image.cpp

    r663 r664  
    2525                                   int keep_dirties, int static_memory)
    2626{
    27     m_clipx1 = 0; m_clipy1 = 0;
    28     m_l = size.x; m_h = size.y;
    29     m_clipx2 = m_l; m_clipy2 = m_h;
     27    m_aa = vec2i(0);
     28    m_bb = size;
     29    m_size = size;
     30
    3031    keep_dirt = keep_dirties;
    3132    static_mem = static_memory;
     
    506507        return;
    507508
    508     x1 = Max(0, x1); x2 = Min(m_l, x2);
    509     y1 = Max(0, y1); y2 = Min(m_h, y2);
     509    x1 = Max(0, x1); x2 = Min(m_size.x, x2);
     510    y1 = Max(0, y1); y2 = Min(m_size.y, y2);
    510511
    511512    if (x1 >= x2 || y1 >= y2)
     
    605606        return;
    606607
    607     x1 = Max(0, x1); x2 = Min(m_l, x2);
    608     y1 = Max(0, y1); y2 = Min(m_h, y2);
     608    x1 = Max(0, x1); x2 = Min(m_size.x, x2);
     609    y1 = Max(0, y1); y2 = Min(m_size.y, y2);
    609610
    610611    if (x1 >= x2 || y1 >= y2)
  • abuse/trunk/src/imlib/image.h

    r661 r664  
    3838{
    3939private:
    40     int m_l, m_h;
    41     int m_clipx1, m_clipy1, m_clipx2, m_clipy2;
     40    vec2i m_size, m_aa, m_bb;
    4241
    4342public:
     
    4948
    5049    image_descriptor(vec2i size, int keep_dirties = 1, int static_memory = 0);
    51     int bound_x1(int x1) { return x1 < m_clipx1 ? m_clipx1 : x1; }
    52     int bound_y1(int y1) { return y1 < m_clipy1 ? m_clipy1 : y1; }
    53     int bound_x2(int x2) { return x2 > m_clipx2 ? m_clipx2 : x2; }
    54     int bound_y2(int y2) { return y2 > m_clipy2 ? m_clipy2 : y2; }
    55     inline int x1_clip() { return m_clipx1; }
    56     inline int y1_clip() { return m_clipy1; }
    57     inline int x2_clip() { return m_clipx2; }
    58     inline int y2_clip() { return m_clipy2; }
     50    int bound_x1(int x1) { return Max(x1, m_aa.x); }
     51    int bound_y1(int y1) { return Max(y1, m_aa.y); }
     52    int bound_x2(int x2) { return Min(x2, m_bb.x); }
     53    int bound_y2(int y2) { return Min(y2, m_bb.y); }
     54    inline int x1_clip() { return m_aa.x; }
     55    inline int y1_clip() { return m_aa.y; }
     56    inline int x2_clip() { return m_bb.x; }
     57    inline int y2_clip() { return m_bb.y; }
    5958    void ClearDirties();
    6059    void GetClip(int &x1, int &y1, int &x2, int &y2)
    6160    {
    62         x1 = m_clipx1; y1 = m_clipy1; x2 = m_clipx2; y2 = m_clipy2;
     61        x1 = m_aa.x; y1 = m_aa.y; x2 = m_bb.x; y2 = m_bb.y;
    6362    }
    6463    void SetClip(int x1, int y1, int x2, int y2)
     
    6665        if(x2 < x1 + 1) x2 = x1 + 1;
    6766        if(y2 < y1 + 1) y2 = y1 + 1;
    68         m_clipx1 = Max(x1, 0); m_clipy1 = Max(y1, 0);
    69         m_clipx2 = Min(x2, m_l); m_clipy2 = Min(y2, m_h);
     67        m_aa.x = Max(x1, 0); m_aa.y = Max(y1, 0);
     68        m_bb.x = Min(x2, m_size.x); m_bb.y = Min(y2, m_size.y);
    7069    }
    7170    void ReduceDirties();
     
    7473    void Resize(vec2i size)
    7574    {
    76         m_l = size.x; m_h = size.y;
    77         m_clipx1 = 0; m_clipy1 = 0; m_clipx2 = m_l; m_clipy2 = m_h;
     75        m_size = size;
     76        m_aa = vec2i(0);
     77        m_bb = size;
    7878    }
    7979};
Note: See TracChangeset for help on using the changeset viewer.