| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "core/paint/BoxBorderPainter.h" | 5 #include "core/paint/BoxBorderPainter.h" |
| 6 | 6 |
| 7 #include "core/paint/BoxPainter.h" | 7 #include "core/paint/BoxPainter.h" |
| 8 #include "core/paint/ObjectPainter.h" | 8 #include "core/paint/ObjectPainter.h" |
| 9 #include "core/paint/PaintInfo.h" | 9 #include "core/paint/PaintInfo.h" |
| 10 #include "core/style/BorderEdge.h" | 10 #include "core/style/BorderEdge.h" |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 struct BoxBorderPainter::ComplexBorderInfo { | 402 struct BoxBorderPainter::ComplexBorderInfo { |
| 403 ComplexBorderInfo(const BoxBorderPainter& borderPainter, bool antiAlias) | 403 ComplexBorderInfo(const BoxBorderPainter& borderPainter, bool antiAlias) |
| 404 : antiAlias(antiAlias) { | 404 : antiAlias(antiAlias) { |
| 405 Vector<BoxSide, 4> sortedSides; | 405 Vector<BoxSide, 4> sortedSides; |
| 406 | 406 |
| 407 // First, collect all visible sides. | 407 // First, collect all visible sides. |
| 408 for (unsigned i = borderPainter.m_firstVisibleEdge; i < 4; ++i) { | 408 for (unsigned i = borderPainter.m_firstVisibleEdge; i < 4; ++i) { |
| 409 BoxSide side = static_cast<BoxSide>(i); | 409 BoxSide side = static_cast<BoxSide>(i); |
| 410 | 410 |
| 411 if (includesEdge(borderPainter.m_visibleEdgeSet, side)) | 411 if (includesEdge(borderPainter.m_visibleEdgeSet, side)) |
| 412 sortedSides.append(side); | 412 sortedSides.push_back(side); |
| 413 } | 413 } |
| 414 DCHECK(!sortedSides.isEmpty()); | 414 DCHECK(!sortedSides.isEmpty()); |
| 415 | 415 |
| 416 // Then sort them in paint order, based on three (prioritized) criteria: | 416 // Then sort them in paint order, based on three (prioritized) criteria: |
| 417 // alpha, style, side. | 417 // alpha, style, side. |
| 418 std::sort( | 418 std::sort( |
| 419 sortedSides.begin(), sortedSides.end(), | 419 sortedSides.begin(), sortedSides.end(), |
| 420 [&borderPainter](BoxSide a, BoxSide b) -> bool { | 420 [&borderPainter](BoxSide a, BoxSide b) -> bool { |
| 421 const BorderEdge& edgeA = borderPainter.m_edges[a]; | 421 const BorderEdge& edgeA = borderPainter.m_edges[a]; |
| 422 const BorderEdge& edgeB = borderPainter.m_edges[b]; | 422 const BorderEdge& edgeB = borderPainter.m_edges[b]; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 452 void buildOpacityGroups(const BoxBorderPainter& borderPainter, | 452 void buildOpacityGroups(const BoxBorderPainter& borderPainter, |
| 453 const Vector<BoxSide, 4>& sortedSides) { | 453 const Vector<BoxSide, 4>& sortedSides) { |
| 454 unsigned currentAlpha = 0; | 454 unsigned currentAlpha = 0; |
| 455 for (BoxSide side : sortedSides) { | 455 for (BoxSide side : sortedSides) { |
| 456 const BorderEdge& edge = borderPainter.m_edges[side]; | 456 const BorderEdge& edge = borderPainter.m_edges[side]; |
| 457 const unsigned edgeAlpha = edge.color.alpha(); | 457 const unsigned edgeAlpha = edge.color.alpha(); |
| 458 | 458 |
| 459 DCHECK_GT(edgeAlpha, 0u); | 459 DCHECK_GT(edgeAlpha, 0u); |
| 460 DCHECK_GE(edgeAlpha, currentAlpha); | 460 DCHECK_GE(edgeAlpha, currentAlpha); |
| 461 if (edgeAlpha != currentAlpha) { | 461 if (edgeAlpha != currentAlpha) { |
| 462 opacityGroups.append(OpacityGroup(edgeAlpha)); | 462 opacityGroups.push_back(OpacityGroup(edgeAlpha)); |
| 463 currentAlpha = edgeAlpha; | 463 currentAlpha = edgeAlpha; |
| 464 } | 464 } |
| 465 | 465 |
| 466 DCHECK(!opacityGroups.isEmpty()); | 466 DCHECK(!opacityGroups.isEmpty()); |
| 467 OpacityGroup& currentGroup = opacityGroups.back(); | 467 OpacityGroup& currentGroup = opacityGroups.back(); |
| 468 currentGroup.sides.append(side); | 468 currentGroup.sides.push_back(side); |
| 469 currentGroup.edgeFlags |= edgeFlagForSide(side); | 469 currentGroup.edgeFlags |= edgeFlagForSide(side); |
| 470 } | 470 } |
| 471 | 471 |
| 472 DCHECK(!opacityGroups.isEmpty()); | 472 DCHECK(!opacityGroups.isEmpty()); |
| 473 } | 473 } |
| 474 }; | 474 }; |
| 475 | 475 |
| 476 void BoxBorderPainter::drawDoubleBorder(GraphicsContext& context, | 476 void BoxBorderPainter::drawDoubleBorder(GraphicsContext& context, |
| 477 const LayoutRect& borderRect) const { | 477 const LayoutRect& borderRect) const { |
| 478 DCHECK(m_isUniformColor); | 478 DCHECK(m_isUniformColor); |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 998 // FIXME: should do this test per side. | 998 // FIXME: should do this test per side. |
| 999 if (numberOfDashes >= 4) { | 999 if (numberOfDashes >= 4) { |
| 1000 bool evenNumberOfFullDashes = !((int)numberOfDashes % 2); | 1000 bool evenNumberOfFullDashes = !((int)numberOfDashes % 2); |
| 1001 bool integralNumberOfDashes = !(numberOfDashes - (int)numberOfDashes); | 1001 bool integralNumberOfDashes = !(numberOfDashes - (int)numberOfDashes); |
| 1002 if (!evenNumberOfFullDashes && !integralNumberOfDashes) { | 1002 if (!evenNumberOfFullDashes && !integralNumberOfDashes) { |
| 1003 float numberOfGaps = numberOfDashes / 2; | 1003 float numberOfGaps = numberOfDashes / 2; |
| 1004 gapLength += (dashLength / numberOfGaps); | 1004 gapLength += (dashLength / numberOfGaps); |
| 1005 } | 1005 } |
| 1006 | 1006 |
| 1007 DashArray lineDash; | 1007 DashArray lineDash; |
| 1008 lineDash.append(dashLength); | 1008 lineDash.push_back(dashLength); |
| 1009 lineDash.append(gapLength); | 1009 lineDash.push_back(gapLength); |
| 1010 graphicsContext.setLineDash(lineDash, dashLength); | 1010 graphicsContext.setLineDash(lineDash, dashLength); |
| 1011 } | 1011 } |
| 1012 | 1012 |
| 1013 // FIXME: stroking the border path causes issues with tight corners: | 1013 // FIXME: stroking the border path causes issues with tight corners: |
| 1014 // https://bugs.webkit.org/show_bug.cgi?id=58711 | 1014 // https://bugs.webkit.org/show_bug.cgi?id=58711 |
| 1015 // Also, to get the best appearance we should stroke a path between the | 1015 // Also, to get the best appearance we should stroke a path between the |
| 1016 // two borders. | 1016 // two borders. |
| 1017 graphicsContext.strokePath(borderPath); | 1017 graphicsContext.strokePath(borderPath); |
| 1018 return; | 1018 return; |
| 1019 } | 1019 } |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1292 FloatPoint secondQuad[4]; | 1292 FloatPoint secondQuad[4]; |
| 1293 secondQuad[0] = quad[0]; | 1293 secondQuad[0] = quad[0]; |
| 1294 secondQuad[1] = FloatPoint(quad[0].x() - r1 * cx, quad[0].y() - r1 * cy); | 1294 secondQuad[1] = FloatPoint(quad[0].x() - r1 * cx, quad[0].y() - r1 * cy); |
| 1295 secondQuad[2] = quad[2]; | 1295 secondQuad[2] = quad[2]; |
| 1296 secondQuad[3] = quad[3]; | 1296 secondQuad[3] = quad[3]; |
| 1297 clipQuad(graphicsContext, secondQuad, secondMiter == SoftMiter); | 1297 clipQuad(graphicsContext, secondQuad, secondMiter == SoftMiter); |
| 1298 } | 1298 } |
| 1299 } | 1299 } |
| 1300 | 1300 |
| 1301 } // namespace blink | 1301 } // namespace blink |
| OLD | NEW |