blob: 339601af5fc25fbeb3f77c495dfd4366d762cc5b (
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
|
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkCanvas.h"
#include "SkShape.h"
#include "SkMatrix.h"
#if 0
static int gShapeCounter;
static void inc_shape(const SkShape* s) {
SkDebugf("inc %d\n", gShapeCounter);
gShapeCounter += 1;
}
static void dec_shape(const SkShape* s) {
--gShapeCounter;
SkDebugf("dec %d\n", gShapeCounter);
}
#else
#define inc_shape(s)
#define dec_shape(s)
#endif
///////////////////////////////////////////////////////////////////////////////
void SkShape::draw(SkCanvas* canvas) {
int saveCount = canvas->getSaveCount();
this->onDraw(canvas);
canvas->restoreToCount(saveCount);
}
void SkShape::drawXY(SkCanvas* canvas, SkScalar dx, SkScalar dy) {
int saveCount = canvas->save(SkCanvas::kMatrix_SaveFlag);
canvas->translate(dx, dy);
this->onDraw(canvas);
canvas->restoreToCount(saveCount);
}
void SkShape::drawMatrix(SkCanvas* canvas, const SkMatrix& matrix) {
int saveCount = canvas->save(SkCanvas::kMatrix_SaveFlag);
canvas->concat(matrix);
this->onDraw(canvas);
canvas->restoreToCount(saveCount);
}
///////////////////////////////////////////////////////////////////////////////
SkShape::SkShape() {
inc_shape(this);
}
SkShape::~SkShape() {
dec_shape(this);
}
SkShape::SkShape(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {
inc_shape(this);
}
SkFlattenable* SkShape::CreateProc(SkFlattenableReadBuffer& buffer) {
return SkNEW_ARGS(SkShape, (buffer));
}
SkFlattenable::Factory SkShape::getFactory() {
return CreateProc;
}
void SkShape::flatten(SkFlattenableWriteBuffer& buffer) {
this->INHERITED::flatten(buffer);
}
void SkShape::onDraw(SkCanvas*) {}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkShape)
|