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

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

Issue 323013004: Clean up transform methods in GraphicsContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2nd Attempt Mac build fix Created 6 years, 6 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 | « Source/core/frame/LocalFrame.cpp ('k') | Source/core/page/PrintContext.cpp » ('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) 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 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 return; 719 return;
720 720
721 realizeSaves(); 721 realizeSaves();
722 722
723 if (!newTransform.isInvertible()) { 723 if (!newTransform.isInvertible()) {
724 modifiableState().m_invertibleCTM = false; 724 modifiableState().m_invertibleCTM = false;
725 return; 725 return;
726 } 726 }
727 727
728 modifiableState().m_transform = newTransform; 728 modifiableState().m_transform = newTransform;
729 c->scale(FloatSize(sx, sy)); 729 c->scale(sx, sy);
730 m_path.transform(AffineTransform().scaleNonUniform(1.0 / sx, 1.0 / sy)); 730 m_path.transform(AffineTransform().scaleNonUniform(1.0 / sx, 1.0 / sy));
731 } 731 }
732 732
733 void CanvasRenderingContext2D::rotate(float angleInRadians) 733 void CanvasRenderingContext2D::rotate(float angleInRadians)
734 { 734 {
735 GraphicsContext* c = drawingContext(); 735 GraphicsContext* c = drawingContext();
736 if (!c) 736 if (!c)
737 return; 737 return;
738 if (!state().m_invertibleCTM) 738 if (!state().m_invertibleCTM)
739 return; 739 return;
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
1532 1532
1533 didDraw(dirtyRect); 1533 didDraw(dirtyRect);
1534 } 1534 }
1535 1535
1536 void CanvasRenderingContext2D::drawVideo(HTMLVideoElement* video, FloatRect srcR ect, FloatRect dstRect) 1536 void CanvasRenderingContext2D::drawVideo(HTMLVideoElement* video, FloatRect srcR ect, FloatRect dstRect)
1537 { 1537 {
1538 GraphicsContext* c = drawingContext(); 1538 GraphicsContext* c = drawingContext();
1539 GraphicsContextStateSaver stateSaver(*c); 1539 GraphicsContextStateSaver stateSaver(*c);
1540 c->clip(dstRect); 1540 c->clip(dstRect);
1541 c->translate(dstRect.x(), dstRect.y()); 1541 c->translate(dstRect.x(), dstRect.y());
1542 c->scale(FloatSize(dstRect.width() / srcRect.width(), dstRect.height() / src Rect.height())); 1542 c->scale(dstRect.width() / srcRect.width(), dstRect.height() / srcRect.heigh t());
1543 c->translate(-srcRect.x(), -srcRect.y()); 1543 c->translate(-srcRect.x(), -srcRect.y());
1544 video->paintCurrentFrameInContext(c, IntRect(IntPoint(), IntSize(video->vide oWidth(), video->videoHeight()))); 1544 video->paintCurrentFrameInContext(c, IntRect(IntPoint(), IntSize(video->vide oWidth(), video->videoHeight())));
1545 stateSaver.restore(); 1545 stateSaver.restore();
1546 validateStateStack(); 1546 validateStateStack();
1547 } 1547 }
1548 1548
1549 void CanvasRenderingContext2D::drawImageFromRect(HTMLImageElement* image, 1549 void CanvasRenderingContext2D::drawImageFromRect(HTMLImageElement* image,
1550 float sx, float sy, float sw, float sh, 1550 float sx, float sy, float sw, float sh,
1551 float dx, float dy, float dw, float dh, 1551 float dx, float dy, float dw, float dh,
1552 const String& compositeOperation) 1552 const String& compositeOperation)
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
2180 fontMetrics.lineSpacing()); 2180 fontMetrics.lineSpacing());
2181 if (!fill) 2181 if (!fill)
2182 inflateStrokeRect(textRunPaintInfo.bounds); 2182 inflateStrokeRect(textRunPaintInfo.bounds);
2183 2183
2184 c->setTextDrawingMode(fill ? TextModeFill : TextModeStroke); 2184 c->setTextDrawingMode(fill ? TextModeFill : TextModeStroke);
2185 2185
2186 GraphicsContextStateSaver stateSaver(*c); 2186 GraphicsContextStateSaver stateSaver(*c);
2187 if (useMaxWidth) { 2187 if (useMaxWidth) {
2188 c->translate(location.x(), location.y()); 2188 c->translate(location.x(), location.y());
2189 // We draw when fontWidth is 0 so compositing operations (eg, a "copy" o p) still work. 2189 // We draw when fontWidth is 0 so compositing operations (eg, a "copy" o p) still work.
2190 c->scale(FloatSize((fontWidth > 0 ? (width / fontWidth) : 0), 1)); 2190 c->scale((fontWidth > 0 ? (width / fontWidth) : 0), 1);
2191 location = FloatPoint(); 2191 location = FloatPoint();
2192 } 2192 }
2193 2193
2194 FloatRect clipBounds; 2194 FloatRect clipBounds;
2195 if (!c->getTransformedClipBounds(&clipBounds)) { 2195 if (!c->getTransformedClipBounds(&clipBounds)) {
2196 return; 2196 return;
2197 } 2197 }
2198 2198
2199 if (isFullCanvasCompositeMode(state().m_globalComposite)) { 2199 if (isFullCanvasCompositeMode(state().m_globalComposite)) {
2200 c->beginLayer(1, state().m_globalComposite); 2200 c->beginLayer(1, state().m_globalComposite);
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
2350 c->setAlphaAsFloat(1.0); 2350 c->setAlphaAsFloat(1.0);
2351 c->clearShadow(); 2351 c->clearShadow();
2352 c->setCompositeOperation(CompositeSourceOver, blink::WebBlendModeNormal); 2352 c->setCompositeOperation(CompositeSourceOver, blink::WebBlendModeNormal);
2353 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor); 2353 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor);
2354 c->restore(); 2354 c->restore();
2355 validateStateStack(); 2355 validateStateStack();
2356 didDraw(dirtyRect); 2356 didDraw(dirtyRect);
2357 } 2357 }
2358 2358
2359 } // namespace WebCore 2359 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/frame/LocalFrame.cpp ('k') | Source/core/page/PrintContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698