1902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
2902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com/*
3902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com * Copyright 2012 Google Inc.
4902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com *
5902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com * Use of this source code is governed by a BSD-style license that can be
6902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com * found in the LICENSE file.
7902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com */
8902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
9902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
10902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com#ifndef SKDEBUGCANVAS_H_
11902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com#define SKDEBUGCANVAS_H_
12902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
13902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com#include "SkCanvas.h"
14902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com#include "SkDrawCommand.h"
152a67e123a3e559774a16a58cbe5106bc0fb86740commit-bot@chromium.org#include "SkPathOps.h"
16902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com#include "SkPicture.h"
178a1cdaece7e1d009befb84f21bb82370025bf4d6robertphillips@google.com#include "SkTArray.h"
1897cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com#include "SkString.h"
19902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
2032bbcf828d66ad244fa25b468bc3a229e531491frobertphillips@google.comclass SkTexOverrideFilter;
2132bbcf828d66ad244fa25b468bc3a229e531491frobertphillips@google.com
2286681b37bd20204e47a492119b345c01d00bc939fmalita@google.comclass SK_API SkDebugCanvas : public SkCanvas {
23902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.compublic:
2480a4a60f96c33ccd850f9b0eb4b69ab08c198196chudy@google.com    SkDebugCanvas(int width, int height);
25f4741c1322944e194ca34a8f5cf8188fe2c0efe2robertphillips@google.com    virtual ~SkDebugCanvas();
26902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
27768ac85655017d4106444bf3ad044680a575ccaacommit-bot@chromium.org    void toggleFilter(bool toggle) { fFilter = toggle; }
28768ac85655017d4106444bf3ad044680a575ccaacommit-bot@chromium.org
29768ac85655017d4106444bf3ad044680a575ccaacommit-bot@chromium.org    void setMegaVizMode(bool megaVizMode) { fMegaVizMode = megaVizMode; }
3057f74e0aa931e7784d47cba3ecc83020aa8e72b2commit-bot@chromium.org    bool getMegaVizMode() const { return fMegaVizMode; }
31902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
32902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    /**
33f4741c1322944e194ca34a8f5cf8188fe2c0efe2robertphillips@google.com     * Enable or disable overdraw visualization
34f4741c1322944e194ca34a8f5cf8188fe2c0efe2robertphillips@google.com     */
35f4741c1322944e194ca34a8f5cf8188fe2c0efe2robertphillips@google.com    void setOverdrawViz(bool overdrawViz) { fOverdrawViz = overdrawViz; }
3657f74e0aa931e7784d47cba3ecc83020aa8e72b2commit-bot@chromium.org    bool getOverdrawViz() const { return fOverdrawViz; }
3757f74e0aa931e7784d47cba3ecc83020aa8e72b2commit-bot@chromium.org
3857f74e0aa931e7784d47cba3ecc83020aa8e72b2commit-bot@chromium.org    void setOutstandingSaveCount(int saveCount) { fOutstandingSaveCount = saveCount; }
3957f74e0aa931e7784d47cba3ecc83020aa8e72b2commit-bot@chromium.org    int getOutstandingSaveCount() const { return fOutstandingSaveCount; }
4057f74e0aa931e7784d47cba3ecc83020aa8e72b2commit-bot@chromium.org
412a67e123a3e559774a16a58cbe5106bc0fb86740commit-bot@chromium.org    bool getAllowSimplifyClip() const { return fAllowSimplifyClip; }
422a67e123a3e559774a16a58cbe5106bc0fb86740commit-bot@chromium.org
4357f74e0aa931e7784d47cba3ecc83020aa8e72b2commit-bot@chromium.org    void setPicture(SkPicture* picture) { fPicture = picture; }
44f4741c1322944e194ca34a8f5cf8188fe2c0efe2robertphillips@google.com
45f4741c1322944e194ca34a8f5cf8188fe2c0efe2robertphillips@google.com    /**
4632bbcf828d66ad244fa25b468bc3a229e531491frobertphillips@google.com     * Enable or disable texure filtering override
4732bbcf828d66ad244fa25b468bc3a229e531491frobertphillips@google.com     */
48f84ad8f7fc0194389a8099da2c5e8fff9f092890skia.committer@gmail.com    void overrideTexFiltering(bool overrideTexFiltering, SkPaint::FilterLevel level);
4932bbcf828d66ad244fa25b468bc3a229e531491frobertphillips@google.com
5032bbcf828d66ad244fa25b468bc3a229e531491frobertphillips@google.com    /**
51902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        Executes all draw calls to the canvas.
52902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        @param canvas  The canvas being drawn to
53902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com     */
54902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    void draw(SkCanvas* canvas);
55902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
56902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    /**
57902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        Executes the draw calls up to the specified index.
58902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        @param canvas  The canvas being drawn to
59902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        @param index  The index of the final command being executed
60902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com     */
610b5bbb0f82e022c8acfbcb6312f0ed18e1ab90cechudy@google.com    void drawTo(SkCanvas* canvas, int index);
620b5bbb0f82e022c8acfbcb6312f0ed18e1ab90cechudy@google.com
630b5bbb0f82e022c8acfbcb6312f0ed18e1ab90cechudy@google.com    /**
64a9e937c7b712b024de108fa963f92d0e70e4a296chudy@google.com        Returns the most recently calculated transformation matrix
65a9e937c7b712b024de108fa963f92d0e70e4a296chudy@google.com     */
66a9e937c7b712b024de108fa963f92d0e70e4a296chudy@google.com    const SkMatrix& getCurrentMatrix() {
67a9e937c7b712b024de108fa963f92d0e70e4a296chudy@google.com        return fMatrix;
68a9e937c7b712b024de108fa963f92d0e70e4a296chudy@google.com    }
69a9e937c7b712b024de108fa963f92d0e70e4a296chudy@google.com
70a9e937c7b712b024de108fa963f92d0e70e4a296chudy@google.com    /**
71a9e937c7b712b024de108fa963f92d0e70e4a296chudy@google.com        Returns the most recently calculated clip
72a9e937c7b712b024de108fa963f92d0e70e4a296chudy@google.com     */
73a9e937c7b712b024de108fa963f92d0e70e4a296chudy@google.com    const SkIRect& getCurrentClip() {
74a9e937c7b712b024de108fa963f92d0e70e4a296chudy@google.com        return fClip;
75a9e937c7b712b024de108fa963f92d0e70e4a296chudy@google.com    }
76a9e937c7b712b024de108fa963f92d0e70e4a296chudy@google.com
77a9e937c7b712b024de108fa963f92d0e70e4a296chudy@google.com    /**
780b5bbb0f82e022c8acfbcb6312f0ed18e1ab90cechudy@google.com        Returns the index of the last draw command to write to the pixel at (x,y)
790b5bbb0f82e022c8acfbcb6312f0ed18e1ab90cechudy@google.com     */
80830b8793bb1646bb76817bdc228dd8e2a92bef7dchudy@google.com    int getCommandAtPoint(int x, int y, int index);
81902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
82902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    /**
8350c84da68b17647371a81593402e897d639989e4robertphillips@google.com        Removes the command at the specified index
8450c84da68b17647371a81593402e897d639989e4robertphillips@google.com        @param index  The index of the command to delete
8550c84da68b17647371a81593402e897d639989e4robertphillips@google.com     */
8650c84da68b17647371a81593402e897d639989e4robertphillips@google.com    void deleteDrawCommandAt(int index);
8750c84da68b17647371a81593402e897d639989e4robertphillips@google.com
8850c84da68b17647371a81593402e897d639989e4robertphillips@google.com    /**
89902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        Returns the draw command at the given index.
90902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        @param index  The index of the command
91902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com     */
92902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    SkDrawCommand* getDrawCommandAt(int index);
93902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
94902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    /**
9550c84da68b17647371a81593402e897d639989e4robertphillips@google.com        Sets the draw command for a given index.
9650c84da68b17647371a81593402e897d639989e4robertphillips@google.com        @param index  The index to overwrite
9750c84da68b17647371a81593402e897d639989e4robertphillips@google.com        @param command The new command
9850c84da68b17647371a81593402e897d639989e4robertphillips@google.com     */
9950c84da68b17647371a81593402e897d639989e4robertphillips@google.com    void setDrawCommandAt(int index, SkDrawCommand* command);
10050c84da68b17647371a81593402e897d639989e4robertphillips@google.com
10150c84da68b17647371a81593402e897d639989e4robertphillips@google.com    /**
102902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        Returns information about the command at the given index.
103902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        @param index  The index of the command
104902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com     */
10597cee9735350cb472249ce1a827ba1aa6b2a5f59chudy@google.com    SkTDArray<SkString*>* getCommandInfo(int index);
106902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
107902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    /**
1087e4cfbf144af7d530d552946cee2a21d30b9b50fchudy@google.com        Returns the visibility of the command at the given index.
1097e4cfbf144af7d530d552946cee2a21d30b9b50fchudy@google.com        @param index  The index of the command
1107e4cfbf144af7d530d552946cee2a21d30b9b50fchudy@google.com     */
1117e4cfbf144af7d530d552946cee2a21d30b9b50fchudy@google.com    bool getDrawCommandVisibilityAt(int index);
1127e4cfbf144af7d530d552946cee2a21d30b9b50fchudy@google.com
1137e4cfbf144af7d530d552946cee2a21d30b9b50fchudy@google.com    /**
114902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        Returns the vector of draw commands
115902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com     */
1164469938e92d779dff05e745559e67907bbf21e78reed@google.com    SK_ATTR_DEPRECATED("please use getDrawCommandAt and getSize instead")
1178a1cdaece7e1d009befb84f21bb82370025bf4d6robertphillips@google.com    const SkTDArray<SkDrawCommand*>& getDrawCommands() const;
1182e71f1619d9a2c51c1292e618f42a56ad2da1de8skia.committer@gmail.com
119febc0ec41b4cff6ea69f2b89d72c0d330d198283robertphillips@google.com    /**
120febc0ec41b4cff6ea69f2b89d72c0d330d198283robertphillips@google.com        Returns the vector of draw commands. Do not use this entry
121febc0ec41b4cff6ea69f2b89d72c0d330d198283robertphillips@google.com        point - it is going away!
122febc0ec41b4cff6ea69f2b89d72c0d330d198283robertphillips@google.com     */
123febc0ec41b4cff6ea69f2b89d72c0d330d198283robertphillips@google.com    SkTDArray<SkDrawCommand*>& getDrawCommands();
124902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
125902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    /**
126902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com     * Returns the string vector of draw commands
127902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com     */
1288a1cdaece7e1d009befb84f21bb82370025bf4d6robertphillips@google.com    SkTArray<SkString>* getDrawCommandsAsStrings() const;
129902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
130902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    /**
13157f74e0aa931e7784d47cba3ecc83020aa8e72b2commit-bot@chromium.org     * Returns an array containing an offset (in the SkPicture) for each command
13257f74e0aa931e7784d47cba3ecc83020aa8e72b2commit-bot@chromium.org     */
13357f74e0aa931e7784d47cba3ecc83020aa8e72b2commit-bot@chromium.org    SkTDArray<size_t>* getDrawCommandOffsets() const;
13457f74e0aa931e7784d47cba3ecc83020aa8e72b2commit-bot@chromium.org
13557f74e0aa931e7784d47cba3ecc83020aa8e72b2commit-bot@chromium.org    /**
136f14143226acf209615c4dd841aa6632aff112ab3chudy@google.com        Returns length of draw command vector.
137f14143226acf209615c4dd841aa6632aff112ab3chudy@google.com     */
1380d4fe14a41bd04535310f8b2edee9e30191fdd79commit-bot@chromium.org    int getSize() const {
13967baba4892649fdb6fb0827c7d54e5adb7538443robertphillips@google.com        return fCommandVector.count();
140f14143226acf209615c4dd841aa6632aff112ab3chudy@google.com    }
141f14143226acf209615c4dd841aa6632aff112ab3chudy@google.com
142902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    /**
143902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        Toggles the visibility / execution of the draw command at index i with
144902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        the value of toggle.
145902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com     */
146902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    void toggleCommand(int index, bool toggle);
147902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
148a8d7f0b13cd4c6d773fcf055fe17db75d260fa05robertphillips    void setWindowSize(int width, int height) { fWindowSize.set(width, height); }
149b9ddd4e9f184f4a4545eca69c55ec1ad1ce59170chudy@google.com
150e8cc6e8071935339a06548b13a0668b56a7540f5bungeman@google.com    void setUserMatrix(SkMatrix matrix) {
151e8cc6e8071935339a06548b13a0668b56a7540f5bungeman@google.com        fUserMatrix = matrix;
152830b8793bb1646bb76817bdc228dd8e2a92bef7dchudy@google.com    }
153830b8793bb1646bb76817bdc228dd8e2a92bef7dchudy@google.com
1542a67e123a3e559774a16a58cbe5106bc0fb86740commit-bot@chromium.org    SkString clipStackData() const { return fClipStackData; }
1552a67e123a3e559774a16a58cbe5106bc0fb86740commit-bot@chromium.org
156902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com////////////////////////////////////////////////////////////////////////////////
157902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com// Inherited from SkCanvas
158902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com////////////////////////////////////////////////////////////////////////////////
159902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
160902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    virtual void clear(SkColor) SK_OVERRIDE;
161902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
162902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    virtual void drawBitmap(const SkBitmap&, SkScalar left, SkScalar top,
163902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com                            const SkPaint*) SK_OVERRIDE;
164902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
1657112173c3c4cd1b1e7da8cdf971d71f01dd91299reed@google.com    virtual void drawBitmapRectToRect(const SkBitmap&, const SkRect* src,
166eed779d866e1e239bfb9ebc6a225b7345a41adf9commit-bot@chromium.org                                      const SkRect& dst, const SkPaint* paint,
167eed779d866e1e239bfb9ebc6a225b7345a41adf9commit-bot@chromium.org                                      DrawBitmapRectFlags flags) SK_OVERRIDE;
168902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
169902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    virtual void drawBitmapMatrix(const SkBitmap&, const SkMatrix&,
170902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com                                  const SkPaint*) SK_OVERRIDE;
171902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
172902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
173902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com                                const SkRect& dst, const SkPaint*) SK_OVERRIDE;
174902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
175902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    virtual void drawData(const void*, size_t) SK_OVERRIDE;
176902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
1770a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com    virtual void beginCommentGroup(const char* description) SK_OVERRIDE;
1780a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com
1790a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com    virtual void addComment(const char* kywd, const char* value) SK_OVERRIDE;
1800a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com
1810a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com    virtual void endCommentGroup() SK_OVERRIDE;
1820a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com
18367baba4892649fdb6fb0827c7d54e5adb7538443robertphillips@google.com    virtual void drawOval(const SkRect& oval, const SkPaint&) SK_OVERRIDE;
18467baba4892649fdb6fb0827c7d54e5adb7538443robertphillips@google.com
185902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE;
186902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
1877ce564cccb246ec56427085872b2e1458fe74bd1bsalomon@google.com    virtual void drawPath(const SkPath& path, const SkPaint&) SK_OVERRIDE;
1887ce564cccb246ec56427085872b2e1458fe74bd1bsalomon@google.com
189902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    virtual void drawPoints(PointMode, size_t count, const SkPoint pts[],
190902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com                            const SkPaint&) SK_OVERRIDE;
191902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
1927ce564cccb246ec56427085872b2e1458fe74bd1bsalomon@google.com    virtual void drawRect(const SkRect& rect, const SkPaint&) SK_OVERRIDE;
1937ce564cccb246ec56427085872b2e1458fe74bd1bsalomon@google.com
19467baba4892649fdb6fb0827c7d54e5adb7538443robertphillips@google.com    virtual void drawRRect(const SkRRect& rrect, const SkPaint& paint) SK_OVERRIDE;
19567baba4892649fdb6fb0827c7d54e5adb7538443robertphillips@google.com
196902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    virtual void drawSprite(const SkBitmap&, int left, int top,
197902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com                            const SkPaint*) SK_OVERRIDE;
198902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
199902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    virtual void drawVertices(VertexMode, int vertexCount,
20067baba4892649fdb6fb0827c7d54e5adb7538443robertphillips@google.com                              const SkPoint vertices[], const SkPoint texs[],
20167baba4892649fdb6fb0827c7d54e5adb7538443robertphillips@google.com                              const SkColor colors[], SkXfermode*,
20267baba4892649fdb6fb0827c7d54e5adb7538443robertphillips@google.com                              const uint16_t indices[], int indexCount,
203902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com                              const SkPaint&) SK_OVERRIDE;
204902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
2053b0a9fe5672e7339ec3e5e6d3986b15f57ae24e7robertphillips@google.com    static const int kVizImageHeight = 256;
2063b0a9fe5672e7339ec3e5e6d3986b15f57ae24e7robertphillips@google.com    static const int kVizImageWidth = 256;
2073b0a9fe5672e7339ec3e5e6d3986b15f57ae24e7robertphillips@google.com
2088f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual bool isClipEmpty() const SK_OVERRIDE { return false; }
2095c70cdca5efe541b70d010e91607bf8626ea49cacommit-bot@chromium.org    virtual bool isClipRect() const SK_OVERRIDE { return true; }
2108f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual bool getClipBounds(SkRect* bounds) const SK_OVERRIDE {
21149f085dddff10473b6ebf832a974288300224e60bsalomon        if (bounds) {
212370a89980b2d38a6d01903b484bf404d6c48b496skia.committer@gmail.com            bounds->setXYWH(0, 0,
213e5ea500d4714a7d84de2bf913e81be3b65d2de68reed                            SkIntToScalar(this->imageInfo().width()),
214e5ea500d4714a7d84de2bf913e81be3b65d2de68reed                            SkIntToScalar(this->imageInfo().height()));
2158f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com        }
2168f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com        return true;
2178f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    }
2188f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual bool getClipDeviceBounds(SkIRect* bounds) const SK_OVERRIDE {
21949f085dddff10473b6ebf832a974288300224e60bsalomon        if (bounds) {
2208f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com            bounds->setLargest();
2218f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com        }
2228f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com        return true;
2238f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    }
2248f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com
225ab5827354e2c23624acc3fc1fe4a83788bc99e96commit-bot@chromium.orgprotected:
2265f6102d07982043542343ff0a6c67b1319ac9fc7Florin Malita    virtual void willSave() SK_OVERRIDE;
227e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org    virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) SK_OVERRIDE;
228e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org    virtual void willRestore() SK_OVERRIDE;
229e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org
23044c48d062f7996b5b46917e1b312a32ad101f326commit-bot@chromium.org    virtual void didConcat(const SkMatrix&) SK_OVERRIDE;
23144c48d062f7996b5b46917e1b312a32ad101f326commit-bot@chromium.org    virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE;
23244c48d062f7996b5b46917e1b312a32ad101f326commit-bot@chromium.org
233ab5827354e2c23624acc3fc1fe4a83788bc99e96commit-bot@chromium.org    virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE;
234e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com    virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
235e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com                            const SkPaint&) SK_OVERRIDE;
236e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com    virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
237e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com                               const SkPaint&) SK_OVERRIDE;
238e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com    virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
239e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com                                SkScalar constY, const SkPaint&) SK_OVERRIDE;
240e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com    virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
241e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com                                  const SkMatrix* matrix, const SkPaint&) SK_OVERRIDE;
242b7425173f96e93b090787e2386ba5f022b6c2869fmalita    virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
243b7425173f96e93b090787e2386ba5f022b6c2869fmalita                                const SkPaint& paint) SK_OVERRIDE;
244210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.org    virtual void onPushCull(const SkRect& cullRect) SK_OVERRIDE;
245210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.org    virtual void onPopCull() SK_OVERRIDE;
246ab5827354e2c23624acc3fc1fe4a83788bc99e96commit-bot@chromium.org
2478f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
2488f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
2498f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
2508f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual void onClipRegion(const SkRegion& region, SkRegion::Op) SK_OVERRIDE;
2518f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com
252d5fa1a455aad61f3e99081fe7a9b065cb3b115c6reed    virtual void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) SK_OVERRIDE;
2539b14f26d0f3a974f3dd626c8354e1db1cfcd322frobertphillips
2541643b2c9bc5adb4324bb459bb7811f58bc7c2d62commit-bot@chromium.org    void markActiveCommands(int index);
255768ac85655017d4106444bf3ad044680a575ccaacommit-bot@chromium.org
256902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.comprivate:
25767baba4892649fdb6fb0827c7d54e5adb7538443robertphillips@google.com    SkTDArray<SkDrawCommand*> fCommandVector;
25857f74e0aa931e7784d47cba3ecc83020aa8e72b2commit-bot@chromium.org    SkPicture* fPicture;
259a8d7f0b13cd4c6d773fcf055fe17db75d260fa05robertphillips    SkISize fWindowSize;
2607e4cfbf144af7d530d552946cee2a21d30b9b50fchudy@google.com    bool fFilter;
261768ac85655017d4106444bf3ad044680a575ccaacommit-bot@chromium.org    bool fMegaVizMode;
262830b8793bb1646bb76817bdc228dd8e2a92bef7dchudy@google.com    int fIndex;
263e8cc6e8071935339a06548b13a0668b56a7540f5bungeman@google.com    SkMatrix fUserMatrix;
264a9e937c7b712b024de108fa963f92d0e70e4a296chudy@google.com    SkMatrix fMatrix;
265a9e937c7b712b024de108fa963f92d0e70e4a296chudy@google.com    SkIRect fClip;
26632bbcf828d66ad244fa25b468bc3a229e531491frobertphillips@google.com
2672a67e123a3e559774a16a58cbe5106bc0fb86740commit-bot@chromium.org    SkString fClipStackData;
2682a67e123a3e559774a16a58cbe5106bc0fb86740commit-bot@chromium.org    bool fCalledAddStackData;
2692a67e123a3e559774a16a58cbe5106bc0fb86740commit-bot@chromium.org    SkPath fSaveDevPath;
2702a67e123a3e559774a16a58cbe5106bc0fb86740commit-bot@chromium.org
271f4741c1322944e194ca34a8f5cf8188fe2c0efe2robertphillips@google.com    bool fOverdrawViz;
272f4741c1322944e194ca34a8f5cf8188fe2c0efe2robertphillips@google.com    SkDrawFilter* fOverdrawFilter;
273902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
27432bbcf828d66ad244fa25b468bc3a229e531491frobertphillips@google.com    bool fOverrideTexFiltering;
27532bbcf828d66ad244fa25b468bc3a229e531491frobertphillips@google.com    SkTexOverrideFilter* fTexOverrideFilter;
27632bbcf828d66ad244fa25b468bc3a229e531491frobertphillips@google.com
277902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    /**
2780699e02101405623ad47f225729ed2521b2a0501tomhudson@google.com        Number of unmatched save() calls at any point during a draw.
2790699e02101405623ad47f225729ed2521b2a0501tomhudson@google.com        If there are any saveLayer() calls outstanding, we need to resolve
2800699e02101405623ad47f225729ed2521b2a0501tomhudson@google.com        all of them, which in practice means resolving all save() calls,
2810699e02101405623ad47f225729ed2521b2a0501tomhudson@google.com        to avoid corruption of our canvas.
2820699e02101405623ad47f225729ed2521b2a0501tomhudson@google.com    */
2830699e02101405623ad47f225729ed2521b2a0501tomhudson@google.com    int fOutstandingSaveCount;
2840699e02101405623ad47f225729ed2521b2a0501tomhudson@google.com
285ade9a3485e78d471f5f0902e9e50a2ec74c88e76skia.committer@gmail.com    /**
2861643b2c9bc5adb4324bb459bb7811f58bc7c2d62commit-bot@chromium.org        The active saveLayer commands at a given point in the renderering.
2871643b2c9bc5adb4324bb459bb7811f58bc7c2d62commit-bot@chromium.org        Only used when "mega" visualization is enabled.
2881643b2c9bc5adb4324bb459bb7811f58bc7c2d62commit-bot@chromium.org    */
2891643b2c9bc5adb4324bb459bb7811f58bc7c2d62commit-bot@chromium.org    SkTDArray<SkDrawCommand*> fActiveLayers;
2901643b2c9bc5adb4324bb459bb7811f58bc7c2d62commit-bot@chromium.org
291ade9a3485e78d471f5f0902e9e50a2ec74c88e76skia.committer@gmail.com    /**
2921643b2c9bc5adb4324bb459bb7811f58bc7c2d62commit-bot@chromium.org        The active cull commands at a given point in the rendering.
2931643b2c9bc5adb4324bb459bb7811f58bc7c2d62commit-bot@chromium.org        Only used when "mega" visualization is enabled.
2941643b2c9bc5adb4324bb459bb7811f58bc7c2d62commit-bot@chromium.org    */
2951643b2c9bc5adb4324bb459bb7811f58bc7c2d62commit-bot@chromium.org    SkTDArray<SkDrawCommand*> fActiveCulls;
2961643b2c9bc5adb4324bb459bb7811f58bc7c2d62commit-bot@chromium.org
2970699e02101405623ad47f225729ed2521b2a0501tomhudson@google.com    /**
298902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        Adds the command to the classes vector of commands.
299902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com        @param command  The draw command for execution
300902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com     */
301902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com    void addDrawCommand(SkDrawCommand* command);
302830b8793bb1646bb76817bdc228dd8e2a92bef7dchudy@google.com
303830b8793bb1646bb76817bdc228dd8e2a92bef7dchudy@google.com    /**
304830b8793bb1646bb76817bdc228dd8e2a92bef7dchudy@google.com        Applies any panning and zooming the user has specified before
305830b8793bb1646bb76817bdc228dd8e2a92bef7dchudy@google.com        drawing anything else into the canvas.
306830b8793bb1646bb76817bdc228dd8e2a92bef7dchudy@google.com     */
307830b8793bb1646bb76817bdc228dd8e2a92bef7dchudy@google.com    void applyUserTransform(SkCanvas* canvas);
3083b0a9fe5672e7339ec3e5e6d3986b15f57ae24e7robertphillips@google.com
30957f74e0aa931e7784d47cba3ecc83020aa8e72b2commit-bot@chromium.org    size_t getOpID() const {
310ce4dd3de38cd7c29bf5b9d8a8efb55c08ec9be47robertphillips#if 0
31149f085dddff10473b6ebf832a974288300224e60bsalomon        if (fPicture) {
31257f74e0aa931e7784d47cba3ecc83020aa8e72b2commit-bot@chromium.org            return fPicture->EXPERIMENTAL_curOpID();
31357f74e0aa931e7784d47cba3ecc83020aa8e72b2commit-bot@chromium.org        }
314ce4dd3de38cd7c29bf5b9d8a8efb55c08ec9be47robertphillips#endif
31557f74e0aa931e7784d47cba3ecc83020aa8e72b2commit-bot@chromium.org        return 0;
31657f74e0aa931e7784d47cba3ecc83020aa8e72b2commit-bot@chromium.org    }
31757f74e0aa931e7784d47cba3ecc83020aa8e72b2commit-bot@chromium.org
3182a67e123a3e559774a16a58cbe5106bc0fb86740commit-bot@chromium.org    void resetClipStackData() { fClipStackData.reset(); fCalledAddStackData = false; }
3192a67e123a3e559774a16a58cbe5106bc0fb86740commit-bot@chromium.org
3202a67e123a3e559774a16a58cbe5106bc0fb86740commit-bot@chromium.org    void addClipStackData(const SkPath& devPath, const SkPath& operand, SkRegion::Op elementOp);
3212a67e123a3e559774a16a58cbe5106bc0fb86740commit-bot@chromium.org    void addPathData(const SkPath& path, const char* pathName);
3222a67e123a3e559774a16a58cbe5106bc0fb86740commit-bot@chromium.org    bool lastClipStackData(const SkPath& devPath);
3232a67e123a3e559774a16a58cbe5106bc0fb86740commit-bot@chromium.org    void outputConicPoints(const SkPoint* pts, SkScalar weight);
3242a67e123a3e559774a16a58cbe5106bc0fb86740commit-bot@chromium.org    void outputPoints(const SkPoint* pts, int count);
3252a67e123a3e559774a16a58cbe5106bc0fb86740commit-bot@chromium.org    void outputPointsCommon(const SkPoint* pts, int count);
3262a67e123a3e559774a16a58cbe5106bc0fb86740commit-bot@chromium.org    void outputScalar(SkScalar num);
3273b9e8be760ad0e576d5145e0aecf0dc73efcd640skia.committer@gmail.com
3283b0a9fe5672e7339ec3e5e6d3986b15f57ae24e7robertphillips@google.com    typedef SkCanvas INHERITED;
329902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com};
330902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com
331902ebe5eb41a350b766238b3b103c22fe9fc0fb5chudy@google.com#endif
332