Commit ab7174a8 authored by junov@chromium.org's avatar junov@chromium.org

Ensure canvas state is preserved when 2d canvas falls out of display list mode

This change adds code to save and replay the canvas state stack when
transferring from a display list to a raste canvas

BUG=423913
TEST=fast/canvas/canvas-unballanced-save.html

Review URL: https://codereview.chromium.org/661763003

git-svn-id: svn://svn.chromium.org/blink/trunk@183904 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 4f6ac64e
<!DOCTYPE html>
<script>
window.onload = function () {
var ctx = document.getElementById('c').getContext('2d');
ctx.fillStyle = 'green';
ctx.fillRect(0, 0, 100, 100);
ctx.fillStyle = 'blue';
ctx.fillRect(10, 10, 80, 80);
ctx.fillStyle = 'red';
ctx.fillRect(20, 20, 60, 60);
}
</script>
<p>The canvas below should contain green, blue and red nested squares, all centered with respect to each other.</p>
<canvas id="c" width="100" height="100"></canvas>
<!DOCTYPE html>
<script>
var ctx;
window.onload = function () {
if (window.testRunner) {
testRunner.waitUntilDone();
}
ctx = document.getElementById('c').getContext('2d');
ctx.fillStyle = 'green';
ctx.fillRect(0, 0, 100, 100);
ctx.save();
ctx.translate(10, 0);
requestAnimationFrame(blueSquare);
}
function blueSquare() {
ctx.fillStyle = 'blue';
ctx.fillRect(0, 10, 80, 80);
requestAnimationFrame(redSquare);
}
function redSquare() {
ctx.fillStyle = 'red';
ctx.fillRect(10, 20, 60, 60);
if (window.testRunner) {
testRunner.notifyDone();
}
}
</script>
<p>The canvas below should contain green, blue and red nested squares, all centered with respect to each other.</p>
<canvas id="c" width="100" height="100"></canvas>
......@@ -88,10 +88,16 @@ void RecordingImageBufferSurface::fallBackToRasterCanvas()
m_previousFrame->draw(m_fallbackSurface->canvas());
m_previousFrame.clear();
}
if (m_currentFrame) {
bool savedState = false;
StateStack stateStack;
savedState = saveState(m_currentFrame->getRecordingCanvas(), &stateStack);
RefPtr<SkPicture> currentPicture = adoptRef(m_currentFrame->endRecording());
currentPicture->draw(m_fallbackSurface->canvas());
m_currentFrame.clear();
if (savedState)
setCurrentState(m_fallbackSurface->canvas(), &stateStack);
}
if (m_imageBuffer) {
......
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