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

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

Issue 24233004: Support currentTransform in 2D Canvas. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 3 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 #include "core/html/canvas/DOMPath.h" 57 #include "core/html/canvas/DOMPath.h"
58 #include "core/page/ImageBitmap.h" 58 #include "core/page/ImageBitmap.h"
59 #include "core/platform/graphics/DrawLooper.h" 59 #include "core/platform/graphics/DrawLooper.h"
60 #include "core/platform/graphics/FloatQuad.h" 60 #include "core/platform/graphics/FloatQuad.h"
61 #include "core/platform/graphics/FontCache.h" 61 #include "core/platform/graphics/FontCache.h"
62 #include "core/platform/graphics/GraphicsContextStateSaver.h" 62 #include "core/platform/graphics/GraphicsContextStateSaver.h"
63 #include "core/platform/graphics/TextRun.h" 63 #include "core/platform/graphics/TextRun.h"
64 #include "core/platform/graphics/transforms/AffineTransform.h" 64 #include "core/platform/graphics/transforms/AffineTransform.h"
65 #include "core/rendering/RenderLayer.h" 65 #include "core/rendering/RenderLayer.h"
66 #include "core/rendering/RenderTheme.h" 66 #include "core/rendering/RenderTheme.h"
67 #include "core/svg/SVGMatrix.h"
Justin Novosad 2013/09/19 19:23:48 Are you sure this include is necessary?
67 #include "weborigin/SecurityOrigin.h" 68 #include "weborigin/SecurityOrigin.h"
68 #include "wtf/CheckedArithmetic.h" 69 #include "wtf/CheckedArithmetic.h"
69 #include "wtf/MathExtras.h" 70 #include "wtf/MathExtras.h"
70 #include "wtf/OwnPtr.h" 71 #include "wtf/OwnPtr.h"
71 #include "wtf/Uint8ClampedArray.h" 72 #include "wtf/Uint8ClampedArray.h"
72 #include "wtf/text/StringBuilder.h" 73 #include "wtf/text/StringBuilder.h"
73 74
74 using namespace std; 75 using namespace std;
75 76
76 namespace WebCore { 77 namespace WebCore {
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 return; 590 return;
590 realizeSaves(); 591 realizeSaves();
591 modifiableState().m_globalComposite = op; 592 modifiableState().m_globalComposite = op;
592 modifiableState().m_globalBlend = blendMode; 593 modifiableState().m_globalBlend = blendMode;
593 GraphicsContext* c = drawingContext(); 594 GraphicsContext* c = drawingContext();
594 if (!c) 595 if (!c)
595 return; 596 return;
596 c->setCompositeOperation(op, blendMode); 597 c->setCompositeOperation(op, blendMode);
597 } 598 }
598 599
600 SVGMatrix CanvasRenderingContext2D::currentTransform() const
601 {
602 return SVGMatrix(state().m_transform);
603 }
604
605 void CanvasRenderingContext2D::setCurrentTransform(const SVGMatrix& currentTrans form)
606 {
607 setTransform(currentTransform.a(), currentTransform.b(), currentTransform.c( ), currentTransform.d(), currentTransform.e(), currentTransform.f());
608 }
609
599 void CanvasRenderingContext2D::scale(float sx, float sy) 610 void CanvasRenderingContext2D::scale(float sx, float sy)
600 { 611 {
601 GraphicsContext* c = drawingContext(); 612 GraphicsContext* c = drawingContext();
602 if (!c) 613 if (!c)
603 return; 614 return;
604 if (!state().m_invertibleCTM) 615 if (!state().m_invertibleCTM)
605 return; 616 return;
606 617
607 if (!std::isfinite(sx) | !std::isfinite(sy)) 618 if (!std::isfinite(sx) | !std::isfinite(sy))
608 return; 619 return;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 if (!std::isfinite(m11) | !std::isfinite(m21) | !std::isfinite(dx) | !std::i sfinite(m12) | !std::isfinite(m22) | !std::isfinite(dy)) 702 if (!std::isfinite(m11) | !std::isfinite(m21) | !std::isfinite(dx) | !std::i sfinite(m12) | !std::isfinite(m22) | !std::isfinite(dy))
692 return; 703 return;
693 704
694 AffineTransform transform(m11, m12, m21, m22, dx, dy); 705 AffineTransform transform(m11, m12, m21, m22, dx, dy);
695 AffineTransform newTransform = state().m_transform * transform; 706 AffineTransform newTransform = state().m_transform * transform;
696 if (state().m_transform == newTransform) 707 if (state().m_transform == newTransform)
697 return; 708 return;
698 709
699 realizeSaves(); 710 realizeSaves();
700 711
712 modifiableState().m_transform = newTransform;
701 if (!newTransform.isInvertible()) { 713 if (!newTransform.isInvertible()) {
702 modifiableState().m_invertibleCTM = false; 714 modifiableState().m_invertibleCTM = false;
703 return; 715 return;
704 } 716 }
705 717
706 modifiableState().m_transform = newTransform;
707 c->concatCTM(transform); 718 c->concatCTM(transform);
708 m_path.transform(transform.inverse()); 719 m_path.transform(transform.inverse());
709 } 720 }
710 721
711 void CanvasRenderingContext2D::resetTransform() 722 void CanvasRenderingContext2D::resetTransform()
712 { 723 {
713 GraphicsContext* c = drawingContext(); 724 GraphicsContext* c = drawingContext();
714 if (!c) 725 if (!c)
715 return; 726 return;
716 727
(...skipping 1649 matching lines...) Expand 10 before | Expand all | Expand 10 after
2366 Color focusRingColor = RenderTheme::focusRingColor(); 2377 Color focusRingColor = RenderTheme::focusRingColor();
2367 const int focusRingWidth = 5; 2378 const int focusRingWidth = 5;
2368 const int focusRingOutline = 0; 2379 const int focusRingOutline = 0;
2369 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor); 2380 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor);
2370 didDraw(path.boundingRect()); 2381 didDraw(path.boundingRect());
2371 2382
2372 c->restore(); 2383 c->restore();
2373 } 2384 }
2374 2385
2375 } // namespace WebCore 2386 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698