| Index: Source/platform/graphics/paint/DrawingRecorder.cpp
|
| diff --git a/Source/platform/graphics/paint/DrawingRecorder.cpp b/Source/platform/graphics/paint/DrawingRecorder.cpp
|
| index 65d0aeaeee5d53cdcff8e0a260558a6d207d4643..ff96604b50796f854b9a885bc82c99f44020d017 100644
|
| --- a/Source/platform/graphics/paint/DrawingRecorder.cpp
|
| +++ b/Source/platform/graphics/paint/DrawingRecorder.cpp
|
| @@ -15,53 +15,30 @@
|
|
|
| namespace blink {
|
|
|
| -DrawingRecorder::DrawingRecorder(GraphicsContext& context, const DisplayItemClientWrapper& displayItemClient, DisplayItem::Type displayItemType, const FloatRect& cullRect)
|
| +DrawingRecorder::DrawingRecorder(GraphicsContext& context, const DisplayItemClientWrapper& displayItemClient, DisplayItem::Type displayItemType)
|
| : m_context(context)
|
| , m_displayItemClient(displayItemClient)
|
| , m_displayItemType(displayItemType)
|
| , m_canUseCachedDrawing(false)
|
| + , m_engaged(false)
|
| #if ENABLE(ASSERT)
|
| , m_checkedCachedDrawing(false)
|
| , m_displayItemPosition(RuntimeEnabledFeatures::slimmingPaintEnabled() ? m_context.displayItemList()->newDisplayItemsSize() : 0)
|
| , m_skipUnderInvalidationChecking(false)
|
| #endif
|
| {
|
| - if (!RuntimeEnabledFeatures::slimmingPaintEnabled())
|
| - return;
|
| -
|
| - ASSERT(context.displayItemList());
|
| - if (context.displayItemList()->displayItemConstructionIsDisabled())
|
| - return;
|
| -
|
| - ASSERT(DisplayItem::isDrawingType(displayItemType));
|
| - m_canUseCachedDrawing = context.displayItemList()->clientCacheIsValid(displayItemClient.displayItemClient());
|
| -
|
| -#if ENABLE(ASSERT)
|
| - context.setInDrawingRecorder(true);
|
| - m_canUseCachedDrawing &= !RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled();
|
| -#endif
|
| -
|
| -#ifndef NDEBUG
|
| - // Enable recording to check if any painter is still doing unnecessary painting when we can use cache.
|
| - context.beginRecording(cullRect);
|
| -#else
|
| - if (!m_canUseCachedDrawing)
|
| - context.beginRecording(cullRect);
|
| -#endif
|
| +}
|
|
|
| -#if ENABLE(ASSERT)
|
| - if (RuntimeEnabledFeatures::slimmingPaintStrictCullRectClippingEnabled() && !m_canUseCachedDrawing) {
|
| - // Skia depends on the cull rect containing all of the display item commands. When strict
|
| - // cull rect clipping is enabled, make this explicit. This allows us to identify potential
|
| - // incorrect cull rects that might otherwise be masked due to Skia internal optimizations.
|
| - context.save();
|
| - context.clipRect(enclosingIntRect(cullRect), NotAntiAliased, SkRegion::kIntersect_Op);
|
| - }
|
| -#endif
|
| +DrawingRecorder::DrawingRecorder(GraphicsContext& context, const DisplayItemClientWrapper& displayItemClient, DisplayItem::Type displayItemType, const FloatRect& cullRect)
|
| + : DrawingRecorder(context, displayItemClient, displayItemType)
|
| +{
|
| + begin(cullRect);
|
| }
|
|
|
| DrawingRecorder::~DrawingRecorder()
|
| {
|
| + if (!m_engaged)
|
| + return;
|
| if (!RuntimeEnabledFeatures::slimmingPaintEnabled())
|
| return;
|
|
|
| @@ -97,4 +74,43 @@ DrawingRecorder::~DrawingRecorder()
|
| }
|
| }
|
|
|
| +void DrawingRecorder::begin(const FloatRect& cullRect)
|
| +{
|
| + ASSERT(!m_engaged);
|
| + m_engaged = true;
|
| +
|
| + if (!RuntimeEnabledFeatures::slimmingPaintEnabled())
|
| + return;
|
| +
|
| + ASSERT(m_context.displayItemList());
|
| + if (m_context.displayItemList()->displayItemConstructionIsDisabled())
|
| + return;
|
| +
|
| + ASSERT(DisplayItem::isDrawingType(m_displayItemType));
|
| + m_canUseCachedDrawing = m_context.displayItemList()->clientCacheIsValid(m_displayItemClient.displayItemClient());
|
| +
|
| +#if ENABLE(ASSERT)
|
| + m_context.setInDrawingRecorder(true);
|
| + m_canUseCachedDrawing &= !RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled();
|
| +#endif
|
| +
|
| +#ifndef NDEBUG
|
| + // Enable recording to check if any painter is still doing unnecessary painting when we can use cache.
|
| + m_context.beginRecording(cullRect);
|
| +#else
|
| + if (!m_canUseCachedDrawing)
|
| + m_context.beginRecording(cullRect);
|
| +#endif
|
| +
|
| +#if ENABLE(ASSERT)
|
| + if (RuntimeEnabledFeatures::slimmingPaintStrictCullRectClippingEnabled() && !m_canUseCachedDrawing) {
|
| + // Skia depends on the cull rect containing all of the display item commands. When strict
|
| + // cull rect clipping is enabled, make this explicit. This allows us to identify potential
|
| + // incorrect cull rects that might otherwise be masked due to Skia internal optimizations.
|
| + m_context.save();
|
| + m_context.clipRect(enclosingIntRect(cullRect), NotAntiAliased, SkRegion::kIntersect_Op);
|
| + }
|
| +#endif
|
| +}
|
| +
|
| } // namespace blink
|
|
|