aboutsummaryrefslogtreecommitdiffhomepage
path: root/debugger/SkDrawCommand.h
blob: 45d9dd62601a1ed6eb31542161ca0c78a2e58a52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346

/*
 * Copyright 2012 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SKDRAWCOMMAND_H_
#define SKDRAWCOMMAND_H_

#include <iostream>
#include "SkPictureFlat.h"
#include "SkCanvas.h"
#include <sstream>
#include <vector>

class SkDrawCommand {
public:
    /* TODO(chudy): Remove subclasses. */
    SkDrawCommand();

    virtual ~SkDrawCommand();

    virtual std::string toString();

    virtual const char* toCString() {
        return GetCommandString(fDrawType);
    }

    bool getVisibility() const { return fVisible; }
    void setVisibility(bool toggle) {fVisible = toggle; }

    std::vector<std::string>* Info() {return &fInfo; };
    virtual void execute(SkCanvas* canvas)=0;
    DrawType getType() { return fDrawType; };

protected:
    DrawType fDrawType;
    std::vector<std::string> fInfo;

private:
    bool fVisible;
    static const char* GetCommandString(DrawType type);
};

class Restore : public SkDrawCommand {
public:
    Restore();
    virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
};

class Clear : public SkDrawCommand {
public:
    Clear(SkColor color);
    virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
    SkColor fColor;
};

class ClipPath : public SkDrawCommand {
public:
    ClipPath(const SkPath& path, SkRegion::Op op, bool doAA);
    virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
    const SkPath* fPath;
    SkRegion::Op fOp;
    bool fDoAA;
};

class ClipRegion : public SkDrawCommand {
public:
    ClipRegion(const SkRegion& region, SkRegion::Op op);
    virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
    const SkRegion* fRegion;
    SkRegion::Op fOp;
};

class ClipRect : public SkDrawCommand {
public:
    ClipRect(const SkRect& rect, SkRegion::Op op, bool doAA);
    virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
    const SkRect* fRect;
    SkRegion::Op fOp;
    bool fDoAA;
};

class Concat : public SkDrawCommand {
public:
    Concat(const SkMatrix& matrix);
    virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
    const SkMatrix* fMatrix;
};

class DrawBitmap : public SkDrawCommand {
public:
    DrawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
            const SkPaint* paint);
    virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
    const SkPaint* fPaint;
    const SkBitmap* fBitmap;
    SkScalar fLeft;
    SkScalar fTop;
};

class DrawBitmapMatrix : public SkDrawCommand {
public:
    DrawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& matrix,
            const SkPaint* paint);
    virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
    const SkPaint* fPaint;
    const SkBitmap* fBitmap;
    const SkMatrix* fMatrix;
};

class DrawBitmapNine : public SkDrawCommand {
public:
    DrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
            const SkRect& dst, const SkPaint* paint);
    virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
    const SkBitmap* fBitmap;
    const SkIRect* fCenter;
    const SkRect* fDst;
    const SkPaint* fPaint;
};

class DrawBitmapRect : public SkDrawCommand {
public:
    DrawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
            const SkRect& dst, const SkPaint* paint);
    virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
    const SkIRect* fSrc;
    const SkPaint* fPaint;
    const SkBitmap* fBitmap;
    const SkRect* fDst;
};

class DrawData : public SkDrawCommand {
public:
    DrawData(const void* data, size_t length);
    virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
    const void* fData;
    size_t fLength;
};

class DrawPaint : public SkDrawCommand {
public:
    DrawPaint(const SkPaint& paint);
    virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
    const SkPaint* fPaint;
};

class DrawPath : public SkDrawCommand {
public:
    DrawPath(const SkPath& path, const SkPaint& paint);
    virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
    const SkPath* fPath;
    const SkPaint* fPaint;
};

class DrawPicture : public SkDrawCommand {
public:
    DrawPicture(SkPicture& picture);
    virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
    SkPicture* fPicture;
};

