michael@0: michael@0: /* michael@0: * Copyright 2006 The Android Open Source Project michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: michael@0: #ifndef SkLayerRasterizer_DEFINED michael@0: #define SkLayerRasterizer_DEFINED michael@0: michael@0: #include "SkRasterizer.h" michael@0: #include "SkDeque.h" michael@0: #include "SkScalar.h" michael@0: michael@0: class SkPaint; michael@0: michael@0: class SK_API SkLayerRasterizer : public SkRasterizer { michael@0: public: michael@0: virtual ~SkLayerRasterizer(); michael@0: michael@0: class SK_API Builder { michael@0: public: michael@0: Builder(); michael@0: ~Builder(); michael@0: michael@0: void addLayer(const SkPaint& paint) { michael@0: this->addLayer(paint, 0, 0); michael@0: } michael@0: michael@0: /** michael@0: * Add a new layer (above any previous layers) to the rasterizer. michael@0: * The layer will extract those fields that affect the mask from michael@0: * the specified paint, but will not retain a reference to the paint michael@0: * object itself, so it may be reused without danger of side-effects. michael@0: */ michael@0: void addLayer(const SkPaint& paint, SkScalar dx, SkScalar dy); michael@0: michael@0: /** michael@0: * Pass queue of layers on to newly created layer rasterizer and return it. The builder michael@0: * cannot be used any more after calling this function. michael@0: */ michael@0: SkLayerRasterizer* detachRasterizer(); michael@0: michael@0: private: michael@0: SkDeque* fLayers; michael@0: }; michael@0: michael@0: #ifdef SK_SUPPORT_LEGACY_LAYERRASTERIZER_API michael@0: void addLayer(const SkPaint& paint) { michael@0: this->addLayer(paint, 0, 0); michael@0: } michael@0: michael@0: /** Add a new layer (above any previous layers) to the rasterizer. michael@0: The layer will extract those fields that affect the mask from michael@0: the specified paint, but will not retain a reference to the paint michael@0: object itself, so it may be reused without danger of side-effects. michael@0: */ michael@0: void addLayer(const SkPaint& paint, SkScalar dx, SkScalar dy); michael@0: #endif michael@0: michael@0: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLayerRasterizer) michael@0: michael@0: protected: michael@0: SkLayerRasterizer(SkDeque* layers); michael@0: SkLayerRasterizer(SkReadBuffer&); michael@0: virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; michael@0: michael@0: // override from SkRasterizer michael@0: virtual bool onRasterize(const SkPath& path, const SkMatrix& matrix, michael@0: const SkIRect* clipBounds, michael@0: SkMask* mask, SkMask::CreateMode mode) const; michael@0: michael@0: #ifdef SK_SUPPORT_LEGACY_LAYERRASTERIZER_API michael@0: public: michael@0: #endif michael@0: SkLayerRasterizer(); michael@0: michael@0: private: michael@0: #ifdef SK_SUPPORT_LEGACY_LAYERRASTERIZER_API michael@0: SkDeque* fLayers; michael@0: #else michael@0: const SkDeque* const fLayers; michael@0: #endif michael@0: michael@0: static SkDeque* ReadLayers(SkReadBuffer& buffer); michael@0: michael@0: typedef SkRasterizer INHERITED; michael@0: }; michael@0: michael@0: #endif