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

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

Issue 865353002: Implement clip and scroll DisplayItems for PartPainter (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: de-dupe clipRoundedInnerRect 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 unified diff | Download patch | Annotate | Revision Log
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/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"
11 #include "core/paint/BackgroundImageGeometry.h" 11 #include "core/paint/BackgroundImageGeometry.h"
12 #include "core/paint/BoxDecorationData.h" 12 #include "core/paint/BoxDecorationData.h"
13 #include "core/paint/RenderDrawingRecorder.h" 13 #include "core/paint/RenderDrawingRecorder.h"
14 #include "core/paint/RoundedInnerRectClipper.h"
14 #include "core/rendering/ImageQualityController.h" 15 #include "core/rendering/ImageQualityController.h"
15 #include "core/rendering/PaintInfo.h" 16 #include "core/rendering/PaintInfo.h"
16 #include "core/rendering/RenderBox.h" 17 #include "core/rendering/RenderBox.h"
17 #include "core/rendering/RenderBoxModelObject.h" 18 #include "core/rendering/RenderBoxModelObject.h"
18 #include "core/rendering/RenderLayer.h" 19 #include "core/rendering/RenderLayer.h"
19 #include "core/rendering/RenderObject.h" 20 #include "core/rendering/RenderObject.h"
20 #include "core/rendering/RenderTable.h" 21 #include "core/rendering/RenderTable.h"
21 #include "core/rendering/RenderTheme.h" 22 #include "core/rendering/RenderTheme.h"
22 #include "core/rendering/RenderView.h" 23 #include "core/rendering/RenderView.h"
23 #include "core/rendering/compositing/CompositedLayerMapping.h" 24 #include "core/rendering/compositing/CompositedLayerMapping.h"
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 if (bleedAvoidance == BackgroundBleedShrinkBackground) { 257 if (bleedAvoidance == BackgroundBleedShrinkBackground) {
257 // We shrink the rectangle by one pixel on each side because the bleed i s one pixel maximum. 258 // We shrink the rectangle by one pixel on each side because the bleed i s one pixel maximum.
258 return BoxPainter::getBackgroundRoundedRect(obj, shrinkRectByOnePixel(co ntext, borderRect), box, boxSize.width(), boxSize.height(), includeLogicalLeftEd ge, includeLogicalRightEdge); 259 return BoxPainter::getBackgroundRoundedRect(obj, shrinkRectByOnePixel(co ntext, borderRect), box, boxSize.width(), boxSize.height(), includeLogicalLeftEd ge, includeLogicalRightEdge);
259 } 260 }
260 if (bleedAvoidance == BackgroundBleedBackgroundOverBorder) 261 if (bleedAvoidance == BackgroundBleedBackgroundOverBorder)
261 return obj.style()->getRoundedInnerBorderFor(borderRect, includeLogicalL eftEdge, includeLogicalRightEdge); 262 return obj.style()->getRoundedInnerBorderFor(borderRect, includeLogicalL eftEdge, includeLogicalRightEdge);
262 263
263 return BoxPainter::getBackgroundRoundedRect(obj, borderRect, box, boxSize.wi dth(), boxSize.height(), includeLogicalLeftEdge, includeLogicalRightEdge); 264 return BoxPainter::getBackgroundRoundedRect(obj, borderRect, box, boxSize.wi dth(), boxSize.height(), includeLogicalLeftEdge, includeLogicalRightEdge);
264 } 265 }
265 266
266 void BoxPainter::clipRoundedInnerRect(GraphicsContext * context, const LayoutRec t& rect, const FloatRoundedRect& clipRect)
267 {
268 if (clipRect.isRenderable()) {
269 context->clipRoundedRect(clipRect);
270 } else {
271 // We create a rounded rect for each of the corners and clip it, while m aking sure we clip opposing corners together.
272 if (!clipRect.radii().topLeft().isEmpty() || !clipRect.radii().bottomRig ht().isEmpty()) {
273 FloatRect topCorner(clipRect.rect().x(), clipRect.rect().y(), rect.m axX() - clipRect.rect().x(), rect.maxY() - clipRect.rect().y());
274 FloatRoundedRect::Radii topCornerRadii;
275 topCornerRadii.setTopLeft(clipRect.radii().topLeft());
276 context->clipRoundedRect(FloatRoundedRect(topCorner, topCornerRadii) );
277
278 FloatRect bottomCorner(rect.x().toFloat(), rect.y().toFloat(), clipR ect.rect().maxX() - rect.x().toFloat(), clipRect.rect().maxY() - rect.y().toFloa t());
279 FloatRoundedRect::Radii bottomCornerRadii;
280 bottomCornerRadii.setBottomRight(clipRect.radii().bottomRight());
281 context->clipRoundedRect(FloatRoundedRect(bottomCorner, bottomCorner Radii));
282 }
283
284 if (!clipRect.radii().topRight().isEmpty() || !clipRect.radii().bottomLe ft().isEmpty()) {
285 FloatRect topCorner(rect.x().toFloat(), clipRect.rect().y(), clipRec t.rect().maxX() - rect.x().toFloat(), rect.maxY() - clipRect.rect().y());
286 FloatRoundedRect::Radii topCornerRadii;
287 topCornerRadii.setTopRight(clipRect.radii().topRight());
288 context->clipRoundedRect(FloatRoundedRect(topCorner, topCornerRadii) );
289
290 FloatRect bottomCorner(clipRect.rect().x(), rect.y().toFloat(), rect .maxX() - clipRect.rect().x(), clipRect.rect().maxY() - rect.y().toFloat());
291 FloatRoundedRect::Radii bottomCornerRadii;
292 bottomCornerRadii.setBottomLeft(clipRect.radii().bottomLeft());
293 context->clipRoundedRect(FloatRoundedRect(bottomCorner, bottomCorner Radii));
294 }
295 }
296 }
297
298 void BoxPainter::paintFillLayerExtended(RenderBoxModelObject& obj, const PaintIn fo& paintInfo, const Color& color, const FillLayer& bgLayer, const LayoutRect& r ect, 267 void BoxPainter::paintFillLayerExtended(RenderBoxModelObject& obj, const PaintIn fo& paintInfo, const Color& color, const FillLayer& bgLayer, const LayoutRect& r ect,
299 BackgroundBleedAvoidance bleedAvoidance, InlineFlowBox* box, const LayoutSiz e& boxSize, SkXfermode::Mode op, RenderObject* backgroundObject, bool skipBaseCo lor) 268 BackgroundBleedAvoidance bleedAvoidance, InlineFlowBox* box, const LayoutSiz e& boxSize, SkXfermode::Mode op, RenderObject* backgroundObject, bool skipBaseCo lor)
300 { 269 {
301 GraphicsContext* context = paintInfo.context; 270 GraphicsContext* context = paintInfo.context;
302 if (rect.isEmpty()) 271 if (rect.isEmpty())
303 return; 272 return;
304 273
305 bool includeLeftEdge = box ? box->includeLogicalLeftEdge() : true; 274 bool includeLeftEdge = box ? box->includeLogicalLeftEdge() : true;
306 bool includeRightEdge = box ? box->includeLogicalRightEdge() : true; 275 bool includeRightEdge = box ? box->includeLogicalRightEdge() : true;
307 276
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 bool boxShadowShouldBeAppliedToBackground = obj.boxShadowShouldBeApplied ToBackground(bleedAvoidance, box); 318 bool boxShadowShouldBeAppliedToBackground = obj.boxShadowShouldBeApplied ToBackground(bleedAvoidance, box);
350 GraphicsContextStateSaver shadowStateSaver(*context, boxShadowShouldBeAp pliedToBackground); 319 GraphicsContextStateSaver shadowStateSaver(*context, boxShadowShouldBeAp pliedToBackground);
351 if (boxShadowShouldBeAppliedToBackground) 320 if (boxShadowShouldBeAppliedToBackground)
352 BoxPainter::applyBoxShadowForBackground(context, obj); 321 BoxPainter::applyBoxShadowForBackground(context, obj);
353 322
354 if (hasRoundedBorder && bleedAvoidance != BackgroundBleedClipBackground) { 323 if (hasRoundedBorder && bleedAvoidance != BackgroundBleedClipBackground) {
355 FloatRoundedRect border = backgroundRoundedRectAdjustedForBleedAvoid ance(obj, context, rect, bleedAvoidance, box, boxSize, includeLeftEdge, includeR ightEdge); 324 FloatRoundedRect border = backgroundRoundedRectAdjustedForBleedAvoid ance(obj, context, rect, bleedAvoidance, box, boxSize, includeLeftEdge, includeR ightEdge);
356 if (border.isRenderable()) { 325 if (border.isRenderable()) {
357 context->fillRoundedRect(border, bgColor); 326 context->fillRoundedRect(border, bgColor);
358 } else { 327 } else {
359 context->save(); 328 RoundedInnerRectClipper clipper(obj, paintInfo, rect, border, Ap plyToContext);
360 clipRoundedInnerRect(context, rect, border);
361 context->fillRect(border.rect(), bgColor); 329 context->fillRect(border.rect(), bgColor);
362 context->restore();
363 } 330 }
364 } else { 331 } else {
365 context->fillRect(pixelSnappedIntRect(rect), bgColor); 332 context->fillRect(pixelSnappedIntRect(rect), bgColor);
366 } 333 }
367 334
368 return; 335 return;
369 } 336 }
370 337
371 // BorderFillBox radius clipping is taken care of by BackgroundBleedClipBack ground 338 // BorderFillBox radius clipping is taken care of by BackgroundBleedClipBack ground
372 bool clipToBorderRadius = hasRoundedBorder && !(isBorderFill && bleedAvoidan ce == BackgroundBleedClipBackground); 339 bool clipToBorderRadius = hasRoundedBorder && !(isBorderFill && bleedAvoidan ce == BackgroundBleedClipBackground);
373 GraphicsContextStateSaver clipToBorderStateSaver(*context, clipToBorderRadiu s); 340 OwnPtr<RoundedInnerRectClipper> clipToBorder;
chrishtr 2015/01/23 23:35:33 Is there a save() you should be deleting?
chrishtr 2015/01/23 23:35:33 Is there a save() you should be deleting?
374 if (clipToBorderRadius) { 341 if (clipToBorderRadius) {
375 FloatRoundedRect border = isBorderFill ? backgroundRoundedRectAdjustedFo rBleedAvoidance(obj, context, rect, bleedAvoidance, box, boxSize, includeLeftEdg e, includeRightEdge) : getBackgroundRoundedRect(obj, rect, box, boxSize.width(), boxSize.height(), includeLeftEdge, includeRightEdge); 342 FloatRoundedRect border = isBorderFill ? backgroundRoundedRectAdjustedFo rBleedAvoidance(obj, context, rect, bleedAvoidance, box, boxSize, includeLeftEdg e, includeRightEdge) : getBackgroundRoundedRect(obj, rect, box, boxSize.width(), boxSize.height(), includeLeftEdge, includeRightEdge);
376 343
377 // Clip to the padding or content boxes as necessary. 344 // Clip to the padding or content boxes as necessary.
378 if (bgLayer.clip() == ContentFillBox) { 345 if (bgLayer.clip() == ContentFillBox) {
379 border = obj.style()->getRoundedInnerBorderFor(LayoutRect(border.rec t()), 346 border = obj.style()->getRoundedInnerBorderFor(LayoutRect(border.rec t()),
380 obj.paddingTop() + obj.borderTop(), obj.paddingBottom() + obj.bo rderBottom(), 347 obj.paddingTop() + obj.borderTop(), obj.paddingBottom() + obj.bo rderBottom(),
381 obj.paddingLeft() + obj.borderLeft(), obj.paddingRight() + obj.b orderRight(), includeLeftEdge, includeRightEdge); 348 obj.paddingLeft() + obj.borderLeft(), obj.paddingRight() + obj.b orderRight(), includeLeftEdge, includeRightEdge);
382 } else if (bgLayer.clip() == PaddingFillBox) { 349 } else if (bgLayer.clip() == PaddingFillBox) {
383 border = obj.style()->getRoundedInnerBorderFor(LayoutRect(border.rec t()), includeLeftEdge, includeRightEdge); 350 border = obj.style()->getRoundedInnerBorderFor(LayoutRect(border.rec t()), includeLeftEdge, includeRightEdge);
384 } 351 }
385 352
386 clipRoundedInnerRect(context, rect, border); 353 clipToBorder = adoptPtr(new RoundedInnerRectClipper(obj, paintInfo, rect , border, ApplyToContext));
387 } 354 }
388 355
389 int bLeft = includeLeftEdge ? obj.borderLeft() : 0; 356 int bLeft = includeLeftEdge ? obj.borderLeft() : 0;
390 int bRight = includeRightEdge ? obj.borderRight() : 0; 357 int bRight = includeRightEdge ? obj.borderRight() : 0;
391 LayoutUnit pLeft = includeLeftEdge ? obj.paddingLeft() : LayoutUnit(); 358 LayoutUnit pLeft = includeLeftEdge ? obj.paddingLeft() : LayoutUnit();
392 LayoutUnit pRight = includeRightEdge ? obj.paddingRight() : LayoutUnit(); 359 LayoutUnit pRight = includeRightEdge ? obj.paddingRight() : LayoutUnit();
393 360
394 GraphicsContextStateSaver clipWithScrollingStateSaver(*context, clippedWithL ocalScrolling); 361 GraphicsContextStateSaver clipWithScrollingStateSaver(*context, clippedWithL ocalScrolling);
395 LayoutRect scrolledPaintRect = rect; 362 LayoutRect scrolledPaintRect = rect;
396 if (clippedWithLocalScrolling) { 363 if (clippedWithLocalScrolling) {
(...skipping 1816 matching lines...) Expand 10 before | Expand all | Expand 10 after
2213 2180
2214 FloatPoint secondQuad[4]; 2181 FloatPoint secondQuad[4];
2215 secondQuad[0] = quad[0]; 2182 secondQuad[0] = quad[0];
2216 secondQuad[1] = FloatPoint(quad[0].x() - r1 * cx, quad[0].y() - r1 * cy); 2183 secondQuad[1] = FloatPoint(quad[0].x() - r1 * cx, quad[0].y() - r1 * cy);
2217 secondQuad[2] = quad[2]; 2184 secondQuad[2] = quad[2];
2218 secondQuad[3] = quad[3]; 2185 secondQuad[3] = quad[3];
2219 graphicsContext->clipPolygon(4, secondQuad, !secondEdgeMatches); 2186 graphicsContext->clipPolygon(4, secondQuad, !secondEdgeMatches);
2220 } 2187 }
2221 2188
2222 } // namespace blink 2189 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698