OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2014 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #ifndef SkNoSaveLayerCanvas_DEFINED |
| 9 #define SkNoSaveLayerCanvas_DEFINED |
| 10 |
| 11 #include "SkCanvas.h" |
| 12 #include "SkRRect.h" |
| 13 |
| 14 // The NoSaveLayerCanvas is used to play back SkPictures when the saveLayer |
| 15 // functionality isn't required (e.g., during analysis of the draw calls). |
| 16 // It also simplifies the clipping calls to only use rectangles. |
| 17 class SkNoSaveLayerCanvas : public SkCanvas { |
| 18 public: |
| 19 SkNoSaveLayerCanvas(SkBaseDevice* device) : INHERITED(device) {} |
| 20 |
| 21 // turn saveLayer() into save() for speed, should not affect correctness. |
| 22 virtual int saveLayer(const SkRect* bounds, |
| 23 const SkPaint* paint, |
| 24 SaveFlags flags) SK_OVERRIDE { |
| 25 |
| 26 // Like SkPictureRecord, we don't want to create layers, but we do need |
| 27 // to respect the save and (possibly) its rect-clip. |
| 28 int count = this->INHERITED::save(flags); |
| 29 if (NULL != bounds) { |
| 30 this->INHERITED::clipRectBounds(bounds, flags, NULL); |
| 31 } |
| 32 return count; |
| 33 } |
| 34 |
| 35 // disable aa for speed |
| 36 virtual bool clipRect(const SkRect& rect, |
| 37 SkRegion::Op op, |
| 38 bool doAA) SK_OVERRIDE { |
| 39 return this->INHERITED::clipRect(rect, op, false); |
| 40 } |
| 41 |
| 42 // for speed, just respect the bounds, and disable AA. May give us a few |
| 43 // false positives and negatives. |
| 44 virtual bool clipPath(const SkPath& path, |
| 45 SkRegion::Op op, |
| 46 bool doAA) SK_OVERRIDE { |
| 47 return this->updateClipConservativelyUsingBounds(path.getBounds(), op, |
| 48 path.isInverseFillType(
)); |
| 49 } |
| 50 virtual bool clipRRect(const SkRRect& rrect, |
| 51 SkRegion::Op op, |
| 52 bool doAA) SK_OVERRIDE { |
| 53 return this->updateClipConservativelyUsingBounds(rrect.getBounds(), op,
false); |
| 54 } |
| 55 |
| 56 private: |
| 57 typedef SkCanvas INHERITED; |
| 58 }; |
| 59 |
| 60 #endif // SkNoSaveLayerCanvas_DEFINED |
OLD | NEW |