1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/include/effects/SkLayerRasterizer.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,92 @@ 1.4 + 1.5 +/* 1.6 + * Copyright 2006 The Android Open Source Project 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 + 1.13 +#ifndef SkLayerRasterizer_DEFINED 1.14 +#define SkLayerRasterizer_DEFINED 1.15 + 1.16 +#include "SkRasterizer.h" 1.17 +#include "SkDeque.h" 1.18 +#include "SkScalar.h" 1.19 + 1.20 +class SkPaint; 1.21 + 1.22 +class SK_API SkLayerRasterizer : public SkRasterizer { 1.23 +public: 1.24 + virtual ~SkLayerRasterizer(); 1.25 + 1.26 + class SK_API Builder { 1.27 + public: 1.28 + Builder(); 1.29 + ~Builder(); 1.30 + 1.31 + void addLayer(const SkPaint& paint) { 1.32 + this->addLayer(paint, 0, 0); 1.33 + } 1.34 + 1.35 + /** 1.36 + * Add a new layer (above any previous layers) to the rasterizer. 1.37 + * The layer will extract those fields that affect the mask from 1.38 + * the specified paint, but will not retain a reference to the paint 1.39 + * object itself, so it may be reused without danger of side-effects. 1.40 + */ 1.41 + void addLayer(const SkPaint& paint, SkScalar dx, SkScalar dy); 1.42 + 1.43 + /** 1.44 + * Pass queue of layers on to newly created layer rasterizer and return it. The builder 1.45 + * cannot be used any more after calling this function. 1.46 + */ 1.47 + SkLayerRasterizer* detachRasterizer(); 1.48 + 1.49 + private: 1.50 + SkDeque* fLayers; 1.51 + }; 1.52 + 1.53 +#ifdef SK_SUPPORT_LEGACY_LAYERRASTERIZER_API 1.54 + void addLayer(const SkPaint& paint) { 1.55 + this->addLayer(paint, 0, 0); 1.56 + } 1.57 + 1.58 + /** Add a new layer (above any previous layers) to the rasterizer. 1.59 + The layer will extract those fields that affect the mask from 1.60 + the specified paint, but will not retain a reference to the paint 1.61 + object itself, so it may be reused without danger of side-effects. 1.62 + */ 1.63 + void addLayer(const SkPaint& paint, SkScalar dx, SkScalar dy); 1.64 +#endif 1.65 + 1.66 + SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLayerRasterizer) 1.67 + 1.68 +protected: 1.69 + SkLayerRasterizer(SkDeque* layers); 1.70 + SkLayerRasterizer(SkReadBuffer&); 1.71 + virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; 1.72 + 1.73 + // override from SkRasterizer 1.74 + virtual bool onRasterize(const SkPath& path, const SkMatrix& matrix, 1.75 + const SkIRect* clipBounds, 1.76 + SkMask* mask, SkMask::CreateMode mode) const; 1.77 + 1.78 +#ifdef SK_SUPPORT_LEGACY_LAYERRASTERIZER_API 1.79 +public: 1.80 +#endif 1.81 + SkLayerRasterizer(); 1.82 + 1.83 +private: 1.84 +#ifdef SK_SUPPORT_LEGACY_LAYERRASTERIZER_API 1.85 + SkDeque* fLayers; 1.86 +#else 1.87 + const SkDeque* const fLayers; 1.88 +#endif 1.89 + 1.90 + static SkDeque* ReadLayers(SkReadBuffer& buffer); 1.91 + 1.92 + typedef SkRasterizer INHERITED; 1.93 +}; 1.94 + 1.95 +#endif