Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / Source / web / tests / sim / SimCanvas.h
blob1b1fc27ed1f8b0700f68aa51b4e7d9750f5ca5a3
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.
5 #ifndef SimCanvas_h
6 #define SimCanvas_h
8 #include "platform/graphics/Color.h"
9 #include "third_party/skia/include/core/SkCanvas.h"
10 #include "wtf/Vector.h"
12 namespace blink {
14 class SimCanvas : public SkCanvas {
15 public:
16 SimCanvas(int width, int height);
18 enum CommandType {
19 Rect,
20 Text,
21 Image,
22 Shape,
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;
32 const Vector<Command>& commands() const { return m_commands; }
34 // Rect
35 void onDrawRect(const SkRect&, const SkPaint&) override;
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;
42 // Image
43 void onDrawImage(const SkImage*, SkScalar, SkScalar, const SkPaint*) override;
44 void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst, const SkPaint*, SrcRectConstraint) override;
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&, const SkMatrix*, const SkPaint&) override;
51 void onDrawTextBlob(const SkTextBlob*, SkScalar x, SkScalar y, const SkPaint&) override;
53 private:
54 void addCommand(CommandType, RGBA32 = 0);
56 Vector<Command> m_commands;
59 } // namespace blink
61 #endif