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 2008 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 SkBlurDrawLooper_DEFINED
|
|
|
|
#define SkBlurDrawLooper_DEFINED
|
|
|
|
|
|
|
|
#include "SkDrawLooper.h"
|
|
|
|
#include "SkColor.h"
|
|
|
|
|
|
|
|
class SkMaskFilter;
|
2011-02-18 19:03:01 +00:00
|
|
|
class SkColorFilter;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
/** \class SkBlurDrawLooper
|
|
|
|
This class draws a shadow of the object (possibly offset), and then draws
|
|
|
|
the original object in its original position.
|
|
|
|
should there be an option to just draw the shadow/blur layer? webkit?
|
|
|
|
*/
|
2011-03-15 21:27:08 +00:00
|
|
|
class SK_API SkBlurDrawLooper : public SkDrawLooper {
|
2008-12-17 15:59:43 +00:00
|
|
|
public:
|
2010-12-06 23:45:58 +00:00
|
|
|
enum BlurFlags {
|
|
|
|
kNone_BlurFlag = 0x00,
|
|
|
|
/**
|
|
|
|
The blur layer's dx/dy/radius aren't affected by the canvas
|
|
|
|
transform.
|
|
|
|
*/
|
2011-02-18 19:03:01 +00:00
|
|
|
kIgnoreTransform_BlurFlag = 0x01,
|
|
|
|
kOverrideColor_BlurFlag = 0x02,
|
|
|
|
kHighQuality_BlurFlag = 0x04,
|
2010-12-06 23:45:58 +00:00
|
|
|
/** mask for all blur flags */
|
2011-02-18 19:03:01 +00:00
|
|
|
kAll_BlurFlag = 0x07
|
2010-12-06 23:45:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
SkBlurDrawLooper(SkScalar radius, SkScalar dx, SkScalar dy, SkColor color,
|
|
|
|
uint32_t flags = kNone_BlurFlag);
|
2008-12-17 15:59:43 +00:00
|
|
|
virtual ~SkBlurDrawLooper();
|
|
|
|
|
|
|
|
// overrides from SkDrawLooper
|
2011-04-07 14:18:59 +00:00
|
|
|
virtual void init(SkCanvas*);
|
|
|
|
virtual bool next(SkCanvas*, SkPaint* paint);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
|
|
|
|
return SkNEW_ARGS(SkBlurDrawLooper, (buffer));
|
|
|
|
}
|
|
|
|
|
2011-12-15 14:16:43 +00:00
|
|
|
SK_DECLARE_FLATTENABLE_REGISTRAR()
|
2010-12-06 23:45:58 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
protected:
|
|
|
|
SkBlurDrawLooper(SkFlattenableReadBuffer&);
|
|
|
|
// overrides from SkFlattenable
|
|
|
|
virtual void flatten(SkFlattenableWriteBuffer& );
|
|
|
|
virtual Factory getFactory() { return CreateProc; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
SkMaskFilter* fBlur;
|
2011-02-18 19:03:01 +00:00
|
|
|
SkColorFilter* fColorFilter;
|
2008-12-17 15:59:43 +00:00
|
|
|
SkScalar fDx, fDy;
|
|
|
|
SkColor fBlurColor;
|
2010-12-06 23:45:58 +00:00
|
|
|
uint32_t fBlurFlags;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
enum State {
|
|
|
|
kBeforeEdge,
|
|
|
|
kAfterEdge,
|
|
|
|
kDone
|
|
|
|
};
|
|
|
|
State fState;
|
|
|
|
|
|
|
|
typedef SkDrawLooper INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|