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

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

Issue 1530503004: 2D canvas: pass unmodified primitive bounds to saveLayer(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mark some more tests NeedsRebaseline Created 5 years 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 | « third_party/WebKit/LayoutTests/TestExpectations ('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 813 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 // CompositeSourceAtop and CompositeDestinationOut are not listed here as th e platforms already 824 // CompositeSourceAtop and CompositeDestinationOut are not listed here as th e platforms already
825 // implement the specification's behavior. 825 // implement the specification's behavior.
826 return op == SkXfermode::kSrcIn_Mode || op == SkXfermode::kSrcOut_Mode || op == SkXfermode::kDstIn_Mode || op == SkXfermode::kDstATop_Mode; 826 return op == SkXfermode::kSrcIn_Mode || op == SkXfermode::kSrcOut_Mode || op == SkXfermode::kDstIn_Mode || op == SkXfermode::kDstATop_Mode;
827 } 827 }
828 828
829 template<typename DrawFunc> 829 template<typename DrawFunc>
830 void CanvasRenderingContext2D::compositedDraw(const DrawFunc& drawFunc, SkCanvas * c, CanvasRenderingContext2DState::PaintType paintType, CanvasRenderingContext2 DState::ImageType imageType) 830 void CanvasRenderingContext2D::compositedDraw(const DrawFunc& drawFunc, SkCanvas * c, CanvasRenderingContext2DState::PaintType paintType, CanvasRenderingContext2 DState::ImageType imageType)
831 { 831 {
832 SkImageFilter* filter = state().getFilter(canvas(), accessFont()); 832 SkImageFilter* filter = state().getFilter(canvas(), accessFont());
833 ASSERT(isFullCanvasCompositeMode(state().globalComposite()) || filter); 833 ASSERT(isFullCanvasCompositeMode(state().globalComposite()) || filter);
834 SkMatrix ctm = c->getTotalMatrix(); 834 SkMatrix ctm = c->getTotalMatrix();
Justin Novosad 2016/01/08 19:14:05 Could you apply the same magic here as well? Neve
835 c->resetMatrix(); 835 c->resetMatrix();
836 SkPaint compositePaint; 836 SkPaint compositePaint;
837 compositePaint.setXfermodeMode(state().globalComposite()); 837 compositePaint.setXfermodeMode(state().globalComposite());
838 if (state().shouldDrawShadows()) { 838 if (state().shouldDrawShadows()) {
839 // unroll into two independently composited passes if drawing shadows 839 // unroll into two independently composited passes if drawing shadows
840 SkPaint shadowPaint = *state().getPaint(paintType, DrawShadowOnly, image Type); 840 SkPaint shadowPaint = *state().getPaint(paintType, DrawShadowOnly, image Type);
841 int saveCount = c->getSaveCount(); 841 int saveCount = c->getSaveCount();
842 if (filter) { 842 if (filter) {
843 SkPaint filterPaint; 843 SkPaint filterPaint;
844 filterPaint.setImageFilter(filter); 844 filterPaint.setImageFilter(filter);
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 widthExpansion = ctm[SkMatrix::kMScaleX], heightExpansion = ctm[SkMatrix ::kMScaleY]; 1301 widthExpansion = ctm[SkMatrix::kMScaleX], heightExpansion = ctm[SkMatrix ::kMScaleY];
1302 return destRect.width() * fabs(widthExpansion) < 1 || destRect.height() * fa bs(heightExpansion) < 1; 1302 return destRect.width() * fabs(widthExpansion) < 1 || destRect.height() * fa bs(heightExpansion) < 1;
1303 } 1303 }
1304 1304
1305 void CanvasRenderingContext2D::drawImageInternal(SkCanvas* c, CanvasImageSource* imageSource, Image* image, const FloatRect& srcRect, const FloatRect& dstRect, const SkPaint* paint) 1305 void CanvasRenderingContext2D::drawImageInternal(SkCanvas* c, CanvasImageSource* imageSource, Image* image, const FloatRect& srcRect, const FloatRect& dstRect, const SkPaint* paint)
1306 { 1306 {
1307 int initialSaveCount = c->getSaveCount(); 1307 int initialSaveCount = c->getSaveCount();
1308 SkPaint imagePaint = *paint; 1308 SkPaint imagePaint = *paint;
1309 1309
1310 if (paint->getImageFilter()) { 1310 if (paint->getImageFilter()) {
1311 SkMatrix ctm = c->getTotalMatrix();
1312 SkMatrix invCtm; 1311 SkMatrix invCtm;
1313 if (!ctm.invert(&invCtm)) { 1312 if (!c->getTotalMatrix().invert(&invCtm)) {
1314 // There is an earlier check for invertibility, but the arithmetic 1313 // There is an earlier check for invertibility, but the arithmetic
1315 // in AffineTransform is not exactly identical, so it is possible 1314 // in AffineTransform is not exactly identical, so it is possible
1316 // for SkMatrix to find the transform to be non-invertible at this s tage. 1315 // for SkMatrix to find the transform to be non-invertible at this s tage.
1317 // crbug.com/504687 1316 // crbug.com/504687
1318 return; 1317 return;
1319 } 1318 }
1320 c->save();
1321 c->concat(invCtm);
1322 SkRect bounds = dstRect; 1319 SkRect bounds = dstRect;
1323 ctm.mapRect(&bounds);
1324 SkRect filteredBounds;
1325 paint->getImageFilter()->computeFastBounds(bounds, &filteredBounds);
1326 SkPaint layerPaint; 1320 SkPaint layerPaint;
1327 layerPaint.setXfermode(paint->getXfermode()); 1321 layerPaint.setXfermode(paint->getXfermode());
1328 layerPaint.setImageFilter(paint->getImageFilter()); 1322 SkAutoTUnref<SkImageFilter> localFilter(paint->getImageFilter()->newWith LocalMatrix(invCtm));
1329 c->saveLayer(&filteredBounds, &layerPaint); 1323 layerPaint.setImageFilter(localFilter);
1330 c->concat(ctm); 1324 c->saveLayer(&bounds, &layerPaint);
1331 imagePaint.setXfermodeMode(SkXfermode::kSrcOver_Mode); 1325 imagePaint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
1332 imagePaint.setImageFilter(nullptr); 1326 imagePaint.setImageFilter(nullptr);
1333 } 1327 }
1334 1328
1335 if (!imageSource->isVideoElement()) { 1329 if (!imageSource->isVideoElement()) {
1336 imagePaint.setAntiAlias(shouldDrawImageAntialiased(dstRect)); 1330 imagePaint.setAntiAlias(shouldDrawImageAntialiased(dstRect));
1337 image->draw(c, imagePaint, dstRect, srcRect, DoNotRespectImageOrientatio n, Image::DoNotClampImageToSourceRect); 1331 image->draw(c, imagePaint, dstRect, srcRect, DoNotRespectImageOrientatio n, Image::DoNotClampImageToSourceRect);
1338 } else { 1332 } else {
1339 c->save(); 1333 c->save();
1340 c->clipRect(dstRect); 1334 c->clipRect(dstRect);
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after
2335 if (imageType == CanvasRenderingContext2DState::NonOpaqueImage) 2329 if (imageType == CanvasRenderingContext2DState::NonOpaqueImage)
2336 return; 2330 return;
2337 if (alpha < 0xFF) 2331 if (alpha < 0xFF)
2338 return; 2332 return;
2339 } 2333 }
2340 2334
2341 canvas()->buffer()->willOverwriteCanvas(); 2335 canvas()->buffer()->willOverwriteCanvas();
2342 } 2336 }
2343 2337
2344 } // namespace blink 2338 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698