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

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

Issue 1017593005: Add a basic custom painting facility to Sky (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Add missing files Created 5 years, 9 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/PaintingContext.h"
7 7
8 #include "base/bind.h"
9 #include "sky/engine/core/dom/Microtask.h"
8 #include "sky/engine/platform/geometry/IntRect.h" 10 #include "sky/engine/platform/geometry/IntRect.h"
9 #include "third_party/skia/include/core/SkCanvas.h" 11 #include "third_party/skia/include/core/SkCanvas.h"
10 12
11 namespace blink { 13 namespace blink {
12 14
13 PaintingContext::PaintingContext(const FloatRect& bounds) 15 PaintingContext::PaintingContext(const FloatSize& size, const CommitCallback& co mmitCallback)
16 : m_size(size)
17 , m_commitCallback(commitCallback)
14 { 18 {
15 m_displayList = adoptRef(new DisplayList(bounds)); 19 m_displayList = adoptRef(new DisplayList);
16 m_canvas = m_displayList->beginRecording(enclosingIntRect(bounds).size()); 20 m_canvas = m_displayList->beginRecording(expandedIntSize(size));
17 } 21 }
18 22
19 PaintingContext::~PaintingContext() 23 PaintingContext::~PaintingContext()
20 { 24 {
21 } 25 }
22 26
23 void PaintingContext::drawCircle(double x, double y, double radius, Paint* paint ) 27 void PaintingContext::drawCircle(double x, double y, double radius, Paint* paint )
24 { 28 {
25 if (!m_canvas) 29 if (!m_canvas)
26 return; 30 return;
27 ASSERT(paint); 31 ASSERT(paint);
28 ASSERT(m_displayList->isRecording()); 32 ASSERT(m_displayList->isRecording());
29 m_canvas->drawCircle(x, y, radius, paint->paint()); 33 m_canvas->drawCircle(x, y, radius, paint->paint());
30 } 34 }
31 35
32 void PaintingContext::commit() 36 void PaintingContext::commit()
33 { 37 {
38 if (!m_canvas)
39 return;
34 m_displayList->endRecording(); 40 m_displayList->endRecording();
35 m_canvas = nullptr; 41 m_canvas = nullptr;
42 Microtask::enqueueMicrotask(base::Bind(m_commitCallback, this));
36 } 43 }
37 44
38 } // namespace blink 45 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698