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

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: rebase 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 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 return getBackgroundRoundedRect(borderRect, box, boxSize.width(), boxSize.he ight(), includeLogicalLeftEdge, includeLogicalRightEdge); 508 return getBackgroundRoundedRect(borderRect, box, boxSize.width(), boxSize.he ight(), includeLogicalLeftEdge, includeLogicalRightEdge);
508 } 509 }
509 510
510 static void applyBoxShadowForBackground(GraphicsContext* context, RenderStyle* s tyle) 511 static void applyBoxShadowForBackground(GraphicsContext* context, RenderStyle* s tyle)
511 { 512 {
512 const ShadowData* boxShadow = style->boxShadow(); 513 const ShadowData* boxShadow = style->boxShadow();
513 while (boxShadow->style() != Normal) 514 while (boxShadow->style() != Normal)
514 boxShadow = boxShadow->next(); 515 boxShadow = boxShadow->next();
515 516
516 FloatSize shadowOffset(boxShadow->x(), boxShadow->y()); 517 FloatSize shadowOffset(boxShadow->x(), boxShadow->y());
517 context->setShadow(shadowOffset, boxShadow->blur(), boxShadow->color(), styl e->colorSpace()); 518 context->setShadow(shadowOffset, boxShadow->blur(), boxShadow->color(), Draw Looper::ShadowIgnoresAlpha);
518 } 519 }
519 520
520 void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, co nst Color& color, const FillLayer* bgLayer, const LayoutRect& rect, 521 void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, co nst Color& color, const FillLayer* bgLayer, const LayoutRect& rect,
521 BackgroundBleedAvoidance bleedAvoidance, InlineFlowBox* box, const LayoutSiz e& boxSize, CompositeOperator op, RenderObject* backgroundObject) 522 BackgroundBleedAvoidance bleedAvoidance, InlineFlowBox* box, const LayoutSiz e& boxSize, CompositeOperator op, RenderObject* backgroundObject)
522 { 523 {
523 GraphicsContext* context = paintInfo.context; 524 GraphicsContext* context = paintInfo.context;
524 if (context->paintingDisabled() || rect.isEmpty()) 525 if (context->paintingDisabled() || rect.isEmpty())
525 return; 526 return;
526 527
527 bool includeLeftEdge = box ? box->includeLogicalLeftEdge() : true; 528 bool includeLeftEdge = box ? box->includeLogicalLeftEdge() : true;
(...skipping 1841 matching lines...) Expand 10 before | Expand all | Expand 10 after
2369 shadowRect.move(shadowOffset); 2370 shadowRect.move(shadowOffset);
2370 2371
2371 GraphicsContextStateSaver stateSaver(*context); 2372 GraphicsContextStateSaver stateSaver(*context);
2372 context->clip(shadowRect); 2373 context->clip(shadowRect);
2373 2374
2374 // Move the fill just outside the clip, adding 1 pixel separation so that the fill does not 2375 // Move the fill just outside the clip, adding 1 pixel separation so that the fill does not
2375 // bleed in (due to antialiasing) if the context is transformed. 2376 // bleed in (due to antialiasing) if the context is transformed.
2376 IntSize extraOffset(paintRect.pixelSnappedWidth() + max(0, shadowOff set.width()) + shadowBlur + 2 * shadowSpread + 1, 0); 2377 IntSize extraOffset(paintRect.pixelSnappedWidth() + max(0, shadowOff set.width()) + shadowBlur + 2 * shadowSpread + 1, 0);
2377 shadowOffset -= extraOffset; 2378 shadowOffset -= extraOffset;
2378 fillRect.move(extraOffset); 2379 fillRect.move(extraOffset);
2379 context->setShadow(shadowOffset, shadowBlur, shadowColor, s->colorSp ace()); 2380 context->setShadow(shadowOffset, shadowBlur, shadowColor, DrawLooper ::ShadowIgnoresAlpha);
2380 2381
2381 if (hasBorderRadius) { 2382 if (hasBorderRadius) {
2382 RoundedRect rectToClipOut = border; 2383 RoundedRect rectToClipOut = border;
2383 2384
2384 // If the box is opaque, it is unnecessary to clip it out. Howev er, doing so saves time 2385 // If the box is opaque, it is unnecessary to clip it out. Howev er, doing so saves time
2385 // when painting the shadow. On the other hand, it introduces su bpixel gaps along the 2386 // when painting the shadow. On the other hand, it introduces su bpixel gaps along the
2386 // corners. Those are avoided by insetting the clipping path by one pixel. 2387 // corners. Those are avoided by insetting the clipping path by one pixel.
2387 if (hasOpaqueBackground) { 2388 if (hasOpaqueBackground) {
2388 rectToClipOut.inflateWithRadii(-1); 2389 rectToClipOut.inflateWithRadii(-1);
2389 } 2390 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
2459 Path path; 2460 Path path;
2460 path.addRoundedRect(border); 2461 path.addRoundedRect(border);
2461 context->clip(path); 2462 context->clip(path);
2462 roundedHole.shrinkRadii(shadowSpread); 2463 roundedHole.shrinkRadii(shadowSpread);
2463 } else 2464 } else
2464 context->clip(border.rect()); 2465 context->clip(border.rect());
2465 2466
2466 IntSize extraOffset(2 * paintRect.pixelSnappedWidth() + max(0, shado wOffset.width()) + shadowBlur - 2 * shadowSpread + 1, 0); 2467 IntSize extraOffset(2 * paintRect.pixelSnappedWidth() + max(0, shado wOffset.width()) + shadowBlur - 2 * shadowSpread + 1, 0);
2467 context->translate(extraOffset.width(), extraOffset.height()); 2468 context->translate(extraOffset.width(), extraOffset.height());
2468 shadowOffset -= extraOffset; 2469 shadowOffset -= extraOffset;
2469 context->setShadow(shadowOffset, shadowBlur, shadowColor, s->colorSp ace()); 2470 context->setShadow(shadowOffset, shadowBlur, shadowColor, DrawLooper ::ShadowIgnoresAlpha);
2470 context->fillRectWithRoundedHole(outerRect, roundedHole, fillColor, s->colorSpace()); 2471 context->fillRectWithRoundedHole(outerRect, roundedHole, fillColor, s->colorSpace());
2471 } 2472 }
2472 } 2473 }
2473 } 2474 }
2474 2475
2475 LayoutUnit RenderBoxModelObject::containingBlockLogicalWidthForContent() const 2476 LayoutUnit RenderBoxModelObject::containingBlockLogicalWidthForContent() const
2476 { 2477 {
2477 return containingBlock()->availableLogicalWidth(); 2478 return containingBlock()->availableLogicalWidth();
2478 } 2479 }
2479 2480
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
2645 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent()); 2646 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent());
2646 for (RenderObject* child = startChild; child && child != endChild; ) { 2647 for (RenderObject* child = startChild; child && child != endChild; ) {
2647 // Save our next sibling as moveChildTo will clear it. 2648 // Save our next sibling as moveChildTo will clear it.
2648 RenderObject* nextSibling = child->nextSibling(); 2649 RenderObject* nextSibling = child->nextSibling();
2649 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert); 2650 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert);
2650 child = nextSibling; 2651 child = nextSibling;
2651 } 2652 }
2652 } 2653 }
2653 2654
2654 } // namespace WebCore 2655 } // 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