Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / Source / platform / graphics / LoggingCanvas.h
blob47a0fc3df7463d3879bbed0dcda3536a35a848b7
1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef LoggingCanvas_h
32 #define LoggingCanvas_h
34 #include "platform/JSONValues.h"
35 #include "platform/graphics/InterceptingCanvas.h"
37 namespace blink {
39 class LoggingCanvas : public InterceptingCanvasBase {
40 public:
41 LoggingCanvas(int width, int height);
42 PassRefPtr<JSONArray> log();
44 void onDrawPaint(const SkPaint&) override;
45 void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) override;
46 void onDrawRect(const SkRect&, const SkPaint&) override;
47 void onDrawOval(const SkRect&, const SkPaint&) override;
48 void onDrawRRect(const SkRRect&, const SkPaint&) override;
49 void onDrawPath(const SkPath&, const SkPaint&) override;
50 void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
51 void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*, SrcRectConstraint) override;
52 void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst, const SkPaint*) override;
53 void onDrawImage(const SkImage*, SkScalar, SkScalar, const SkPaint*) override;
54 void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst, const SkPaint*, SrcRectConstraint) override;
55 void onDrawSprite(const SkBitmap&, int left, int top, const SkPaint*) override;
56 virtual void onDrawVertices(VertexMode vmode, int vertexCount, const SkPoint vertices[], const SkPoint texs[],
57 const SkColor colors[], SkXfermode* xmode, const uint16_t indices[], int indexCount, const SkPaint&) override;
59 void onDrawDRRect(const SkRRect& outer, const SkRRect& inner, const SkPaint&) override;
60 void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, const SkPaint&) override;
61 void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], const SkPaint&) override;
62 void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], SkScalar constY, const SkPaint&) override;
63 void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath&, const SkMatrix*, const SkPaint&) override;
64 void onDrawTextBlob(const SkTextBlob*, SkScalar x, SkScalar y, const SkPaint&) override;
65 void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) override;
66 void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) override;
67 void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) override;
68 void onClipRegion(const SkRegion&, SkRegion::Op) override;
69 virtual void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*);
70 void didSetMatrix(const SkMatrix&) override;
71 void didConcat(const SkMatrix&) override;
72 void willSave() override;
73 SaveLayerStrategy willSaveLayer(const SkRect* bounds, const SkPaint*, SaveFlags) override;
74 void willRestore() override;
76 private:
77 friend class AutoLogger;
79 RefPtr<JSONArray> m_log;
82 #ifndef NDEBUG
83 String pictureAsDebugString(const SkPicture*);
84 void showSkPicture(const SkPicture*);
85 #endif
87 } // namespace blink
89 #endif // LoggingCanvas_h