OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 canvas->saveLayer(nullptr, &layerPaint); | 55 canvas->saveLayer(nullptr, &layerPaint); |
56 | 56 |
57 SkPaint imagePaint(paint); | 57 SkPaint imagePaint(paint); |
58 imagePaint.setXfermodeMode(SkXfermode::kSrcOver_Mode); | 58 imagePaint.setXfermodeMode(SkXfermode::kSrcOver_Mode); |
59 int imageAlpha = clampedAlphaForBlending(1 - m_percentage); | 59 int imageAlpha = clampedAlphaForBlending(1 - m_percentage); |
60 imagePaint.setAlpha(imageAlpha > 255 ? 255 : imageAlpha); | 60 imagePaint.setAlpha(imageAlpha > 255 ? 255 : imageAlpha); |
61 imagePaint.setAntiAlias(paint.isAntiAlias()); | 61 imagePaint.setAntiAlias(paint.isAntiAlias()); |
62 // TODO(junov): This code should probably be propagating the RespectImageOri
entationEnum | 62 // TODO(junov): This code should probably be propagating the RespectImageOri
entationEnum |
63 // form CrossfadeGeneratedImage::draw. Code was written this way during refa
ctoring to | 63 // form CrossfadeGeneratedImage::draw. Code was written this way during refa
ctoring to |
64 // avoid modifying existing behavior, but this warrants further investigatio
n. crbug.com/472634 | 64 // avoid modifying existing behavior, but this warrants further investigatio
n. crbug.com/472634 |
65 m_fromImage->draw(canvas, imagePaint, destRect, fromImageRect, DoNotRespectI
mageOrientation, clampMode); | 65 m_fromImage->draw(canvas, imagePaint, destRect, fromImageRect, true, DoNotRe
spectImageOrientation, clampMode); |
66 imagePaint.setXfermodeMode(SkXfermode::kPlus_Mode); | 66 imagePaint.setXfermodeMode(SkXfermode::kPlus_Mode); |
67 imageAlpha = clampedAlphaForBlending(m_percentage); | 67 imageAlpha = clampedAlphaForBlending(m_percentage); |
68 imagePaint.setAlpha(imageAlpha > 255 ? 255 : imageAlpha); | 68 imagePaint.setAlpha(imageAlpha > 255 ? 255 : imageAlpha); |
69 m_toImage->draw(canvas, imagePaint, destRect, toImageRect, DoNotRespectImage
Orientation, clampMode); | 69 m_toImage->draw(canvas, imagePaint, destRect, toImageRect, true, DoNotRespec
tImageOrientation, clampMode); |
70 } | 70 } |
71 | 71 |
72 void CrossfadeGeneratedImage::draw(SkCanvas* canvas, const SkPaint& paint, const
FloatRect& dstRect, const FloatRect& srcRect, RespectImageOrientationEnum, Imag
eClampingMode clampMode) | 72 void CrossfadeGeneratedImage::draw(SkCanvas* canvas, const SkPaint& paint, const
FloatRect& dstRect, const FloatRect& srcRect, bool imageSmoothingEnabled, Respe
ctImageOrientationEnum, ImageClampingMode clampMode) |
73 { | 73 { |
74 // Draw nothing if either of the images hasn't loaded yet. | 74 // Draw nothing if either of the images hasn't loaded yet. |
75 if (m_fromImage == Image::nullImage() || m_toImage == Image::nullImage()) | 75 if (m_fromImage == Image::nullImage() || m_toImage == Image::nullImage()) |
76 return; | 76 return; |
77 | 77 |
78 SkAutoCanvasRestore ar(canvas, true); | 78 SkAutoCanvasRestore ar(canvas, true); |
79 canvas->clipRect(dstRect); | 79 canvas->clipRect(dstRect); |
80 canvas->translate(dstRect.x(), dstRect.y()); | 80 canvas->translate(dstRect.x(), dstRect.y()); |
81 if (dstRect.size() != srcRect.size()) | 81 if (dstRect.size() != srcRect.size()) |
82 canvas->scale(dstRect.width() / srcRect.width(), dstRect.height() / srcR
ect.height()); | 82 canvas->scale(dstRect.width() / srcRect.width(), dstRect.height() / srcR
ect.height()); |
83 canvas->translate(-srcRect.x(), -srcRect.y()); | 83 canvas->translate(-srcRect.x(), -srcRect.y()); |
84 | 84 |
85 drawCrossfade(canvas, paint, clampMode); | 85 SkPaint adjustedPaint = paint; |
| 86 if (!imageSmoothingEnabled && Image::isDrawScalingDown(srcRect, dstRect)) |
| 87 adjustedPaint.setFilterQuality(kLow_SkFilterQuality); |
| 88 |
| 89 drawCrossfade(canvas, adjustedPaint, clampMode); |
86 } | 90 } |
87 | 91 |
88 void CrossfadeGeneratedImage::drawTile(GraphicsContext& context, const FloatRect
& srcRect) | 92 void CrossfadeGeneratedImage::drawTile(GraphicsContext& context, const FloatRect
& srcRect) |
89 { | 93 { |
90 // Draw nothing if either of the images hasn't loaded yet. | 94 // Draw nothing if either of the images hasn't loaded yet. |
91 if (m_fromImage == Image::nullImage() || m_toImage == Image::nullImage()) | 95 if (m_fromImage == Image::nullImage() || m_toImage == Image::nullImage()) |
92 return; | 96 return; |
93 | 97 |
94 SkPaint paint = context.fillPaint(); | 98 SkPaint paint = context.fillPaint(); |
95 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); | 99 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); |
96 paint.setAntiAlias(context.shouldAntialias()); | 100 paint.setAntiAlias(context.shouldAntialias()); |
97 FloatRect destRect((FloatPoint()), FloatSize(m_crossfadeSize)); | 101 FloatRect destRect((FloatPoint()), FloatSize(m_crossfadeSize)); |
98 paint.setFilterQuality(context.computeFilterQuality(this, destRect, srcRect)
); | 102 paint.setFilterQuality(context.computeFilterQuality(this, destRect, srcRect)
); |
99 drawCrossfade(context.canvas(), paint, ClampImageToSourceRect); | 103 drawCrossfade(context.canvas(), paint, ClampImageToSourceRect); |
100 } | 104 } |
101 | 105 |
102 } // namespace blink | 106 } // namespace blink |
OLD | NEW |