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

Unified Diff: sky/engine/core/painting/Canvas.cpp

Issue 1122423009: Make it possible to custom-paint without an Element. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Comment tweak 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
Index: sky/engine/core/painting/Canvas.cpp
diff --git a/sky/engine/core/painting/PaintingContext.cpp b/sky/engine/core/painting/Canvas.cpp
similarity index 55%
copy from sky/engine/core/painting/PaintingContext.cpp
copy to sky/engine/core/painting/Canvas.cpp
index 0bac4898e52ba248bbd421c8bbed01ef0073a218..5e25baf4893daf35302066caabb6bb74ca24b369 100644
--- a/sky/engine/core/painting/PaintingContext.cpp
+++ b/sky/engine/core/painting/Canvas.cpp
@@ -3,7 +3,7 @@
// found in the LICENSE file.
#include "sky/engine/config.h"
-#include "sky/engine/core/painting/PaintingContext.h"
+#include "sky/engine/core/painting/PictureRecorder.h"
#include "sky/engine/core/dom/Document.h"
#include "sky/engine/core/dom/Element.h"
@@ -13,24 +13,18 @@
namespace blink {
-PassRefPtr<PaintingContext> PaintingContext::create(PassRefPtr<Element> element, const FloatSize& size)
-{
- return adoptRef(new PaintingContext(element, size));
-}
-
-PaintingContext::PaintingContext(PassRefPtr<Element> element, const FloatSize& size)
- : m_element(element)
- , m_size(size)
+Canvas::Canvas(const FloatSize& size)
+ : m_size(size)
{
m_displayList = adoptRef(new DisplayList);
m_canvas = m_displayList->beginRecording(expandedIntSize(m_size));
}
-PaintingContext::~PaintingContext()
+Canvas::~Canvas()
{
}
-void PaintingContext::drawCircle(double x, double y, double radius, Paint* paint)
+void Canvas::drawCircle(double x, double y, double radius, Paint* paint)
{
if (!m_canvas)
return;
@@ -39,14 +33,13 @@ void PaintingContext::drawCircle(double x, double y, double radius, Paint* paint
m_canvas->drawCircle(x, y, radius, paint->paint());
}
-void PaintingContext::commit()
+PassRefPtr<DisplayList> Canvas::finishRecording()
{
- if (!m_canvas)
- return;
- m_displayList->endRecording();
+ if (!isRecording())
+ return nullptr;
m_canvas = nullptr;
- PaintingTasks::enqueueCommit(m_element, m_displayList.release());
- m_element->document().scheduleVisualUpdate();
+ m_displayList->endRecording();
+ return m_displayList.release();
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698