OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "SkCanvasStack.h" | 8 #include "SkCanvasStack.h" |
9 | 9 |
10 SkCanvasStack::SkCanvasStack(int width, int height) | 10 SkCanvasStack::SkCanvasStack(int width, int height) |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 } | 58 } |
59 } | 59 } |
60 | 60 |
61 //////////////////////////////////////////////////////////////////////////////// | 61 //////////////////////////////////////////////////////////////////////////////// |
62 | 62 |
63 /** | 63 /** |
64 * We need to handle setMatrix specially as it overwrites the matrix in each | 64 * We need to handle setMatrix specially as it overwrites the matrix in each |
65 * canvas unlike all other matrix operations (i.e. translate, scale, etc) which | 65 * canvas unlike all other matrix operations (i.e. translate, scale, etc) which |
66 * just pre-concatenate with the existing matrix. | 66 * just pre-concatenate with the existing matrix. |
67 */ | 67 */ |
68 void SkCanvasStack::setMatrix(const SkMatrix& matrix) { | 68 void SkCanvasStack::didSetMatrix(const SkMatrix& matrix) { |
69 SkASSERT(fList.count() == fCanvasData.count()); | 69 SkASSERT(fList.count() == fCanvasData.count()); |
70 for (int i = 0; i < fList.count(); ++i) { | 70 for (int i = 0; i < fList.count(); ++i) { |
71 | 71 |
72 SkMatrix tempMatrix = matrix; | 72 SkMatrix tempMatrix = matrix; |
73 tempMatrix.postTranslate(SkIntToScalar(-fCanvasData[i].origin.x()), | 73 tempMatrix.postTranslate(SkIntToScalar(-fCanvasData[i].origin.x()), |
74 SkIntToScalar(-fCanvasData[i].origin.y())); | 74 SkIntToScalar(-fCanvasData[i].origin.y())); |
75 fList[i]->setMatrix(tempMatrix); | 75 fList[i]->setMatrix(tempMatrix); |
76 } | 76 } |
77 this->SkCanvas::setMatrix(matrix); | 77 this->SkCanvas::didSetMatrix(matrix); |
78 } | 78 } |
79 | 79 |
80 void SkCanvasStack::onClipRect(const SkRect& r, SkRegion::Op op, ClipEdgeStyle e
dgeStyle) { | 80 void SkCanvasStack::onClipRect(const SkRect& r, SkRegion::Op op, ClipEdgeStyle e
dgeStyle) { |
81 this->INHERITED::onClipRect(r, op, edgeStyle); | 81 this->INHERITED::onClipRect(r, op, edgeStyle); |
82 this->clipToZOrderedBounds(); | 82 this->clipToZOrderedBounds(); |
83 } | 83 } |
84 | 84 |
85 void SkCanvasStack::onClipRRect(const SkRRect& rr, SkRegion::Op op, ClipEdgeStyl
e edgeStyle) { | 85 void SkCanvasStack::onClipRRect(const SkRRect& rr, SkRegion::Op op, ClipEdgeStyl
e edgeStyle) { |
86 this->INHERITED::onClipRRect(rr, op, edgeStyle); | 86 this->INHERITED::onClipRRect(rr, op, edgeStyle); |
87 this->clipToZOrderedBounds(); | 87 this->clipToZOrderedBounds(); |
88 } | 88 } |
89 | 89 |
90 void SkCanvasStack::onClipPath(const SkPath& p, SkRegion::Op op, ClipEdgeStyle e
dgeStyle) { | 90 void SkCanvasStack::onClipPath(const SkPath& p, SkRegion::Op op, ClipEdgeStyle e
dgeStyle) { |
91 this->INHERITED::onClipPath(p, op, edgeStyle); | 91 this->INHERITED::onClipPath(p, op, edgeStyle); |
92 this->clipToZOrderedBounds(); | 92 this->clipToZOrderedBounds(); |
93 } | 93 } |
94 | 94 |
95 void SkCanvasStack::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { | 95 void SkCanvasStack::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { |
96 SkASSERT(fList.count() == fCanvasData.count()); | 96 SkASSERT(fList.count() == fCanvasData.count()); |
97 for (int i = 0; i < fList.count(); ++i) { | 97 for (int i = 0; i < fList.count(); ++i) { |
98 SkRegion tempRegion; | 98 SkRegion tempRegion; |
99 deviceRgn.translate(-fCanvasData[i].origin.x(), | 99 deviceRgn.translate(-fCanvasData[i].origin.x(), |
100 -fCanvasData[i].origin.y(), &tempRegion); | 100 -fCanvasData[i].origin.y(), &tempRegion); |
101 tempRegion.op(fCanvasData[i].requiredClip, SkRegion::kIntersect_Op); | 101 tempRegion.op(fCanvasData[i].requiredClip, SkRegion::kIntersect_Op); |
102 fList[i]->clipRegion(tempRegion, op); | 102 fList[i]->clipRegion(tempRegion, op); |
103 } | 103 } |
104 this->SkCanvas::onClipRegion(deviceRgn, op); | 104 this->SkCanvas::onClipRegion(deviceRgn, op); |
105 } | 105 } |
OLD | NEW |