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

Unified Diff: third_party/WebKit/Source/modules/csspaint/CSSPaintImageGeneratorImpl.cpp

Issue 1866623002: Hook up CSSPaintValue::image to CSS Paint API callback. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments + rebase. Created 4 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: third_party/WebKit/Source/modules/csspaint/CSSPaintImageGeneratorImpl.cpp
diff --git a/third_party/WebKit/Source/modules/csspaint/CSSPaintImageGeneratorImpl.cpp b/third_party/WebKit/Source/modules/csspaint/CSSPaintImageGeneratorImpl.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ddcec10b0b5d0789a7f95f9a6ee93d10563c556f
--- /dev/null
+++ b/third_party/WebKit/Source/modules/csspaint/CSSPaintImageGeneratorImpl.cpp
@@ -0,0 +1,68 @@
+// Copyright 2016 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 "modules/csspaint/CSSPaintImageGeneratorImpl.h"
+
+#include "core/dom/Document.h"
+#include "core/frame/LocalDOMWindow.h"
+#include "modules/csspaint/CSSPaintDefinition.h"
+#include "modules/csspaint/PaintWorklet.h"
+#include "modules/csspaint/WindowPaintWorklet.h"
+#include "platform/graphics/Image.h"
+
+namespace blink {
+
+CSSPaintImageGenerator* CSSPaintImageGeneratorImpl::create(const String& name, Document& document, Observer* observer)
+{
+ LocalDOMWindow* domWindow = document.domWindow();
+ PaintWorklet* paintWorklet = WindowPaintWorklet::from(*domWindow).paintWorklet(&document);
+
+ CSSPaintDefinition* paintDefinition = paintWorklet->findDefinition(name);
+ CSSPaintImageGeneratorImpl* generator;
+ if (!paintDefinition) {
+ generator = new CSSPaintImageGeneratorImpl(observer);
+ paintWorklet->addPendingGenerator(name, generator);
+ } else {
+ generator = new CSSPaintImageGeneratorImpl(paintDefinition);
+ }
+
+ return generator;
+}
+
+CSSPaintImageGeneratorImpl::CSSPaintImageGeneratorImpl(CSSPaintDefinition* definition)
+ : m_definition(definition)
+{
+}
+
+CSSPaintImageGeneratorImpl::CSSPaintImageGeneratorImpl(Observer* observer)
+ : m_observer(observer)
+{
+}
+
+CSSPaintImageGeneratorImpl::~CSSPaintImageGeneratorImpl()
+{
+}
+
+void CSSPaintImageGeneratorImpl::setDefinition(CSSPaintDefinition* definition)
+{
+ ASSERT(!m_definition);
+ m_definition = definition;
+
+ ASSERT(m_observer);
+ m_observer->paintImageGeneratorReady();
+}
+
+PassRefPtr<Image> CSSPaintImageGeneratorImpl::paint(const IntSize& size)
+{
+ return m_definition ? m_definition->paint(size) : nullptr;
+}
+
+DEFINE_TRACE(CSSPaintImageGeneratorImpl)
+{
+ visitor->trace(m_definition);
+ visitor->trace(m_observer);
+ CSSPaintImageGenerator::trace(visitor);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698