Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Unified Diff: Source/platform/graphics/paint/DrawingRecorder.cpp

Issue 1144203004: Allow certain SP recorder classes to defer their "begin" operation. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/graphics/paint/DrawingRecorder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « Source/platform/graphics/paint/DrawingRecorder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698