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

Side by Side Diff: Source/core/paint/InlinePainter.cpp

Issue 1195933002: SP: Always anti-alias borders in slimming paint mode. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/paint/BoxPainter.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/InlinePainter.h" 6 #include "core/paint/InlinePainter.h"
7 7
8 #include "core/layout/LayoutBlock.h" 8 #include "core/layout/LayoutBlock.h"
9 #include "core/layout/LayoutInline.h" 9 #include "core/layout/LayoutInline.h"
10 #include "core/layout/LayoutTheme.h" 10 #include "core/layout/LayoutTheme.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 graphicsContext->endLayer(); 99 graphicsContext->endLayer();
100 } 100 }
101 101
102 void InlinePainter::paintOutlineForLine(GraphicsContext* graphicsContext, const LayoutPoint& paintOffset, 102 void InlinePainter::paintOutlineForLine(GraphicsContext* graphicsContext, const LayoutPoint& paintOffset,
103 const LayoutRect& lastline, const LayoutRect& thisline, const LayoutRect& ne xtline, const Color outlineColor) 103 const LayoutRect& lastline, const LayoutRect& thisline, const LayoutRect& ne xtline, const Color outlineColor)
104 { 104 {
105 const ComputedStyle& styleToUse = m_layoutInline.styleRef(); 105 const ComputedStyle& styleToUse = m_layoutInline.styleRef();
106 int outlineWidth = styleToUse.outlineWidth(); 106 int outlineWidth = styleToUse.outlineWidth();
107 EBorderStyle outlineStyle = styleToUse.outlineStyle(); 107 EBorderStyle outlineStyle = styleToUse.outlineStyle();
108 108
109 bool antialias = BoxPainter::shouldAntialiasLines(graphicsContext);
110
111 int offset = m_layoutInline.style()->outlineOffset(); 109 int offset = m_layoutInline.style()->outlineOffset();
112 110
113 LayoutRect box(LayoutPoint(paintOffset.x() + thisline.x() - offset, paintOff set.y() + thisline.y() - offset), 111 LayoutRect box(LayoutPoint(paintOffset.x() + thisline.x() - offset, paintOff set.y() + thisline.y() - offset),
114 LayoutSize(thisline.width() + offset, thisline.height() + offset)); 112 LayoutSize(thisline.width() + offset, thisline.height() + offset));
115 113
116 IntRect pixelSnappedBox = pixelSnappedIntRect(box); 114 IntRect pixelSnappedBox = pixelSnappedIntRect(box);
117 if (pixelSnappedBox.width() < 0 || pixelSnappedBox.height() < 0) 115 if (pixelSnappedBox.width() < 0 || pixelSnappedBox.height() < 0)
118 return; 116 return;
119 // Note that we use IntRect below for working with solely x/width values, si mplifying logic at cost of a bit of memory. 117 // Note that we use IntRect below for working with solely x/width values, si mplifying logic at cost of a bit of memory.
120 IntRect pixelSnappedLastLine = pixelSnappedIntRect(paintOffset.x() + lastlin e.x() - offset, 0, lastline.width() + offset, 0); 118 IntRect pixelSnappedLastLine = pixelSnappedIntRect(paintOffset.x() + lastlin e.x() - offset, 0, lastline.width() + offset, 0);
121 IntRect pixelSnappedNextLine = pixelSnappedIntRect(paintOffset.x() + nextlin e.x() - offset, 0, nextline.width() + offset, 0); 119 IntRect pixelSnappedNextLine = pixelSnappedIntRect(paintOffset.x() + nextlin e.x() - offset, 0, nextline.width() + offset, 0);
122 120
123 const int fallbackMaxOutlineX = std::numeric_limits<int>::max(); 121 const int fallbackMaxOutlineX = std::numeric_limits<int>::max();
124 const int fallbackMinOutlineX = std::numeric_limits<int>::min(); 122 const int fallbackMinOutlineX = std::numeric_limits<int>::min();
125 123
126 // left edge 124 // left edge
127 ObjectPainter::drawLineForBoxSide(graphicsContext, 125 ObjectPainter::drawLineForBoxSide(graphicsContext,
128 pixelSnappedBox.x() - outlineWidth, 126 pixelSnappedBox.x() - outlineWidth,
129 pixelSnappedBox.y() - (lastline.isEmpty() || thisline.x() < lastline.x() || (lastline.maxX() - 1) <= thisline.x() ? outlineWidth : 0), 127 pixelSnappedBox.y() - (lastline.isEmpty() || thisline.x() < lastline.x() || (lastline.maxX() - 1) <= thisline.x() ? outlineWidth : 0),
130 pixelSnappedBox.x(), 128 pixelSnappedBox.x(),
131 pixelSnappedBox.maxY() + (nextline.isEmpty() || thisline.x() <= nextline .x() || (nextline.maxX() - 1) <= thisline.x() ? outlineWidth : 0), 129 pixelSnappedBox.maxY() + (nextline.isEmpty() || thisline.x() <= nextline .x() || (nextline.maxX() - 1) <= thisline.x() ? outlineWidth : 0),
132 BSLeft, 130 BSLeft,
133 outlineColor, outlineStyle, 131 outlineColor, outlineStyle,
134 (lastline.isEmpty() || thisline.x() < lastline.x() || (lastline.maxX() - 1) <= thisline.x() ? outlineWidth : -outlineWidth), 132 (lastline.isEmpty() || thisline.x() < lastline.x() || (lastline.maxX() - 1) <= thisline.x() ? outlineWidth : -outlineWidth),
135 (nextline.isEmpty() || thisline.x() <= nextline.x() || (nextline.maxX() - 1) <= thisline.x() ? outlineWidth : -outlineWidth), 133 (nextline.isEmpty() || thisline.x() <= nextline.x() || (nextline.maxX() - 1) <= thisline.x() ? outlineWidth : -outlineWidth),
136 antialias); 134 false);
137 135
138 // right edge 136 // right edge
139 ObjectPainter::drawLineForBoxSide(graphicsContext, 137 ObjectPainter::drawLineForBoxSide(graphicsContext,
140 pixelSnappedBox.maxX(), 138 pixelSnappedBox.maxX(),
141 pixelSnappedBox.y() - (lastline.isEmpty() || lastline.maxX() < thisline. maxX() || (thisline.maxX() - 1) <= lastline.x() ? outlineWidth : 0), 139 pixelSnappedBox.y() - (lastline.isEmpty() || lastline.maxX() < thisline. maxX() || (thisline.maxX() - 1) <= lastline.x() ? outlineWidth : 0),
142 pixelSnappedBox.maxX() + outlineWidth, 140 pixelSnappedBox.maxX() + outlineWidth,
143 pixelSnappedBox.maxY() + (nextline.isEmpty() || nextline.maxX() <= thisl ine.maxX() || (thisline.maxX() - 1) <= nextline.x() ? outlineWidth : 0), 141 pixelSnappedBox.maxY() + (nextline.isEmpty() || nextline.maxX() <= thisl ine.maxX() || (thisline.maxX() - 1) <= nextline.x() ? outlineWidth : 0),
144 BSRight, 142 BSRight,
145 outlineColor, outlineStyle, 143 outlineColor, outlineStyle,
146 (lastline.isEmpty() || lastline.maxX() < thisline.maxX() || (thisline.ma xX() - 1) <= lastline.x() ? outlineWidth : -outlineWidth), 144 (lastline.isEmpty() || lastline.maxX() < thisline.maxX() || (thisline.ma xX() - 1) <= lastline.x() ? outlineWidth : -outlineWidth),
147 (nextline.isEmpty() || nextline.maxX() <= thisline.maxX() || (thisline.m axX() - 1) <= nextline.x() ? outlineWidth : -outlineWidth), 145 (nextline.isEmpty() || nextline.maxX() <= thisline.maxX() || (thisline.m axX() - 1) <= nextline.x() ? outlineWidth : -outlineWidth),
148 antialias); 146 false);
149 // upper edge 147 // upper edge
150 if (thisline.x() < lastline.x()) { 148 if (thisline.x() < lastline.x()) {
151 ObjectPainter::drawLineForBoxSide(graphicsContext, 149 ObjectPainter::drawLineForBoxSide(graphicsContext,
152 pixelSnappedBox.x() - outlineWidth, 150 pixelSnappedBox.x() - outlineWidth,
153 pixelSnappedBox.y() - outlineWidth, 151 pixelSnappedBox.y() - outlineWidth,
154 std::min(pixelSnappedBox.maxX() + outlineWidth, (lastline.isEmpty() ? fallbackMaxOutlineX : pixelSnappedLastLine.x())), 152 std::min(pixelSnappedBox.maxX() + outlineWidth, (lastline.isEmpty() ? fallbackMaxOutlineX : pixelSnappedLastLine.x())),
155 pixelSnappedBox.y(), 153 pixelSnappedBox.y(),
156 BSTop, outlineColor, outlineStyle, 154 BSTop, outlineColor, outlineStyle,
157 outlineWidth, 155 outlineWidth,
158 (!lastline.isEmpty() && paintOffset.x() + lastline.x() + 1 < pixelSn appedBox.maxX() + outlineWidth) ? -outlineWidth : outlineWidth, 156 (!lastline.isEmpty() && paintOffset.x() + lastline.x() + 1 < pixelSn appedBox.maxX() + outlineWidth) ? -outlineWidth : outlineWidth,
159 antialias); 157 false);
160 } 158 }
161 159
162 if (lastline.maxX() < thisline.maxX()) { 160 if (lastline.maxX() < thisline.maxX()) {
163 ObjectPainter::drawLineForBoxSide(graphicsContext, 161 ObjectPainter::drawLineForBoxSide(graphicsContext,
164 std::max(lastline.isEmpty() ? fallbackMinOutlineX : pixelSnappedLast Line.maxX(), pixelSnappedBox.x() - outlineWidth), 162 std::max(lastline.isEmpty() ? fallbackMinOutlineX : pixelSnappedLast Line.maxX(), pixelSnappedBox.x() - outlineWidth),
165 pixelSnappedBox.y() - outlineWidth, 163 pixelSnappedBox.y() - outlineWidth,
166 pixelSnappedBox.maxX() + outlineWidth, 164 pixelSnappedBox.maxX() + outlineWidth,
167 pixelSnappedBox.y(), 165 pixelSnappedBox.y(),
168 BSTop, outlineColor, outlineStyle, 166 BSTop, outlineColor, outlineStyle,
169 (!lastline.isEmpty() && pixelSnappedBox.x() - outlineWidth < paintOf fset.x() + lastline.maxX()) ? -outlineWidth : outlineWidth, 167 (!lastline.isEmpty() && pixelSnappedBox.x() - outlineWidth < paintOf fset.x() + lastline.maxX()) ? -outlineWidth : outlineWidth,
170 outlineWidth, antialias); 168 outlineWidth, false);
171 } 169 }
172 170
173 if (thisline.x() == thisline.maxX()) { 171 if (thisline.x() == thisline.maxX()) {
174 ObjectPainter::drawLineForBoxSide(graphicsContext, 172 ObjectPainter::drawLineForBoxSide(graphicsContext,
175 pixelSnappedBox.x() - outlineWidth, 173 pixelSnappedBox.x() - outlineWidth,
176 pixelSnappedBox.y() - outlineWidth, 174 pixelSnappedBox.y() - outlineWidth,
177 pixelSnappedBox.maxX() + outlineWidth, 175 pixelSnappedBox.maxX() + outlineWidth,
178 pixelSnappedBox.y(), 176 pixelSnappedBox.y(),
179 BSTop, outlineColor, outlineStyle, 177 BSTop, outlineColor, outlineStyle,
180 outlineWidth, 178 outlineWidth,
181 outlineWidth, 179 outlineWidth,
182 antialias); 180 false);
183 } 181 }
184 182
185 // lower edge 183 // lower edge
186 if (thisline.x() < nextline.x()) { 184 if (thisline.x() < nextline.x()) {
187 ObjectPainter::drawLineForBoxSide(graphicsContext, 185 ObjectPainter::drawLineForBoxSide(graphicsContext,
188 pixelSnappedBox.x() - outlineWidth, 186 pixelSnappedBox.x() - outlineWidth,
189 pixelSnappedBox.maxY(), 187 pixelSnappedBox.maxY(),
190 std::min(pixelSnappedBox.maxX() + outlineWidth, !nextline.isEmpty() ? pixelSnappedNextLine.x() + 1 : fallbackMaxOutlineX), 188 std::min(pixelSnappedBox.maxX() + outlineWidth, !nextline.isEmpty() ? pixelSnappedNextLine.x() + 1 : fallbackMaxOutlineX),
191 pixelSnappedBox.maxY() + outlineWidth, 189 pixelSnappedBox.maxY() + outlineWidth,
192 BSBottom, outlineColor, outlineStyle, 190 BSBottom, outlineColor, outlineStyle,
193 outlineWidth, 191 outlineWidth,
194 (!nextline.isEmpty() && paintOffset.x() + nextline.x() + 1 < pixelSn appedBox.maxX() + outlineWidth) ? -outlineWidth : outlineWidth, 192 (!nextline.isEmpty() && paintOffset.x() + nextline.x() + 1 < pixelSn appedBox.maxX() + outlineWidth) ? -outlineWidth : outlineWidth,
195 antialias); 193 false);
196 } 194 }
197 195
198 if (nextline.maxX() < thisline.maxX()) { 196 if (nextline.maxX() < thisline.maxX()) {
199 ObjectPainter::drawLineForBoxSide(graphicsContext, 197 ObjectPainter::drawLineForBoxSide(graphicsContext,
200 std::max(!nextline.isEmpty() ? pixelSnappedNextLine.maxX() : fallbac kMinOutlineX, pixelSnappedBox.x() - outlineWidth), 198 std::max(!nextline.isEmpty() ? pixelSnappedNextLine.maxX() : fallbac kMinOutlineX, pixelSnappedBox.x() - outlineWidth),
201 pixelSnappedBox.maxY(), 199 pixelSnappedBox.maxY(),
202 pixelSnappedBox.maxX() + outlineWidth, 200 pixelSnappedBox.maxX() + outlineWidth,
203 pixelSnappedBox.maxY() + outlineWidth, 201 pixelSnappedBox.maxY() + outlineWidth,
204 BSBottom, outlineColor, outlineStyle, 202 BSBottom, outlineColor, outlineStyle,
205 (!nextline.isEmpty() && pixelSnappedBox.x() - outlineWidth < paintOf fset.x() + nextline.maxX()) ? -outlineWidth : outlineWidth, 203 (!nextline.isEmpty() && pixelSnappedBox.x() - outlineWidth < paintOf fset.x() + nextline.maxX()) ? -outlineWidth : outlineWidth,
206 outlineWidth, antialias); 204 outlineWidth, false);
207 } 205 }
208 206
209 if (thisline.x() == thisline.maxX()) { 207 if (thisline.x() == thisline.maxX()) {
210 ObjectPainter::drawLineForBoxSide(graphicsContext, 208 ObjectPainter::drawLineForBoxSide(graphicsContext,
211 pixelSnappedBox.x() - outlineWidth, 209 pixelSnappedBox.x() - outlineWidth,
212 pixelSnappedBox.maxY(), 210 pixelSnappedBox.maxY(),
213 pixelSnappedBox.maxX() + outlineWidth, 211 pixelSnappedBox.maxX() + outlineWidth,
214 pixelSnappedBox.maxY() + outlineWidth, 212 pixelSnappedBox.maxY() + outlineWidth,
215 BSBottom, outlineColor, outlineStyle, 213 BSBottom, outlineColor, outlineStyle,
216 outlineWidth, 214 outlineWidth,
217 outlineWidth, 215 outlineWidth,
218 antialias); 216 false);
219 } 217 }
220 } 218 }
221 219
222 } // namespace blink 220 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/BoxPainter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698