| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/csspaint/CSSPaintImageGeneratorImpl.h" | 5 #include "modules/csspaint/CSSPaintImageGeneratorImpl.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/frame/LocalDOMWindow.h" | 8 #include "core/frame/LocalDOMWindow.h" |
| 9 #include "modules/csspaint/CSSPaintDefinition.h" | 9 #include "modules/csspaint/CSSPaintDefinition.h" |
| 10 #include "modules/csspaint/PaintWorklet.h" | 10 #include "modules/csspaint/PaintWorklet.h" |
| 11 #include "modules/csspaint/WindowPaintWorklet.h" | 11 #include "modules/csspaint/WindowPaintWorklet.h" |
| 12 #include "platform/graphics/Image.h" | 12 #include "platform/graphics/Image.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 CSSPaintImageGenerator* CSSPaintImageGeneratorImpl::Create(const String& name, | 16 CSSPaintImageGenerator* CSSPaintImageGeneratorImpl::Create( |
| 17 Document& document, | 17 const String& name, |
| 18 Observer* observer) { | 18 const Document& document, |
| 19 Observer* observer) { |
| 19 LocalDOMWindow* dom_window = document.domWindow(); | 20 LocalDOMWindow* dom_window = document.domWindow(); |
| 20 PaintWorklet* paint_worklet = | 21 PaintWorklet* paint_worklet = |
| 21 WindowPaintWorklet::From(*dom_window).paintWorklet(); | 22 WindowPaintWorklet::From(*dom_window).paintWorklet(); |
| 22 | 23 |
| 23 CSSPaintDefinition* paint_definition = paint_worklet->FindDefinition(name); | 24 CSSPaintDefinition* paint_definition = paint_worklet->FindDefinition(name); |
| 24 CSSPaintImageGeneratorImpl* generator; | 25 CSSPaintImageGeneratorImpl* generator; |
| 25 if (!paint_definition) { | 26 if (!paint_definition) { |
| 26 generator = new CSSPaintImageGeneratorImpl(observer); | 27 generator = new CSSPaintImageGeneratorImpl(observer); |
| 27 paint_worklet->AddPendingGenerator(name, generator); | 28 paint_worklet->AddPendingGenerator(name, generator); |
| 28 } else { | 29 } else { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 43 | 44 |
| 44 void CSSPaintImageGeneratorImpl::SetDefinition(CSSPaintDefinition* definition) { | 45 void CSSPaintImageGeneratorImpl::SetDefinition(CSSPaintDefinition* definition) { |
| 45 DCHECK(!definition_); | 46 DCHECK(!definition_); |
| 46 definition_ = definition; | 47 definition_ = definition; |
| 47 | 48 |
| 48 DCHECK(observer_); | 49 DCHECK(observer_); |
| 49 observer_->PaintImageGeneratorReady(); | 50 observer_->PaintImageGeneratorReady(); |
| 50 } | 51 } |
| 51 | 52 |
| 52 PassRefPtr<Image> CSSPaintImageGeneratorImpl::Paint( | 53 PassRefPtr<Image> CSSPaintImageGeneratorImpl::Paint( |
| 53 const LayoutObject& layout_object, | 54 const ImageResourceObserver& observer, |
| 54 const IntSize& size, | 55 const IntSize& size, |
| 55 const CSSStyleValueVector* data) { | 56 const CSSStyleValueVector* data) { |
| 56 return definition_ ? definition_->Paint(layout_object, size, data) : nullptr; | 57 return definition_ ? definition_->Paint(observer, size, data) : nullptr; |
| 57 } | 58 } |
| 58 | 59 |
| 59 const Vector<CSSPropertyID>& | 60 const Vector<CSSPropertyID>& |
| 60 CSSPaintImageGeneratorImpl::NativeInvalidationProperties() const { | 61 CSSPaintImageGeneratorImpl::NativeInvalidationProperties() const { |
| 61 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, empty_vector, ()); | 62 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, empty_vector, ()); |
| 62 return definition_ ? definition_->NativeInvalidationProperties() | 63 return definition_ ? definition_->NativeInvalidationProperties() |
| 63 : empty_vector; | 64 : empty_vector; |
| 64 } | 65 } |
| 65 | 66 |
| 66 const Vector<AtomicString>& | 67 const Vector<AtomicString>& |
| (...skipping 17 matching lines...) Expand all Loading... |
| 84 return definition_; | 85 return definition_; |
| 85 } | 86 } |
| 86 | 87 |
| 87 DEFINE_TRACE(CSSPaintImageGeneratorImpl) { | 88 DEFINE_TRACE(CSSPaintImageGeneratorImpl) { |
| 88 visitor->Trace(definition_); | 89 visitor->Trace(definition_); |
| 89 visitor->Trace(observer_); | 90 visitor->Trace(observer_); |
| 90 CSSPaintImageGenerator::Trace(visitor); | 91 CSSPaintImageGenerator::Trace(visitor); |
| 91 } | 92 } |
| 92 | 93 |
| 93 } // namespace blink | 94 } // namespace blink |
| OLD | NEW |