Chromium Code Reviews| Index: Source/platform/graphics/GraphicsContext.cpp |
| diff --git a/Source/platform/graphics/GraphicsContext.cpp b/Source/platform/graphics/GraphicsContext.cpp |
| index 02af6b47f1201460f733dcbcf36ccf8566019a05..a841e288a01b899e51be7893761b2c729cb5739c 100644 |
| --- a/Source/platform/graphics/GraphicsContext.cpp |
| +++ b/Source/platform/graphics/GraphicsContext.cpp |
| @@ -122,6 +122,8 @@ GraphicsContext::GraphicsContext(SkCanvas* canvas, DisabledMode disableContextOr |
| #if !ASSERT_DISABLED |
| , m_annotationCount(0) |
| , m_layerCount(0) |
| + , m_saveCount(0) |
| + , m_disableDestructionChecks(false) |
| #endif |
| , m_disabledState(disableContextOrPainting) |
| , m_trackOpaqueRegion(false) |
| @@ -144,23 +146,24 @@ GraphicsContext::GraphicsContext(SkCanvas* canvas, DisabledMode disableContextOr |
| GraphicsContext::~GraphicsContext() |
| { |
| -#if !ENABLE(OILPAN) |
| - // FIXME: Oilpan: These asserts are not true for |
| - // CanvasRenderingContext2D. Therefore, there is debug mode code |
| - // in the CanvasRenderingContext2D that forces this to be true so |
| - // that the assertions can be here for all the other cases. With |
| - // Oilpan we cannot run that code in the CanvasRenderingContext2D |
| - // destructor because it touches other objects that are already |
| - // dead. We need to find another way of doing these asserts when |
| - // Oilpan is enabled. |
| - ASSERT(!m_paintStateIndex); |
| - ASSERT(!m_paintState->saveCount()); |
| - ASSERT(!m_annotationCount); |
| - ASSERT(!m_layerCount); |
| - ASSERT(m_recordingStateStack.isEmpty()); |
| +#if !ASSERT_DISABLED |
| + if (!m_disableDestructionChecks) { |
| + ASSERT(!m_paintStateIndex); |
| + ASSERT(!m_paintState->saveCount()); |
| + ASSERT(!m_annotationCount); |
| + ASSERT(!m_layerCount); |
| + ASSERT(!m_saveCount); |
| + ASSERT(m_recordingStateStack.isEmpty()); |
| + } |
| #endif |
| } |
| +void GraphicsContext::unwindStateStack() |
| +{ |
| + while (m_paintStateIndex || m_paintState->saveCount()) |
| + restore(); |
|
f(malita)
2014/05/27 20:28:22
You can probably drive this off m_canvasStateStack
|
| +} |
| + |
| void GraphicsContext::save() |
| { |
| if (contextDisabled()) |
| @@ -170,6 +173,10 @@ void GraphicsContext::save() |
| m_canvasStateStack.append(CanvasSaveState(m_pendingCanvasSave, m_canvas->getSaveCount())); |
| m_pendingCanvasSave = true; |
| + |
| +#if !ASSERT_DISABLED |
| + m_saveCount++; |
| +#endif |
| } |
| void GraphicsContext::restore() |
| @@ -193,6 +200,9 @@ void GraphicsContext::restore() |
| m_canvasStateStack.removeLast(); |
| m_pendingCanvasSave = savedState.m_pendingSave; |
| m_canvas->restoreToCount(savedState.m_restoreCount); |
| +#if !ASSERT_DISABLED |
| + m_saveCount--; |
| +#endif |
| } |
| void GraphicsContext::saveLayer(const SkRect* bounds, const SkPaint* paint) |