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

Side by Side Diff: sky/engine/core/painting/Canvas.cpp

Issue 1122423009: Make it possible to custom-paint without an Element. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Comment tweak Created 5 years, 7 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 unified diff | Download patch
OLDNEW
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/PictureRecorder.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" 12 #include "third_party/skia/include/core/SkCanvas.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 PassRefPtr<PaintingContext> PaintingContext::create(PassRefPtr<Element> element, const FloatSize& size) 16 Canvas::Canvas(const FloatSize& size)
17 { 17 : m_size(size)
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)
24 { 18 {
25 m_displayList = adoptRef(new DisplayList); 19 m_displayList = adoptRef(new DisplayList);
26 m_canvas = m_displayList->beginRecording(expandedIntSize(m_size)); 20 m_canvas = m_displayList->beginRecording(expandedIntSize(m_size));
27 } 21 }
28 22
29 PaintingContext::~PaintingContext() 23 Canvas::~Canvas()
30 { 24 {
31 } 25 }
32 26
33 void PaintingContext::drawCircle(double x, double y, double radius, Paint* paint ) 27 void Canvas::drawCircle(double x, double y, double radius, Paint* paint)
34 { 28 {
35 if (!m_canvas) 29 if (!m_canvas)
36 return; 30 return;
37 ASSERT(paint); 31 ASSERT(paint);
38 ASSERT(m_displayList->isRecording()); 32 ASSERT(m_displayList->isRecording());
39 m_canvas->drawCircle(x, y, radius, paint->paint()); 33 m_canvas->drawCircle(x, y, radius, paint->paint());
40 } 34 }
41 35
42 void PaintingContext::commit() 36 PassRefPtr<DisplayList> Canvas::finishRecording()
43 { 37 {
44 if (!m_canvas) 38 if (!isRecording())
45 return; 39 return nullptr;
40 m_canvas = nullptr;
46 m_displayList->endRecording(); 41 m_displayList->endRecording();
47 m_canvas = nullptr; 42 return m_displayList.release();
48 PaintingTasks::enqueueCommit(m_element, m_displayList.release());
49 m_element->document().scheduleVisualUpdate();
50 } 43 }
51 44
52 } // namespace blink 45 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698