gfx/skia/trunk/include/utils/SkNoSaveLayerCanvas.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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  */
     8 #ifndef SkNoSaveLayerCanvas_DEFINED
     9 #define SkNoSaveLayerCanvas_DEFINED
    11 #include "SkCanvas.h"
    12 #include "SkRRect.h"
    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 SK_API SkNoSaveLayerCanvas : public SkCanvas {
    18 public:
    19     SkNoSaveLayerCanvas(SkBaseDevice* device) : INHERITED(device) {}
    21 protected:
    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;
    26     }
    28     // disable aa for speed
    29     virtual void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle) SK_OVERRIDE {
    30         this->INHERITED::onClipRect(rect, op, kHard_ClipEdgeStyle);
    31     }
    33     // for speed, just respect the bounds, and disable AA. May give us a few
    34     // false positives and negatives.
    35     virtual void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle) SK_OVERRIDE {
    36         this->updateClipConservativelyUsingBounds(path.getBounds(), op,
    37                                                   path.isInverseFillType());
    38     }
    39     virtual void onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle) SK_OVERRIDE {
    40         this->updateClipConservativelyUsingBounds(rrect.getBounds(), op, false);
    41     }
    43 private:
    44     typedef SkCanvas INHERITED;
    45 };
    47 #endif // SkNoSaveLayerCanvas_DEFINED

mercurial