| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/canvas2d/BaseRenderingContext2D.h" | 5 #include "modules/canvas2d/BaseRenderingContext2D.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionMessages.h" | 7 #include "bindings/core/v8/ExceptionMessages.h" |
| 8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
| 9 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 9 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 10 #include "core/css/parser/CSSParser.h" | 10 #include "core/css/parser/CSSParser.h" |
| (...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 904 widthExpansion = ctm[SkMatrix::kMScaleX], heightExpansion = ctm[SkMatrix
::kMScaleY]; | 904 widthExpansion = ctm[SkMatrix::kMScaleX], heightExpansion = ctm[SkMatrix
::kMScaleY]; |
| 905 return destRect.width() * fabs(widthExpansion) < 1 || destRect.height() * fa
bs(heightExpansion) < 1; | 905 return destRect.width() * fabs(widthExpansion) < 1 || destRect.height() * fa
bs(heightExpansion) < 1; |
| 906 } | 906 } |
| 907 | 907 |
| 908 void BaseRenderingContext2D::drawImageInternal(SkCanvas* c, CanvasImageSource* i
mageSource, Image* image, const FloatRect& srcRect, const FloatRect& dstRect, co
nst SkPaint* paint) | 908 void BaseRenderingContext2D::drawImageInternal(SkCanvas* c, CanvasImageSource* i
mageSource, Image* image, const FloatRect& srcRect, const FloatRect& dstRect, co
nst SkPaint* paint) |
| 909 { | 909 { |
| 910 int initialSaveCount = c->getSaveCount(); | 910 int initialSaveCount = c->getSaveCount(); |
| 911 SkPaint imagePaint = *paint; | 911 SkPaint imagePaint = *paint; |
| 912 | 912 |
| 913 if (paint->getImageFilter()) { | 913 if (paint->getImageFilter()) { |
| 914 SkMatrix ctm = c->getTotalMatrix(); |
| 914 SkMatrix invCtm; | 915 SkMatrix invCtm; |
| 915 if (!c->getTotalMatrix().invert(&invCtm)) { | 916 if (!ctm.invert(&invCtm)) { |
| 916 // There is an earlier check for invertibility, but the arithmetic | 917 // There is an earlier check for invertibility, but the arithmetic |
| 917 // in AffineTransform is not exactly identical, so it is possible | 918 // in AffineTransform is not exactly identical, so it is possible |
| 918 // for SkMatrix to find the transform to be non-invertible at this s
tage. | 919 // for SkMatrix to find the transform to be non-invertible at this s
tage. |
| 919 // crbug.com/504687 | 920 // crbug.com/504687 |
| 920 return; | 921 return; |
| 921 } | 922 } |
| 923 c->save(); |
| 924 c->concat(invCtm); |
| 922 SkRect bounds = dstRect; | 925 SkRect bounds = dstRect; |
| 926 ctm.mapRect(&bounds); |
| 923 SkPaint layerPaint; | 927 SkPaint layerPaint; |
| 924 layerPaint.setXfermode(sk_ref_sp(paint->getXfermode())); | 928 layerPaint.setXfermode(sk_ref_sp(paint->getXfermode())); |
| 925 layerPaint.setImageFilter(paint->getImageFilter()->makeWithLocalMatrix(i
nvCtm)); | 929 layerPaint.setImageFilter(paint->getImageFilter()); |
| 930 |
| 926 c->saveLayer(&bounds, &layerPaint); | 931 c->saveLayer(&bounds, &layerPaint); |
| 932 c->concat(ctm); |
| 927 imagePaint.setXfermodeMode(SkXfermode::kSrcOver_Mode); | 933 imagePaint.setXfermodeMode(SkXfermode::kSrcOver_Mode); |
| 928 imagePaint.setImageFilter(nullptr); | 934 imagePaint.setImageFilter(nullptr); |
| 929 } | 935 } |
| 930 | 936 |
| 931 if (!imageSource->isVideoElement()) { | 937 if (!imageSource->isVideoElement()) { |
| 932 imagePaint.setAntiAlias(shouldDrawImageAntialiased(dstRect)); | 938 imagePaint.setAntiAlias(shouldDrawImageAntialiased(dstRect)); |
| 933 image->draw(c, imagePaint, dstRect, srcRect, DoNotRespectImageOrientatio
n, Image::DoNotClampImageToSourceRect); | 939 image->draw(c, imagePaint, dstRect, srcRect, DoNotRespectImageOrientatio
n, Image::DoNotClampImageToSourceRect); |
| 934 } else { | 940 } else { |
| 935 c->save(); | 941 c->save(); |
| 936 c->clipRect(dstRect); | 942 c->clipRect(dstRect); |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1366 | 1372 |
| 1367 imageBuffer()->willOverwriteCanvas(); | 1373 imageBuffer()->willOverwriteCanvas(); |
| 1368 } | 1374 } |
| 1369 | 1375 |
| 1370 DEFINE_TRACE(BaseRenderingContext2D) | 1376 DEFINE_TRACE(BaseRenderingContext2D) |
| 1371 { | 1377 { |
| 1372 visitor->trace(m_stateStack); | 1378 visitor->trace(m_stateStack); |
| 1373 } | 1379 } |
| 1374 | 1380 |
| 1375 } // namespace blink | 1381 } // namespace blink |
| OLD | NEW |