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

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
Index: Source/platform/graphics/GraphicsContext.cpp
diff --git a/Source/platform/graphics/GraphicsContext.cpp b/Source/platform/graphics/GraphicsContext.cpp
index 62c278281ef1aeef0be5148bd72acb027d9d80ff..f655de002f4885467da85cc843f9c7f4fd5d12cb 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));
}
@@ -111,6 +113,10 @@ GraphicsContext::GraphicsContext(SkCanvas* canvas, DisplayItemList* displayItemL
DEFINE_STATIC_LOCAL(RefPtr<SkCanvas>, nullCanvas, (adoptRef(SkCreateNullCanvas())));
m_canvas = nullCanvas.get();
}
+
+ // TODO(chrishtr): switch the type of the parameter to DisplayItemList&
+ ASSERT(displayItemList);
+ m_pictureRecorder = adoptPtr(new SkPictureRecorder);
}
GraphicsContext::~GraphicsContext()
@@ -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 = nullptr;
+ 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;
+
return !m_recordingStateStack.isEmpty();
}
« Source/platform/graphics/GraphicsContext.h ('K') | « Source/platform/graphics/GraphicsContext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698