本文整理汇总了C++中SkPaint::getStyle方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPaint::getStyle方法的具体用法?C++ SkPaint::getStyle怎么用?C++ SkPaint::getStyle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkPaint
的用法示例。
在下文中一共展示了SkPaint::getStyle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: canDraw
bool GrDistanceFieldTextContext::canDraw(const SkPaint& paint, const SkMatrix& viewMatrix) {
// TODO: support perspective (need getMaxScale replacement)
if (viewMatrix.hasPerspective()) {
return false;
}
SkScalar maxScale = viewMatrix.getMaxScale();
SkScalar scaledTextSize = maxScale*paint.getTextSize();
// Scaling up beyond 2x yields undesireable artifacts
if (scaledTextSize > 2*kLargeDFFontSize) {
return false;
}
if (!fEnableDFRendering && !paint.isDistanceFieldTextTEMP() &&
scaledTextSize < kLargeDFFontSize) {
return false;
}
// rasterizers and mask filters modify alpha, which doesn't
// translate well to distance
if (paint.getRasterizer() || paint.getMaskFilter() ||
!fContext->getTextTarget()->caps()->shaderDerivativeSupport()) {
return false;
}
// TODO: add some stroking support
if (paint.getStyle() != SkPaint::kFill_Style) {
return false;
}
return true;
}
示例2: switch
SkStrokeRec::SkStrokeRec(const SkPaint& paint) {
switch (paint.getStyle()) {
case SkPaint::kFill_Style:
fWidth = kStrokeRec_FillStyleWidth;
fStrokeAndFill = false;
break;
case SkPaint::kStroke_Style:
fWidth = paint.getStrokeWidth();
fStrokeAndFill = false;
break;
case SkPaint::kStrokeAndFill_Style:
if (0 == paint.getStrokeWidth()) {
// hairline+fill == fill
fWidth = kStrokeRec_FillStyleWidth;
fStrokeAndFill = false;
} else {
fWidth = paint.getStrokeWidth();
fStrokeAndFill = true;
}
break;
default:
SkASSERT(!"unknown paint style");
// fall back on just fill
fWidth = kStrokeRec_FillStyleWidth;
fStrokeAndFill = false;
break;
}
// copy these from the paint, regardless of our "style"
fMiterLimit = paint.getStrokeMiter();
fCap = paint.getStrokeCap();
fJoin = paint.getStrokeJoin();
}
示例3:
SkStroke::SkStroke(const SkPaint& p, SkScalar width) {
fWidth = width;
fMiterLimit = p.getStrokeMiter();
fCap = (uint8_t)p.getStrokeCap();
fJoin = (uint8_t)p.getStrokeJoin();
fDoFill = SkToU8(p.getStyle() == SkPaint::kStrokeAndFill_Style);
}
示例4: canDraw
bool GrStencilAndCoverTextContext::canDraw(const GrRenderTarget* rt,
const GrClip& clip,
const GrPaint& paint,
const SkPaint& skPaint,
const SkMatrix& viewMatrix) {
if (skPaint.getRasterizer()) {
return false;
}
if (skPaint.getMaskFilter()) {
return false;
}
if (SkPathEffect* pe = skPaint.getPathEffect()) {
if (pe->asADash(NULL) != SkPathEffect::kDash_DashType) {
return false;
}
}
// No hairlines unless we can map the 1 px width to the object space.
if (skPaint.getStyle() == SkPaint::kStroke_Style
&& skPaint.getStrokeWidth() == 0
&& viewMatrix.hasPerspective()) {
return false;
}
// No color bitmap fonts.
SkScalerContext::Rec rec;
SkScalerContext::MakeRec(skPaint, &fDeviceProperties, NULL, &rec);
return rec.getFormat() != SkMask::kARGB32_Format;
}
示例5: canDraw
bool GrDistanceFieldTextContext::canDraw(const SkPaint& paint) {
if (!fEnableDFRendering && !paint.isDistanceFieldTextTEMP()) {
return false;
}
// rasterizers and mask filters modify alpha, which doesn't
// translate well to distance
if (paint.getRasterizer() || paint.getMaskFilter() ||
!fContext->getTextTarget()->caps()->shaderDerivativeSupport()) {
return false;
}
// TODO: add some stroking support
if (paint.getStyle() != SkPaint::kFill_Style) {
return false;
}
// TODO: choose an appropriate maximum scale for distance fields and
// enable perspective
if (SkDraw::ShouldDrawTextAsPaths(paint, fContext->getMatrix())) {
return false;
}
return true;
}
示例6: ShouldDisableLCD
bool GrTextUtils::ShouldDisableLCD(const SkPaint& paint) {
return !SkXfermode::AsMode(paint.getXfermode(), nullptr) ||
paint.getMaskFilter() ||
paint.getRasterizer() ||
paint.getPathEffect() ||
paint.isFakeBoldText() ||
paint.getStyle() != SkPaint::kFill_Style;
}
示例7: drawArc
void SkBaseDevice::drawArc(const SkDraw& draw, const SkRect& oval, SkScalar startAngle,
SkScalar sweepAngle, bool useCenter, const SkPaint& paint) {
SkPath path;
bool isFillNoPathEffect = SkPaint::kFill_Style == paint.getStyle() && !paint.getPathEffect();
SkPathPriv::CreateDrawArcPath(&path, oval, startAngle, sweepAngle, useCenter,
isFillNoPathEffect);
this->drawPath(draw, path, paint);
}
示例8: type
TessellationCache::Description::Description(Type type, const Matrix4& transform, const SkPaint& paint)
: type(type)
, aa(paint.isAntiAlias())
, cap(paint.getStrokeCap())
, style(paint.getStyle())
, strokeWidth(paint.getStrokeWidth()) {
PathTessellator::extractTessellationScales(transform, &scaleX, &scaleY);
memset(&shape, 0, sizeof(Shape));
}
示例9: paint_write
static void paint_write(const SkPaint& paint, SkFlattenableWriteBuffer& buffer)
{
buffer.writeBool(paint.isAntiAlias());
buffer.write8(paint.getStyle());
buffer.write8(paint.getAlpha());
if (paint.getStyle() != SkPaint::kFill_Style)
{
buffer.writeScalar(paint.getStrokeWidth());
buffer.writeScalar(paint.getStrokeMiter());
buffer.write8(paint.getStrokeCap());
buffer.write8(paint.getStrokeJoin());
}
buffer.writeFlattenable(paint.getMaskFilter());
buffer.writeFlattenable(paint.getPathEffect());
buffer.writeFlattenable(paint.getRasterizer());
buffer.writeFlattenable(paint.getXfermode());
}
示例10: drawPath
void SkGLDevice::drawPath(const SkDraw& draw, const SkPath& path,
const SkPaint& paint) {
TRACE_DRAW("coreDrawPath", this, draw);
if (paint.getStyle() == SkPaint::kStroke_Style) {
return;
}
AutoPaintShader shader(this, paint);
SkGL::FillPath(path, paint, shader.useTex(), this->updateMatrixClip());
}
示例11: onShouldDisableLCD
bool SkBitmapDevice::onShouldDisableLCD(const SkPaint& paint) const {
if (kN32_SkColorType != fBitmap.colorType() ||
paint.getRasterizer() ||
paint.getPathEffect() ||
paint.isFakeBoldText() ||
paint.getStyle() != SkPaint::kFill_Style ||
!SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode))
{
return true;
}
return false;
}
示例12: DrawPosTextAsPath
void GrTextUtils::DrawPosTextAsPath(GrContext* context,
GrDrawContext* dc,
const SkSurfaceProps& props,
const GrClip& clip,
const SkPaint& origPaint, const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset, const SkIRect& clipBounds) {
// setup our std paint, in hopes of getting hits in the cache
SkPaint paint(origPaint);
SkScalar matrixScale = paint.setupForAsPaths();
SkMatrix matrix;
matrix.setScale(matrixScale, matrixScale);
// Temporarily jam in kFill, so we only ever ask for the raw outline from the cache.
paint.setStyle(SkPaint::kFill_Style);
paint.setPathEffect(nullptr);
SkPaint::GlyphCacheProc glyphCacheProc = paint.getGlyphCacheProc(true);
SkAutoGlyphCache autoCache(paint, &props, nullptr);
SkGlyphCache* cache = autoCache.getCache();
const char* stop = text + byteLength;
SkTextAlignProc alignProc(paint.getTextAlign());
SkTextMapStateProc tmsProc(SkMatrix::I(), offset, scalarsPerPosition);
// Now restore the original settings, so we "draw" with whatever style/stroking.
paint.setStyle(origPaint.getStyle());
paint.setPathEffect(origPaint.getPathEffect());
while (text < stop) {
const SkGlyph& glyph = glyphCacheProc(cache, &text);
if (glyph.fWidth) {
const SkPath* path = cache->findPath(glyph);
if (path) {
SkPoint tmsLoc;
tmsProc(pos, &tmsLoc);
SkPoint loc;
alignProc(tmsLoc, glyph, &loc);
matrix[SkMatrix::kMTransX] = loc.fX;
matrix[SkMatrix::kMTransY] = loc.fY;
GrBlurUtils::drawPathWithMaskFilter(context, dc, clip, *path, paint,
viewMatrix, &matrix, clipBounds, false);
}
}
pos += scalarsPerPosition;
}
}
示例13: SkASSERT
static uint16_t compute_nondef(const SkPaint& paint, PaintUsage usage) {
// kRespectsStroke_PaintUsage is only valid if other bits are also set
SkASSERT(0 != (usage & ~kRespectsStroke_PaintUsage));
const SkScalar kTextSize_Default = 12;
const SkScalar kTextScaleX_Default = 1;
const SkScalar kTextSkewX_Default = 0;
const SkScalar kStrokeWidth_Default = 0;
const SkScalar kStrokeMiter_Default = 4;
const SkColor kColor_Default = SK_ColorBLACK;
unsigned bits = (paint.getColor() != kColor_Default) ? kColor_NonDef : 0;
if (usage & kText_PaintUsage) {
bits |= (paint.getTextSize() != kTextSize_Default ? kTextSize_NonDef : 0);
bits |= (paint.getTextScaleX() != kTextScaleX_Default ? kTextScaleX_NonDef : 0);
bits |= (paint.getTextSkewX() != kTextSkewX_Default ? kTextSkewX_NonDef : 0);
bits |= (paint.getTypeface() ? kTypeface_NonDef : 0);
}
// TODO: kImage_PaintUsage only needs the shader/maskfilter IF its colortype is kAlpha_8
if (usage & (kVertices_PaintUsage | kDrawPaint_PaintUsage | kImage_PaintUsage |
kText_PaintUsage | kGeometry_PaintUsage | kTextBlob_PaintUsage)) {
bits |= (paint.getShader() ? kShader_NonDef : 0);
}
if (usage & (kText_PaintUsage | kGeometry_PaintUsage | kTextBlob_PaintUsage)) {
bits |= (paint.getPathEffect() ? kPathEffect_NonDef : 0);
bits |= (paint.getRasterizer() ? kRasterizer_NonDef : 0);
if (paint.getStyle() != SkPaint::kFill_Style || (usage & kRespectsStroke_PaintUsage)) {
bits |= (paint.getStrokeWidth() != kStrokeWidth_Default ? kStrokeWidth_NonDef : 0);
bits |= (paint.getStrokeMiter() != kStrokeMiter_Default ? kStrokeMiter_NonDef : 0);
}
}
if (usage &
(kText_PaintUsage | kGeometry_PaintUsage | kImage_PaintUsage | kTextBlob_PaintUsage))
{
bits |= (paint.getMaskFilter() ? kMaskFilter_NonDef : 0);
}
bits |= (paint.getColorFilter() ? kColorFilter_NonDef : 0);
bits |= (paint.getImageFilter() ? kImageFilter_NonDef : 0);
bits |= (paint.getDrawLooper() ? kDrawLooper_NonDef : 0);
return SkToU16(bits);
}
示例14: internalCanDraw
bool GrStencilAndCoverTextContext::internalCanDraw(const SkPaint& skPaint) {
if (skPaint.getRasterizer()) {
return false;
}
if (skPaint.getMaskFilter()) {
return false;
}
if (SkPathEffect* pe = skPaint.getPathEffect()) {
if (pe->asADash(nullptr) != SkPathEffect::kDash_DashType) {
return false;
}
}
// No hairlines. They would require new paths with customized strokes for every new draw matrix.
return SkPaint::kStroke_Style != skPaint.getStyle() || 0 != skPaint.getStrokeWidth();
}
示例15: apply_paint_style
static void apply_paint_style(const SkPaint& paint, Json::Value* target) {
SkPaint::Style style = paint.getStyle();
if (style != SkPaint::kFill_Style) {
switch (style) {
case SkPaint::kStroke_Style: {
Json::Value stroke(SKJSONCANVAS_STYLE_STROKE);
(*target)[SKJSONCANVAS_ATTRIBUTE_STYLE] = stroke;
break;
}
case SkPaint::kStrokeAndFill_Style: {
Json::Value strokeAndFill(SKJSONCANVAS_STYLE_STROKEANDFILL);
(*target)[SKJSONCANVAS_ATTRIBUTE_STYLE] = strokeAndFill;
break;
}
default: SkASSERT(false);
}
}
}