the imageSmoothingEnabled flag needs to be in the state object

https://bugs.webkit.org/show_bug.cgi?id=87853

Patch by Keyar Hood <keyar@chromium.org> on 2012-05-31
Reviewed by Darin Adler.

Source/WebCore:

Updated fast/canvas/canvas-imageSmoothingEnabled.html instead of
adding a new test.

The imageSmoothingEnabled flag is saved in the draw state now.
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::CanvasRenderingContext2D):
(WebCore::CanvasRenderingContext2D::State::State):
(WebCore::CanvasRenderingContext2D::State::operator=):
(WebCore::CanvasRenderingContext2D::webkitImageSmoothingEnabled):
(WebCore::CanvasRenderingContext2D::setWebkitImageSmoothingEnabled):
* html/canvas/CanvasRenderingContext2D.h:
(State):

LayoutTests:

Updated the test for imageSmoothingEnabled to test that it is saved in
the draw state.

* fast/canvas/canvas-imageSmoothingEnabled-expected.txt:
* fast/canvas/script-tests/canvas-imageSmoothingEnabled.js:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@119100 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 083d46a1
2012-05-31 Keyar Hood <keyar@chromium.org>
the imageSmoothingEnabled flag needs to be in the state object
https://bugs.webkit.org/show_bug.cgi?id=87853
Reviewed by Darin Adler.
Updated the test for imageSmoothingEnabled to test that it is saved in
the draw state.
* fast/canvas/canvas-imageSmoothingEnabled-expected.txt:
* fast/canvas/script-tests/canvas-imageSmoothingEnabled.js:
2012-05-31 Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com>
[EFL] Gardening after r118989
......
......@@ -7,6 +7,8 @@ Test that the default value is true.
PASS ctx.webkitImageSmoothingEnabled is true
Test that false is returned after a the attribute is set to false.
PASS ctx.webkitImageSmoothingEnabled is false
Test that restore works. We save a false state; create, then save a true state; and then finally restore.
PASS ctx.webkitImageSmoothingEnabled is false
New canvas element created.
Test that the image is smoothed by default. We check by making sure the pixel just to the left of the middle line is not completely black.
PASS left_of_center_pixel.data[0] !== 0 is true
......@@ -20,6 +22,10 @@ Test that the image is smoothed when imageSmoothingEnabled is set to true.
PASS left_of_center_pixel.data[0] !== 0 is true
PASS left_of_center_pixel.data[1] !== 0 is true
PASS left_of_center_pixel.data[2] !== 0 is true
Test that restoring actually changes smoothing and not just the attribute value. We are restoring to a point where imageSmoothingEnabled is set to false.
PASS left_of_center_pixel.data[0] is 0
PASS left_of_center_pixel.data[1] is 0
PASS left_of_center_pixel.data[2] is 0
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -8,6 +8,12 @@ debug("Test that false is returned after a the attribute is set to false.");
ctx.webkitImageSmoothingEnabled = false;
shouldBe("ctx.webkitImageSmoothingEnabled", "false");
debug("Test that restore works. We save a false state; create, then save a true state; and then finally restore.");
ctx.save();
ctx.webkitImageSmoothingEnabled = true;
ctx.restore();
shouldBe("ctx.webkitImageSmoothingEnabled", "false");
var image = document.createElement('canvas');
image.width = 2;
image.height = 1;
......@@ -59,3 +65,14 @@ shouldBe("left_of_center_pixel.data[0] !== 0", "true");
shouldBe("left_of_center_pixel.data[1] !== 0", "true");
shouldBe("left_of_center_pixel.data[2] !== 0", "true");
debug("Test that restoring actually changes smoothing and not just the attribute value. We are restoring to a point where imageSmoothingEnabled is set to false.");
ctx.webkitImageSmoothingEnabled = false;
ctx.save();
ctx.webkitImageSmoothingEnabled = true;
ctx.restore();
ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
left_of_center_pixel = ctx.getImageData(1, 0, 1, 1);
shouldBe("left_of_center_pixel.data[0]", "0");
shouldBe("left_of_center_pixel.data[1]", "0");
shouldBe("left_of_center_pixel.data[2]", "0");
2012-05-31 Keyar Hood <keyar@chromium.org>
the imageSmoothingEnabled flag needs to be in the state object
https://bugs.webkit.org/show_bug.cgi?id=87853
Reviewed by Darin Adler.
Updated fast/canvas/canvas-imageSmoothingEnabled.html instead of
adding a new test.
The imageSmoothingEnabled flag is saved in the draw state now.
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::CanvasRenderingContext2D):
(WebCore::CanvasRenderingContext2D::State::State):
(WebCore::CanvasRenderingContext2D::State::operator=):
(WebCore::CanvasRenderingContext2D::webkitImageSmoothingEnabled):
(WebCore::CanvasRenderingContext2D::setWebkitImageSmoothingEnabled):
* html/canvas/CanvasRenderingContext2D.h:
(State):
2012-05-31 Eugene Klyuchnikov <eustas.bug@gmail.com>
Web Inspector: Fix checkbox position on Settings screen.
......
......@@ -120,7 +120,6 @@ CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement* canvas, bo
#if ENABLE(DASHBOARD_SUPPORT)
, m_usesDashboardCompatibilityMode(usesDashboardCompatibilityMode)
#endif
, m_imageSmoothingEnabled(true)
{
#if !ENABLE(DASHBOARD_SUPPORT)
ASSERT_UNUSED(usesDashboardCompatibilityMode, !usesDashboardCompatibilityMode);
......@@ -181,6 +180,7 @@ CanvasRenderingContext2D::State::State()
, m_globalComposite(CompositeSourceOver)
, m_invertibleCTM(true)
, m_lineDashOffset(0)
, m_imageSmoothingEnabled(true)
, m_textAlign(StartTextAlign)
, m_textBaseline(AlphabeticTextBaseline)
, m_unparsedFont(defaultFont)
......@@ -206,6 +206,7 @@ CanvasRenderingContext2D::State::State(const State& other)
, m_transform(other.m_transform)
, m_invertibleCTM(other.m_invertibleCTM)
, m_lineDashOffset(other.m_lineDashOffset)
, m_imageSmoothingEnabled(other.m_imageSmoothingEnabled)
, m_textAlign(other.m_textAlign)
, m_textBaseline(other.m_textBaseline)
, m_unparsedFont(other.m_unparsedFont)
......@@ -239,6 +240,7 @@ CanvasRenderingContext2D::State& CanvasRenderingContext2D::State::operator=(cons
m_globalComposite = other.m_globalComposite;
m_transform = other.m_transform;
m_invertibleCTM = other.m_invertibleCTM;
m_imageSmoothingEnabled = other.m_imageSmoothingEnabled;
m_textAlign = other.m_textAlign;
m_textBaseline = other.m_textBaseline;
m_unparsedFont = other.m_unparsedFont;
......@@ -2268,16 +2270,17 @@ PlatformLayer* CanvasRenderingContext2D::platformLayer() const
bool CanvasRenderingContext2D::webkitImageSmoothingEnabled() const
{
return m_imageSmoothingEnabled;
return state().m_imageSmoothingEnabled;
}
void CanvasRenderingContext2D::setWebkitImageSmoothingEnabled(bool enabled)
{
if (enabled == m_imageSmoothingEnabled)
if (enabled == state().m_imageSmoothingEnabled)
return;
realizeSaves();
modifiableState().m_imageSmoothingEnabled = enabled;
drawingContext()->setImageInterpolationQuality(enabled ? DefaultInterpolationQuality : InterpolationNone);
m_imageSmoothingEnabled = enabled;
}
} // namespace WebCore
......@@ -252,6 +252,7 @@ private:
bool m_invertibleCTM;
DashArray m_lineDash;
float m_lineDashOffset;
bool m_imageSmoothingEnabled;
// Text state.
TextAlign m_textAlign;
......@@ -336,7 +337,6 @@ private:
#if ENABLE(DASHBOARD_SUPPORT)
bool m_usesDashboardCompatibilityMode;
#endif
bool m_imageSmoothingEnabled;
};
} // namespace WebCore
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment