| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "core/paint/PaintInfo.h" | 6 #include "platform/graphics/paint/CullRect.h" |
| 7 |
| 8 #include "platform/geometry/FloatRect.h" |
| 9 #include "platform/geometry/LayoutRect.h" |
| 7 | 10 |
| 8 namespace blink { | 11 namespace blink { |
| 9 | 12 |
| 10 void PaintInfo::updatePaintingRootForChildren(const LayoutObject* layoutObject) | |
| 11 { | |
| 12 if (!paintingRoot) | |
| 13 return; | |
| 14 | |
| 15 // If we're the painting root, kids draw normally, and see root of nullptr. | |
| 16 if (paintingRoot == layoutObject) { | |
| 17 paintingRoot = nullptr; | |
| 18 return; | |
| 19 } | |
| 20 } | |
| 21 | |
| 22 bool PaintInfo::shouldPaintWithinRoot(const LayoutObject* layoutObject) const | |
| 23 { | |
| 24 return !paintingRoot || paintingRoot == layoutObject; | |
| 25 } | |
| 26 | |
| 27 CullRect::CullRect(const CullRect& cullRect, const IntPoint& offset) | 13 CullRect::CullRect(const CullRect& cullRect, const IntPoint& offset) |
| 28 { | 14 { |
| 29 m_rect = cullRect.m_rect; | 15 m_rect = cullRect.m_rect; |
| 30 m_rect.moveBy(offset); | 16 m_rect.moveBy(offset); |
| 31 } | 17 } |
| 32 | 18 |
| 19 CullRect::CullRect(const CullRect& cullRect, const IntSize& offset) |
| 20 { |
| 21 m_rect = cullRect.m_rect; |
| 22 m_rect.move(offset); |
| 23 } |
| 24 |
| 33 bool CullRect::intersectsCullRect(const IntRect& boundingBox) const | 25 bool CullRect::intersectsCullRect(const IntRect& boundingBox) const |
| 34 { | 26 { |
| 35 return boundingBox.intersects(m_rect); | 27 return boundingBox.intersects(m_rect); |
| 36 } | 28 } |
| 37 | 29 |
| 38 bool CullRect::intersectsCullRect(const AffineTransform& transform, const FloatR
ect& boundingBox) const | 30 bool CullRect::intersectsCullRect(const AffineTransform& transform, const FloatR
ect& boundingBox) const |
| 39 { | 31 { |
| 40 return transform.mapRect(boundingBox).intersects(m_rect); | 32 return transform.mapRect(boundingBox).intersects(m_rect); |
| 41 } | 33 } |
| 42 | 34 |
| 43 bool CullRect::intersectsCullRect(const LayoutRect& rectArg) const | 35 bool CullRect::intersectsCullRect(const LayoutRect& rectArg) const |
| 44 { | 36 { |
| 45 return m_rect.intersects(enclosingIntRect(rectArg)); | 37 return m_rect.intersects(enclosingIntRect(rectArg)); |
| 46 } | 38 } |
| 47 | 39 |
| 48 bool CullRect::intersectsHorizontalRange(LayoutUnit lo, LayoutUnit hi) const | 40 bool CullRect::intersectsHorizontalRange(LayoutUnit lo, LayoutUnit hi) const |
| 49 { | 41 { |
| 50 return !(lo >= m_rect.maxX() || hi <= m_rect.x()); | 42 return !(lo >= m_rect.maxX() || hi <= m_rect.x()); |
| 51 } | 43 } |
| 52 | 44 |
| 53 bool CullRect::intersectsVerticalRange(LayoutUnit lo, LayoutUnit hi) const | 45 bool CullRect::intersectsVerticalRange(LayoutUnit lo, LayoutUnit hi) const |
| 54 { | 46 { |
| 55 return !(lo >= m_rect.maxY() || hi <= m_rect.y()); | 47 return !(lo >= m_rect.maxY() || hi <= m_rect.y()); |
| 56 } | 48 } |
| 57 | 49 |
| 58 void PaintInfo::updateCullRect(const AffineTransform& localToParentTransform) | |
| 59 { | |
| 60 m_cullRect.updateCullRect(localToParentTransform); | |
| 61 } | |
| 62 | |
| 63 void CullRect::updateCullRect(const AffineTransform& localToParentTransform) | 50 void CullRect::updateCullRect(const AffineTransform& localToParentTransform) |
| 64 { | 51 { |
| 65 if (m_rect != LayoutRect::infiniteIntRect()) | 52 if (m_rect != LayoutRect::infiniteIntRect()) |
| 66 m_rect = localToParentTransform.inverse().mapRect(m_rect); | 53 m_rect = localToParentTransform.inverse().mapRect(m_rect); |
| 67 } | 54 } |
| 68 | 55 |
| 69 } // namespace blink | 56 } // namespace blink |
| OLD | NEW |