blob: 686f179901d6181c9fb5a47ece5cd4243d1f8311 [file] [log] [blame]
robertphillips@google.com81e87392014-01-07 16:08:04 +00001/*
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.
robertphillips@google.com0f03f432014-03-16 21:59:11 +000017class SK_API SkNoSaveLayerCanvas : public SkCanvas {
robertphillips@google.com81e87392014-01-07 16:08:04 +000018public:
19 SkNoSaveLayerCanvas(SkBaseDevice* device) : INHERITED(device) {}
20
commit-bot@chromium.orge54a23f2014-03-12 20:21:48 +000021protected:
22 virtual SaveLayerStrategy willSaveLayer(const SkRect* bounds, const SkPaint* paint,
23 SaveFlags flags) SK_OVERRIDE {
24 this->INHERITED::willSaveLayer(bounds, paint, flags);
25 return kNoLayer_SaveLayerStrategy;
robertphillips@google.com81e87392014-01-07 16:08:04 +000026 }
27
28 // disable aa for speed
robertphillips@google.com8f90a892014-02-28 18:19:39 +000029 virtual void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle) SK_OVERRIDE {
30 this->INHERITED::onClipRect(rect, op, kHard_ClipEdgeStyle);
robertphillips@google.com81e87392014-01-07 16:08:04 +000031 }
32
33 // for speed, just respect the bounds, and disable AA. May give us a few
34 // false positives and negatives.
robertphillips@google.com8f90a892014-02-28 18:19:39 +000035 virtual void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle) SK_OVERRIDE {
36 this->updateClipConservativelyUsingBounds(path.getBounds(), op,
37 path.isInverseFillType());
robertphillips@google.com81e87392014-01-07 16:08:04 +000038 }
robertphillips@google.com8f90a892014-02-28 18:19:39 +000039 virtual void onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle) SK_OVERRIDE {
40 this->updateClipConservativelyUsingBounds(rrect.getBounds(), op, false);
robertphillips@google.com81e87392014-01-07 16:08:04 +000041 }
42
43private:
44 typedef SkCanvas INHERITED;
45};
46
47#endif // SkNoSaveLayerCanvas_DEFINED