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

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

Issue 1151753009: Add Sky framework support for drawing images (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Run git cl format once more Created 5 years, 6 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
« no previous file with comments | « sky/engine/core/painting/Canvas.h ('k') | sky/engine/core/painting/Canvas.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/Canvas.h" 6 #include "sky/engine/core/painting/Canvas.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/CanvasImage.h"
10 #include "sky/engine/core/painting/PaintingTasks.h" 11 #include "sky/engine/core/painting/PaintingTasks.h"
11 #include "sky/engine/platform/geometry/IntRect.h" 12 #include "sky/engine/platform/geometry/IntRect.h"
12 #include "third_party/skia/include/core/SkCanvas.h" 13 #include "third_party/skia/include/core/SkCanvas.h"
14 #include "third_party/skia/include/core/SkBitmap.h"
13 15
14 namespace blink { 16 namespace blink {
15 17
16 Canvas::Canvas(const FloatSize& size) 18 Canvas::Canvas(const FloatSize& size)
17 : m_size(size) 19 : m_size(size)
18 { 20 {
19 m_displayList = adoptRef(new DisplayList); 21 m_displayList = adoptRef(new DisplayList);
20 m_canvas = m_displayList->beginRecording(expandedIntSize(m_size)); 22 m_canvas = m_displayList->beginRecording(expandedIntSize(m_size));
21 } 23 }
22 24
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 void Canvas::drawPath(const CanvasPath* path, const Paint* paint) 150 void Canvas::drawPath(const CanvasPath* path, const Paint* paint)
149 { 151 {
150 if (!m_canvas) 152 if (!m_canvas)
151 return; 153 return;
152 ASSERT(path); 154 ASSERT(path);
153 ASSERT(paint); 155 ASSERT(paint);
154 ASSERT(m_displayList->isRecording()); 156 ASSERT(m_displayList->isRecording());
155 m_canvas->drawPath(path->path(), paint->paint()); 157 m_canvas->drawPath(path->path(), paint->paint());
156 } 158 }
157 159
160 void Canvas::drawImage(const CanvasImage* image,
161 float x,
162 float y,
163 const Paint* paint) {
164 if (!m_canvas)
165 return;
166 ASSERT(image);
167 ASSERT(m_displayList->isRecording());
168 m_canvas->drawBitmap(image->bitmap(), x, y, &paint->paint());
169 }
170
158 PassRefPtr<DisplayList> Canvas::finishRecording() 171 PassRefPtr<DisplayList> Canvas::finishRecording()
159 { 172 {
160 if (!isRecording()) 173 if (!isRecording())
161 return nullptr; 174 return nullptr;
162 m_canvas = nullptr; 175 m_canvas = nullptr;
163 m_displayList->endRecording(); 176 m_displayList->endRecording();
164 return m_displayList.release(); 177 return m_displayList.release();
165 } 178 }
166 179
167 } // namespace blink 180 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/painting/Canvas.h ('k') | sky/engine/core/painting/Canvas.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698