| 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/BoxPainter.h" | 6 #include "core/paint/BoxPainter.h" |
| 7 | 7 |
| 8 #include "core/HTMLNames.h" | 8 #include "core/HTMLNames.h" |
| 9 #include "core/frame/Settings.h" | 9 #include "core/frame/Settings.h" |
| 10 #include "core/html/HTMLFrameOwnerElement.h" | 10 #include "core/html/HTMLFrameOwnerElement.h" |
| (...skipping 1991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2002 | 2002 |
| 2003 // Save the state and clip, if not already done. | 2003 // Save the state and clip, if not already done. |
| 2004 // The clip does not depend on any shadow-specific properties. | 2004 // The clip does not depend on any shadow-specific properties. |
| 2005 if (!stateSaver.saved()) { | 2005 if (!stateSaver.saved()) { |
| 2006 stateSaver.save(); | 2006 stateSaver.save(); |
| 2007 if (hasBorderRadius) { | 2007 if (hasBorderRadius) { |
| 2008 FloatRoundedRect rectToClipOut = border; | 2008 FloatRoundedRect rectToClipOut = border; |
| 2009 | 2009 |
| 2010 // If the box is opaque, it is unnecessary to clip it out. H
owever, doing so saves time | 2010 // If the box is opaque, it is unnecessary to clip it out. H
owever, doing so saves time |
| 2011 // when painting the shadow. On the other hand, it introduce
s subpixel gaps along the | 2011 // when painting the shadow. On the other hand, it introduce
s subpixel gaps along the |
| 2012 // corners. Those are avoided by insetting the clipping path
by one pixel. | 2012 // corners. Those are avoided by insetting the clipping path
by one CSS pixel. |
| 2013 if (hasOpaqueBackground) | 2013 if (hasOpaqueBackground) |
| 2014 rectToClipOut.inflateWithRadii(-1); | 2014 rectToClipOut.inflateWithRadii(-1); |
| 2015 | 2015 |
| 2016 if (!rectToClipOut.isEmpty()) { | 2016 if (!rectToClipOut.isEmpty()) |
| 2017 context->clipOutRoundedRect(rectToClipOut); | 2017 context->clipOutRoundedRect(rectToClipOut); |
| 2018 } | |
| 2019 } else { | 2018 } else { |
| 2020 // This IntRect is correct even with fractional shadows, bec
ause it is used for the rectangle | 2019 // This IntRect is correct even with fractional shadows, bec
ause it is used for the rectangle |
| 2021 // of the box itself, which is always pixel-aligned. | 2020 // of the box itself, which is always pixel-aligned. |
| 2022 FloatRect rectToClipOut = border.rect(); | 2021 FloatRect rectToClipOut = border.rect(); |
| 2023 | 2022 |
| 2024 // If the box is opaque, it is unnecessary to clip it out. H
owever, doing so saves time | 2023 // If the box is opaque, it is unnecessary to clip it out. H
owever, doing so saves time |
| 2025 // when painting the shadow. On the other hand, it introduce
s subpixel gaps along the | 2024 // when painting the shadow. On the other hand, it introduce
s subpixel gaps along the |
| 2026 // edges if they are not pixel-aligned. Those are avoided by
insetting the clipping path | 2025 // edges if they are not pixel-aligned. Those are avoided by
insetting the clipping path |
| 2027 // by one pixel. | 2026 // by one CSS pixel. |
| 2028 // When Slimming Paint is enabled, turn off this heuristic.
See crbug.com/382491 for details. | 2027 if (hasOpaqueBackground) |
| 2029 if (hasOpaqueBackground && !RuntimeEnabledFeatures::slimming
PaintEnabled()) { | 2028 rectToClipOut.inflate(-1); |
| 2030 // FIXME: The function to decide on the policy based on
the transform should be a named function. | |
| 2031 // FIXME: It's not clear if this check is right. What ab
out integral scale factors? | |
| 2032 // FIXME: See crbug.com/382491. The use of getCTM may al
so be wrong because it does not include | |
| 2033 // device zoom applied at raster time. | |
| 2034 AffineTransform transform = context->getCTM(); | |
| 2035 if (transform.a() != 1 || (transform.d() != 1 && transfo
rm.d() != -1) || transform.b() || transform.c()) | |
| 2036 rectToClipOut.inflate(-1); | |
| 2037 } | |
| 2038 | 2029 |
| 2039 if (!rectToClipOut.isEmpty()) { | 2030 if (!rectToClipOut.isEmpty()) |
| 2040 context->clipOut(rectToClipOut); | 2031 context->clipOut(rectToClipOut); |
| 2041 } | |
| 2042 } | 2032 } |
| 2043 } | 2033 } |
| 2044 | 2034 |
| 2045 // Draw only the shadow. | 2035 // Draw only the shadow. |
| 2046 context->setShadow(shadowOffset, shadowBlur, shadowColor, DrawLooper
Builder::ShadowRespectsTransforms, DrawLooperBuilder::ShadowIgnoresAlpha, DrawSh
adowOnly); | 2036 context->setShadow(shadowOffset, shadowBlur, shadowColor, DrawLooper
Builder::ShadowRespectsTransforms, DrawLooperBuilder::ShadowIgnoresAlpha, DrawSh
adowOnly); |
| 2047 | 2037 |
| 2048 if (hasBorderRadius) { | 2038 if (hasBorderRadius) { |
| 2049 FloatRoundedRect influenceRect(pixelSnappedIntRect(LayoutRect(sh
adowRect)), border.radii()); | 2039 FloatRoundedRect influenceRect(pixelSnappedIntRect(LayoutRect(sh
adowRect)), border.radii()); |
| 2050 float changeAmount = 2 * shadowBlur + shadowSpread; | 2040 float changeAmount = 2 * shadowBlur + shadowSpread; |
| 2051 if (changeAmount >= 0) | 2041 if (changeAmount >= 0) |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2273 | 2263 |
| 2274 FloatPoint secondQuad[4]; | 2264 FloatPoint secondQuad[4]; |
| 2275 secondQuad[0] = quad[0]; | 2265 secondQuad[0] = quad[0]; |
| 2276 secondQuad[1] = FloatPoint(quad[0].x() - r1 * cx, quad[0].y() - r1 * cy); | 2266 secondQuad[1] = FloatPoint(quad[0].x() - r1 * cx, quad[0].y() - r1 * cy); |
| 2277 secondQuad[2] = quad[2]; | 2267 secondQuad[2] = quad[2]; |
| 2278 secondQuad[3] = quad[3]; | 2268 secondQuad[3] = quad[3]; |
| 2279 graphicsContext->clipPolygon(4, secondQuad, !secondEdgeMatches); | 2269 graphicsContext->clipPolygon(4, secondQuad, !secondEdgeMatches); |
| 2280 } | 2270 } |
| 2281 | 2271 |
| 2282 } // namespace blink | 2272 } // namespace blink |
| OLD | NEW |