Exemple #1
0
 void updateEffectiveRect()
 {
     if (clipRectStack.empty())
     {
         haveEffectiveRect = false;
         return;
     }
     
     ClipRect result = { 0, 0, 0x7fffffff, 0x7fffffff };
     for (int i = 0; i < clipRectStack.size(); ++i)
     {
         const ClipRect& rect = clipRectStack[i];
         int right = std::min<int>(result.x + result.width, rect.x + rect.width);
         int bottom = std::min<int>(result.y + result.height, rect.y + rect.height);
         result.x = std::max<int>(result.x, rect.x);
         result.y = std::max<int>(result.y, rect.y);
         
         if (result.x >= right || result.y >= bottom)
         {
             haveEffectiveRect = false;
             return;
         }
         
         result.width = right - result.x;
         result.height = bottom - result.y;
     }
     
     int fac = clipRectBaseFactor();
     result.x *= fac, result.y *= fac, result.width *= fac, result.height *= fac;
     
     effectiveRect = result;
     haveEffectiveRect = true;
 }
Exemple #2
0
 void updateEffectiveRect()
 {
     // Nothing to do, no clipping in place.
     if (stack.empty())
     {
         hasEffectiveRect = false;
         return;
     }
     
     ClipRect result = { 0.0, 0.0, 1e10, 1e10 };
     for (std::size_t i = 0, end = stack.size(); i < end; ++i)
     {
         const ClipRect& rect = stack[i];
         int resultRight = std::min(result.x + result.width, rect.x + rect.width);
         int resultBottom = std::min(result.y + result.height, rect.y + rect.height);
         result.x = std::max(result.x, rect.x);
         result.y = std::max(result.y, rect.y);
         
         if (result.x >= resultRight || result.y >= resultBottom)
         {
             // We have clipped the world away!
             hasEffectiveRect = false;
             return;
         }
         
         result.width = resultRight - result.x;
         result.height = resultBottom - result.y;
     }
     
     // On the iPhone, we may have to multiply everything by 2 for Retina displays.
     // TODO: Doesn't this affect Retina Macs as well?
     // TODO: This should be handled by a global transform.
     int fac = clipRectBaseFactor();
     result.x *= fac, result.y *= fac, result.width *= fac, result.height *= fac;
     
     // Normal clipping.
     effectiveRect = result;
     hasEffectiveRect = true;
 }