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

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: 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
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, float x, float y, const Paint* paint)
161 {
162 if (!m_canvas)
163 return;
164 ASSERT(image);
165 ASSERT(m_displayList->isRecording());
166 m_canvas->drawBitmap(image->bitmap(), x, y, &paint->paint());
167 }
168
158 PassRefPtr<DisplayList> Canvas::finishRecording() 169 PassRefPtr<DisplayList> Canvas::finishRecording()
159 { 170 {
160 if (!isRecording()) 171 if (!isRecording())
161 return nullptr; 172 return nullptr;
162 m_canvas = nullptr; 173 m_canvas = nullptr;
163 m_displayList->endRecording(); 174 m_displayList->endRecording();
164 return m_displayList.release(); 175 return m_displayList.release();
165 } 176 }
166 177
167 } // namespace blink 178 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698