2013-12-10 15:19:32 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef SkBorder_DEFINED
|
|
|
|
#define SkBorder_DEFINED
|
|
|
|
|
|
|
|
#include "SkColor.h"
|
|
|
|
#include "SkPaint.h"
|
|
|
|
#include "SkScalar.h"
|
|
|
|
#include "SkTArray.h"
|
|
|
|
|
|
|
|
// This class provides a concise means of specifying all the geometry/shading
|
|
|
|
// associated with a CSS-style box/round-rect.
|
|
|
|
class SkBorder {
|
|
|
|
public:
|
|
|
|
enum BorderStyle {
|
2013-12-11 07:02:06 +00:00
|
|
|
/**
|
2013-12-10 15:19:32 +00:00
|
|
|
*/
|
|
|
|
kNone_BorderStyle,
|
2013-12-11 07:02:06 +00:00
|
|
|
/**
|
2013-12-10 15:19:32 +00:00
|
|
|
*/
|
|
|
|
kHidden_BorderStyle,
|
2013-12-11 07:02:06 +00:00
|
|
|
/**
|
2013-12-10 15:19:32 +00:00
|
|
|
*/
|
|
|
|
kDotted_BorderStyle,
|
2013-12-11 07:02:06 +00:00
|
|
|
/**
|
2013-12-10 15:19:32 +00:00
|
|
|
*/
|
|
|
|
kDashed_BorderStyle,
|
2013-12-11 07:02:06 +00:00
|
|
|
/**
|
2013-12-10 15:19:32 +00:00
|
|
|
*/
|
|
|
|
kSolid_BorderStyle,
|
2013-12-11 07:02:06 +00:00
|
|
|
/**
|
2013-12-10 15:19:32 +00:00
|
|
|
*/
|
|
|
|
kDouble_BorderStyle,
|
2013-12-11 07:02:06 +00:00
|
|
|
/**
|
2013-12-10 15:19:32 +00:00
|
|
|
*/
|
|
|
|
kGroove_BorderStyle,
|
2013-12-11 07:02:06 +00:00
|
|
|
/**
|
2013-12-10 15:19:32 +00:00
|
|
|
*/
|
|
|
|
kRidge_BorderStyle,
|
2013-12-11 07:02:06 +00:00
|
|
|
/**
|
2013-12-10 15:19:32 +00:00
|
|
|
*/
|
|
|
|
kInset_BorderStyle,
|
2013-12-11 07:02:06 +00:00
|
|
|
/**
|
2013-12-10 15:19:32 +00:00
|
|
|
*/
|
|
|
|
kOutset_BorderStyle,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum BlurStyle {
|
|
|
|
kNormal_BlurStyle, //!< fuzzy inside and outside
|
|
|
|
kInner_BlurStyle, //!< fuzzy inside, nothing outside
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ShadowInfo {
|
|
|
|
SkScalar fXOffset;
|
|
|
|
SkScalar fYOffset;
|
|
|
|
SkScalar fBlurSigma;
|
|
|
|
SkColor fColor;
|
|
|
|
BlurStyle fStyle;
|
|
|
|
};
|
|
|
|
|
|
|
|
SkBorder(SkPaint& p, SkScalar width, BorderStyle style);
|
|
|
|
|
|
|
|
SkBorder(const SkPaint paints[4], const SkScalar widths[4], const BorderStyle styles[4]);
|
|
|
|
|
|
|
|
void setBackground(SkPaint* p) {
|
|
|
|
if (NULL == p) {
|
|
|
|
fBackground.reset();
|
|
|
|
fFlags &= ~kDrawBackground_Flag;
|
|
|
|
} else {
|
|
|
|
fBackground = *p;
|
|
|
|
fFlags |= kDrawBackground_Flag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void addShadow(ShadowInfo& info) {
|
|
|
|
fShadows.push_back(info);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
enum Flags {
|
|
|
|
// One paint "fPaints[0]" is applied to all the borders
|
|
|
|
kOnePaint_Flag = 0x01,
|
|
|
|
// Use 'fBackground' to draw the background
|
|
|
|
kDrawBackground_Flag = 0x02,
|
|
|
|
};
|
|
|
|
|
|
|
|
// If kOnePaint_Flag is specified then fBorder[0] is applied to all sides.
|
|
|
|
// Otherwise the order is: left, top, right, bottom
|
|
|
|
SkPaint fPaints[4];
|
|
|
|
// Only valid if kDrawBackground_Flag is set.
|
|
|
|
SkPaint fBackground;
|
|
|
|
SkScalar fWidths[4];
|
|
|
|
BorderStyle fStyles[4];
|
|
|
|
SkTArray<ShadowInfo> fShadows;
|
|
|
|
uint32_t fFlags;
|
|
|
|
};
|
|
|
|
|
2013-12-10 15:51:43 +00:00
|
|
|
#endif
|