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_PAINTINGCONTEXT_H_ | 5 #ifndef SKY_ENGINE_CORE_PAINTING_CANVAS_H_ |
6 #define SKY_ENGINE_CORE_PAINTING_PAINTINGCONTEXT_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 PaintingContext : public RefCounted<PaintingContext>, public DartWrappable { | 17 class Canvas : public RefCounted<Canvas>, public DartWrappable { |
18 DEFINE_WRAPPERTYPEINFO(); | 18 DEFINE_WRAPPERTYPEINFO(); |
19 public: | 19 public: |
20 ~PaintingContext() override; | 20 Canvas(const FloatSize& size); |
21 static PassRefPtr<PaintingContext> create(PassRefPtr<Element> element, const FloatSize& size); | 21 ~Canvas() override; |
22 | 22 |
23 // Width/Height define a culling rect which Skia may use for optimizing | |
24 // out draw calls issued outside the rect. | |
25 double width() const { return m_size.width(); } | |
23 double height() const { return m_size.height(); } | 26 double height() const { return m_size.height(); } |
24 double width() const { return m_size.width(); } | |
25 | 27 |
26 void drawCircle(double x, double y, double radius, Paint* paint); | 28 void drawCircle(double x, double y, double radius, Paint* paint); |
Matt Perry
2015/05/13 18:33:21
Skia takes these params as SkScalars, which are fl
| |
27 void commit(); | 29 |
30 protected: | |
31 PassRefPtr<DisplayList> finishRecording(); | |
32 | |
33 bool isRecording() const { return m_canvas; } | |
28 | 34 |
29 private: | 35 private: |
30 PaintingContext(PassRefPtr<Element> element, const FloatSize& size); | |
31 | |
32 RefPtr<Element> m_element; | |
33 FloatSize m_size; | 36 FloatSize m_size; |
34 RefPtr<DisplayList> m_displayList; | 37 RefPtr<DisplayList> m_displayList; |
35 SkCanvas* m_canvas; | 38 SkCanvas* m_canvas; |
36 }; | 39 }; |
37 | 40 |
38 } // namespace blink | 41 } // namespace blink |
39 | 42 |
40 #endif // SKY_ENGINE_CORE_PAINTING_PAINTINGCONTEXT_H_ | 43 #endif // SKY_ENGINE_CORE_PAINTING_CANVAS_H_ |
OLD | NEW |