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

Side by Side Diff: sky/engine/core/rendering/RenderBoxModelObject.cpp

Issue 766943003: Remove uses of PaintBehaviorFlattenCompositingLayers (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: patch for landing Created 6 years 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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 if (boxShadow.style() != Normal) 370 if (boxShadow.style() != Normal)
371 continue; 371 continue;
372 FloatSize shadowOffset(boxShadow.x(), boxShadow.y()); 372 FloatSize shadowOffset(boxShadow.x(), boxShadow.y());
373 context->setShadow(shadowOffset, boxShadow.blur(), boxShadow.color(), 373 context->setShadow(shadowOffset, boxShadow.blur(), boxShadow.color(),
374 DrawLooperBuilder::ShadowRespectsTransforms, DrawLooperBuilder::Shad owIgnoresAlpha); 374 DrawLooperBuilder::ShadowRespectsTransforms, DrawLooperBuilder::Shad owIgnoresAlpha);
375 return; 375 return;
376 } 376 }
377 } 377 }
378 378
379 void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, co nst Color& color, const FillLayer& bgLayer, const LayoutRect& rect, 379 void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, co nst Color& color, const FillLayer& bgLayer, const LayoutRect& rect,
380 BackgroundBleedAvoidance bleedAvoidance, InlineFlowBox* box, const LayoutSiz e& boxSize, CompositeOperator op, RenderObject* backgroundObject, bool skipBaseC olor) 380 BackgroundBleedAvoidance bleedAvoidance, InlineFlowBox* box, const LayoutSiz e& boxSize, RenderObject* backgroundObject, bool skipBaseColor)
381 { 381 {
382 GraphicsContext* context = paintInfo.context; 382 GraphicsContext* context = paintInfo.context;
383 if (rect.isEmpty()) 383 if (rect.isEmpty())
384 return; 384 return;
385 385
386 bool includeLeftEdge = box ? box->includeLogicalLeftEdge() : true; 386 bool includeLeftEdge = box ? box->includeLogicalLeftEdge() : true;
387 bool includeRightEdge = box ? box->includeLogicalRightEdge() : true; 387 bool includeRightEdge = box ? box->includeLogicalRightEdge() : true;
388 388
389 bool hasRoundedBorder = style()->hasBorderRadius() && (includeLeftEdge || in cludeRightEdge); 389 bool hasRoundedBorder = style()->hasBorderRadius() && (includeLeftEdge || in cludeRightEdge);
390 bool clippedWithLocalScrolling = hasOverflowClip() && bgLayer.attachment() = = LocalBackgroundAttachment; 390 bool clippedWithLocalScrolling = hasOverflowClip() && bgLayer.attachment() = = LocalBackgroundAttachment;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 } 523 }
524 } 524 }
525 } 525 }
526 526
527 // no progressive loading of the background image 527 // no progressive loading of the background image
528 if (shouldPaintBackgroundImage) { 528 if (shouldPaintBackgroundImage) {
529 BackgroundImageGeometry geometry; 529 BackgroundImageGeometry geometry;
530 calculateBackgroundImageGeometry(paintInfo.paintContainer(), bgLayer, sc rolledPaintRect, geometry, backgroundObject); 530 calculateBackgroundImageGeometry(paintInfo.paintContainer(), bgLayer, sc rolledPaintRect, geometry, backgroundObject);
531 geometry.clip(paintInfo.rect); 531 geometry.clip(paintInfo.rect);
532 if (!geometry.destRect().isEmpty()) { 532 if (!geometry.destRect().isEmpty()) {
533 CompositeOperator compositeOp = op == CompositeSourceOver ? bgLayer. composite() : op; 533 // FIXME(sky): Is it possible for the bgLayer to be something other that CompositeSourceOver?
534 CompositeOperator compositeOp = bgLayer.composite();
534 RenderObject* clientForBackgroundImage = backgroundObject ? backgrou ndObject : this; 535 RenderObject* clientForBackgroundImage = backgroundObject ? backgrou ndObject : this;
535 RefPtr<Image> image = bgImage->image(clientForBackgroundImage, geome try.tileSize()); 536 RefPtr<Image> image = bgImage->image(clientForBackgroundImage, geome try.tileSize());
536 InterpolationQuality interpolationQuality = chooseInterpolationQuali ty(context, image.get(), &bgLayer, geometry.tileSize()); 537 InterpolationQuality interpolationQuality = chooseInterpolationQuali ty(context, image.get(), &bgLayer, geometry.tileSize());
537 if (bgLayer.maskSourceType() == MaskLuminance) 538 if (bgLayer.maskSourceType() == MaskLuminance)
538 context->setColorFilter(ColorFilterLuminanceToAlpha); 539 context->setColorFilter(ColorFilterLuminanceToAlpha);
539 InterpolationQuality previousInterpolationQuality = context->imageIn terpolationQuality(); 540 InterpolationQuality previousInterpolationQuality = context->imageIn terpolationQuality();
540 context->setImageInterpolationQuality(interpolationQuality); 541 context->setImageInterpolationQuality(interpolationQuality);
541 context->drawTiledImage(image.get(), geometry.destRect(), geometry.r elativePhase(), geometry.tileSize(), 542 context->drawTiledImage(image.get(), geometry.destRect(), geometry.r elativePhase(), geometry.tileSize(),
542 compositeOp, bgLayer.blendMode(), geometry.spaceSize()); 543 compositeOp, bgLayer.blendMode(), geometry.spaceSize());
543 context->setImageInterpolationQuality(previousInterpolationQuality); 544 context->setImageInterpolationQuality(previousInterpolationQuality);
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 static LayoutUnit computeBorderImageSide(const BorderImageLength& borderSlice, L ayoutUnit borderSide, LayoutUnit imageSide, LayoutUnit boxExtent) 924 static LayoutUnit computeBorderImageSide(const BorderImageLength& borderSlice, L ayoutUnit borderSide, LayoutUnit imageSide, LayoutUnit boxExtent)
924 { 925 {
925 if (borderSlice.isNumber()) 926 if (borderSlice.isNumber())
926 return borderSlice.number() * borderSide; 927 return borderSlice.number() * borderSide;
927 if (borderSlice.length().isAuto()) 928 if (borderSlice.length().isAuto())
928 return imageSide; 929 return imageSide;
929 return valueForLength(borderSlice.length(), boxExtent); 930 return valueForLength(borderSlice.length(), boxExtent);
930 } 931 }
931 932
932 bool RenderBoxModelObject::paintNinePieceImage(GraphicsContext* graphicsContext, const LayoutRect& rect, const RenderStyle* style, 933 bool RenderBoxModelObject::paintNinePieceImage(GraphicsContext* graphicsContext, const LayoutRect& rect, const RenderStyle* style,
933 const NinePieceImage& ninePieceIm age, CompositeOperator op) 934 const NinePieceImage& ninePieceIm age)
934 { 935 {
935 StyleImage* styleImage = ninePieceImage.image(); 936 StyleImage* styleImage = ninePieceImage.image();
936 if (!styleImage) 937 if (!styleImage)
937 return false; 938 return false;
938 939
939 if (!styleImage->isLoaded()) 940 if (!styleImage->isLoaded())
940 return true; // Never paint a nine-piece image incrementally, but don't paint the fallback borders either. 941 return true; // Never paint a nine-piece image incrementally, but don't paint the fallback borders either.
941 942
942 if (!styleImage->canRender(*this)) 943 if (!styleImage->canRender(*this))
943 return false; 944 return false;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 float topSideScale = drawTop ? (float)topWidth / topSlice : 1; 1003 float topSideScale = drawTop ? (float)topWidth / topSlice : 1;
1003 float bottomSideScale = drawBottom ? (float)bottomWidth / bottomSlice : 1; 1004 float bottomSideScale = drawBottom ? (float)bottomWidth / bottomSlice : 1;
1004 1005
1005 if (drawLeft) { 1006 if (drawLeft) {
1006 // Paint the top and bottom left corners. 1007 // Paint the top and bottom left corners.
1007 1008
1008 // The top left corner rect is (tx, ty, leftWidth, topWidth) 1009 // The top left corner rect is (tx, ty, leftWidth, topWidth)
1009 // The rect to use from within the image is obtained from our slice, and is (0, 0, leftSlice, topSlice) 1010 // The rect to use from within the image is obtained from our slice, and is (0, 0, leftSlice, topSlice)
1010 if (drawTop) 1011 if (drawTop)
1011 graphicsContext->drawImage(image.get(), IntRect(borderImageRect.loca tion(), IntSize(leftWidth, topWidth)), 1012 graphicsContext->drawImage(image.get(), IntRect(borderImageRect.loca tion(), IntSize(leftWidth, topWidth)),
1012 LayoutRect(0, 0, leftSlice, topSlice), op ); 1013 LayoutRect(0, 0, leftSlice, topSlice), Co mpositeSourceOver);
1013 1014
1014 // The bottom left corner rect is (tx, ty + h - bottomWidth, leftWidth, bottomWidth) 1015 // The bottom left corner rect is (tx, ty + h - bottomWidth, leftWidth, bottomWidth)
1015 // The rect to use from within the image is (0, imageHeight - bottomSlic e, leftSlice, botomSlice) 1016 // The rect to use from within the image is (0, imageHeight - bottomSlic e, leftSlice, botomSlice)
1016 if (drawBottom) 1017 if (drawBottom)
1017 graphicsContext->drawImage(image.get(), IntRect(borderImageRect.x(), borderImageRect.maxY() - bottomWidth, leftWidth, bottomWidth), 1018 graphicsContext->drawImage(image.get(), IntRect(borderImageRect.x(), borderImageRect.maxY() - bottomWidth, leftWidth, bottomWidth),
1018 LayoutRect(0, imageHeight - bottomSlice, leftSlice, bottomSlice), op); 1019 LayoutRect(0, imageHeight - bottomSlice, leftSlice, bottomSlice), CompositeSourceOver);
1019 1020
1020 // Paint the left edge. 1021 // Paint the left edge.
1021 // Have to scale and tile into the border rect. 1022 // Have to scale and tile into the border rect.
1022 if (sourceHeight > 0) 1023 if (sourceHeight > 0)
1023 graphicsContext->drawTiledImage(image.get(), IntRect(borderImageRect .x(), borderImageRect.y() + topWidth, leftWidth, destinationHeight), 1024 graphicsContext->drawTiledImage(image.get(), IntRect(borderImageRect .x(), borderImageRect.y() + topWidth, leftWidth, destinationHeight),
1024 IntRect(0, topSlice, leftSlice, sour ceHeight), 1025 IntRect(0, topSlice, leftSlice, sour ceHeight),
1025 FloatSize(leftSideScale, leftSideSca le), Image::StretchTile, (Image::TileRule)vRule, op); 1026 FloatSize(leftSideScale, leftSideSca le), Image::StretchTile, (Image::TileRule)vRule, CompositeSourceOver);
1026 } 1027 }
1027 1028
1028 if (drawRight) { 1029 if (drawRight) {
1029 // Paint the top and bottom right corners 1030 // Paint the top and bottom right corners
1030 // The top right corner rect is (tx + w - rightWidth, ty, rightWidth, to pWidth) 1031 // The top right corner rect is (tx + w - rightWidth, ty, rightWidth, to pWidth)
1031 // The rect to use from within the image is obtained from our slice, and is (imageWidth - rightSlice, 0, rightSlice, topSlice) 1032 // The rect to use from within the image is obtained from our slice, and is (imageWidth - rightSlice, 0, rightSlice, topSlice)
1032 if (drawTop) 1033 if (drawTop)
1033 graphicsContext->drawImage(image.get(), IntRect(borderImageRect.maxX () - rightWidth, borderImageRect.y(), rightWidth, topWidth), 1034 graphicsContext->drawImage(image.get(), IntRect(borderImageRect.maxX () - rightWidth, borderImageRect.y(), rightWidth, topWidth),
1034 LayoutRect(imageWidth - rightSlice, 0, ri ghtSlice, topSlice), op); 1035 LayoutRect(imageWidth - rightSlice, 0, ri ghtSlice, topSlice), CompositeSourceOver);
1035 1036
1036 // The bottom right corner rect is (tx + w - rightWidth, ty + h - bottom Width, rightWidth, bottomWidth) 1037 // The bottom right corner rect is (tx + w - rightWidth, ty + h - bottom Width, rightWidth, bottomWidth)
1037 // The rect to use from within the image is (imageWidth - rightSlice, im ageHeight - bottomSlice, rightSlice, bottomSlice) 1038 // The rect to use from within the image is (imageWidth - rightSlice, im ageHeight - bottomSlice, rightSlice, bottomSlice)
1038 if (drawBottom) 1039 if (drawBottom)
1039 graphicsContext->drawImage(image.get(), IntRect(borderImageRect.maxX () - rightWidth, borderImageRect.maxY() - bottomWidth, rightWidth, bottomWidth), 1040 graphicsContext->drawImage(image.get(), IntRect(borderImageRect.maxX () - rightWidth, borderImageRect.maxY() - bottomWidth, rightWidth, bottomWidth),
1040 LayoutRect(imageWidth - rightSlice, image Height - bottomSlice, rightSlice, bottomSlice), op); 1041 LayoutRect(imageWidth - rightSlice, image Height - bottomSlice, rightSlice, bottomSlice), CompositeSourceOver);
1041 1042
1042 // Paint the right edge. 1043 // Paint the right edge.
1043 if (sourceHeight > 0) 1044 if (sourceHeight > 0)
1044 graphicsContext->drawTiledImage(image.get(), IntRect(borderImageRect .maxX() - rightWidth, borderImageRect.y() + topWidth, rightWidth, 1045 graphicsContext->drawTiledImage(image.get(), IntRect(borderImageRect .maxX() - rightWidth, borderImageRect.y() + topWidth, rightWidth,
1045 destinationHeight), 1046 destinationHeight),
1046 IntRect(imageWidth - rightSlice, top Slice, rightSlice, sourceHeight), 1047 IntRect(imageWidth - rightSlice, top Slice, rightSlice, sourceHeight),
1047 FloatSize(rightSideScale, rightSideS cale), 1048 FloatSize(rightSideScale, rightSideS cale),
1048 Image::StretchTile, (Image::TileRule )vRule, op); 1049 Image::StretchTile, (Image::TileRule )vRule, CompositeSourceOver);
1049 } 1050 }
1050 1051
1051 // Paint the top edge. 1052 // Paint the top edge.
1052 if (drawTop && sourceWidth > 0) 1053 if (drawTop && sourceWidth > 0)
1053 graphicsContext->drawTiledImage(image.get(), IntRect(borderImageRect.x() + leftWidth, borderImageRect.y(), destinationWidth, topWidth), 1054 graphicsContext->drawTiledImage(image.get(), IntRect(borderImageRect.x() + leftWidth, borderImageRect.y(), destinationWidth, topWidth),
1054 IntRect(leftSlice, 0, sourceWidth, topSl ice), 1055 IntRect(leftSlice, 0, sourceWidth, topSl ice),
1055 FloatSize(topSideScale, topSideScale), ( Image::TileRule)hRule, Image::StretchTile, op); 1056 FloatSize(topSideScale, topSideScale), ( Image::TileRule)hRule, Image::StretchTile, CompositeSourceOver);
1056 1057
1057 // Paint the bottom edge. 1058 // Paint the bottom edge.
1058 if (drawBottom && sourceWidth > 0) 1059 if (drawBottom && sourceWidth > 0)
1059 graphicsContext->drawTiledImage(image.get(), IntRect(borderImageRect.x() + leftWidth, borderImageRect.maxY() - bottomWidth, 1060 graphicsContext->drawTiledImage(image.get(), IntRect(borderImageRect.x() + leftWidth, borderImageRect.maxY() - bottomWidth,
1060 destinationWidth, bottomWidth), 1061 destinationWidth, bottomWidth),
1061 IntRect(leftSlice, imageHeight - bottomS lice, sourceWidth, bottomSlice), 1062 IntRect(leftSlice, imageHeight - bottomS lice, sourceWidth, bottomSlice),
1062 FloatSize(bottomSideScale, bottomSideSca le), 1063 FloatSize(bottomSideScale, bottomSideSca le),
1063 (Image::TileRule)hRule, Image::StretchTi le, op); 1064 (Image::TileRule)hRule, Image::StretchTi le, CompositeSourceOver);
1064 1065
1065 // Paint the middle. 1066 // Paint the middle.
1066 if (drawMiddle) { 1067 if (drawMiddle) {
1067 FloatSize middleScaleFactor(1, 1); 1068 FloatSize middleScaleFactor(1, 1);
1068 if (drawTop) 1069 if (drawTop)
1069 middleScaleFactor.setWidth(topSideScale); 1070 middleScaleFactor.setWidth(topSideScale);
1070 else if (drawBottom) 1071 else if (drawBottom)
1071 middleScaleFactor.setWidth(bottomSideScale); 1072 middleScaleFactor.setWidth(bottomSideScale);
1072 if (drawLeft) 1073 if (drawLeft)
1073 middleScaleFactor.setHeight(leftSideScale); 1074 middleScaleFactor.setHeight(leftSideScale);
1074 else if (drawRight) 1075 else if (drawRight)
1075 middleScaleFactor.setHeight(rightSideScale); 1076 middleScaleFactor.setHeight(rightSideScale);
1076 1077
1077 // For "stretch" rules, just override the scale factor and replace. We o nly had to do this for the 1078 // For "stretch" rules, just override the scale factor and replace. We o nly had to do this for the
1078 // center tile, since sides don't even use the scale factor unless they have a rule other than "stretch". 1079 // center tile, since sides don't even use the scale factor unless they have a rule other than "stretch".
1079 // The middle however can have "stretch" specified in one axis but not t he other, so we have to 1080 // The middle however can have "stretch" specified in one axis but not t he other, so we have to
1080 // correct the scale here. 1081 // correct the scale here.
1081 if (hRule == StretchImageRule) 1082 if (hRule == StretchImageRule)
1082 middleScaleFactor.setWidth(destinationWidth / sourceWidth); 1083 middleScaleFactor.setWidth(destinationWidth / sourceWidth);
1083 1084
1084 if (vRule == StretchImageRule) 1085 if (vRule == StretchImageRule)
1085 middleScaleFactor.setHeight(destinationHeight / sourceHeight); 1086 middleScaleFactor.setHeight(destinationHeight / sourceHeight);
1086 1087
1087 graphicsContext->drawTiledImage(image.get(), 1088 graphicsContext->drawTiledImage(image.get(),
1088 IntRect(borderImageRect.x() + leftWidth, borderImageRect.y() + topWi dth, destinationWidth, destinationHeight), 1089 IntRect(borderImageRect.x() + leftWidth, borderImageRect.y() + topWi dth, destinationWidth, destinationHeight),
1089 IntRect(leftSlice, topSlice, sourceWidth, sourceHeight), 1090 IntRect(leftSlice, topSlice, sourceWidth, sourceHeight),
1090 middleScaleFactor, (Image::TileRule)hRule, (Image::TileRule)vRule, o p); 1091 middleScaleFactor, (Image::TileRule)hRule, (Image::TileRule)vRule, C ompositeSourceOver);
1091 } 1092 }
1092 1093
1093 return true; 1094 return true;
1094 } 1095 }
1095 1096
1096 class BorderEdge { 1097 class BorderEdge {
1097 public: 1098 public:
1098 BorderEdge(int edgeWidth, const Color& edgeColor, EBorderStyle edgeStyle, bo ol edgeIsTransparent, bool edgeIsPresent = true) 1099 BorderEdge(int edgeWidth, const Color& edgeColor, EBorderStyle edgeStyle, bo ol edgeIsTransparent, bool edgeIsPresent = true)
1099 : width(edgeWidth) 1100 : width(edgeWidth)
1100 , color(edgeColor) 1101 , color(edgeColor)
(...skipping 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after
2528 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent()); 2529 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent());
2529 for (RenderObject* child = slowFirstChild(); child; ) { 2530 for (RenderObject* child = slowFirstChild(); child; ) {
2530 // Save our next sibling as moveChildTo will clear it. 2531 // Save our next sibling as moveChildTo will clear it.
2531 RenderObject* nextSibling = child->nextSibling(); 2532 RenderObject* nextSibling = child->nextSibling();
2532 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert); 2533 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert);
2533 child = nextSibling; 2534 child = nextSibling;
2534 } 2535 }
2535 } 2536 }
2536 2537
2537 } // namespace blink 2538 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/RenderBoxModelObject.h ('k') | sky/engine/core/rendering/RenderLayer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698