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

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

Issue 1216833003: Make rendering use PaintingNodes for increased efficiency. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Feedback fixes plus missing critical line that makes it work Created 5 years, 5 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/PaintingNode.cpp
diff --git a/sky/engine/core/painting/PaintingNode.cpp b/sky/engine/core/painting/PaintingNode.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..55742ab6dc60d2ec23db52d20d948107d38ed7a9
--- /dev/null
+++ b/sky/engine/core/painting/PaintingNode.cpp
@@ -0,0 +1,76 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "sky/engine/core/painting/PaintingNode.h"
+#include "sky/engine/core/painting/Picture.h"
+
+namespace blink {
+
+// static
+PassRefPtr<PaintingNodeDrawable> PaintingNodeDrawable::create()
+{
+ return adoptRef(new PaintingNodeDrawable());
+}
+
+PassRefPtr<PaintingNodeDrawable> PaintingNodeDrawable::create(PassRefPtr<SkDrawable> skDrawable)
+{
+ return adoptRef(new PaintingNodeDrawable(skDrawable));
+}
+
+PaintingNodeDrawable::PaintingNodeDrawable()
+ : m_drawable(nullptr)
+{
+}
+
+PaintingNodeDrawable::PaintingNodeDrawable(PassRefPtr<SkDrawable> skDrawable)
+ : m_drawable(skDrawable)
+{
+}
abarth-chromium 2015/07/06 20:50:57 Rather than having two constructors, we could just
iansf 2015/07/07 21:11:22 Done.
+
+SkPicture* PaintingNodeDrawable::onNewPictureSnapshot()
+{
+ if (!m_drawable)
+ return nullptr;
+ return m_drawable->newPictureSnapshot();
+}
+
+SkRect PaintingNodeDrawable::onGetBounds()
+{
+ if (!m_drawable)
+ return SkRect::MakeEmpty();
+ return m_drawable->getBounds();
+}
+
+void PaintingNodeDrawable::onDraw(SkCanvas* canvas)
+{
+ if (!m_drawable)
+ return;
+ return m_drawable->draw(canvas);
+}
+
+
+
+
+PassRefPtr<PaintingNode> PaintingNode::create()
+{
+ return adoptRef(new PaintingNode());
+}
+
+PaintingNode::PaintingNode()
+ : m_paintingNodeDrawable(PaintingNodeDrawable::create())
+{
+}
+
+PassRefPtr<Picture> PaintingNode::newPictureSnapshot()
+{
+ assert(m_paintingNodeDrawable);
abarth-chromium 2015/07/06 20:50:57 s/assert/ASSERT/ ASSERT is a macro we define that
iansf 2015/07/07 20:36:47 Done.
+ return Picture::create(
+ adoptRef(m_paintingNodeDrawable->newPictureSnapshot()));
+}
+
+PaintingNode::~PaintingNode()
+{
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698