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

Side by Side Diff: Source/core/html/canvas/CanvasRenderingContext2D.cpp

Issue 672593002: 2D canvas: fix shadow rendering with "copy" compositing mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 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 | « LayoutTests/fast/canvas/canvas-composite-shadow.html ('k') | no next file » | 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) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> 4 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> 5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> 6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org>
7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
8 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved. 8 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved.
9 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 9 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
10 * 10 *
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 } 1026 }
1027 1027
1028 WindRule windRule = c->fillRule(); 1028 WindRule windRule = c->fillRule();
1029 c->setFillRule(parseWinding(windingRuleString)); 1029 c->setFillRule(parseWinding(windingRuleString));
1030 1030
1031 if (isFullCanvasCompositeMode(state().m_globalComposite)) { 1031 if (isFullCanvasCompositeMode(state().m_globalComposite)) {
1032 fullCanvasCompositedDraw(bind(&GraphicsContext::fillPath, c, path)); 1032 fullCanvasCompositedDraw(bind(&GraphicsContext::fillPath, c, path));
1033 didDraw(clipBounds); 1033 didDraw(clipBounds);
1034 } else if (state().m_globalComposite == CompositeCopy) { 1034 } else if (state().m_globalComposite == CompositeCopy) {
1035 clearCanvas(); 1035 clearCanvas();
1036 c->clearShadow();
1036 c->fillPath(path); 1037 c->fillPath(path);
1038 applyShadow(DrawShadowAndForeground);
1037 didDraw(clipBounds); 1039 didDraw(clipBounds);
1038 } else { 1040 } else {
1039 FloatRect dirtyRect; 1041 FloatRect dirtyRect;
1040 if (computeDirtyRect(path.boundingRect(), clipBounds, &dirtyRect)) { 1042 if (computeDirtyRect(path.boundingRect(), clipBounds, &dirtyRect)) {
1041 c->fillPath(path); 1043 c->fillPath(path);
1042 didDraw(dirtyRect); 1044 didDraw(dirtyRect);
1043 } 1045 }
1044 } 1046 }
1045 1047
1046 c->setFillRule(windRule); 1048 c->setFillRule(windRule);
(...skipping 29 matching lines...) Expand all
1076 Gradient* gradient = c->strokeGradient(); 1078 Gradient* gradient = c->strokeGradient();
1077 if (gradient && gradient->isZeroSize()) { 1079 if (gradient && gradient->isZeroSize()) {
1078 return; 1080 return;
1079 } 1081 }
1080 1082
1081 if (isFullCanvasCompositeMode(state().m_globalComposite)) { 1083 if (isFullCanvasCompositeMode(state().m_globalComposite)) {
1082 fullCanvasCompositedDraw(bind(&GraphicsContext::strokePath, c, path)); 1084 fullCanvasCompositedDraw(bind(&GraphicsContext::strokePath, c, path));
1083 didDraw(clipBounds); 1085 didDraw(clipBounds);
1084 } else if (state().m_globalComposite == CompositeCopy) { 1086 } else if (state().m_globalComposite == CompositeCopy) {
1085 clearCanvas(); 1087 clearCanvas();
1088 c->clearShadow();
1086 c->strokePath(path); 1089 c->strokePath(path);
1090 applyShadow(DrawShadowAndForeground);
1087 didDraw(clipBounds); 1091 didDraw(clipBounds);
1088 } else { 1092 } else {
1089 FloatRect bounds = path.boundingRect(); 1093 FloatRect bounds = path.boundingRect();
1090 inflateStrokeRect(bounds); 1094 inflateStrokeRect(bounds);
1091 FloatRect dirtyRect; 1095 FloatRect dirtyRect;
1092 if (computeDirtyRect(bounds, clipBounds, &dirtyRect)) { 1096 if (computeDirtyRect(bounds, clipBounds, &dirtyRect)) {
1093 c->strokePath(path); 1097 c->strokePath(path);
1094 didDraw(dirtyRect); 1098 didDraw(dirtyRect);
1095 } 1099 }
1096 } 1100 }
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 1310
1307 FloatRect rect(x, y, width, height); 1311 FloatRect rect(x, y, width, height);
1308 if (rectContainsTransformedRect(rect, clipBounds)) { 1312 if (rectContainsTransformedRect(rect, clipBounds)) {
1309 c->fillRect(rect); 1313 c->fillRect(rect);
1310 didDraw(clipBounds); 1314 didDraw(clipBounds);
1311 } else if (isFullCanvasCompositeMode(state().m_globalComposite)) { 1315 } else if (isFullCanvasCompositeMode(state().m_globalComposite)) {
1312 fullCanvasCompositedDraw(bind(&fillRectOnContext, c, rect)); 1316 fullCanvasCompositedDraw(bind(&fillRectOnContext, c, rect));
1313 didDraw(clipBounds); 1317 didDraw(clipBounds);
1314 } else if (state().m_globalComposite == CompositeCopy) { 1318 } else if (state().m_globalComposite == CompositeCopy) {
1315 clearCanvas(); 1319 clearCanvas();
1320 c->clearShadow();
1316 c->fillRect(rect); 1321 c->fillRect(rect);
1322 applyShadow(DrawShadowAndForeground);
1317 didDraw(clipBounds); 1323 didDraw(clipBounds);
1318 } else { 1324 } else {
1319 FloatRect dirtyRect; 1325 FloatRect dirtyRect;
1320 if (computeDirtyRect(rect, clipBounds, &dirtyRect)) { 1326 if (computeDirtyRect(rect, clipBounds, &dirtyRect)) {
1321 c->fillRect(rect); 1327 c->fillRect(rect);
1322 didDraw(dirtyRect); 1328 didDraw(dirtyRect);
1323 } 1329 }
1324 } 1330 }
1325 } 1331 }
1326 1332
(...skipping 18 matching lines...) Expand all
1345 Gradient* gradient = c->strokeGradient(); 1351 Gradient* gradient = c->strokeGradient();
1346 if (gradient && gradient->isZeroSize()) 1352 if (gradient && gradient->isZeroSize())
1347 return; 1353 return;
1348 1354
1349 FloatRect rect(x, y, width, height); 1355 FloatRect rect(x, y, width, height);
1350 if (isFullCanvasCompositeMode(state().m_globalComposite)) { 1356 if (isFullCanvasCompositeMode(state().m_globalComposite)) {
1351 fullCanvasCompositedDraw(bind(&strokeRectOnContext, c, rect)); 1357 fullCanvasCompositedDraw(bind(&strokeRectOnContext, c, rect));
1352 didDraw(clipBounds); 1358 didDraw(clipBounds);
1353 } else if (state().m_globalComposite == CompositeCopy) { 1359 } else if (state().m_globalComposite == CompositeCopy) {
1354 clearCanvas(); 1360 clearCanvas();
1361 c->clearShadow();
1355 c->strokeRect(rect); 1362 c->strokeRect(rect);
1363 applyShadow(DrawShadowAndForeground);
1356 didDraw(clipBounds); 1364 didDraw(clipBounds);
1357 } else { 1365 } else {
1358 FloatRect boundingRect = rect; 1366 FloatRect boundingRect = rect;
1359 boundingRect.inflate(state().m_lineWidth / 2); 1367 boundingRect.inflate(state().m_lineWidth / 2);
1360 FloatRect dirtyRect; 1368 FloatRect dirtyRect;
1361 if (computeDirtyRect(boundingRect, clipBounds, &dirtyRect)) { 1369 if (computeDirtyRect(boundingRect, clipBounds, &dirtyRect)) {
1362 c->strokeRect(rect); 1370 c->strokeRect(rect);
1363 didDraw(dirtyRect); 1371 didDraw(dirtyRect);
1364 } 1372 }
1365 } 1373 }
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
2205 FloatRect clipBounds; 2213 FloatRect clipBounds;
2206 if (!c->getTransformedClipBounds(&clipBounds)) { 2214 if (!c->getTransformedClipBounds(&clipBounds)) {
2207 return; 2215 return;
2208 } 2216 }
2209 2217
2210 if (isFullCanvasCompositeMode(state().m_globalComposite)) { 2218 if (isFullCanvasCompositeMode(state().m_globalComposite)) {
2211 fullCanvasCompositedDraw(bind(&GraphicsContext::drawBidiText, c, font, t extRunPaintInfo, location, Font::UseFallbackIfFontNotReady)); 2219 fullCanvasCompositedDraw(bind(&GraphicsContext::drawBidiText, c, font, t extRunPaintInfo, location, Font::UseFallbackIfFontNotReady));
2212 didDraw(clipBounds); 2220 didDraw(clipBounds);
2213 } else if (state().m_globalComposite == CompositeCopy) { 2221 } else if (state().m_globalComposite == CompositeCopy) {
2214 clearCanvas(); 2222 clearCanvas();
2223 c->clearShadow();
2215 c->drawBidiText(font, textRunPaintInfo, location, Font::UseFallbackIfFon tNotReady); 2224 c->drawBidiText(font, textRunPaintInfo, location, Font::UseFallbackIfFon tNotReady);
2225 applyShadow(DrawShadowAndForeground);
2216 didDraw(clipBounds); 2226 didDraw(clipBounds);
2217 } else { 2227 } else {
2218 FloatRect dirtyRect; 2228 FloatRect dirtyRect;
2219 if (computeDirtyRect(textRunPaintInfo.bounds, clipBounds, &dirtyRect)) { 2229 if (computeDirtyRect(textRunPaintInfo.bounds, clipBounds, &dirtyRect)) {
2220 c->drawBidiText(font, textRunPaintInfo, location, Font::UseFallbackI fFontNotReady); 2230 c->drawBidiText(font, textRunPaintInfo, location, Font::UseFallbackI fFontNotReady);
2221 didDraw(dirtyRect); 2231 didDraw(dirtyRect);
2222 } 2232 }
2223 } 2233 }
2224 } 2234 }
2225 2235
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
2431 2441
2432 unsigned CanvasRenderingContext2D::hitRegionsCount() const 2442 unsigned CanvasRenderingContext2D::hitRegionsCount() const
2433 { 2443 {
2434 if (m_hitRegionManager) 2444 if (m_hitRegionManager)
2435 return m_hitRegionManager->getHitRegionsCount(); 2445 return m_hitRegionManager->getHitRegionsCount();
2436 2446
2437 return 0; 2447 return 0;
2438 } 2448 }
2439 2449
2440 } // namespace blink 2450 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/canvas/canvas-composite-shadow.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698