1/*
2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
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.
17 *
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.
29 */
30
31#ifndef ProfilingCanvas_h
32#define ProfilingCanvas_h
33
34#include "platform/graphics/InterceptingCanvas.h"
35#include "wtf/Vector.h"
36
37namespace blink {
38
39class ProfilingCanvas : public InterceptingCanvas {
40public:
41    ProfilingCanvas(SkBitmap);
42    void setTimings(Vector<double>*);
43
44    virtual void clear(SkColor) OVERRIDE;
45    virtual void drawPaint(const SkPaint&) OVERRIDE;
46    virtual void drawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) OVERRIDE;
47    virtual void drawRect(const SkRect&, const SkPaint&) OVERRIDE;
48    virtual void drawOval(const SkRect&, const SkPaint&) OVERRIDE;
49    virtual void drawRRect(const SkRRect&, const SkPaint&) OVERRIDE;
50    virtual void drawPath(const SkPath&, const SkPaint&) OVERRIDE;
51    virtual void drawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint* = 0) OVERRIDE;
52    virtual void drawBitmapRectToRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*, DrawBitmapRectFlags) OVERRIDE;
53    virtual void drawBitmapMatrix(const SkBitmap&, const SkMatrix&, const SkPaint* = 0) OVERRIDE;
54    virtual void drawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst, const SkPaint*) OVERRIDE;
55    virtual void drawSprite(const SkBitmap&, int left, int top, const SkPaint* = 0) OVERRIDE;
56    virtual void drawVertices(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;
58    virtual void drawData(const void* data, size_t length) OVERRIDE;
59    virtual void beginCommentGroup(const char* description) OVERRIDE;
60    virtual void addComment(const char* keyword, const char* value) OVERRIDE;
61    virtual void endCommentGroup() OVERRIDE;
62
63    virtual void onDrawDRRect(const SkRRect& outer, const SkRRect& inner, const SkPaint&) OVERRIDE;
64    virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, const SkPaint&) OVERRIDE;
65    virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], const SkPaint&) OVERRIDE;
66    virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], SkScalar constY, const SkPaint&) OVERRIDE;
67    virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath&, const SkMatrix*, const SkPaint&) OVERRIDE;
68    virtual void onPushCull(const SkRect& cullRect) OVERRIDE;
69    virtual void onPopCull() OVERRIDE;
70    virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) OVERRIDE;
71    virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) OVERRIDE;
72    virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) OVERRIDE;
73    virtual void onClipRegion(const SkRegion&, SkRegion::Op) OVERRIDE;
74    virtual void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*);
75    virtual void didSetMatrix(const SkMatrix&) OVERRIDE;
76    virtual void didConcat(const SkMatrix&) OVERRIDE;
77    virtual void willSave() OVERRIDE;
78    SaveLayerStrategy willSaveLayer(const SkRect* bounds, const SkPaint*, SaveFlags) OVERRIDE;
79    virtual void willRestore() OVERRIDE;
80
81private:
82    Vector<double>* m_timings;
83    friend class AutoStamper;
84};
85
86} // namespace blink
87
88#endif // ProfilingCanvas_h
89