2008-12-17 15:59:43 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2008 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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));
|
|
|
|
}
|
|
|
|
|
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
|