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

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

Issue 886263003: Remove mask painting. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: fix comment Created 5 years, 10 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
« no previous file with comments | « sky/engine/core/rendering/InlineFlowBox.h ('k') | sky/engine/core/rendering/PaintPhase.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 } 990 }
991 991
992 void InlineFlowBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom) 992 void InlineFlowBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom)
993 { 993 {
994 LayoutRect overflowRect(visualOverflowRect(lineTop, lineBottom)); 994 LayoutRect overflowRect(visualOverflowRect(lineTop, lineBottom));
995 overflowRect.moveBy(paintOffset); 995 overflowRect.moveBy(paintOffset);
996 996
997 if (!paintInfo.rect.intersects(pixelSnappedIntRect(overflowRect))) 997 if (!paintInfo.rect.intersects(pixelSnappedIntRect(overflowRect)))
998 return; 998 return;
999 999
1000 if (paintInfo.phase == PaintPhaseMask) {
1001 paintMask(paintInfo, paintOffset);
1002 return;
1003 }
1004
1005 paintBoxDecorationBackground(paintInfo, paintOffset); 1000 paintBoxDecorationBackground(paintInfo, paintOffset);
1006 1001
1007 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { 1002 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
1008 if (curr->renderer().isText() || !curr->boxModelObject()->hasSelfPaintin gLayer()) 1003 if (curr->renderer().isText() || !curr->boxModelObject()->hasSelfPaintin gLayer())
1009 curr->paint(paintInfo, paintOffset, lineTop, lineBottom); 1004 curr->paint(paintInfo, paintOffset, lineTop, lineBottom);
1010 } 1005 }
1011 } 1006 }
1012 1007
1013 void InlineFlowBox::paintFillLayers(const PaintInfo& paintInfo, const Color& c, const FillLayer& fillLayer, const LayoutRect& rect) 1008 void InlineFlowBox::paintFillLayers(const PaintInfo& paintInfo, const Color& c, const FillLayer& fillLayer, const LayoutRect& rect)
1014 { 1009 {
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 LayoutUnit stripHeight = frameRect.height(); 1156 LayoutUnit stripHeight = frameRect.height();
1162 1157
1163 LayoutRect clipRect = clipRectForNinePieceImageStrip(this, borderIma ge, paintRect); 1158 LayoutRect clipRect = clipRectForNinePieceImageStrip(this, borderIma ge, paintRect);
1164 GraphicsContextStateSaver stateSaver(*paintInfo.context); 1159 GraphicsContextStateSaver stateSaver(*paintInfo.context);
1165 paintInfo.context->clip(clipRect); 1160 paintInfo.context->clip(clipRect);
1166 boxModelObject()->paintBorder(paintInfo, LayoutRect(stripX, stripY, stripWidth, stripHeight), renderer().style(isFirstLineStyle())); 1161 boxModelObject()->paintBorder(paintInfo, LayoutRect(stripX, stripY, stripWidth, stripHeight), renderer().style(isFirstLineStyle()));
1167 } 1162 }
1168 } 1163 }
1169 } 1164 }
1170 1165
1171 void InlineFlowBox::paintMask(PaintInfo& paintInfo, const LayoutPoint& paintOffs et)
1172 {
1173 // Pixel snap mask painting.
1174 LayoutRect frameRect = roundedFrameRect();
1175
1176 // Move x/y to our coordinates.
1177 LayoutRect localRect(frameRect);
1178 LayoutPoint adjustedPaintOffset = paintOffset + localRect.location();
1179
1180 const NinePieceImage& maskNinePieceImage = renderer().style()->maskBoxImage( );
1181 StyleImage* maskBoxImage = renderer().style()->maskBoxImage().image();
1182
1183 LayoutRect paintRect = LayoutRect(adjustedPaintOffset, frameRect.size());
1184 paintFillLayers(paintInfo, Color::transparent, renderer().style()->maskLayer s(), paintRect);
1185
1186 bool hasBoxImage = maskBoxImage && maskBoxImage->canRender(renderer());
1187 if (!hasBoxImage || !maskBoxImage->isLoaded()) {
1188 return; // Don't paint anything while we wait for the image to load.
1189 }
1190
1191 // The simple case is where we are the only box for this object. In those
1192 // cases only a single call to draw is required.
1193 if (!prevLineBox() && !nextLineBox()) {
1194 boxModelObject()->paintNinePieceImage(paintInfo.context, LayoutRect(adju stedPaintOffset, frameRect.size()), renderer().style(), maskNinePieceImage);
1195 } else {
1196 // We have a mask image that spans multiple lines.
1197 // We need to adjust _tx and _ty by the width of all previous lines.
1198 LayoutUnit logicalOffsetOnLine = 0;
1199 for (InlineFlowBox* curr = prevLineBox(); curr; curr = curr->prevLineBox ())
1200 logicalOffsetOnLine += curr->logicalWidth();
1201 LayoutUnit totalLogicalWidth = logicalOffsetOnLine;
1202 for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox())
1203 totalLogicalWidth += curr->logicalWidth();
1204 LayoutUnit stripX = adjustedPaintOffset.x() - logicalOffsetOnLine;
1205 LayoutUnit stripY = adjustedPaintOffset.y();
1206 LayoutUnit stripWidth = totalLogicalWidth;
1207 LayoutUnit stripHeight = frameRect.height();
1208
1209 LayoutRect clipRect = clipRectForNinePieceImageStrip(this, maskNinePiece Image, paintRect);
1210 GraphicsContextStateSaver stateSaver(*paintInfo.context);
1211 paintInfo.context->clip(clipRect);
1212 boxModelObject()->paintNinePieceImage(paintInfo.context, LayoutRect(stri pX, stripY, stripWidth, stripHeight), renderer().style(), maskNinePieceImage);
1213 }
1214 }
1215
1216 InlineBox* InlineFlowBox::firstLeafChild() const 1166 InlineBox* InlineFlowBox::firstLeafChild() const
1217 { 1167 {
1218 InlineBox* leaf = 0; 1168 InlineBox* leaf = 0;
1219 for (InlineBox* child = firstChild(); child && !leaf; child = child->nextOnL ine()) 1169 for (InlineBox* child = firstChild(); child && !leaf; child = child->nextOnL ine())
1220 leaf = child->isLeaf() ? child : toInlineFlowBox(child)->firstLeafChild( ); 1170 leaf = child->isLeaf() ? child : toInlineFlowBox(child)->firstLeafChild( );
1221 return leaf; 1171 return leaf;
1222 } 1172 }
1223 1173
1224 InlineBox* InlineFlowBox::lastLeafChild() const 1174 InlineBox* InlineFlowBox::lastLeafChild() const
1225 { 1175 {
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 ASSERT(child->prevOnLine() == prev); 1352 ASSERT(child->prevOnLine() == prev);
1403 prev = child; 1353 prev = child;
1404 } 1354 }
1405 ASSERT(prev == m_lastChild); 1355 ASSERT(prev == m_lastChild);
1406 #endif 1356 #endif
1407 } 1357 }
1408 1358
1409 #endif 1359 #endif
1410 1360
1411 } // namespace blink 1361 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/InlineFlowBox.h ('k') | sky/engine/core/rendering/PaintPhase.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698