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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/GradientGeneratedImage.cpp

Issue 2157953002: Change filter quality when scaling-down in drawImage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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) 2008, 2009, 2010, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2008, 2009, 2010, 2012 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 14 matching lines...) Expand all
25 25
26 #include "platform/graphics/GradientGeneratedImage.h" 26 #include "platform/graphics/GradientGeneratedImage.h"
27 27
28 #include "platform/geometry/FloatRect.h" 28 #include "platform/geometry/FloatRect.h"
29 #include "platform/geometry/IntSize.h" 29 #include "platform/geometry/IntSize.h"
30 #include "platform/graphics/GraphicsContext.h" 30 #include "platform/graphics/GraphicsContext.h"
31 31
32 namespace blink { 32 namespace blink {
33 33
34 void GradientGeneratedImage::draw(SkCanvas* canvas, const SkPaint& paint, const FloatRect& destRect, 34 void GradientGeneratedImage::draw(SkCanvas* canvas, const SkPaint& paint, const FloatRect& destRect,
35 const FloatRect& srcRect, RespectImageOrientationEnum, ImageClampingMode) 35 const FloatRect& srcRect, bool imageSmoothingEnabled, RespectImageOrientatio nEnum, ImageClampingMode)
36 { 36 {
37 SkRect visibleSrcRect = srcRect; 37 SkRect visibleSrcRect = srcRect;
38 if (!visibleSrcRect.intersect(SkRect::MakeIWH(m_size.width(), m_size.height( )))) 38 if (!visibleSrcRect.intersect(SkRect::MakeIWH(m_size.width(), m_size.height( ))))
39 return; 39 return;
40 40
41 const SkMatrix transform = SkMatrix::MakeRectToRect(srcRect, destRect, SkMat rix::kFill_ScaleToFit); 41 const SkMatrix transform = SkMatrix::MakeRectToRect(srcRect, destRect, SkMat rix::kFill_ScaleToFit);
42 SkRect visibleDestRect; 42 SkRect visibleDestRect;
43 transform.mapRect(&visibleDestRect, visibleSrcRect); 43 transform.mapRect(&visibleDestRect, visibleSrcRect);
44 44
45 SkPaint gradientPaint(paint); 45 SkPaint gradientPaint(paint);
46 m_gradient->applyToPaint(gradientPaint, transform); 46 m_gradient->applyToPaint(gradientPaint, transform);
47
48 if (!imageSmoothingEnabled && Image::isDrawScalingDown(visibleSrcRect, visib leDestRect))
49 gradientPaint.setFilterQuality(kLow_SkFilterQuality);
50
47 canvas->drawRect(visibleDestRect, gradientPaint); 51 canvas->drawRect(visibleDestRect, gradientPaint);
48 } 52 }
49 53
50 void GradientGeneratedImage::drawTile(GraphicsContext& context, const FloatRect& srcRect) 54 void GradientGeneratedImage::drawTile(GraphicsContext& context, const FloatRect& srcRect)
51 { 55 {
52 SkPaint gradientPaint(context.fillPaint()); 56 SkPaint gradientPaint(context.fillPaint());
53 m_gradient->applyToPaint(gradientPaint, SkMatrix::I()); 57 m_gradient->applyToPaint(gradientPaint, SkMatrix::I());
54 58
55 context.drawRect(srcRect, gradientPaint); 59 context.drawRect(srcRect, gradientPaint);
56 } 60 }
57 61
58 bool GradientGeneratedImage::applyShader(SkPaint& paint, const SkMatrix& localMa trix) 62 bool GradientGeneratedImage::applyShader(SkPaint& paint, const SkMatrix& localMa trix)
59 { 63 {
60 DCHECK(m_gradient); 64 DCHECK(m_gradient);
61 m_gradient->applyToPaint(paint, localMatrix); 65 m_gradient->applyToPaint(paint, localMatrix);
62 66
63 return true; 67 return true;
64 } 68 }
65 69
66 } // namespace blink 70 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698