Example #1
0
static void annotation_rp(SkCanvas*, SkReader32* reader, uint32_t op32,
                          SkGPipeState* state) {
    SkPaint* p = state->editPaint();

    const size_t size = DrawOp_unpackData(op32);
    if (size > 0) {
        SkReadBuffer buffer(reader->skip(size), size);
        p->setAnnotation(SkAnnotation::Create(buffer))->unref();
        SkASSERT(buffer.offset() == size);
    } else {
        p->setAnnotation(NULL);
    }
}
Example #2
0
static void annotate_paint(SkPaint& paint, const char* key, SkData* value) {
    SkAutoTUnref<SkDataSet> dataset(SkNEW_ARGS(SkDataSet, (key, value)));
    SkAnnotation* ann = SkNEW_ARGS(SkAnnotation, (dataset,
                                                  SkAnnotation::kNoDraw_Flag));

    paint.setAnnotation(ann)->unref();
    SkASSERT(paint.isNoDrawAnnotation());
}
static SkPaint make_paint() {
    SkPaint paint;
    paint.setHinting(make_paint_hinting());
    paint.setAntiAlias(make_bool());
    paint.setDither(make_bool());
    paint.setLinearText(make_bool());
    paint.setSubpixelText(make_bool());
    paint.setLCDRenderText(make_bool());
    paint.setEmbeddedBitmapText(make_bool());
    paint.setAutohinted(make_bool());
    paint.setVerticalText(make_bool());
    paint.setUnderlineText(make_bool());
    paint.setStrikeThruText(make_bool());
    paint.setFakeBoldText(make_bool());
    paint.setDevKernText(make_bool());
    paint.setFilterQuality(make_filter_quality());
    paint.setStyle(make_paint_style());
    paint.setColor(make_color());
    paint.setStrokeWidth(make_scalar());
    paint.setStrokeMiter(make_scalar());
    paint.setStrokeCap(make_paint_cap());
    paint.setStrokeJoin(make_paint_join());
    paint.setColorFilter(make_color_filter());
    paint.setXfermodeMode(make_xfermode());
    paint.setPathEffect(make_path_effect());
    paint.setMaskFilter(make_mask_filter());
    SkAutoTUnref<SkTypeface> typeface(
        SkTypeface::CreateFromName(make_font_name().c_str(), make_typeface_style()));
    paint.setTypeface(typeface);
    SkLayerRasterizer::Builder rasterizerBuilder;
    SkPaint paintForRasterizer;
    if (R(2) == 1) {
        paintForRasterizer = make_paint();
    }
    rasterizerBuilder.addLayer(paintForRasterizer);
    SkAutoTUnref<SkRasterizer> rasterizer(rasterizerBuilder.detachRasterizer());
    paint.setRasterizer(rasterizer);
    paint.setImageFilter(make_image_filter());
    SkAutoDataUnref data(make_3Dlut(nullptr, make_bool(), make_bool(), make_bool()));
    SkAutoTUnref<SkAnnotation> annotation(
        SkAnnotation::Create(make_string().c_str(), data));
    paint.setAnnotation(annotation);
    paint.setTextAlign(make_paint_align());
    paint.setTextSize(make_scalar());
    paint.setTextScaleX(make_scalar());
    paint.setTextSkewX(make_scalar());
    paint.setTextEncoding(make_paint_text_encoding());
    return paint;
}
static void annotate_paint(SkPaint& paint, const char* key, SkData* value) {
    paint.setAnnotation(SkAnnotation::Create(key, value))->unref();
}