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

Side by Side Diff: third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp

Issue 1399853005: Changed CSSColorValue to return a Color (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@split_color
Patch Set: Rebase Created 5 years, 1 month 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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 void CanvasRenderingContext2D::setStrokeStyle(const StringOrCanvasGradientOrCanv asPattern& style) 377 void CanvasRenderingContext2D::setStrokeStyle(const StringOrCanvasGradientOrCanv asPattern& style)
378 { 378 {
379 ASSERT(!style.isNull()); 379 ASSERT(!style.isNull());
380 380
381 String colorString; 381 String colorString;
382 CanvasStyle* canvasStyle = nullptr; 382 CanvasStyle* canvasStyle = nullptr;
383 if (style.isString()) { 383 if (style.isString()) {
384 colorString = style.getAsString(); 384 colorString = style.getAsString();
385 if (colorString == state().unparsedStrokeColor()) 385 if (colorString == state().unparsedStrokeColor())
386 return; 386 return;
387 RGBA32 parsedColor = 0; 387 Color parsedColor = 0;
388 if (!parseColorOrCurrentColor(parsedColor, colorString, canvas())) 388 if (!parseColorOrCurrentColor(parsedColor, colorString, canvas()))
389 return; 389 return;
390 if (state().strokeStyle()->isEquivalentRGBA(parsedColor)) { 390 if (state().strokeStyle()->isEquivalentRGBA(parsedColor.rgb())) {
391 modifiableState().setUnparsedStrokeColor(colorString); 391 modifiableState().setUnparsedStrokeColor(colorString);
392 return; 392 return;
393 } 393 }
394 canvasStyle = CanvasStyle::createFromRGBA(parsedColor); 394 canvasStyle = CanvasStyle::createFromRGBA(parsedColor.rgb());
395 } else if (style.isCanvasGradient()) { 395 } else if (style.isCanvasGradient()) {
396 canvasStyle = CanvasStyle::createFromGradient(style.getAsCanvasGradient( )); 396 canvasStyle = CanvasStyle::createFromGradient(style.getAsCanvasGradient( ));
397 } else if (style.isCanvasPattern()) { 397 } else if (style.isCanvasPattern()) {
398 CanvasPattern* canvasPattern = style.getAsCanvasPattern(); 398 CanvasPattern* canvasPattern = style.getAsCanvasPattern();
399 399
400 if (canvas()->originClean() && !canvasPattern->originClean()) 400 if (canvas()->originClean() && !canvasPattern->originClean())
401 canvas()->setOriginTainted(); 401 canvas()->setOriginTainted();
402 402
403 canvasStyle = CanvasStyle::createFromPattern(canvasPattern); 403 canvasStyle = CanvasStyle::createFromPattern(canvasPattern);
404 } 404 }
(...skipping 12 matching lines...) Expand all
417 void CanvasRenderingContext2D::setFillStyle(const StringOrCanvasGradientOrCanvas Pattern& style) 417 void CanvasRenderingContext2D::setFillStyle(const StringOrCanvasGradientOrCanvas Pattern& style)
418 { 418 {
419 ASSERT(!style.isNull()); 419 ASSERT(!style.isNull());
420 validateStateStack(); 420 validateStateStack();
421 String colorString; 421 String colorString;
422 CanvasStyle* canvasStyle = nullptr; 422 CanvasStyle* canvasStyle = nullptr;
423 if (style.isString()) { 423 if (style.isString()) {
424 colorString = style.getAsString(); 424 colorString = style.getAsString();
425 if (colorString == state().unparsedFillColor()) 425 if (colorString == state().unparsedFillColor())
426 return; 426 return;
427 RGBA32 parsedColor = 0; 427 Color parsedColor = 0;
428 if (!parseColorOrCurrentColor(parsedColor, colorString, canvas())) 428 if (!parseColorOrCurrentColor(parsedColor, colorString, canvas()))
429 return; 429 return;
430 if (state().fillStyle()->isEquivalentRGBA(parsedColor)) { 430 if (state().fillStyle()->isEquivalentRGBA(parsedColor.rgb())) {
431 modifiableState().setUnparsedFillColor(colorString); 431 modifiableState().setUnparsedFillColor(colorString);
432 return; 432 return;
433 } 433 }
434 canvasStyle = CanvasStyle::createFromRGBA(parsedColor); 434 canvasStyle = CanvasStyle::createFromRGBA(parsedColor.rgb());
435 } else if (style.isCanvasGradient()) { 435 } else if (style.isCanvasGradient()) {
436 canvasStyle = CanvasStyle::createFromGradient(style.getAsCanvasGradient( )); 436 canvasStyle = CanvasStyle::createFromGradient(style.getAsCanvasGradient( ));
437 } else if (style.isCanvasPattern()) { 437 } else if (style.isCanvasPattern()) {
438 CanvasPattern* canvasPattern = style.getAsCanvasPattern(); 438 CanvasPattern* canvasPattern = style.getAsCanvasPattern();
439 439
440 if (canvas()->originClean() && !canvasPattern->originClean()) 440 if (canvas()->originClean() && !canvasPattern->originClean())
441 canvas()->setOriginTainted(); 441 canvas()->setOriginTainted();
442 if (canvasPattern->pattern()->isTextureBacked()) 442 if (canvasPattern->pattern()->isTextureBacked())
443 canvas()->disableDeferral(); 443 canvas()->disableDeferral();
444 canvasStyle = CanvasStyle::createFromPattern(canvasPattern); 444 canvasStyle = CanvasStyle::createFromPattern(canvasPattern);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 if (state().shadowBlur() == blur) 547 if (state().shadowBlur() == blur)
548 return; 548 return;
549 modifiableState().setShadowBlur(blur); 549 modifiableState().setShadowBlur(blur);
550 } 550 }
551 551
552 String CanvasRenderingContext2D::shadowColor() const 552 String CanvasRenderingContext2D::shadowColor() const
553 { 553 {
554 return Color(state().shadowColor()).serialized(); 554 return Color(state().shadowColor()).serialized();
555 } 555 }
556 556
557 void CanvasRenderingContext2D::setShadowColor(const String& color) 557 void CanvasRenderingContext2D::setShadowColor(const String& colorString)
558 { 558 {
559 RGBA32 rgba; 559 Color color;
560 if (!parseColorOrCurrentColor(rgba, color, canvas())) 560 if (!parseColorOrCurrentColor(color, colorString, canvas()))
561 return; 561 return;
562 if (state().shadowColor() == rgba) 562 if (state().shadowColor() == color)
563 return; 563 return;
564 modifiableState().setShadowColor(rgba); 564 modifiableState().setShadowColor(color.rgb());
565 } 565 }
566 566
567 const Vector<float>& CanvasRenderingContext2D::getLineDash() const 567 const Vector<float>& CanvasRenderingContext2D::getLineDash() const
568 { 568 {
569 return state().lineDash(); 569 return state().lineDash();
570 } 570 }
571 571
572 static bool lineDashSequenceIsValid(const Vector<float>& dash) 572 static bool lineDashSequenceIsValid(const Vector<float>& dash)
573 { 573 {
574 for (size_t i = 0; i < dash.size(); i++) { 574 for (size_t i = 0; i < dash.size(); i++) {
(...skipping 1762 matching lines...) Expand 10 before | Expand all | Expand 10 after
2337 if (imageType == CanvasRenderingContext2DState::NonOpaqueImage) 2337 if (imageType == CanvasRenderingContext2DState::NonOpaqueImage)
2338 return; 2338 return;
2339 if (alpha < 0xFF) 2339 if (alpha < 0xFF)
2340 return; 2340 return;
2341 } 2341 }
2342 2342
2343 canvas()->buffer()->willOverwriteCanvas(); 2343 canvas()->buffer()->willOverwriteCanvas();
2344 } 2344 }
2345 2345
2346 } // namespace blink 2346 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698