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 #ifndef SKY_ENGINE_CORE_PAINTING_CANVAS_H_ | 5 #ifndef SKY_ENGINE_CORE_PAINTING_CANVAS_H_ |
6 #define SKY_ENGINE_CORE_PAINTING_CANVAS_H_ | 6 #define SKY_ENGINE_CORE_PAINTING_CANVAS_H_ |
7 | 7 |
8 #include "sky/engine/core/painting/CanvasPath.h" | 8 #include "sky/engine/core/painting/CanvasPath.h" |
9 #include "sky/engine/core/painting/Paint.h" | 9 #include "sky/engine/core/painting/Paint.h" |
10 #include "sky/engine/core/painting/Picture.h" | 10 #include "sky/engine/core/painting/Picture.h" |
11 #include "sky/engine/core/painting/Rect.h" | 11 #include "sky/engine/core/painting/Rect.h" |
12 #include "sky/engine/platform/graphics/DisplayList.h" | 12 #include "sky/engine/platform/graphics/DisplayList.h" |
13 #include "sky/engine/tonic/dart_wrappable.h" | 13 #include "sky/engine/tonic/dart_wrappable.h" |
14 #include "sky/engine/wtf/PassRefPtr.h" | 14 #include "sky/engine/wtf/PassRefPtr.h" |
15 #include "sky/engine/wtf/RefCounted.h" | 15 #include "sky/engine/wtf/RefCounted.h" |
16 | 16 |
17 namespace blink { | 17 namespace blink { |
18 class Element; | 18 class Element; |
| 19 class CanvasImage; |
19 | 20 |
20 class Canvas : public RefCounted<Canvas>, public DartWrappable { | 21 class Canvas : public RefCounted<Canvas>, public DartWrappable { |
21 DEFINE_WRAPPERTYPEINFO(); | 22 DEFINE_WRAPPERTYPEINFO(); |
22 public: | 23 public: |
23 Canvas(const FloatSize& size); | 24 Canvas(const FloatSize& size); |
24 ~Canvas() override; | 25 ~Canvas() override; |
25 | 26 |
26 // Width/Height define a culling rect which Skia may use for optimizing | 27 // Width/Height define a culling rect which Skia may use for optimizing |
27 // out draw calls issued outside the rect. | 28 // out draw calls issued outside the rect. |
28 float width() const { return m_size.width(); } | 29 float width() const { return m_size.width(); } |
(...skipping 10 matching lines...) Expand all Loading... |
39 void concat(const Vector<float>& matrix); | 40 void concat(const Vector<float>& matrix); |
40 | 41 |
41 void clipRect(const Rect& rect); | 42 void clipRect(const Rect& rect); |
42 | 43 |
43 void drawPicture(Picture* picture); | 44 void drawPicture(Picture* picture); |
44 void drawPaint(const Paint* paint); | 45 void drawPaint(const Paint* paint); |
45 void drawRect(const Rect& rect, const Paint* paint); | 46 void drawRect(const Rect& rect, const Paint* paint); |
46 void drawOval(const Rect& rect, const Paint* paint); | 47 void drawOval(const Rect& rect, const Paint* paint); |
47 void drawCircle(float x, float y, float radius, const Paint* paint); | 48 void drawCircle(float x, float y, float radius, const Paint* paint); |
48 void drawPath(const CanvasPath* path, const Paint* paint); | 49 void drawPath(const CanvasPath* path, const Paint* paint); |
| 50 void drawImage(const CanvasImage* image, |
| 51 float x, |
| 52 float y, |
| 53 const Paint* paint); |
49 | 54 |
50 SkCanvas* skCanvas() { return m_canvas; } | 55 SkCanvas* skCanvas() { return m_canvas; } |
51 | 56 |
52 protected: | 57 protected: |
53 PassRefPtr<DisplayList> finishRecording(); | 58 PassRefPtr<DisplayList> finishRecording(); |
54 | 59 |
55 bool isRecording() const { return m_canvas; } | 60 bool isRecording() const { return m_canvas; } |
56 | 61 |
57 private: | 62 private: |
58 FloatSize m_size; | 63 FloatSize m_size; |
59 RefPtr<DisplayList> m_displayList; | 64 RefPtr<DisplayList> m_displayList; |
60 SkCanvas* m_canvas; | 65 SkCanvas* m_canvas; |
61 }; | 66 }; |
62 | 67 |
63 } // namespace blink | 68 } // namespace blink |
64 | 69 |
65 #endif // SKY_ENGINE_CORE_PAINTING_CANVAS_H_ | 70 #endif // SKY_ENGINE_CORE_PAINTING_CANVAS_H_ |
OLD | NEW |