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

Side by Side Diff: Source/core/rendering/RenderBoxModelObject.cpp

Issue 15137009: Refactor shadow rendering logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: merge upstream changes Created 7 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
7 * Copyright (C) 2010 Google Inc. All rights reserved. 7 * Copyright (C) 2010 Google Inc. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 13 matching lines...) Expand all
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "core/rendering/RenderBoxModelObject.h" 27 #include "core/rendering/RenderBoxModelObject.h"
28 28
29 #include "HTMLNames.h" 29 #include "HTMLNames.h"
30 #include "core/html/HTMLFrameOwnerElement.h" 30 #include "core/html/HTMLFrameOwnerElement.h"
31 #include "core/page/Page.h" 31 #include "core/page/Page.h"
32 #include "core/page/Settings.h" 32 #include "core/page/Settings.h"
33 #include "core/page/scrolling/ScrollingConstraints.h" 33 #include "core/page/scrolling/ScrollingConstraints.h"
34 #include "core/platform/graphics/DrawLooper.h"
34 #include "core/platform/graphics/GraphicsContextStateSaver.h" 35 #include "core/platform/graphics/GraphicsContextStateSaver.h"
35 #include "core/platform/graphics/ImageBuffer.h" 36 #include "core/platform/graphics/ImageBuffer.h"
36 #include "core/platform/graphics/Path.h" 37 #include "core/platform/graphics/Path.h"
37 #include "core/platform/graphics/transforms/TransformState.h" 38 #include "core/platform/graphics/transforms/TransformState.h"
38 #include "core/rendering/ImageQualityController.h" 39 #include "core/rendering/ImageQualityController.h"
39 #include "core/rendering/RenderBlock.h" 40 #include "core/rendering/RenderBlock.h"
40 #include "core/rendering/RenderInline.h" 41 #include "core/rendering/RenderInline.h"
41 #include "core/rendering/RenderLayer.h" 42 #include "core/rendering/RenderLayer.h"
42 #include "core/rendering/RenderLayerBacking.h" 43 #include "core/rendering/RenderLayerBacking.h"
43 #include "core/rendering/RenderLayerCompositor.h" 44 #include "core/rendering/RenderLayerCompositor.h"
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 return getBackgroundRoundedRect(borderRect, box, boxSize.width(), boxSize.he ight(), includeLogicalLeftEdge, includeLogicalRightEdge); 514 return getBackgroundRoundedRect(borderRect, box, boxSize.width(), boxSize.he ight(), includeLogicalLeftEdge, includeLogicalRightEdge);
514 } 515 }
515 516
516 static void applyBoxShadowForBackground(GraphicsContext* context, RenderStyle* s tyle) 517 static void applyBoxShadowForBackground(GraphicsContext* context, RenderStyle* s tyle)
517 { 518 {
518 const ShadowData* boxShadow = style->boxShadow(); 519 const ShadowData* boxShadow = style->boxShadow();
519 while (boxShadow->style() != Normal) 520 while (boxShadow->style() != Normal)
520 boxShadow = boxShadow->next(); 521 boxShadow = boxShadow->next();
521 522
522 FloatSize shadowOffset(boxShadow->x(), boxShadow->y()); 523 FloatSize shadowOffset(boxShadow->x(), boxShadow->y());
523 context->setShadow(shadowOffset, boxShadow->blur(), boxShadow->color(), styl e->colorSpace()); 524 context->setShadow(shadowOffset, boxShadow->blur(), boxShadow->color(), Draw Looper::ShadowIgnoresAlpha);
524 } 525 }
525 526
526 void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, co nst Color& color, const FillLayer* bgLayer, const LayoutRect& rect, 527 void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, co nst Color& color, const FillLayer* bgLayer, const LayoutRect& rect,
527 BackgroundBleedAvoidance bleedAvoidance, InlineFlowBox* box, const LayoutSiz e& boxSize, CompositeOperator op, RenderObject* backgroundObject) 528 BackgroundBleedAvoidance bleedAvoidance, InlineFlowBox* box, const LayoutSiz e& boxSize, CompositeOperator op, RenderObject* backgroundObject)
528 { 529 {
529 GraphicsContext* context = paintInfo.context; 530 GraphicsContext* context = paintInfo.context;
530 if (context->paintingDisabled() || rect.isEmpty()) 531 if (context->paintingDisabled() || rect.isEmpty())
531 return; 532 return;
532 533
533 bool includeLeftEdge = box ? box->includeLogicalLeftEdge() : true; 534 bool includeLeftEdge = box ? box->includeLogicalLeftEdge() : true;
(...skipping 1851 matching lines...) Expand 10 before | Expand all | Expand 10 after
2385 shadowRect.move(shadowOffset); 2386 shadowRect.move(shadowOffset);
2386 2387
2387 GraphicsContextStateSaver stateSaver(*context); 2388 GraphicsContextStateSaver stateSaver(*context);
2388 context->clip(shadowRect); 2389 context->clip(shadowRect);
2389 2390
2390 // Move the fill just outside the clip, adding 1 pixel separation so that the fill does not 2391 // Move the fill just outside the clip, adding 1 pixel separation so that the fill does not
2391 // bleed in (due to antialiasing) if the context is transformed. 2392 // bleed in (due to antialiasing) if the context is transformed.
2392 IntSize extraOffset(paintRect.pixelSnappedWidth() + max(0, shadowOff set.width()) + shadowBlur + 2 * shadowSpread + 1, 0); 2393 IntSize extraOffset(paintRect.pixelSnappedWidth() + max(0, shadowOff set.width()) + shadowBlur + 2 * shadowSpread + 1, 0);
2393 shadowOffset -= extraOffset; 2394 shadowOffset -= extraOffset;
2394 fillRect.move(extraOffset); 2395 fillRect.move(extraOffset);
2395 context->setShadow(shadowOffset, shadowBlur, shadowColor, s->colorSp ace()); 2396 context->setShadow(shadowOffset, shadowBlur, shadowColor, DrawLooper ::ShadowIgnoresAlpha);
2396 2397
2397 if (hasBorderRadius) { 2398 if (hasBorderRadius) {
2398 RoundedRect rectToClipOut = border; 2399 RoundedRect rectToClipOut = border;
2399 2400
2400 // If the box is opaque, it is unnecessary to clip it out. Howev er, doing so saves time 2401 // If the box is opaque, it is unnecessary to clip it out. Howev er, doing so saves time
2401 // when painting the shadow. On the other hand, it introduces su bpixel gaps along the 2402 // when painting the shadow. On the other hand, it introduces su bpixel gaps along the
2402 // corners. Those are avoided by insetting the clipping path by one pixel. 2403 // corners. Those are avoided by insetting the clipping path by one pixel.
2403 if (hasOpaqueBackground) { 2404 if (hasOpaqueBackground) {
2404 rectToClipOut.inflateWithRadii(-1); 2405 rectToClipOut.inflateWithRadii(-1);
2405 } 2406 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
2475 Path path; 2476 Path path;
2476 path.addRoundedRect(border); 2477 path.addRoundedRect(border);
2477 context->clip(path); 2478 context->clip(path);
2478 roundedHole.shrinkRadii(shadowSpread); 2479 roundedHole.shrinkRadii(shadowSpread);
2479 } else 2480 } else
2480 context->clip(border.rect()); 2481 context->clip(border.rect());
2481 2482
2482 IntSize extraOffset(2 * paintRect.pixelSnappedWidth() + max(0, shado wOffset.width()) + shadowBlur - 2 * shadowSpread + 1, 0); 2483 IntSize extraOffset(2 * paintRect.pixelSnappedWidth() + max(0, shado wOffset.width()) + shadowBlur - 2 * shadowSpread + 1, 0);
2483 context->translate(extraOffset.width(), extraOffset.height()); 2484 context->translate(extraOffset.width(), extraOffset.height());
2484 shadowOffset -= extraOffset; 2485 shadowOffset -= extraOffset;
2485 context->setShadow(shadowOffset, shadowBlur, shadowColor, s->colorSp ace()); 2486 context->setShadow(shadowOffset, shadowBlur, shadowColor, DrawLooper ::ShadowIgnoresAlpha);
2486 context->fillRectWithRoundedHole(outerRect, roundedHole, fillColor, s->colorSpace()); 2487 context->fillRectWithRoundedHole(outerRect, roundedHole, fillColor, s->colorSpace());
2487 } 2488 }
2488 } 2489 }
2489 } 2490 }
2490 2491
2491 LayoutUnit RenderBoxModelObject::containingBlockLogicalWidthForContent() const 2492 LayoutUnit RenderBoxModelObject::containingBlockLogicalWidthForContent() const
2492 { 2493 {
2493 return containingBlock()->availableLogicalWidth(); 2494 return containingBlock()->availableLogicalWidth();
2494 } 2495 }
2495 2496
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
2661 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent()); 2662 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent());
2662 for (RenderObject* child = startChild; child && child != endChild; ) { 2663 for (RenderObject* child = startChild; child && child != endChild; ) {
2663 // Save our next sibling as moveChildTo will clear it. 2664 // Save our next sibling as moveChildTo will clear it.
2664 RenderObject* nextSibling = child->nextSibling(); 2665 RenderObject* nextSibling = child->nextSibling();
2665 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert); 2666 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert);
2666 child = nextSibling; 2667 child = nextSibling;
2667 } 2668 }
2668 } 2669 }
2669 2670
2670 } // namespace WebCore 2671 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/InlineTextBox.cpp ('k') | Source/core/rendering/svg/SVGRenderingContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698