Home | History | Annotate | Download | only in rendering
      1 /*
      2  * Copyright (C) 2003, 2009, 2012 Apple Inc. All rights reserved.
      3  * Copyright (C) 2013 Intel Corporation. All rights reserved.
      4  *
      5  * Portions are Copyright (C) 1998 Netscape Communications Corporation.
      6  *
      7  * Other contributors:
      8  *   Robert O'Callahan <roc+@cs.cmu.edu>
      9  *   David Baron <dbaron (at) fas.harvard.edu>
     10  *   Christian Biesinger <cbiesinger (at) web.de>
     11  *   Randall Jesup <rjesup (at) wgate.com>
     12  *   Roland Mainz <roland.mainz (at) informatik.med.uni-giessen.de>
     13  *   Josh Soref <timeless (at) mac.com>
     14  *   Boris Zbarsky <bzbarsky (at) mit.edu>
     15  *
     16  * This library is free software; you can redistribute it and/or
     17  * modify it under the terms of the GNU Lesser General Public
     18  * License as published by the Free Software Foundation; either
     19  * version 2.1 of the License, or (at your option) any later version.
     20  *
     21  * This library is distributed in the hope that it will be useful,
     22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     24  * Lesser General Public License for more details.
     25  *
     26  * You should have received a copy of the GNU Lesser General Public
     27  * License along with this library; if not, write to the Free Software
     28  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
     29  *
     30  * Alternatively, the contents of this file may be used under the terms
     31  * of either the Mozilla Public License Version 1.1, found at
     32  * http://www.mozilla.org/MPL/ (the "MPL") or the GNU General Public
     33  * License Version 2.0, found at http://www.fsf.org/copyleft/gpl.html
     34  * (the "GPL"), in which case the provisions of the MPL or the GPL are
     35  * applicable instead of those above.  If you wish to allow use of your
     36  * version of this file only under the terms of one of those two
     37  * licenses (the MPL or the GPL) and not to allow others to use your
     38  * version of this file under the LGPL, indicate your decision by
     39  * deletingthe provisions above and replace them with the notice and
     40  * other provisions required by the MPL or the GPL, as the case may be.
     41  * If you do not delete the provisions above, a recipient may use your
     42  * version of this file under any of the LGPL, the MPL or the GPL.
     43  */
     44 
     45 #ifndef RenderLayerRepainter_h
     46 #define RenderLayerRepainter_h
     47 
     48 #include "platform/geometry/LayoutRect.h"
     49 #include "wtf/Noncopyable.h"
     50 
     51 namespace WebCore {
     52 
     53 enum RepaintStatus {
     54     NeedsNormalRepaint = 0,
     55     NeedsFullRepaint = 1 << 0,
     56     NeedsFullRepaintForPositionedMovementLayout = NeedsFullRepaint | 1 << 1
     57 };
     58 
     59 class RenderLayer;
     60 class RenderLayerModelObject;
     61 
     62 class RenderLayerRepainter {
     63     WTF_MAKE_NONCOPYABLE(RenderLayerRepainter);
     64 public:
     65     RenderLayerRepainter(RenderLayerModelObject&);
     66 
     67     // Return a cached repaint rect, computed relative to the layer renderer's containerForPaintInvalidation.
     68     LayoutRect repaintRect() const { return m_repaintRect; }
     69     LayoutRect repaintRectIncludingNonCompositingDescendants() const;
     70 
     71     void repaintAfterLayout(bool shouldCheckForRepaint);
     72     void repaintIncludingNonCompositingDescendants();
     73 
     74     void setRepaintStatus(RepaintStatus status) { m_repaintStatus = status; }
     75 
     76     void computeRepaintRects();
     77     void computeRepaintRectsIncludingNonCompositingDescendants();
     78 
     79     // Indicate that the layer contents need to be repainted. Only has an effect
     80     // if layer compositing is being used,
     81     void setBackingNeedsRepaintInRect(const LayoutRect&); // r is in the coordinate space of the layer's render object
     82 
     83     void setFilterBackendNeedsRepaintingInRect(const LayoutRect&);
     84 
     85 private:
     86     void repaintIncludingNonCompositingDescendantsInternal(const RenderLayerModelObject* repaintContainer);
     87 
     88     bool shouldRepaintLayer() const;
     89 
     90     void clearRepaintRects();
     91 
     92     RenderLayer* enclosingFilterRepaintLayer() const;
     93 
     94     RenderLayerModelObject& m_renderer;
     95 
     96     unsigned m_repaintStatus; // RepaintStatus
     97 
     98     LayoutRect m_repaintRect; // Cached repaint rects. Used by layout.
     99     LayoutPoint m_offset;
    100 };
    101 
    102 } // namespace WebCore
    103 
    104 #endif // RenderLayerRepainter_h
    105