2011-07-28 14:26:00 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Copyright 2006 The Android Open Source Project
|
2008-12-17 15:59:43 +00:00
|
|
|
*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
|
2011-07-28 14:26:00 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
#ifndef SkLayerRasterizer_DEFINED
|
|
|
|
#define SkLayerRasterizer_DEFINED
|
|
|
|
|
|
|
|
#include "SkRasterizer.h"
|
|
|
|
#include "SkDeque.h"
|
|
|
|
#include "SkScalar.h"
|
|
|
|
|
|
|
|
class SkPaint;
|
|
|
|
|
2012-10-12 14:41:39 +00:00
|
|
|
class SK_API SkLayerRasterizer : public SkRasterizer {
|
2008-12-17 15:59:43 +00:00
|
|
|
public:
|
|
|
|
virtual ~SkLayerRasterizer();
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2014-02-26 13:27:37 +00:00
|
|
|
class SK_API Builder {
|
|
|
|
public:
|
|
|
|
Builder();
|
|
|
|
~Builder();
|
|
|
|
|
|
|
|
void addLayer(const SkPaint& paint) {
|
|
|
|
this->addLayer(paint, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a new layer (above any previous layers) to the rasterizer.
|
|
|
|
* The layer will extract those fields that affect the mask from
|
|
|
|
* the specified paint, but will not retain a reference to the paint
|
|
|
|
* object itself, so it may be reused without danger of side-effects.
|
|
|
|
*/
|
|
|
|
void addLayer(const SkPaint& paint, SkScalar dx, SkScalar dy);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pass queue of layers on to newly created layer rasterizer and return it. The builder
|
|
|
|
* cannot be used any more after calling this function.
|
|
|
|
*/
|
|
|
|
SkLayerRasterizer* detachRasterizer();
|
|
|
|
|
|
|
|
private:
|
|
|
|
SkDeque* fLayers;
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef SK_SUPPORT_LEGACY_LAYERRASTERIZER_API
|
2011-04-20 11:17:30 +00:00
|
|
|
void addLayer(const SkPaint& paint) {
|
2008-12-17 15:59:43 +00:00
|
|
|
this->addLayer(paint, 0, 0);
|
|
|
|
}
|
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
/** Add a new layer (above any previous layers) to the rasterizer.
|
|
|
|
The layer will extract those fields that affect the mask from
|
|
|
|
the specified paint, but will not retain a reference to the paint
|
|
|
|
object itself, so it may be reused without danger of side-effects.
|
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
void addLayer(const SkPaint& paint, SkScalar dx, SkScalar dy);
|
2014-02-26 13:27:37 +00:00
|
|
|
#endif
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2012-03-26 17:57:35 +00:00
|
|
|
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLayerRasterizer)
|
2011-08-09 19:01:50 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
protected:
|
2014-02-26 13:27:37 +00:00
|
|
|
SkLayerRasterizer(SkDeque* layers);
|
2014-01-30 18:58:24 +00:00
|
|
|
SkLayerRasterizer(SkReadBuffer&);
|
|
|
|
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
// override from SkRasterizer
|
|
|
|
virtual bool onRasterize(const SkPath& path, const SkMatrix& matrix,
|
|
|
|
const SkIRect* clipBounds,
|
2012-12-18 16:57:03 +00:00
|
|
|
SkMask* mask, SkMask::CreateMode mode) const;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2014-02-26 13:27:37 +00:00
|
|
|
#ifdef SK_SUPPORT_LEGACY_LAYERRASTERIZER_API
|
|
|
|
public:
|
|
|
|
#endif
|
|
|
|
SkLayerRasterizer();
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
private:
|
2014-02-26 13:27:37 +00:00
|
|
|
#ifdef SK_SUPPORT_LEGACY_LAYERRASTERIZER_API
|
|
|
|
SkDeque* fLayers;
|
|
|
|
#else
|
|
|
|
const SkDeque* const fLayers;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static SkDeque* ReadLayers(SkReadBuffer& buffer);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
typedef SkRasterizer INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|