| 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_PAINTINGCONTEXT_H_ |
| 6 #define SKY_ENGINE_CORE_PAINTING_PAINTINGCONTEXT_H_ | 6 #define SKY_ENGINE_CORE_PAINTING_PAINTINGCONTEXT_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | |
| 9 #include "sky/engine/core/painting/Paint.h" | 8 #include "sky/engine/core/painting/Paint.h" |
| 10 #include "sky/engine/platform/graphics/DisplayList.h" | 9 #include "sky/engine/platform/graphics/DisplayList.h" |
| 11 #include "sky/engine/tonic/dart_wrappable.h" | 10 #include "sky/engine/tonic/dart_wrappable.h" |
| 12 #include "sky/engine/wtf/PassRefPtr.h" | 11 #include "sky/engine/wtf/PassRefPtr.h" |
| 13 #include "sky/engine/wtf/RefCounted.h" | 12 #include "sky/engine/wtf/RefCounted.h" |
| 14 | 13 |
| 15 namespace blink { | 14 namespace blink { |
| 15 class Element; |
| 16 | 16 |
| 17 class PaintingContext : public RefCounted<PaintingContext>, public DartWrappable
{ | 17 class PaintingContext : public RefCounted<PaintingContext>, public DartWrappable
{ |
| 18 DEFINE_WRAPPERTYPEINFO(); | 18 DEFINE_WRAPPERTYPEINFO(); |
| 19 public: | 19 public: |
| 20 typedef base::Callback<void (RefPtr<PaintingContext>)> CommitCallback; | |
| 21 | |
| 22 ~PaintingContext() override; | 20 ~PaintingContext() override; |
| 23 static PassRefPtr<PaintingContext> create(const FloatSize& size, const Commi
tCallback& commitCallback) | 21 static PassRefPtr<PaintingContext> create(PassRefPtr<Element> element, const
FloatSize& size); |
| 24 { | |
| 25 return adoptRef(new PaintingContext(size, commitCallback)); | |
| 26 } | |
| 27 | 22 |
| 28 double height() const { return m_size.height(); } | 23 double height() const { return m_size.height(); } |
| 29 double width() const { return m_size.width(); } | 24 double width() const { return m_size.width(); } |
| 30 | 25 |
| 31 void drawCircle(double x, double y, double radius, Paint* paint); | 26 void drawCircle(double x, double y, double radius, Paint* paint); |
| 32 void commit(); | 27 void commit(); |
| 33 | 28 |
| 34 PassRefPtr<DisplayList> takeDisplayList() | 29 private: |
| 35 { | 30 PaintingContext(PassRefPtr<Element> element, const FloatSize& size); |
| 36 ASSERT(!m_canvas); | |
| 37 return m_displayList.release(); | |
| 38 } | |
| 39 | 31 |
| 40 private: | 32 RefPtr<Element> m_element; |
| 41 PaintingContext(const FloatSize& size, const CommitCallback& commitCallback)
; | |
| 42 | |
| 43 FloatSize m_size; | 33 FloatSize m_size; |
| 44 CommitCallback m_commitCallback; | |
| 45 RefPtr<DisplayList> m_displayList; | 34 RefPtr<DisplayList> m_displayList; |
| 46 SkCanvas* m_canvas; | 35 SkCanvas* m_canvas; |
| 47 }; | 36 }; |
| 48 | 37 |
| 49 } // namespace blink | 38 } // namespace blink |
| 50 | 39 |
| 51 #endif // SKY_ENGINE_CORE_PAINTING_PAINTINGCONTEXT_H_ | 40 #endif // SKY_ENGINE_CORE_PAINTING_PAINTINGCONTEXT_H_ |
| OLD | NEW |