1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/utils/SkCanvasStack.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,53 @@ 1.4 + 1.5 +/* 1.6 + * Copyright 2013 Google Inc. 1.7 + * 1.8 + * Use of this source code is governed by a BSD-style license that can be 1.9 + * found in the LICENSE file. 1.10 + */ 1.11 + 1.12 +#ifndef SkCanvasStack_DEFINED 1.13 +#define SkCanvasStack_DEFINED 1.14 + 1.15 +#include "SkNWayCanvas.h" 1.16 +#include "SkTArray.h" 1.17 + 1.18 +class SkCanvasStack : public SkNWayCanvas { 1.19 +public: 1.20 + SkCanvasStack(int width, int height); 1.21 + virtual ~SkCanvasStack(); 1.22 + 1.23 + void pushCanvas(SkCanvas* canvas, const SkIPoint& origin); 1.24 + virtual void removeAll() SK_OVERRIDE; 1.25 + 1.26 + /* 1.27 + * The following add/remove canvas methods are overrides from SkNWayCanvas 1.28 + * that do not make sense in the context of our CanvasStack, but since we 1.29 + * can share most of the other implementation of NWay we override those 1.30 + * methods to be no-ops. 1.31 + */ 1.32 + virtual void addCanvas(SkCanvas*) SK_OVERRIDE { SkDEBUGFAIL("Invalid Op"); } 1.33 + virtual void removeCanvas(SkCanvas*) SK_OVERRIDE { SkDEBUGFAIL("Invalid Op"); } 1.34 + 1.35 +protected: 1.36 + virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE; 1.37 + 1.38 + virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE; 1.39 + virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE; 1.40 + virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE; 1.41 + virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE; 1.42 + 1.43 +private: 1.44 + void clipToZOrderedBounds(); 1.45 + 1.46 + struct CanvasData { 1.47 + SkIPoint origin; 1.48 + SkRegion requiredClip; 1.49 + }; 1.50 + 1.51 + SkTArray<CanvasData> fCanvasData; 1.52 + 1.53 + typedef SkNWayCanvas INHERITED; 1.54 +}; 1.55 + 1.56 +#endif