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