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,
|
2012-08-23 18:09:54 +00:00
|
|
|
/**
|
|
|
|
The blur layer's dx/dy/radius aren't affected by the canvas
|
2010-12-06 23:45:58 +00:00
|
|
|
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 */
|
2012-11-29 17:09:27 +00:00
|
|
|
kAll_BlurFlag = 0x07
|
2010-12-06 23:45:58 +00:00
|
|
|
};
|
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
SkBlurDrawLooper(SkScalar radius, SkScalar dx, SkScalar dy, SkColor color,
|
2010-12-06 23:45:58 +00:00
|
|
|
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
|
|
|
|
2012-03-26 17:57:35 +00:00
|
|
|
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurDrawLooper)
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
SkBlurDrawLooper(SkFlattenableReadBuffer&);
|
2012-03-29 15:18:04 +00:00
|
|
|
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
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;
|
2012-08-23 18:09:54 +00:00
|
|
|
uint32_t fBlurFlags;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
enum State {
|
|
|
|
kBeforeEdge,
|
|
|
|
kAfterEdge,
|
|
|
|
kDone
|
|
|
|
};
|
|
|
|
State fState;
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
typedef SkDrawLooper INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|