Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Side by Side Diff: src/utils/SkCanvasStack.cpp

Issue 2355483002: abstract name of clipping ops, to transtion to a more restricted set (Closed)
Patch Set: no need for ifdef for globals Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/utils/SkCanvasStack.h ('k') | src/utils/SkCanvasStateUtils.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 #include "SkCanvasStack.h" 7 #include "SkCanvasStack.h"
8 8
9 SkCanvasStack::SkCanvasStack(int width, int height) 9 SkCanvasStack::SkCanvasStack(int width, int height)
10 : INHERITED(width, height) {} 10 : INHERITED(width, height) {}
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 } 46 }
47 47
48 /** 48 /**
49 * Traverse all canvases (e.g. layers) the stack and ensure that they are clippe d 49 * Traverse all canvases (e.g. layers) the stack and ensure that they are clippe d
50 * to their bounds and that the area covered by any canvas higher in the stack i s 50 * to their bounds and that the area covered by any canvas higher in the stack i s
51 * also clipped out. 51 * also clipped out.
52 */ 52 */
53 void SkCanvasStack::clipToZOrderedBounds() { 53 void SkCanvasStack::clipToZOrderedBounds() {
54 SkASSERT(fList.count() == fCanvasData.count()); 54 SkASSERT(fList.count() == fCanvasData.count());
55 for (int i = 0; i < fList.count(); ++i) { 55 for (int i = 0; i < fList.count(); ++i) {
56 fList[i]->clipRegion(fCanvasData[i].requiredClip, SkRegion::kIntersect_O p); 56 fList[i]->clipRegion(fCanvasData[i].requiredClip);
57 } 57 }
58 } 58 }
59 59
60 //////////////////////////////////////////////////////////////////////////////// 60 ////////////////////////////////////////////////////////////////////////////////
61 61
62 /** 62 /**
63 * We need to handle setMatrix specially as it overwrites the matrix in each 63 * We need to handle setMatrix specially as it overwrites the matrix in each
64 * canvas unlike all other matrix operations (i.e. translate, scale, etc) which 64 * canvas unlike all other matrix operations (i.e. translate, scale, etc) which
65 * just pre-concatenate with the existing matrix. 65 * just pre-concatenate with the existing matrix.
66 */ 66 */
67 void SkCanvasStack::didSetMatrix(const SkMatrix& matrix) { 67 void SkCanvasStack::didSetMatrix(const SkMatrix& matrix) {
68 SkASSERT(fList.count() == fCanvasData.count()); 68 SkASSERT(fList.count() == fCanvasData.count());
69 for (int i = 0; i < fList.count(); ++i) { 69 for (int i = 0; i < fList.count(); ++i) {
70 70
71 SkMatrix tempMatrix = matrix; 71 SkMatrix tempMatrix = matrix;
72 tempMatrix.postTranslate(SkIntToScalar(-fCanvasData[i].origin.x()), 72 tempMatrix.postTranslate(SkIntToScalar(-fCanvasData[i].origin.x()),
73 SkIntToScalar(-fCanvasData[i].origin.y())); 73 SkIntToScalar(-fCanvasData[i].origin.y()));
74 fList[i]->setMatrix(tempMatrix); 74 fList[i]->setMatrix(tempMatrix);
75 } 75 }
76 this->SkCanvas::didSetMatrix(matrix); 76 this->SkCanvas::didSetMatrix(matrix);
77 } 77 }
78 78
79 void SkCanvasStack::onClipRect(const SkRect& r, SkRegion::Op op, ClipEdgeStyle e dgeStyle) { 79 void SkCanvasStack::onClipRect(const SkRect& r, ClipOp op, ClipEdgeStyle edgeSty le) {
80 this->INHERITED::onClipRect(r, op, edgeStyle); 80 this->INHERITED::onClipRect(r, op, edgeStyle);
81 this->clipToZOrderedBounds(); 81 this->clipToZOrderedBounds();
82 } 82 }
83 83
84 void SkCanvasStack::onClipRRect(const SkRRect& rr, SkRegion::Op op, ClipEdgeStyl e edgeStyle) { 84 void SkCanvasStack::onClipRRect(const SkRRect& rr, ClipOp op, ClipEdgeStyle edge Style) {
85 this->INHERITED::onClipRRect(rr, op, edgeStyle); 85 this->INHERITED::onClipRRect(rr, op, edgeStyle);
86 this->clipToZOrderedBounds(); 86 this->clipToZOrderedBounds();
87 } 87 }
88 88
89 void SkCanvasStack::onClipPath(const SkPath& p, SkRegion::Op op, ClipEdgeStyle e dgeStyle) { 89 void SkCanvasStack::onClipPath(const SkPath& p, ClipOp op, ClipEdgeStyle edgeSty le) {
90 this->INHERITED::onClipPath(p, op, edgeStyle); 90 this->INHERITED::onClipPath(p, op, edgeStyle);
91 this->clipToZOrderedBounds(); 91 this->clipToZOrderedBounds();
92 } 92 }
93 93
94 void SkCanvasStack::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { 94 void SkCanvasStack::onClipRegion(const SkRegion& deviceRgn, ClipOp op) {
95 SkASSERT(fList.count() == fCanvasData.count()); 95 SkASSERT(fList.count() == fCanvasData.count());
96 for (int i = 0; i < fList.count(); ++i) { 96 for (int i = 0; i < fList.count(); ++i) {
97 SkRegion tempRegion; 97 SkRegion tempRegion;
98 deviceRgn.translate(-fCanvasData[i].origin.x(), 98 deviceRgn.translate(-fCanvasData[i].origin.x(),
99 -fCanvasData[i].origin.y(), &tempRegion); 99 -fCanvasData[i].origin.y(), &tempRegion);
100 tempRegion.op(fCanvasData[i].requiredClip, SkRegion::kIntersect_Op); 100 tempRegion.op(fCanvasData[i].requiredClip, SkRegion::kIntersect_Op);
101 fList[i]->clipRegion(tempRegion, op); 101 fList[i]->clipRegion(tempRegion, op);
102 } 102 }
103 this->SkCanvas::onClipRegion(deviceRgn, op); 103 this->SkCanvas::onClipRegion(deviceRgn, op);
104 } 104 }
OLDNEW
« no previous file with comments | « src/utils/SkCanvasStack.h ('k') | src/utils/SkCanvasStateUtils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698