| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "sky/engine/config.h" | 5 #include "sky/engine/config.h" |
| 6 #include "sky/engine/core/painting/PaintingContext.h" | 6 #include "sky/engine/core/painting/PaintingContext.h" |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "sky/engine/core/dom/Document.h" |
| 9 #include "sky/engine/core/dom/Microtask.h" | 9 #include "sky/engine/core/dom/Element.h" |
| 10 #include "sky/engine/core/painting/PaintingTasks.h" |
| 10 #include "sky/engine/platform/geometry/IntRect.h" | 11 #include "sky/engine/platform/geometry/IntRect.h" |
| 11 #include "third_party/skia/include/core/SkCanvas.h" | 12 #include "third_party/skia/include/core/SkCanvas.h" |
| 12 | 13 |
| 13 namespace blink { | 14 namespace blink { |
| 14 | 15 |
| 15 PaintingContext::PaintingContext(const FloatSize& size, const CommitCallback& co
mmitCallback) | 16 PassRefPtr<PaintingContext> PaintingContext::create(PassRefPtr<Element> element,
const FloatSize& size) |
| 16 : m_size(size) | 17 { |
| 17 , m_commitCallback(commitCallback) | 18 return adoptRef(new PaintingContext(element, size)); |
| 19 } |
| 20 |
| 21 PaintingContext::PaintingContext(PassRefPtr<Element> element, const FloatSize& s
ize) |
| 22 : m_element(element) |
| 23 , m_size(size) |
| 18 { | 24 { |
| 19 m_displayList = adoptRef(new DisplayList); | 25 m_displayList = adoptRef(new DisplayList); |
| 20 m_canvas = m_displayList->beginRecording(expandedIntSize(size)); | 26 m_canvas = m_displayList->beginRecording(expandedIntSize(m_size)); |
| 21 } | 27 } |
| 22 | 28 |
| 23 PaintingContext::~PaintingContext() | 29 PaintingContext::~PaintingContext() |
| 24 { | 30 { |
| 25 } | 31 } |
| 26 | 32 |
| 27 void PaintingContext::drawCircle(double x, double y, double radius, Paint* paint
) | 33 void PaintingContext::drawCircle(double x, double y, double radius, Paint* paint
) |
| 28 { | 34 { |
| 29 if (!m_canvas) | 35 if (!m_canvas) |
| 30 return; | 36 return; |
| 31 ASSERT(paint); | 37 ASSERT(paint); |
| 32 ASSERT(m_displayList->isRecording()); | 38 ASSERT(m_displayList->isRecording()); |
| 33 m_canvas->drawCircle(x, y, radius, paint->paint()); | 39 m_canvas->drawCircle(x, y, radius, paint->paint()); |
| 34 } | 40 } |
| 35 | 41 |
| 36 void PaintingContext::commit() | 42 void PaintingContext::commit() |
| 37 { | 43 { |
| 38 if (!m_canvas) | 44 if (!m_canvas) |
| 39 return; | 45 return; |
| 40 m_displayList->endRecording(); | 46 m_displayList->endRecording(); |
| 41 m_canvas = nullptr; | 47 m_canvas = nullptr; |
| 42 Microtask::enqueueMicrotask(base::Bind(m_commitCallback, this)); | 48 PaintingTasks::enqueueCommit(m_element, m_displayList.release()); |
| 49 m_element->document().scheduleVisualUpdate(); |
| 43 } | 50 } |
| 44 | 51 |
| 45 } // namespace blink | 52 } // namespace blink |
| OLD | NEW |