| 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 SimCanvas_h | 5 #ifndef SimCanvas_h |
| 6 #define SimCanvas_h | 6 #define SimCanvas_h |
| 7 | 7 |
| 8 #include "platform/graphics/Color.h" | 8 #include "platform/graphics/Color.h" |
| 9 #include "third_party/skia/include/core/SkCanvas.h" | 9 #include "platform/graphics/paint/PaintCanvas.h" |
| 10 #include "platform/graphics/paint/PaintFlags.h" |
| 10 #include "wtf/Vector.h" | 11 #include "wtf/Vector.h" |
| 11 | 12 |
| 12 namespace blink { | 13 namespace blink { |
| 13 | 14 |
| 14 class SimCanvas : public SkCanvas { | 15 class SimCanvas : public PaintCanvas { |
| 15 public: | 16 public: |
| 16 SimCanvas(int width, int height); | 17 SimCanvas(int width, int height); |
| 17 | 18 |
| 18 enum CommandType { | 19 enum CommandType { |
| 19 Rect, | 20 Rect, |
| 20 Text, | 21 Text, |
| 21 Image, | 22 Image, |
| 22 Shape, | 23 Shape, |
| 23 }; | 24 }; |
| 24 | 25 |
| 25 // TODO(esprehn): Ideally we'd put the text in here too, but SkTextBlob | 26 // TODO(esprehn): Ideally we'd put the text in here too, but SkTextBlob |
| 26 // has no way to get the text back out so we can't assert about drawn text. | 27 // has no way to get the text back out so we can't assert about drawn text. |
| 27 struct Command { | 28 struct Command { |
| 28 CommandType type; | 29 CommandType type; |
| 29 RGBA32 color; | 30 RGBA32 color; |
| 30 }; | 31 }; |
| 31 | 32 |
| 32 const Vector<Command>& commands() const { return m_commands; } | 33 const Vector<Command>& commands() const { return m_commands; } |
| 33 | 34 |
| 34 // Rect | 35 // Rect |
| 35 void onDrawRect(const SkRect&, const SkPaint&) override; | 36 void onDrawRect(const SkRect&, const PaintFlags&) override; |
| 36 | 37 |
| 37 // Shape | 38 // Shape |
| 38 void onDrawOval(const SkRect&, const SkPaint&) override; | 39 void onDrawOval(const SkRect&, const PaintFlags&) override; |
| 39 void onDrawRRect(const SkRRect&, const SkPaint&) override; | 40 void onDrawRRect(const SkRRect&, const PaintFlags&) override; |
| 40 void onDrawPath(const SkPath&, const SkPaint&) override; | 41 void onDrawPath(const SkPath&, const PaintFlags&) override; |
| 41 | 42 |
| 42 // Image | 43 // Image |
| 43 void onDrawImage(const SkImage*, SkScalar, SkScalar, const SkPaint*) override; | 44 void onDrawImage(const SkImage*, |
| 45 SkScalar, |
| 46 SkScalar, |
| 47 const PaintFlags*) override; |
| 44 void onDrawImageRect(const SkImage*, | 48 void onDrawImageRect(const SkImage*, |
| 45 const SkRect* src, | 49 const SkRect* src, |
| 46 const SkRect& dst, | 50 const SkRect& dst, |
| 47 const SkPaint*, | 51 const PaintFlags*, |
| 48 SrcRectConstraint) override; | 52 SkCanvas::SrcRectConstraint) override; |
| 49 | 53 |
| 50 // Text | 54 // Text |
| 51 void onDrawText(const void* text, | 55 void onDrawText(const void* text, |
| 52 size_t byteLength, | 56 size_t byteLength, |
| 53 SkScalar x, | 57 SkScalar x, |
| 54 SkScalar y, | 58 SkScalar y, |
| 55 const SkPaint&) override; | 59 const PaintFlags&) override; |
| 56 void onDrawPosText(const void* text, | 60 void onDrawPosText(const void* text, |
| 57 size_t byteLength, | 61 size_t byteLength, |
| 58 const SkPoint pos[], | 62 const SkPoint pos[], |
| 59 const SkPaint&) override; | 63 const PaintFlags&) override; |
| 60 void onDrawPosTextH(const void* text, | 64 void onDrawPosTextH(const void* text, |
| 61 size_t byteLength, | 65 size_t byteLength, |
| 62 const SkScalar xpos[], | 66 const SkScalar xpos[], |
| 63 SkScalar constY, | 67 SkScalar constY, |
| 64 const SkPaint&) override; | 68 const PaintFlags&) override; |
| 69 |
| 65 void onDrawTextOnPath(const void* text, | 70 void onDrawTextOnPath(const void* text, |
| 66 size_t byteLength, | 71 size_t byteLength, |
| 67 const SkPath&, | 72 const SkPath&, |
| 68 const SkMatrix*, | 73 const SkMatrix*, |
| 69 const SkPaint&) override; | 74 const PaintFlags&) override; |
| 70 void onDrawTextBlob(const SkTextBlob*, | 75 void onDrawTextBlob(const SkTextBlob*, |
| 71 SkScalar x, | 76 SkScalar x, |
| 72 SkScalar y, | 77 SkScalar y, |
| 73 const SkPaint&) override; | 78 const PaintFlags&) override; |
| 74 | 79 |
| 75 private: | 80 private: |
| 76 void addCommand(CommandType, RGBA32 = 0); | 81 void addCommand(CommandType, RGBA32 = 0); |
| 77 | 82 |
| 78 Vector<Command> m_commands; | 83 Vector<Command> m_commands; |
| 79 }; | 84 }; |
| 80 | 85 |
| 81 } // namespace blink | 86 } // namespace blink |
| 82 | 87 |
| 83 #endif | 88 #endif |
| OLD | NEW |