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

Unified Diff: Source/platform/graphics/GraphicsContext.cpp

Issue 1087633002: [SP] Allocate an SkPictureRecorder only once per GraphicsContext instantiation (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 8 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/GraphicsContext.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/GraphicsContext.cpp
diff --git a/Source/platform/graphics/GraphicsContext.cpp b/Source/platform/graphics/GraphicsContext.cpp
index 62c278281ef1aeef0be5148bd72acb027d9d80ff..8ded7947e1ac8e0aa85a66e15093152e612efd37 100644
--- a/Source/platform/graphics/GraphicsContext.cpp
+++ b/Source/platform/graphics/GraphicsContext.cpp
@@ -56,6 +56,8 @@ class GraphicsContext::RecordingState {
public:
static PassOwnPtr<RecordingState> Create(SkCanvas* canvas, const SkMatrix& matrix)
{
+ // Slimmming Paint uses m_pictureRecorder on GraphicsContext instead.
+ ASSERT(!RuntimeEnabledFeatures::slimmingPaintEnabled());
return adoptPtr(new RecordingState(canvas, matrix));
}
@@ -76,7 +78,10 @@ private:
GraphicsContext::GraphicsContext(DisplayItemList* displayItemList, DisabledMode disableContextOrPainting)
: GraphicsContext(nullptr, displayItemList, disableContextOrPainting)
-{ }
+{
+ // TODO(chrishtr): switch the type of the parameter to DisplayItemList&.
+ ASSERT(displayItemList);
+}
PassOwnPtr<GraphicsContext> GraphicsContext::deprecatedCreateWithCanvas(SkCanvas* canvas, DisabledMode disableContextOrPainting)
{
@@ -85,6 +90,7 @@ PassOwnPtr<GraphicsContext> GraphicsContext::deprecatedCreateWithCanvas(SkCanvas
GraphicsContext::GraphicsContext(SkCanvas* canvas, DisplayItemList* displayItemList, DisabledMode disableContextOrPainting)
: m_canvas(canvas)
+ , m_originalCanvas(canvas)
, m_displayItemList(displayItemList)
, m_clipRecorderStack(0)
, m_paintStateStack()
@@ -472,6 +478,11 @@ void GraphicsContext::beginRecording(const FloatRect& bounds, uint32_t recordFla
if (contextDisabled())
return;
+ if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
+ m_canvas = m_pictureRecorder.beginRecording(bounds, 0, recordFlags);
+ return;
+ }
+
m_recordingStateStack.append(
RecordingState::Create(m_canvas, getTotalMatrix()));
m_canvas = m_recordingStateStack.last()->recorder().beginRecording(bounds, 0, recordFlags);
@@ -482,6 +493,13 @@ PassRefPtr<const SkPicture> GraphicsContext::endRecording()
if (contextDisabled())
return nullptr;
+ if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
+ RefPtr<const SkPicture> picture = adoptRef(m_pictureRecorder.endRecordingAsPicture());
+ m_canvas = m_originalCanvas;
+ ASSERT(picture);
+ return picture.release();
+ }
+
ASSERT(!m_recordingStateStack.isEmpty());
RecordingState* recording = m_recordingStateStack.last().get();
RefPtr<const SkPicture> picture = adoptRef(recording->recorder().endRecordingAsPicture());
@@ -495,6 +513,9 @@ PassRefPtr<const SkPicture> GraphicsContext::endRecording()
bool GraphicsContext::isRecording() const
{
+ if (RuntimeEnabledFeatures::slimmingPaintEnabled())
+ return m_canvas != m_originalCanvas;
+
return !m_recordingStateStack.isEmpty();
}
« no previous file with comments | « Source/platform/graphics/GraphicsContext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698