OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef SimCanvas_h |
| 6 #define SimCanvas_h |
| 7 |
| 8 #include "platform/graphics/Color.h" |
| 9 #include "third_party/skia/include/core/SkCanvas.h" |
| 10 #include "wtf/Vector.h" |
| 11 |
| 12 namespace blink { |
| 13 |
| 14 class SimCanvas : public SkCanvas { |
| 15 public: |
| 16 SimCanvas(int width, int height); |
| 17 |
| 18 enum CommandType { |
| 19 Rect, |
| 20 Text, |
| 21 Image, |
| 22 Shape, |
| 23 }; |
| 24 |
| 25 // 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 struct Command { |
| 28 CommandType type; |
| 29 RGBA32 color; |
| 30 }; |
| 31 |
| 32 const Vector<Command>& commands() const { return m_commands; } |
| 33 |
| 34 // Rect |
| 35 void onDrawRect(const SkRect&, const SkPaint&) override; |
| 36 |
| 37 // Shape |
| 38 void onDrawOval(const SkRect&, const SkPaint&) override; |
| 39 void onDrawRRect(const SkRRect&, const SkPaint&) override; |
| 40 void onDrawPath(const SkPath&, const SkPaint&) override; |
| 41 |
| 42 // Image |
| 43 void onDrawImage(const SkImage*, SkScalar, SkScalar, const SkPaint*) overrid
e; |
| 44 void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst, c
onst SkPaint*, SrcRectConstraint) override; |
| 45 |
| 46 // Text |
| 47 void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
const SkPaint&) override; |
| 48 void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
const SkPaint&) override; |
| 49 void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos
[], SkScalar constY, const SkPaint&) override; |
| 50 void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath&, co
nst SkMatrix*, const SkPaint&) override; |
| 51 void onDrawTextBlob(const SkTextBlob*, SkScalar x, SkScalar y, const SkPaint
&) override; |
| 52 |
| 53 private: |
| 54 void addCommand(CommandType, RGBA32 = 0); |
| 55 |
| 56 Vector<Command> m_commands; |
| 57 }; |
| 58 |
| 59 } // namespace blink |
| 60 |
| 61 #endif |
OLD | NEW |