Chromium Code Reviews| 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 "SkTSort.h" | 9 #include "SkTSort.h" |
| 10 | 10 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 void updateClipBounds(const ClipRegion& op) { fCurrentClipBounds = op.devBou nds; } | 178 void updateClipBounds(const ClipRegion& op) { fCurrentClipBounds = op.devBou nds; } |
| 179 void updateClipBounds(const SaveLayer& op) { | 179 void updateClipBounds(const SaveLayer& op) { |
| 180 if (op.bounds) { | 180 if (op.bounds) { |
| 181 fCurrentClipBounds.intersect(this->adjustAndMap(*op.bounds, op.paint )); | 181 fCurrentClipBounds.intersect(this->adjustAndMap(*op.bounds, op.paint )); |
| 182 } | 182 } |
| 183 } | 183 } |
| 184 | 184 |
| 185 // The bounds of these ops must be calculated when we hit the Restore | 185 // The bounds of these ops must be calculated when we hit the Restore |
| 186 // from the bounds of the ops in the same Save block. | 186 // from the bounds of the ops in the same Save block. |
| 187 void trackBounds(const Save&) { this->pushSaveBlock(NULL); } | 187 void trackBounds(const Save&) { this->pushSaveBlock(NULL); } |
| 188 // TODO: bounds of SaveLayer may be more complicated? | |
| 189 void trackBounds(const SaveLayer& op) { this->pushSaveBlock(op.paint); } | 188 void trackBounds(const SaveLayer& op) { this->pushSaveBlock(op.paint); } |
| 190 void trackBounds(const Restore&) { fBounds[fCurrentOp] = this->popSaveBlock( ); } | 189 void trackBounds(const Restore&) { fBounds[fCurrentOp] = this->popSaveBlock( ); } |
| 191 | 190 |
| 192 void trackBounds(const SetMatrix&) { this->pushControl(); } | 191 void trackBounds(const SetMatrix&) { this->pushControl(); } |
| 193 void trackBounds(const ClipRect&) { this->pushControl(); } | 192 void trackBounds(const ClipRect&) { this->pushControl(); } |
| 194 void trackBounds(const ClipRRect&) { this->pushControl(); } | 193 void trackBounds(const ClipRRect&) { this->pushControl(); } |
| 195 void trackBounds(const ClipPath&) { this->pushControl(); } | 194 void trackBounds(const ClipPath&) { this->pushControl(); } |
| 196 void trackBounds(const ClipRegion&) { this->pushControl(); } | 195 void trackBounds(const ClipRegion&) { this->pushControl(); } |
|
robertphillips
2014/08/25 20:28:19
Seems like we should do more with the culling info
mtklein
2014/08/25 20:36:12
Yes. It's a little moot right now because we're n
| |
| 196 void trackBounds(const PushCull&) { this->pushControl(); } | |
| 197 void trackBounds(const PopCull&) { this->pushControl(); } | |
|
robertphillips
2014/08/25 20:28:19
Could these guys be treated like Noop (since they
mtklein
2014/08/25 20:36:13
Could be, but then we'd be in the odd spot of play
| |
| 198 void trackBounds(const BeginCommentGroup&) { this->pushControl(); } | |
| 199 void trackBounds(const AddComment&) { this->pushControl(); } | |
| 200 void trackBounds(const EndCommentGroup&) { this->pushControl(); } | |
| 197 | 201 |
| 198 // For all other ops, we can calculate and store the bounds directly now. | 202 // For all other ops, we can calculate and store the bounds directly now. |
| 199 template <typename T> void trackBounds(const T& op) { | 203 template <typename T> void trackBounds(const T& op) { |
| 200 fBounds[fCurrentOp] = this->bounds(op); | 204 fBounds[fCurrentOp] = this->bounds(op); |
| 201 this->updateSaveBounds(fBounds[fCurrentOp]); | 205 this->updateSaveBounds(fBounds[fCurrentOp]); |
| 202 } | 206 } |
| 203 | 207 |
| 204 void pushSaveBlock(const SkPaint* paint) { | 208 void pushSaveBlock(const SkPaint* paint) { |
| 205 // Starting a new Save block. Push a new entry to represent that. | 209 // Starting a new Save block. Push a new entry to represent that. |
| 206 SaveBounds sb = { 0, SkIRect::MakeEmpty(), paint }; | 210 SaveBounds sb = { 0, SkIRect::MakeEmpty(), paint }; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 fControlIndices.pop(); | 249 fControlIndices.pop(); |
| 246 } | 250 } |
| 247 | 251 |
| 248 void updateSaveBounds(const SkIRect& bounds) { | 252 void updateSaveBounds(const SkIRect& bounds) { |
| 249 // If we're in a Save block, expand its bounds to cover these bounds too . | 253 // If we're in a Save block, expand its bounds to cover these bounds too . |
| 250 if (!fSaveStack.isEmpty()) { | 254 if (!fSaveStack.isEmpty()) { |
| 251 fSaveStack.top().bounds.join(bounds); | 255 fSaveStack.top().bounds.join(bounds); |
| 252 } | 256 } |
| 253 } | 257 } |
| 254 | 258 |
| 255 // TODO(mtklein): Remove this default when done bounding all ops. | 259 // FIXME: these methods could use better bounds |
| 256 template <typename T> SkIRect bounds(const T&) const { return fCurrentClipBo unds; } | 260 SkIRect bounds(const DrawPatch&) const { return fCurrentClipBounds; } |
| 261 SkIRect bounds(const DrawPicture&) const { return fCurrentClipBounds; } | |
| 262 SkIRect bounds(const DrawTextOnPath&) const { return fCurrentClipBounds; } | |
| 263 SkIRect bounds(const DrawSprite&) const { return fCurrentClipBounds; } | |
| 264 SkIRect bounds(const DrawTextBlob&) const { return fCurrentClipBounds; } | |
| 265 SkIRect bounds(const DrawText&) const { return fCurrentClipBounds; } | |
| 266 SkIRect bounds(const DrawVertices&) const { return fCurrentClipBounds; } | |
| 267 // end of methods that could use better bounds | |
| 268 | |
| 257 SkIRect bounds(const Clear&) const { return SkIRect::MakeLargest(); } // Ig nores the clip | 269 SkIRect bounds(const Clear&) const { return SkIRect::MakeLargest(); } // Ig nores the clip |
| 270 SkIRect bounds(const DrawPaint&) const { return fCurrentClipBounds; } | |
| 258 SkIRect bounds(const NoOp&) const { return SkIRect::MakeEmpty(); } // No Ops don't draw. | 271 SkIRect bounds(const NoOp&) const { return SkIRect::MakeEmpty(); } // No Ops don't draw. |
| 259 | 272 |
| 260 SkIRect bounds(const DrawRect& op) const { return this->adjustAndMap(op.rect , &op.paint); } | 273 SkIRect bounds(const DrawRect& op) const { return this->adjustAndMap(op.rect , &op.paint); } |
| 261 SkIRect bounds(const DrawOval& op) const { return this->adjustAndMap(op.oval , &op.paint); } | 274 SkIRect bounds(const DrawOval& op) const { return this->adjustAndMap(op.oval , &op.paint); } |
| 262 SkIRect bounds(const DrawRRect& op) const { | 275 SkIRect bounds(const DrawRRect& op) const { |
| 263 return this->adjustAndMap(op.rrect.rect(), &op.paint); | 276 return this->adjustAndMap(op.rrect.rect(), &op.paint); |
| 264 } | 277 } |
| 265 SkIRect bounds(const DrawDRRect& op) const { | 278 SkIRect bounds(const DrawDRRect& op) const { |
| 266 return this->adjustAndMap(op.outer.rect(), &op.paint); | 279 return this->adjustAndMap(op.outer.rect(), &op.paint); |
| 267 } | 280 } |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 404 // Used to track the bounds of Save/Restore blocks and the control ops insid e them. | 417 // Used to track the bounds of Save/Restore blocks and the control ops insid e them. |
| 405 SkTDArray<SaveBounds> fSaveStack; | 418 SkTDArray<SaveBounds> fSaveStack; |
| 406 SkTDArray<unsigned> fControlIndices; | 419 SkTDArray<unsigned> fControlIndices; |
| 407 }; | 420 }; |
| 408 | 421 |
| 409 } // namespace SkRecords | 422 } // namespace SkRecords |
| 410 | 423 |
| 411 void SkRecordFillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) { | 424 void SkRecordFillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) { |
| 412 SkRecords::FillBounds(record, bbh); | 425 SkRecords::FillBounds(record, bbh); |
| 413 } | 426 } |
| OLD | NEW |