class DrawPoints : public SkDrawCommand {
public:
    DrawPoints(SkCanvas::PointMode mode, size_t count, const SkPoint pts[],
            const SkPaint& paint);
    virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
    const SkPoint* fPts;
    SkCanvas::PointMode fMode;
    size_t fCount;
    const SkPaint* fPaint;
};

/* TODO(chudy): DrawText is a predefined macro and was breaking something
 * in the windows build of the debugger.
 */
class DrawTextC : public SkDrawCommand {
public:
    DrawTextC(const void* text, size_t byteLength, SkScalar x, SkScalar y,
            const SkPaint& paint);
    virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
    const void* fText;
    size_t fByteLength;
    SkScalar fX;
    SkScalar fY;
    const SkPaint* fPaint;
};

class DrawPosText : public SkDrawCommand {
public:
    DrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
            const SkPaint& paint);
    virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
    const SkPoint* fPos;
    const void* fText;
    size_t fByteLength;
    const SkPaint* fPaint;
};

class DrawTextOnPath : public SkDrawCommand {
public:
    DrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
            const SkMatrix* matrix, const SkPaint& paint);
    virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
    const SkMatrix* fMatrix;
    const void* fText;
    size_t fByteLength;
    const SkPath* fPath;
    const SkPaint* fPaint;
};

class DrawPosTextH : public SkDrawCommand {
public:
    DrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
            SkScalar constY, const SkPaint& paint);
    virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
    const SkScalar* fXpos;
    const void* fText;
    size_t fByteLength;
    SkScalar fConstY;
    const SkPaint* fPaint;
};

class DrawRectC : public SkDrawCommand {
public:
    DrawRectC(const SkRect& rect, const SkPaint& paint);
    virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
    const SkRect* fRect;
    const SkPaint* fPaint;
};

class DrawSprite : public SkDrawCommand {
public:
    DrawSprite(const SkBitmap& bitmap, int left, int top, const SkPaint* paint);
    virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
    const SkPaint* fPaint;
    int fLeft;
    int fTop;
    const SkBitmap* fBitmap;
};

class DrawVertices : public SkDrawCommand {
public:
    DrawVertices(SkCanvas::VertexMode vmode, int vertexCount,
            const SkPoint vertices[], const SkPoint texs[], const SkColor colors[],
            SkXfermode* xfermode, const uint16_t indices[], int indexCount,
            const SkPaint& paint);
    virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
    SkCanvas::VertexMode fVmode;
    int fVertexCount;
    int fIndexCount;
    const SkPoint* fVertices;
    const SkPoint* fTexs;
    const SkColor* fColors;
    const uint16_t* fIndices;
    SkXfermode* fXfermode;
    const SkPaint* fPaint;
};

class Rotate : public SkDrawCommand {
public:
    Rotate(SkScalar degrees);
    virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
    SkScalar fDegrees;
};

class Save : public SkDrawCommand {
public:
    Save(SkCanvas::SaveFlags flags);
    virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
    SkCanvas::SaveFlags fFlags;
};

class SaveLayer : public SkDrawCommand {
public:
    SaveLayer(const SkRect* bounds, const SkPaint* paint,
            SkCanvas::SaveFlags flags);
    virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
    const SkRect* fBounds;
    const SkPaint* fPaint;
    SkCanvas::SaveFlags fFlags;
};

class Scale : public SkDrawCommand {
public:
    Scale(SkScalar sx, SkScalar sy);
    virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
    SkScalar fSx;
    SkScalar fSy;
};

class SetMatrix : public SkDrawCommand {
public:
    SetMatrix(const SkMatrix& matrix);
    virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
    const SkMatrix* fMatrix;
};

class Skew : public SkDrawCommand {
public:
    Skew(SkScalar sx, SkScalar sy);
    virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
    SkScalar fSx;
    SkScalar fSy;
};

class Translate : public SkDrawCommand {
public:
    Translate(SkScalar dx, SkScalar dy);
    virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
private:
    SkScalar fDx;
    SkScalar fDy;
};

#endif