Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1457)

Unified Diff: Source/core/paint/RoundedInnerRectClipper.cpp

Issue 865353002: Implement clip and scroll DisplayItems for PartPainter (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix displayItemTypeForClipping unreachable failure Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/paint/RoundedInnerRectClipper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/paint/RoundedInnerRectClipper.cpp
diff --git a/Source/core/paint/RoundedInnerRectClipper.cpp b/Source/core/paint/RoundedInnerRectClipper.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a3825bbcf0dac6d936682cd8bb5076845ed77773
--- /dev/null
+++ b/Source/core/paint/RoundedInnerRectClipper.cpp
@@ -0,0 +1,72 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "core/paint/RoundedInnerRectClipper.h"
+
+#include "core/rendering/PaintInfo.h"
+#include "core/rendering/RenderBox.h"
+#include "platform/graphics/paint/ClipDisplayItem.h"
+#include "platform/graphics/paint/DisplayItemList.h"
+
+namespace blink {
+
+RoundedInnerRectClipper::RoundedInnerRectClipper(RenderObject& renderer, const PaintInfo& paintInfo, const LayoutRect& rect, const FloatRoundedRect& clipRect, RoundedInnerRectClipperBehavior behavior)
+ : m_renderer(renderer)
+ , m_paintInfo(paintInfo)
+ , m_useDisplayItemList(RuntimeEnabledFeatures::slimmingPaintEnabled() && behavior == ApplyToDisplayListIfEnabled)
+{
+ DisplayItem::Type clipType = m_useDisplayItemList ? m_paintInfo.displayItemTypeForClipping() : DisplayItem::ClipBoxForeground;
+ OwnPtr<ClipDisplayItem> clipDisplayItem = ClipDisplayItem::create(renderer.displayItemClient(), clipType, LayoutRect::infiniteIntRect());
+
+ if (clipRect.isRenderable()) {
+ clipDisplayItem->roundedRectClips().append(clipRect);
+ } else {
+ // We create a rounded rect for each of the corners and clip it, while making sure we clip opposing corners together.
+ if (!clipRect.radii().topLeft().isEmpty() || !clipRect.radii().bottomRight().isEmpty()) {
+ FloatRect topCorner(clipRect.rect().x(), clipRect.rect().y(), rect.maxX() - clipRect.rect().x(), rect.maxY() - clipRect.rect().y());
+ FloatRoundedRect::Radii topCornerRadii;
+ topCornerRadii.setTopLeft(clipRect.radii().topLeft());
+ clipDisplayItem->roundedRectClips().append(FloatRoundedRect(topCorner, topCornerRadii));
+
+ FloatRect bottomCorner(rect.x().toFloat(), rect.y().toFloat(), clipRect.rect().maxX() - rect.x().toFloat(), clipRect.rect().maxY() - rect.y().toFloat());
+ FloatRoundedRect::Radii bottomCornerRadii;
+ bottomCornerRadii.setBottomRight(clipRect.radii().bottomRight());
+ clipDisplayItem->roundedRectClips().append(FloatRoundedRect(bottomCorner, bottomCornerRadii));
+ }
+
+ if (!clipRect.radii().topRight().isEmpty() || !clipRect.radii().bottomLeft().isEmpty()) {
+ FloatRect topCorner(rect.x().toFloat(), clipRect.rect().y(), clipRect.rect().maxX() - rect.x().toFloat(), rect.maxY() - clipRect.rect().y());
+ FloatRoundedRect::Radii topCornerRadii;
+ topCornerRadii.setTopRight(clipRect.radii().topRight());
+ clipDisplayItem->roundedRectClips().append(FloatRoundedRect(topCorner, topCornerRadii));
+
+ FloatRect bottomCorner(clipRect.rect().x(), rect.y().toFloat(), rect.maxX() - clipRect.rect().x(), clipRect.rect().maxY() - rect.y().toFloat());
+ FloatRoundedRect::Radii bottomCornerRadii;
+ bottomCornerRadii.setBottomLeft(clipRect.radii().bottomLeft());
+ clipDisplayItem->roundedRectClips().append(FloatRoundedRect(bottomCorner, bottomCornerRadii));
+ }
+ }
+
+ if (m_useDisplayItemList) {
+ ASSERT(m_paintInfo.context->displayItemList());
+ m_paintInfo.context->displayItemList()->add(clipDisplayItem.release());
+ } else {
+ clipDisplayItem->replay(paintInfo.context);
+ }
+}
+
+RoundedInnerRectClipper::~RoundedInnerRectClipper()
+{
+ OwnPtr<EndClipDisplayItem> endClipDisplayItem = EndClipDisplayItem::create(m_renderer.displayItemClient());
+
+ if (m_useDisplayItemList) {
+ ASSERT(m_paintInfo.context->displayItemList());
+ m_paintInfo.context->displayItemList()->add(endClipDisplayItem.release());
+ } else {
+ endClipDisplayItem->replay(m_paintInfo.context);
+ }
+}
+
+} // namespace blink
« no previous file with comments | « Source/core/paint/RoundedInnerRectClipper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698