OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 | 7 |
8 #include "SkRecordDraw.h" | 8 #include "SkRecordDraw.h" |
9 #include "SkPatchUtils.h" | 9 #include "SkPatchUtils.h" |
10 | 10 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 76 |
77 #define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; } | 77 #define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; } |
78 DRAW(Restore, restore()); | 78 DRAW(Restore, restore()); |
79 DRAW(Save, save()); | 79 DRAW(Save, save()); |
80 DRAW(SaveLayer, saveLayer(SkCanvas::SaveLayerRec(r.bounds, | 80 DRAW(SaveLayer, saveLayer(SkCanvas::SaveLayerRec(r.bounds, |
81 r.paint, | 81 r.paint, |
82 r.backdrop.get(), | 82 r.backdrop.get(), |
83 r.saveLayerFlags))); | 83 r.saveLayerFlags))); |
84 DRAW(SetMatrix, setMatrix(SkMatrix::Concat(fInitialCTM, r.matrix))); | 84 DRAW(SetMatrix, setMatrix(SkMatrix::Concat(fInitialCTM, r.matrix))); |
85 DRAW(Concat, concat(r.matrix)); | 85 DRAW(Concat, concat(r.matrix)); |
| 86 DRAW(Translate, translate(r.dx, r.dy)); |
86 | 87 |
87 DRAW(ClipPath, clipPath(r.path, r.opAA.op, r.opAA.aa)); | 88 DRAW(ClipPath, clipPath(r.path, r.opAA.op, r.opAA.aa)); |
88 DRAW(ClipRRect, clipRRect(r.rrect, r.opAA.op, r.opAA.aa)); | 89 DRAW(ClipRRect, clipRRect(r.rrect, r.opAA.op, r.opAA.aa)); |
89 DRAW(ClipRect, clipRect(r.rect, r.opAA.op, r.opAA.aa)); | 90 DRAW(ClipRect, clipRect(r.rect, r.opAA.op, r.opAA.aa)); |
90 DRAW(ClipRegion, clipRegion(r.region, r.op)); | 91 DRAW(ClipRegion, clipRegion(r.region, r.op)); |
91 | 92 |
92 #ifdef SK_EXPERIMENTAL_SHADOWING | 93 #ifdef SK_EXPERIMENTAL_SHADOWING |
93 DRAW(TranslateZ, SkCanvas::translateZ(r.z)); | 94 DRAW(TranslateZ, SkCanvas::translateZ(r.z)); |
94 #else | 95 #else |
95 template <> void Draw::draw(const TranslateZ& r) { } | 96 template <> void Draw::draw(const TranslateZ& r) { } |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 } | 235 } |
235 | 236 |
236 private: | 237 private: |
237 struct SaveBounds { | 238 struct SaveBounds { |
238 int controlOps; // Number of control ops in this Save block, incl
uding the Save. | 239 int controlOps; // Number of control ops in this Save block, incl
uding the Save. |
239 Bounds bounds; // Bounds of everything in the block. | 240 Bounds bounds; // Bounds of everything in the block. |
240 const SkPaint* paint; // Unowned. If set, adjusts the bounds of all op
s in this block. | 241 const SkPaint* paint; // Unowned. If set, adjusts the bounds of all op
s in this block. |
241 SkMatrix ctm; | 242 SkMatrix ctm; |
242 }; | 243 }; |
243 | 244 |
244 // Only Restore, SetMatrix, and Concat change the CTM. | 245 // Only Restore, SetMatrix, Concat, and Translate change the CTM. |
245 template <typename T> void updateCTM(const T&) {} | 246 template <typename T> void updateCTM(const T&) {} |
246 void updateCTM(const Restore& op) { fCTM = op.matrix; } | 247 void updateCTM(const Restore& op) { fCTM = op.matrix; } |
247 void updateCTM(const SetMatrix& op) { fCTM = op.matrix; } | 248 void updateCTM(const SetMatrix& op) { fCTM = op.matrix; } |
248 void updateCTM(const Concat& op) { fCTM.preConcat(op.matrix); } | 249 void updateCTM(const Concat& op) { fCTM.preConcat(op.matrix); } |
| 250 void updateCTM(const Translate& op) { fCTM.preTranslate(op.dx, op.dy); } |
249 | 251 |
250 // Most ops don't change the clip. | 252 // Most ops don't change the clip. |
251 template <typename T> void updateClipBounds(const T&) {} | 253 template <typename T> void updateClipBounds(const T&) {} |
252 | 254 |
253 // Clip{Path,RRect,Rect,Region} obviously change the clip. They all know th
eir bounds already. | 255 // Clip{Path,RRect,Rect,Region} obviously change the clip. They all know th
eir bounds already. |
254 void updateClipBounds(const ClipPath& op) { this->updateClipBoundsForClipO
p(op.devBounds); } | 256 void updateClipBounds(const ClipPath& op) { this->updateClipBoundsForClipO
p(op.devBounds); } |
255 void updateClipBounds(const ClipRRect& op) { this->updateClipBoundsForClipO
p(op.devBounds); } | 257 void updateClipBounds(const ClipRRect& op) { this->updateClipBoundsForClipO
p(op.devBounds); } |
256 void updateClipBounds(const ClipRect& op) { this->updateClipBoundsForClipO
p(op.devBounds); } | 258 void updateClipBounds(const ClipRect& op) { this->updateClipBoundsForClipO
p(op.devBounds); } |
257 void updateClipBounds(const ClipRegion& op) { this->updateClipBoundsForClipO
p(op.devBounds); } | 259 void updateClipBounds(const ClipRegion& op) { this->updateClipBoundsForClipO
p(op.devBounds); } |
258 | 260 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 } | 294 } |
293 | 295 |
294 // The bounds of these ops must be calculated when we hit the Restore | 296 // The bounds of these ops must be calculated when we hit the Restore |
295 // from the bounds of the ops in the same Save block. | 297 // from the bounds of the ops in the same Save block. |
296 void trackBounds(const Save&) { this->pushSaveBlock(nullptr); } | 298 void trackBounds(const Save&) { this->pushSaveBlock(nullptr); } |
297 void trackBounds(const SaveLayer& op) { this->pushSaveBlock(op.paint); } | 299 void trackBounds(const SaveLayer& op) { this->pushSaveBlock(op.paint); } |
298 void trackBounds(const Restore&) { fBounds[fCurrentOp] = this->popSaveBlock(
); } | 300 void trackBounds(const Restore&) { fBounds[fCurrentOp] = this->popSaveBlock(
); } |
299 | 301 |
300 void trackBounds(const SetMatrix&) { this->pushControl(); } | 302 void trackBounds(const SetMatrix&) { this->pushControl(); } |
301 void trackBounds(const Concat&) { this->pushControl(); } | 303 void trackBounds(const Concat&) { this->pushControl(); } |
| 304 void trackBounds(const Translate&) { this->pushControl(); } |
| 305 void trackBounds(const TranslateZ&) { this->pushControl(); } |
302 void trackBounds(const ClipRect&) { this->pushControl(); } | 306 void trackBounds(const ClipRect&) { this->pushControl(); } |
303 void trackBounds(const ClipRRect&) { this->pushControl(); } | 307 void trackBounds(const ClipRRect&) { this->pushControl(); } |
304 void trackBounds(const ClipPath&) { this->pushControl(); } | 308 void trackBounds(const ClipPath&) { this->pushControl(); } |
305 void trackBounds(const ClipRegion&) { this->pushControl(); } | 309 void trackBounds(const ClipRegion&) { this->pushControl(); } |
306 | 310 |
307 void trackBounds(const TranslateZ&) { this->pushControl(); } | |
308 | 311 |
309 // For all other ops, we can calculate and store the bounds directly now. | 312 // For all other ops, we can calculate and store the bounds directly now. |
310 template <typename T> void trackBounds(const T& op) { | 313 template <typename T> void trackBounds(const T& op) { |
311 fBounds[fCurrentOp] = this->bounds(op); | 314 fBounds[fCurrentOp] = this->bounds(op); |
312 this->updateSaveBounds(fBounds[fCurrentOp]); | 315 this->updateSaveBounds(fBounds[fCurrentOp]); |
313 } | 316 } |
314 | 317 |
315 void pushSaveBlock(const SkPaint* paint) { | 318 void pushSaveBlock(const SkPaint* paint) { |
316 // Starting a new Save block. Push a new entry to represent that. | 319 // Starting a new Save block. Push a new entry to represent that. |
317 SaveBounds sb; | 320 SaveBounds sb; |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 | 621 |
619 void SkRecordFillBounds(const SkRect& cullRect, const SkRecord& record, SkRect b
ounds[]) { | 622 void SkRecordFillBounds(const SkRect& cullRect, const SkRecord& record, SkRect b
ounds[]) { |
620 SkRecords::FillBounds visitor(cullRect, record, bounds); | 623 SkRecords::FillBounds visitor(cullRect, record, bounds); |
621 for (int curOp = 0; curOp < record.count(); curOp++) { | 624 for (int curOp = 0; curOp < record.count(); curOp++) { |
622 visitor.setCurrentOp(curOp); | 625 visitor.setCurrentOp(curOp); |
623 record.visit(curOp, visitor); | 626 record.visit(curOp, visitor); |
624 } | 627 } |
625 visitor.cleanUp(); | 628 visitor.cleanUp(); |
626 } | 629 } |
627 | 630 |
OLD | NEW |