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/Paint.h" | 8 #include "sky/engine/core/painting/Paint.h" |
9 #include "sky/engine/platform/graphics/DisplayList.h" | 9 #include "sky/engine/platform/graphics/DisplayList.h" |
10 #include "sky/engine/tonic/dart_wrappable.h" | 10 #include "sky/engine/tonic/dart_wrappable.h" |
11 #include "sky/engine/wtf/PassRefPtr.h" | 11 #include "sky/engine/wtf/PassRefPtr.h" |
12 #include "sky/engine/wtf/RefCounted.h" | 12 #include "sky/engine/wtf/RefCounted.h" |
13 | 13 |
14 namespace blink { | 14 namespace blink { |
15 class Element; | 15 class Element; |
16 | 16 |
17 class Canvas : public RefCounted<Canvas>, public DartWrappable { | 17 class Canvas : public RefCounted<Canvas>, public DartWrappable { |
18 DEFINE_WRAPPERTYPEINFO(); | 18 DEFINE_WRAPPERTYPEINFO(); |
19 public: | 19 public: |
20 Canvas(const FloatSize& size); | 20 Canvas(const FloatSize& size); |
21 ~Canvas() override; | 21 ~Canvas() override; |
22 | 22 |
23 // Width/Height define a culling rect which Skia may use for optimizing | 23 // Width/Height define a culling rect which Skia may use for optimizing |
24 // out draw calls issued outside the rect. | 24 // out draw calls issued outside the rect. |
25 double width() const { return m_size.width(); } | 25 float width() const { return m_size.width(); } |
26 double height() const { return m_size.height(); } | 26 float height() const { return m_size.height(); } |
27 | 27 |
28 void drawCircle(double x, double y, double radius, Paint* paint); | 28 void save(); |
29 void saveLayer(const Vector<float>& bounds, const Paint* paint); | |
reed1
2015/05/13 21:20:10
The bounds to saveLayer is optional (passing NULL
Matt Perry
2015/05/13 21:22:00
The IDL compiler dictates the interface. But passi
| |
30 void restore(); | |
31 | |
32 void translate(float dx, float dy); | |
33 void scale(float sx, float sy); | |
34 void rotateDegrees(float degrees); | |
35 void skew(float sx, float sy); | |
36 void concat(const Vector<float>& matrix); | |
37 | |
38 void clipRect(const Vector<float>& rect); | |
39 | |
40 void drawPaint(Paint* paint); | |
reed1
2015/05/13 21:20:10
const for drawPaint
Matt Perry
2015/05/13 21:22:00
Oops, thanks. Will fix in a future CL.
| |
41 void drawRect(const Vector<float>& rect, const Paint* paint); | |
42 void drawOval(const Vector<float>& rect, const Paint* paint); | |
43 void drawCircle(float x, float y, float radius, Paint* paint); | |
reed1
2015/05/13 21:20:11
const for drawCircle
| |
29 | 44 |
30 protected: | 45 protected: |
31 PassRefPtr<DisplayList> finishRecording(); | 46 PassRefPtr<DisplayList> finishRecording(); |
32 | 47 |
33 bool isRecording() const { return m_canvas; } | 48 bool isRecording() const { return m_canvas; } |
34 | 49 |
35 private: | 50 private: |
36 FloatSize m_size; | 51 FloatSize m_size; |
37 RefPtr<DisplayList> m_displayList; | 52 RefPtr<DisplayList> m_displayList; |
38 SkCanvas* m_canvas; | 53 SkCanvas* m_canvas; |
39 }; | 54 }; |
40 | 55 |
41 } // namespace blink | 56 } // namespace blink |
42 | 57 |
43 #endif // SKY_ENGINE_CORE_PAINTING_CANVAS_H_ | 58 #endif // SKY_ENGINE_CORE_PAINTING_CANVAS_H_ |
OLD | NEW |