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

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

Issue 661053003: Make beginLayer() and CanvasRenderingContext2D use SkXfermode::Mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase to ToT Created 5 years, 11 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) 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 : m_unrealizedSaveCount(0) 268 : m_unrealizedSaveCount(0)
269 , m_strokeStyle(CanvasStyle::createFromRGBA(Color::black)) 269 , m_strokeStyle(CanvasStyle::createFromRGBA(Color::black))
270 , m_fillStyle(CanvasStyle::createFromRGBA(Color::black)) 270 , m_fillStyle(CanvasStyle::createFromRGBA(Color::black))
271 , m_lineWidth(1) 271 , m_lineWidth(1)
272 , m_lineCap(ButtCap) 272 , m_lineCap(ButtCap)
273 , m_lineJoin(MiterJoin) 273 , m_lineJoin(MiterJoin)
274 , m_miterLimit(10) 274 , m_miterLimit(10)
275 , m_shadowBlur(0) 275 , m_shadowBlur(0)
276 , m_shadowColor(Color::transparent) 276 , m_shadowColor(Color::transparent)
277 , m_globalAlpha(1) 277 , m_globalAlpha(1)
278 , m_globalComposite(CompositeSourceOver) 278 , m_globalComposite(SkXfermode::kSrcOver_Mode)
279 , m_globalBlend(WebBlendModeNormal)
280 , m_invertibleCTM(true) 279 , m_invertibleCTM(true)
281 , m_lineDashOffset(0) 280 , m_lineDashOffset(0)
282 , m_imageSmoothingEnabled(true) 281 , m_imageSmoothingEnabled(true)
283 , m_textAlign(StartTextAlign) 282 , m_textAlign(StartTextAlign)
284 , m_textBaseline(AlphabeticTextBaseline) 283 , m_textBaseline(AlphabeticTextBaseline)
285 , m_direction(DirectionInherit) 284 , m_direction(DirectionInherit)
286 , m_unparsedFont(defaultFont) 285 , m_unparsedFont(defaultFont)
287 , m_realizedFont(false) 286 , m_realizedFont(false)
288 , m_hasClip(false) 287 , m_hasClip(false)
289 { 288 {
290 } 289 }
291 290
292 CanvasRenderingContext2D::State::State(const State& other, ClipListCopyMode mode ) 291 CanvasRenderingContext2D::State::State(const State& other, ClipListCopyMode mode )
293 : CSSFontSelectorClient() 292 : CSSFontSelectorClient()
294 , m_unrealizedSaveCount(other.m_unrealizedSaveCount) 293 , m_unrealizedSaveCount(other.m_unrealizedSaveCount)
295 , m_unparsedStrokeColor(other.m_unparsedStrokeColor) 294 , m_unparsedStrokeColor(other.m_unparsedStrokeColor)
296 , m_unparsedFillColor(other.m_unparsedFillColor) 295 , m_unparsedFillColor(other.m_unparsedFillColor)
297 , m_strokeStyle(other.m_strokeStyle) 296 , m_strokeStyle(other.m_strokeStyle)
298 , m_fillStyle(other.m_fillStyle) 297 , m_fillStyle(other.m_fillStyle)
299 , m_lineWidth(other.m_lineWidth) 298 , m_lineWidth(other.m_lineWidth)
300 , m_lineCap(other.m_lineCap) 299 , m_lineCap(other.m_lineCap)
301 , m_lineJoin(other.m_lineJoin) 300 , m_lineJoin(other.m_lineJoin)
302 , m_miterLimit(other.m_miterLimit) 301 , m_miterLimit(other.m_miterLimit)
303 , m_shadowOffset(other.m_shadowOffset) 302 , m_shadowOffset(other.m_shadowOffset)
304 , m_shadowBlur(other.m_shadowBlur) 303 , m_shadowBlur(other.m_shadowBlur)
305 , m_shadowColor(other.m_shadowColor) 304 , m_shadowColor(other.m_shadowColor)
306 , m_globalAlpha(other.m_globalAlpha) 305 , m_globalAlpha(other.m_globalAlpha)
307 , m_globalComposite(other.m_globalComposite) 306 , m_globalComposite(other.m_globalComposite)
308 , m_globalBlend(other.m_globalBlend)
309 , m_transform(other.m_transform) 307 , m_transform(other.m_transform)
310 , m_invertibleCTM(other.m_invertibleCTM) 308 , m_invertibleCTM(other.m_invertibleCTM)
311 , m_lineDashOffset(other.m_lineDashOffset) 309 , m_lineDashOffset(other.m_lineDashOffset)
312 , m_imageSmoothingEnabled(other.m_imageSmoothingEnabled) 310 , m_imageSmoothingEnabled(other.m_imageSmoothingEnabled)
313 , m_textAlign(other.m_textAlign) 311 , m_textAlign(other.m_textAlign)
314 , m_textBaseline(other.m_textBaseline) 312 , m_textBaseline(other.m_textBaseline)
315 , m_direction(other.m_direction) 313 , m_direction(other.m_direction)
316 , m_unparsedFont(other.m_unparsedFont) 314 , m_unparsedFont(other.m_unparsedFont)
317 , m_font(other.m_font) 315 , m_font(other.m_font)
318 , m_realizedFont(other.m_realizedFont) 316 , m_realizedFont(other.m_realizedFont)
(...skipping 23 matching lines...) Expand all
342 m_fillStyle = other.m_fillStyle; 340 m_fillStyle = other.m_fillStyle;
343 m_lineWidth = other.m_lineWidth; 341 m_lineWidth = other.m_lineWidth;
344 m_lineCap = other.m_lineCap; 342 m_lineCap = other.m_lineCap;
345 m_lineJoin = other.m_lineJoin; 343 m_lineJoin = other.m_lineJoin;
346 m_miterLimit = other.m_miterLimit; 344 m_miterLimit = other.m_miterLimit;
347 m_shadowOffset = other.m_shadowOffset; 345 m_shadowOffset = other.m_shadowOffset;
348 m_shadowBlur = other.m_shadowBlur; 346 m_shadowBlur = other.m_shadowBlur;
349 m_shadowColor = other.m_shadowColor; 347 m_shadowColor = other.m_shadowColor;
350 m_globalAlpha = other.m_globalAlpha; 348 m_globalAlpha = other.m_globalAlpha;
351 m_globalComposite = other.m_globalComposite; 349 m_globalComposite = other.m_globalComposite;
352 m_globalBlend = other.m_globalBlend;
353 m_transform = other.m_transform; 350 m_transform = other.m_transform;
354 m_invertibleCTM = other.m_invertibleCTM; 351 m_invertibleCTM = other.m_invertibleCTM;
355 m_imageSmoothingEnabled = other.m_imageSmoothingEnabled; 352 m_imageSmoothingEnabled = other.m_imageSmoothingEnabled;
356 m_textAlign = other.m_textAlign; 353 m_textAlign = other.m_textAlign;
357 m_textBaseline = other.m_textBaseline; 354 m_textBaseline = other.m_textBaseline;
358 m_direction = other.m_direction; 355 m_direction = other.m_direction;
359 m_unparsedFont = other.m_unparsedFont; 356 m_unparsedFont = other.m_unparsedFont;
360 m_font = other.m_font; 357 m_font = other.m_font;
361 m_realizedFont = other.m_realizedFont; 358 m_realizedFont = other.m_realizedFont;
362 m_hasClip = other.m_hasClip; 359 m_hasClip = other.m_hasClip;
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 GraphicsContext* c = drawingContext(); 747 GraphicsContext* c = drawingContext();
751 realizeSaves(c); 748 realizeSaves(c);
752 modifiableState().m_globalAlpha = alpha; 749 modifiableState().m_globalAlpha = alpha;
753 if (!c) 750 if (!c)
754 return; 751 return;
755 c->setAlphaAsFloat(alpha); 752 c->setAlphaAsFloat(alpha);
756 } 753 }
757 754
758 String CanvasRenderingContext2D::globalCompositeOperation() const 755 String CanvasRenderingContext2D::globalCompositeOperation() const
759 { 756 {
760 return compositeOperatorName(state().m_globalComposite, state().m_globalBlen d); 757 return compositeOperatorName(compositeOperatorFromSkia(state().m_globalCompo site), blendModeFromSkia(state().m_globalComposite));
761 } 758 }
762 759
763 void CanvasRenderingContext2D::setGlobalCompositeOperation(const String& operati on) 760 void CanvasRenderingContext2D::setGlobalCompositeOperation(const String& operati on)
764 { 761 {
765 CompositeOperator op = CompositeSourceOver; 762 CompositeOperator op = CompositeSourceOver;
766 WebBlendMode blendMode = WebBlendModeNormal; 763 WebBlendMode blendMode = WebBlendModeNormal;
767 if (!parseCompositeAndBlendOperator(operation, op, blendMode)) 764 if (!parseCompositeAndBlendOperator(operation, op, blendMode))
768 return; 765 return;
769 if ((state().m_globalComposite == op) && (state().m_globalBlend == blendMode )) 766 SkXfermode::Mode xfermode = WebCoreCompositeToSkiaComposite(op, blendMode);
767 if (state().m_globalComposite == xfermode)
770 return; 768 return;
771 GraphicsContext* c = drawingContext(); 769 GraphicsContext* c = drawingContext();
772 realizeSaves(c); 770 realizeSaves(c);
773 modifiableState().m_globalComposite = op; 771 modifiableState().m_globalComposite = xfermode;
774 modifiableState().m_globalBlend = blendMode;
775 if (!c) 772 if (!c)
776 return; 773 return;
777 c->setCompositeOperation(op, blendMode); 774 c->setCompositeOperation(xfermode);
778 } 775 }
779 776
780 void CanvasRenderingContext2D::setCurrentTransform(PassRefPtrWillBeRawPtr<SVGMat rixTearOff> passMatrixTearOff) 777 void CanvasRenderingContext2D::setCurrentTransform(PassRefPtrWillBeRawPtr<SVGMat rixTearOff> passMatrixTearOff)
781 { 778 {
782 RefPtrWillBeRawPtr<SVGMatrixTearOff> matrixTearOff = passMatrixTearOff; 779 RefPtrWillBeRawPtr<SVGMatrixTearOff> matrixTearOff = passMatrixTearOff;
783 const AffineTransform& transform = matrixTearOff->value(); 780 const AffineTransform& transform = matrixTearOff->value();
784 setTransform(transform.a(), transform.b(), transform.c(), transform.d(), tra nsform.e(), transform.f()); 781 setTransform(transform.a(), transform.b(), transform.c(), transform.d(), tra nsform.e(), transform.f());
785 } 782 }
786 783
787 void CanvasRenderingContext2D::scale(float sx, float sy) 784 void CanvasRenderingContext2D::scale(float sx, float sy)
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 } 950 }
954 951
955 if (height < 0) { 952 if (height < 0) {
956 height = -height; 953 height = -height;
957 y -= height; 954 y -= height;
958 } 955 }
959 956
960 return true; 957 return true;
961 } 958 }
962 959
963 static bool isFullCanvasCompositeMode(CompositeOperator op) 960 static bool isFullCanvasCompositeMode(SkXfermode::Mode op)
964 { 961 {
965 // See 4.8.11.1.3 Compositing 962 // See 4.8.11.1.3 Compositing
966 // CompositeSourceAtop and CompositeDestinationOut are not listed here as th e platforms already 963 // CompositeSourceAtop and CompositeDestinationOut are not listed here as th e platforms already
967 // implement the specification's behavior. 964 // implement the specification's behavior.
968 return op == CompositeSourceIn || op == CompositeSourceOut || op == Composit eDestinationIn || op == CompositeDestinationAtop; 965 return op == SkXfermode::kSrcIn_Mode || op == SkXfermode::kSrcOut_Mode || op == SkXfermode::kDstIn_Mode || op == SkXfermode::kDstATop_Mode;
969 } 966 }
970 967
971 static WindRule parseWinding(const String& windingRuleString) 968 static WindRule parseWinding(const String& windingRuleString)
972 { 969 {
973 if (windingRuleString == "nonzero") 970 if (windingRuleString == "nonzero")
974 return RULE_NONZERO; 971 return RULE_NONZERO;
975 if (windingRuleString == "evenodd") 972 if (windingRuleString == "evenodd")
976 return RULE_EVENODD; 973 return RULE_EVENODD;
977 974
978 ASSERT_NOT_REACHED(); 975 ASSERT_NOT_REACHED();
(...skipping 22 matching lines...) Expand all
1001 if (gradient && gradient->isZeroSize()) { 998 if (gradient && gradient->isZeroSize()) {
1002 return; 999 return;
1003 } 1000 }
1004 1001
1005 WindRule windRule = c->fillRule(); 1002 WindRule windRule = c->fillRule();
1006 c->setFillRule(parseWinding(windingRuleString)); 1003 c->setFillRule(parseWinding(windingRuleString));
1007 1004
1008 if (isFullCanvasCompositeMode(state().m_globalComposite)) { 1005 if (isFullCanvasCompositeMode(state().m_globalComposite)) {
1009 fullCanvasCompositedDraw(bind(&GraphicsContext::fillPath, c, path)); 1006 fullCanvasCompositedDraw(bind(&GraphicsContext::fillPath, c, path));
1010 didDraw(clipBounds); 1007 didDraw(clipBounds);
1011 } else if (state().m_globalComposite == CompositeCopy) { 1008 } else if (state().m_globalComposite == SkXfermode::kSrc_Mode) {
1012 clearCanvas(); 1009 clearCanvas();
1013 c->clearShadow(); 1010 c->clearShadow();
1014 c->fillPath(path); 1011 c->fillPath(path);
1015 applyShadow(DrawShadowAndForeground); 1012 applyShadow(DrawShadowAndForeground);
1016 didDraw(clipBounds); 1013 didDraw(clipBounds);
1017 } else { 1014 } else {
1018 FloatRect dirtyRect; 1015 FloatRect dirtyRect;
1019 if (computeDirtyRect(path.boundingRect(), clipBounds, &dirtyRect)) { 1016 if (computeDirtyRect(path.boundingRect(), clipBounds, &dirtyRect)) {
1020 c->fillPath(path); 1017 c->fillPath(path);
1021 didDraw(dirtyRect); 1018 didDraw(dirtyRect);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 1050
1054 // If gradient size is zero, then paint nothing. 1051 // If gradient size is zero, then paint nothing.
1055 Gradient* gradient = c->strokeGradient(); 1052 Gradient* gradient = c->strokeGradient();
1056 if (gradient && gradient->isZeroSize()) { 1053 if (gradient && gradient->isZeroSize()) {
1057 return; 1054 return;
1058 } 1055 }
1059 1056
1060 if (isFullCanvasCompositeMode(state().m_globalComposite)) { 1057 if (isFullCanvasCompositeMode(state().m_globalComposite)) {
1061 fullCanvasCompositedDraw(bind(&GraphicsContext::strokePath, c, path)); 1058 fullCanvasCompositedDraw(bind(&GraphicsContext::strokePath, c, path));
1062 didDraw(clipBounds); 1059 didDraw(clipBounds);
1063 } else if (state().m_globalComposite == CompositeCopy) { 1060 } else if (state().m_globalComposite == SkXfermode::kSrc_Mode) {
1064 clearCanvas(); 1061 clearCanvas();
1065 c->clearShadow(); 1062 c->clearShadow();
1066 c->strokePath(path); 1063 c->strokePath(path);
1067 applyShadow(DrawShadowAndForeground); 1064 applyShadow(DrawShadowAndForeground);
1068 didDraw(clipBounds); 1065 didDraw(clipBounds);
1069 } else { 1066 } else {
1070 FloatRect bounds = path.boundingRect(); 1067 FloatRect bounds = path.boundingRect();
1071 inflateStrokeRect(bounds); 1068 inflateStrokeRect(bounds);
1072 FloatRect dirtyRect; 1069 FloatRect dirtyRect;
1073 if (computeDirtyRect(bounds, clipBounds, &dirtyRect)) { 1070 if (computeDirtyRect(bounds, clipBounds, &dirtyRect)) {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 saved = true; 1232 saved = true;
1236 context->clearShadow(); 1233 context->clearShadow();
1237 } 1234 }
1238 if (state().m_globalAlpha != 1) { 1235 if (state().m_globalAlpha != 1) {
1239 if (!saved) { 1236 if (!saved) {
1240 context->save(); 1237 context->save();
1241 saved = true; 1238 saved = true;
1242 } 1239 }
1243 context->setAlphaAsFloat(1); 1240 context->setAlphaAsFloat(1);
1244 } 1241 }
1245 if (state().m_globalComposite != CompositeSourceOver) { 1242 if (state().m_globalComposite != SkXfermode::kSrcOver_Mode) {
1246 if (!saved) { 1243 if (!saved) {
1247 context->save(); 1244 context->save();
1248 saved = true; 1245 saved = true;
1249 } 1246 }
1250 context->setCompositeOperation(CompositeSourceOver); 1247 context->setCompositeOperation(SkXfermode::kSrcOver_Mode);
1251 } 1248 }
1252 context->clearRect(rect); 1249 context->clearRect(rect);
1253 if (m_hitRegionManager) 1250 if (m_hitRegionManager)
1254 m_hitRegionManager->removeHitRegionsInRect(rect, state().m_transform); 1251 m_hitRegionManager->removeHitRegionsInRect(rect, state().m_transform);
1255 if (saved) 1252 if (saved)
1256 context->restore(); 1253 context->restore();
1257 1254
1258 validateStateStack(); 1255 validateStateStack();
1259 didDraw(dirtyRect); 1256 didDraw(dirtyRect);
1260 } 1257 }
(...skipping 30 matching lines...) Expand all
1291 if (gradient && gradient->isZeroSize()) 1288 if (gradient && gradient->isZeroSize())
1292 return; 1289 return;
1293 1290
1294 FloatRect rect(x, y, width, height); 1291 FloatRect rect(x, y, width, height);
1295 if (rectContainsTransformedRect(rect, clipBounds)) { 1292 if (rectContainsTransformedRect(rect, clipBounds)) {
1296 c->fillRect(rect); 1293 c->fillRect(rect);
1297 didDraw(clipBounds); 1294 didDraw(clipBounds);
1298 } else if (isFullCanvasCompositeMode(state().m_globalComposite)) { 1295 } else if (isFullCanvasCompositeMode(state().m_globalComposite)) {
1299 fullCanvasCompositedDraw(bind(&fillRectOnContext, c, rect)); 1296 fullCanvasCompositedDraw(bind(&fillRectOnContext, c, rect));
1300 didDraw(clipBounds); 1297 didDraw(clipBounds);
1301 } else if (state().m_globalComposite == CompositeCopy) { 1298 } else if (state().m_globalComposite == SkXfermode::kSrc_Mode) {
1302 clearCanvas(); 1299 clearCanvas();
1303 c->clearShadow(); 1300 c->clearShadow();
1304 c->fillRect(rect); 1301 c->fillRect(rect);
1305 applyShadow(DrawShadowAndForeground); 1302 applyShadow(DrawShadowAndForeground);
1306 didDraw(clipBounds); 1303 didDraw(clipBounds);
1307 } else { 1304 } else {
1308 FloatRect dirtyRect; 1305 FloatRect dirtyRect;
1309 if (computeDirtyRect(rect, clipBounds, &dirtyRect)) { 1306 if (computeDirtyRect(rect, clipBounds, &dirtyRect)) {
1310 c->fillRect(rect); 1307 c->fillRect(rect);
1311 didDraw(dirtyRect); 1308 didDraw(dirtyRect);
(...skipping 20 matching lines...) Expand all
1332 1329
1333 // If gradient size is zero, then paint nothing. 1330 // If gradient size is zero, then paint nothing.
1334 Gradient* gradient = c->strokeGradient(); 1331 Gradient* gradient = c->strokeGradient();
1335 if (gradient && gradient->isZeroSize()) 1332 if (gradient && gradient->isZeroSize())
1336 return; 1333 return;
1337 1334
1338 FloatRect rect(x, y, width, height); 1335 FloatRect rect(x, y, width, height);
1339 if (isFullCanvasCompositeMode(state().m_globalComposite)) { 1336 if (isFullCanvasCompositeMode(state().m_globalComposite)) {
1340 fullCanvasCompositedDraw(bind(&strokeRectOnContext, c, rect)); 1337 fullCanvasCompositedDraw(bind(&strokeRectOnContext, c, rect));
1341 didDraw(clipBounds); 1338 didDraw(clipBounds);
1342 } else if (state().m_globalComposite == CompositeCopy) { 1339 } else if (state().m_globalComposite == SkXfermode::kSrc_Mode) {
1343 clearCanvas(); 1340 clearCanvas();
1344 c->clearShadow(); 1341 c->clearShadow();
1345 c->strokeRect(rect); 1342 c->strokeRect(rect);
1346 applyShadow(DrawShadowAndForeground); 1343 applyShadow(DrawShadowAndForeground);
1347 didDraw(clipBounds); 1344 didDraw(clipBounds);
1348 } else { 1345 } else {
1349 FloatRect boundingRect = rect; 1346 FloatRect boundingRect = rect;
1350 boundingRect.inflate(state().m_lineWidth / 2); 1347 boundingRect.inflate(state().m_lineWidth / 2);
1351 FloatRect dirtyRect; 1348 FloatRect dirtyRect;
1352 if (computeDirtyRect(boundingRect, clipBounds, &dirtyRect)) { 1349 if (computeDirtyRect(boundingRect, clipBounds, &dirtyRect)) {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1506 canvas()->buffer()->willDrawVideo(); 1503 canvas()->buffer()->willDrawVideo();
1507 1504
1508 // FIXME: crbug.com/447218 1505 // FIXME: crbug.com/447218
1509 // We make the destination canvas fall out of display list mode by calling 1506 // We make the destination canvas fall out of display list mode by calling
1510 // willAccessPixels. This is to prevent run-away memory consumption caused b y SkSurface 1507 // willAccessPixels. This is to prevent run-away memory consumption caused b y SkSurface
1511 // copyOnWrite when the source canvas is animated and consumed at a rate hig her than the 1508 // copyOnWrite when the source canvas is animated and consumed at a rate hig her than the
1512 // presentation frame rate of the destination canvas. 1509 // presentation frame rate of the destination canvas.
1513 if (imageSource->isCanvasElement()) 1510 if (imageSource->isCanvasElement())
1514 canvas()->buffer()->willAccessPixels(); 1511 canvas()->buffer()->willAccessPixels();
1515 1512
1516 CompositeOperator op = state().m_globalComposite;
1517 if (rectContainsTransformedRect(dstRect, clipBounds)) { 1513 if (rectContainsTransformedRect(dstRect, clipBounds)) {
1518 drawImageOnContext(c, imageSource, image.get(), srcRect, dstRect); 1514 drawImageOnContext(c, imageSource, image.get(), srcRect, dstRect);
1519 didDraw(clipBounds); 1515 didDraw(clipBounds);
1520 } else if (isFullCanvasCompositeMode(op)) { 1516 } else if (isFullCanvasCompositeMode(state().m_globalComposite)) {
1521 fullCanvasCompositedDraw(bind(&drawImageOnContext, c, imageSource, image .get(), srcRect, dstRect)); 1517 fullCanvasCompositedDraw(bind(&drawImageOnContext, c, imageSource, image .get(), srcRect, dstRect));
1522 didDraw(clipBounds); 1518 didDraw(clipBounds);
1523 } else if (op == CompositeCopy) { 1519 } else if (state().m_globalComposite == SkXfermode::kSrc_Mode) {
1524 clearCanvas(); 1520 clearCanvas();
1525 drawImageOnContext(c, imageSource, image.get(), srcRect, dstRect); 1521 drawImageOnContext(c, imageSource, image.get(), srcRect, dstRect);
1526 didDraw(clipBounds); 1522 didDraw(clipBounds);
1527 } else { 1523 } else {
1528 FloatRect dirtyRect; 1524 FloatRect dirtyRect;
1529 if (computeDirtyRect(dstRect, clipBounds, &dirtyRect)) { 1525 if (computeDirtyRect(dstRect, clipBounds, &dirtyRect)) {
1530 drawImageOnContext(c, imageSource, image.get(), srcRect, dstRect); 1526 drawImageOnContext(c, imageSource, image.get(), srcRect, dstRect);
1531 didDraw(dirtyRect); 1527 didDraw(dirtyRect);
1532 } 1528 }
1533 } 1529 }
(...skipping 26 matching lines...) Expand all
1560 return state().m_transform.mapQuad(quad).containsQuad(transformedQuad); 1556 return state().m_transform.mapQuad(quad).containsQuad(transformedQuad);
1561 } 1557 }
1562 1558
1563 void CanvasRenderingContext2D::fullCanvasCompositedDraw(PassOwnPtr<Closure> draw ) 1559 void CanvasRenderingContext2D::fullCanvasCompositedDraw(PassOwnPtr<Closure> draw )
1564 { 1560 {
1565 ASSERT(isFullCanvasCompositeMode(state().m_globalComposite)); 1561 ASSERT(isFullCanvasCompositeMode(state().m_globalComposite));
1566 1562
1567 GraphicsContext* c = drawingContext(); 1563 GraphicsContext* c = drawingContext();
1568 ASSERT(c); 1564 ASSERT(c);
1569 1565
1570 CompositeOperator previousOperator = c->compositeOperation();
1571 if (shouldDrawShadows()) { 1566 if (shouldDrawShadows()) {
1572 // unroll into two independently composited passes if drawing shadows 1567 // unroll into two independently composited passes if drawing shadows
1573 c->beginLayer(1, state().m_globalComposite); 1568 c->beginLayer(1, state().m_globalComposite);
1574 c->setCompositeOperation(CompositeSourceOver); 1569 c->setCompositeOperation(SkXfermode::kSrcOver_Mode);
1575 applyShadow(DrawShadowOnly); 1570 applyShadow(DrawShadowOnly);
1576 (*draw)(); 1571 (*draw)();
1577 c->setCompositeOperation(previousOperator); 1572 c->setCompositeOperation(state().m_globalComposite);
1578 c->endLayer(); 1573 c->endLayer();
1579 } 1574 }
1580 1575
1581 c->beginLayer(1, state().m_globalComposite); 1576 c->beginLayer(1, state().m_globalComposite);
1582 c->clearShadow(); 1577 c->clearShadow();
1583 c->setCompositeOperation(CompositeSourceOver); 1578 c->setCompositeOperation(SkXfermode::kSrcOver_Mode);
1584 (*draw)(); 1579 (*draw)();
1585 c->setCompositeOperation(previousOperator); 1580 c->setCompositeOperation(state().m_globalComposite);
1586 c->endLayer(); 1581 c->endLayer();
1587 applyShadow(DrawShadowAndForeground); // go back to normal shadows mode 1582 applyShadow(DrawShadowAndForeground); // go back to normal shadows mode
1588 } 1583 }
1589 1584
1590 PassRefPtrWillBeRawPtr<CanvasGradient> CanvasRenderingContext2D::createLinearGra dient(float x0, float y0, float x1, float y1) 1585 PassRefPtrWillBeRawPtr<CanvasGradient> CanvasRenderingContext2D::createLinearGra dient(float x0, float y0, float x1, float y1)
1591 { 1586 {
1592 RefPtrWillBeRawPtr<CanvasGradient> gradient = CanvasGradient::create(FloatPo int(x0, y0), FloatPoint(x1, y1)); 1587 RefPtrWillBeRawPtr<CanvasGradient> gradient = CanvasGradient::create(FloatPo int(x0, y0), FloatPoint(x1, y1));
1593 return gradient.release(); 1588 return gradient.release();
1594 } 1589 }
1595 1590
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
2139 } 2134 }
2140 2135
2141 FloatRect clipBounds; 2136 FloatRect clipBounds;
2142 if (!c->getTransformedClipBounds(&clipBounds)) { 2137 if (!c->getTransformedClipBounds(&clipBounds)) {
2143 return; 2138 return;
2144 } 2139 }
2145 2140
2146 if (isFullCanvasCompositeMode(state().m_globalComposite)) { 2141 if (isFullCanvasCompositeMode(state().m_globalComposite)) {
2147 fullCanvasCompositedDraw(bind(&GraphicsContext::drawBidiText, c, font, t extRunPaintInfo, location, Font::UseFallbackIfFontNotReady)); 2142 fullCanvasCompositedDraw(bind(&GraphicsContext::drawBidiText, c, font, t extRunPaintInfo, location, Font::UseFallbackIfFontNotReady));
2148 didDraw(clipBounds); 2143 didDraw(clipBounds);
2149 } else if (state().m_globalComposite == CompositeCopy) { 2144 } else if (state().m_globalComposite == SkXfermode::kSrc_Mode) {
2150 clearCanvas(); 2145 clearCanvas();
2151 c->clearShadow(); 2146 c->clearShadow();
2152 c->drawBidiText(font, textRunPaintInfo, location, Font::UseFallbackIfFon tNotReady); 2147 c->drawBidiText(font, textRunPaintInfo, location, Font::UseFallbackIfFon tNotReady);
2153 applyShadow(DrawShadowAndForeground); 2148 applyShadow(DrawShadowAndForeground);
2154 didDraw(clipBounds); 2149 didDraw(clipBounds);
2155 } else { 2150 } else {
2156 FloatRect dirtyRect; 2151 FloatRect dirtyRect;
2157 if (computeDirtyRect(textRunPaintInfo.bounds, clipBounds, &dirtyRect)) { 2152 if (computeDirtyRect(textRunPaintInfo.bounds, clipBounds, &dirtyRect)) {
2158 c->drawBidiText(font, textRunPaintInfo, location, Font::UseFallbackI fFontNotReady); 2153 c->drawBidiText(font, textRunPaintInfo, location, Font::UseFallbackI fFontNotReady);
2159 didDraw(dirtyRect); 2154 didDraw(dirtyRect);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
2291 StrokeData strokeData; 2286 StrokeData strokeData;
2292 strokeData.setThickness(focusRingWidth); 2287 strokeData.setThickness(focusRingWidth);
2293 2288
2294 FloatRect dirtyRect; 2289 FloatRect dirtyRect;
2295 if (!computeDirtyRect(path.strokeBoundingRect(strokeData), &dirtyRect)) 2290 if (!computeDirtyRect(path.strokeBoundingRect(strokeData), &dirtyRect))
2296 return; 2291 return;
2297 2292
2298 c->save(); 2293 c->save();
2299 c->setAlphaAsFloat(1.0); 2294 c->setAlphaAsFloat(1.0);
2300 c->clearShadow(); 2295 c->clearShadow();
2301 c->setCompositeOperation(CompositeSourceOver, WebBlendModeNormal); 2296 c->setCompositeOperation(SkXfermode::kSrcOver_Mode);
2302 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor); 2297 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor);
2303 c->restore(); 2298 c->restore();
2304 validateStateStack(); 2299 validateStateStack();
2305 didDraw(dirtyRect); 2300 didDraw(dirtyRect);
2306 } 2301 }
2307 2302
2308 void CanvasRenderingContext2D::addHitRegion(const HitRegionOptions& options, Exc eptionState& exceptionState) 2303 void CanvasRenderingContext2D::addHitRegion(const HitRegionOptions& options, Exc eptionState& exceptionState)
2309 { 2304 {
2310 if (options.id().isEmpty() && !options.control()) { 2305 if (options.id().isEmpty() && !options.control()) {
2311 exceptionState.throwDOMException(NotSupportedError, "Both id and control are null."); 2306 exceptionState.throwDOMException(NotSupportedError, "Both id and control are null.");
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2367 2362
2368 unsigned CanvasRenderingContext2D::hitRegionsCount() const 2363 unsigned CanvasRenderingContext2D::hitRegionsCount() const
2369 { 2364 {
2370 if (m_hitRegionManager) 2365 if (m_hitRegionManager)
2371 return m_hitRegionManager->getHitRegionsCount(); 2366 return m_hitRegionManager->getHitRegionsCount();
2372 2367
2373 return 0; 2368 return 0;
2374 } 2369 }
2375 2370
2376 } // namespace blink 2371 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/html/canvas/CanvasRenderingContext2D.h ('k') | Source/core/rendering/svg/RenderSVGResourceClipper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698