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

Unified Diff: third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DState.cpp

Issue 1402963003: ** DO NO COMMIT ** for jake Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DState.cpp
diff --git a/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DState.cpp b/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DState.cpp
index 510e4df93938e7b739ac62600a2a23050c96fe3a..6ad2fdb2781730acfc48551ecdc34d39c1242c2c 100644
--- a/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DState.cpp
+++ b/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DState.cpp
@@ -23,6 +23,7 @@
static const char defaultFont[] = "10px sans-serif";
static const char defaultFilter[] = "none";
+static const char defaultImageSmoothingQuality[] = "low";
namespace blink {
@@ -58,6 +59,7 @@ CanvasRenderingContext2DState::CanvasRenderingContext2DState()
m_strokePaint.setStrokeJoin(SkPaint::kMiter_Join);
m_strokePaint.setAntiAlias(true);
setImageSmoothingEnabled(true);
+ setImageSmoothingQuality(defaultImageSmoothingQuality);
}
CanvasRenderingContext2DState::CanvasRenderingContext2DState(const CanvasRenderingContext2DState& other, ClipListCopyMode mode)
@@ -479,6 +481,43 @@ bool CanvasRenderingContext2DState::imageSmoothingEnabled() const
return m_imagePaint.getFilterQuality() == kLow_SkFilterQuality;
zino 2015/10/14 07:51:36 I think you will have to modify the imageSmoothing
}
+void CanvasRenderingContext2DState::setImageSmoothingQuality(String quality)
+{
+ SkFilterQuality filterQuality = imageSmoothingQuality2SkFilterQuality(quality);
+ m_strokePaint.setFilterQuality(filterQuality);
+ m_fillPaint.setFilterQuality(filterQuality);
+ m_imagePaint.setFilterQuality(filterQuality);
+}
+
+String CanvasRenderingContext2DState::imageSmoothingQuality() const
+{
+ return SkFilterQuality2imageSmoothingQuality(m_imagePaint.getFilterQuality());
+}
+
+String CanvasRenderingContext2DState::SkFilterQuality2imageSmoothingQuality(SkFilterQuality quality) const
zino 2015/10/14 07:51:36 I think it is better to avoid unnecessary addition
+{
+ if (quality == kLow_SkFilterQuality)
zino 2015/10/14 07:51:36 Please see: http://www.chromium.org/blink/coding-s
+ return "low";
+ else if (quality == kMedium_SkFilterQuality)
+ return "medium";
+ else if (quality == kHigh_SkFilterQuality)
+ return "high";
+ else
+ return "none";
+}
+
+SkFilterQuality CanvasRenderingContext2DState::imageSmoothingQuality2SkFilterQuality(String quality) const
+{
+ if (quality == "low")
zino 2015/10/14 07:51:36 ditto ('ditto' means that this is the same as abov
+ return kLow_SkFilterQuality;
+ else if (quality == "medium")
+ return kMedium_SkFilterQuality;
+ else if (quality == "high")
+ return kHigh_SkFilterQuality;
+ else
+ return kNone_SkFilterQuality;
+}
+
bool CanvasRenderingContext2DState::shouldDrawShadows() const
{
return alphaChannel(m_shadowColor) && (m_shadowBlur || !m_shadowOffset.isZero());

Powered by Google App Engine
This is Rietveld 408576698