Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / platform / graphics / GraphicsContextState.cpp
index abd3c18..21cdba8 100644 (file)
@@ -5,7 +5,9 @@
 #include "config.h"
 #include "platform/graphics/GraphicsContextState.h"
 
-namespace WebCore {
+#include "platform/graphics/skia/SkiaUtils.h"
+
+namespace blink {
 
 GraphicsContextState::GraphicsContextState()
     : m_fillColor(Color::black)
@@ -14,7 +16,7 @@ GraphicsContextState::GraphicsContextState()
     , m_alpha(256)
     , m_xferMode(nullptr)
     , m_compositeOperator(CompositeSourceOver)
-    , m_blendMode(blink::WebBlendModeNormal)
+    , m_blendMode(WebBlendModeNormal)
     , m_interpolationQuality(InterpolationDefault)
     , m_saveCount(0)
     , m_shouldAntialias(true)
@@ -27,34 +29,38 @@ GraphicsContextState::GraphicsContextState()
     m_strokePaint.setStrokeCap(SkPaint::kDefault_Cap);
     m_strokePaint.setStrokeJoin(SkPaint::kDefault_Join);
     m_strokePaint.setStrokeMiter(SkFloatToScalar(m_strokeData.miterLimit()));
-    m_strokePaint.setFilterBitmap(m_interpolationQuality != InterpolationNone);
+    m_strokePaint.setFilterLevel(WebCoreInterpolationQualityToSkFilterLevel(m_interpolationQuality));
     m_strokePaint.setAntiAlias(m_shouldAntialias);
     m_fillPaint.setColor(applyAlpha(m_fillColor.rgb()));
-    m_fillPaint.setFilterBitmap(m_interpolationQuality != InterpolationNone);
+    m_fillPaint.setFilterLevel(WebCoreInterpolationQualityToSkFilterLevel(m_interpolationQuality));
     m_fillPaint.setAntiAlias(m_shouldAntialias);
 }
 
-void GraphicsContextState::copy(GraphicsContextState* source)
-{
-    m_strokePaint = source->m_strokePaint;
-    m_fillPaint = source->m_fillPaint;
-    m_strokeData = source->m_strokeData;
-    m_fillColor = source->m_fillColor;
-    m_fillRule = source->m_fillRule;
-    m_fillGradient = source->m_fillGradient;
-    m_fillPattern = source->m_fillPattern;
-    m_looper = source->m_looper;
-    m_textDrawingMode = source->m_textDrawingMode;
-    m_alpha = source->m_alpha;
-    m_xferMode = source->m_xferMode;
-    m_colorFilter = source->m_colorFilter;
-    m_compositeOperator = source->m_compositeOperator;
-    m_blendMode = source->m_blendMode;
-    m_interpolationQuality = source->m_interpolationQuality;
-    m_saveCount = 0;
-    m_shouldAntialias = source->m_shouldAntialias;
-    m_shouldSmoothFonts = source->m_shouldSmoothFonts;
-    m_shouldClampToSourceRect = source->m_shouldClampToSourceRect;
+GraphicsContextState::GraphicsContextState(const GraphicsContextState& other)
+    : m_strokePaint(other.m_strokePaint)
+    , m_fillPaint(other.m_fillPaint)
+    , m_strokeData(other.m_strokeData)
+    , m_fillColor(other.m_fillColor)
+    , m_fillRule(other.m_fillRule)
+    , m_fillGradient(other.m_fillGradient)
+    , m_fillPattern(other.m_fillPattern)
+    , m_looper(other.m_looper)
+    , m_textDrawingMode(other.m_textDrawingMode)
+    , m_alpha(other.m_alpha)
+    , m_xferMode(other.m_xferMode)
+    , m_colorFilter(other.m_colorFilter)
+    , m_compositeOperator(other.m_compositeOperator)
+    , m_blendMode(other.m_blendMode)
+    , m_interpolationQuality(other.m_interpolationQuality)
+    , m_saveCount(0)
+    , m_shouldAntialias(other.m_shouldAntialias)
+    , m_shouldSmoothFonts(other.m_shouldSmoothFonts)
+    , m_shouldClampToSourceRect(other.m_shouldClampToSourceRect) { }
+
+void GraphicsContextState::copy(const GraphicsContextState& source)
+{
+    this->~GraphicsContextState();
+    new (this) GraphicsContextState(source);
 }
 
 const SkPaint& GraphicsContextState::strokePaint(int strokedPathLength) const
@@ -223,7 +229,7 @@ void GraphicsContextState::setColorFilter(PassRefPtr<SkColorFilter> colorFilter)
     m_fillPaint.setColorFilter(m_colorFilter.get());
 }
 
-void GraphicsContextState::setCompositeOperation(CompositeOperator compositeOperation, blink::WebBlendMode blendMode)
+void GraphicsContextState::setCompositeOperation(CompositeOperator compositeOperation, WebBlendMode blendMode)
 {
     m_compositeOperator = compositeOperation;
     m_blendMode = blendMode;
@@ -235,8 +241,8 @@ void GraphicsContextState::setCompositeOperation(CompositeOperator compositeOper
 void GraphicsContextState::setInterpolationQuality(InterpolationQuality quality)
 {
     m_interpolationQuality = quality;
-    m_strokePaint.setFilterBitmap(quality != InterpolationNone);
-    m_fillPaint.setFilterBitmap(quality != InterpolationNone);
+    m_strokePaint.setFilterLevel(WebCoreInterpolationQualityToSkFilterLevel(quality));
+    m_fillPaint.setFilterLevel(WebCoreInterpolationQualityToSkFilterLevel(quality));
 }
 
 void GraphicsContextState::setShouldAntialias(bool shouldAntialias)
@@ -247,4 +253,4 @@ void GraphicsContextState::setShouldAntialias(bool shouldAntialias)
 }
 
 
-} // namespace WebCore
+} // namespace blink