本文整理汇总了C++中sk_sp::makeShader方法的典型用法代码示例。如果您正苦于以下问题:C++ sk_sp::makeShader方法的具体用法?C++ sk_sp::makeShader怎么用?C++ sk_sp::makeShader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sk_sp
的用法示例。
在下文中一共展示了sk_sp::makeShader方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dopatch
static void dopatch(SkCanvas* canvas, const SkColor colors[], sk_sp<SkImage> img = nullptr) {
SkPaint paint;
const SkBlendMode modes[] = {
SkBlendMode::kSrc,
SkBlendMode::kDst,
SkBlendMode::kModulate,
};
SkPoint texStorage[4];
const SkPoint* tex = gTexCoords;
sk_sp<SkShader> shader;
if (img) {
SkScalar w = img->width();
SkScalar h = img->height();
shader = img->makeShader();
texStorage[0].set(0, 0);
texStorage[1].set(w, 0);
texStorage[2].set(w, h);
texStorage[3].set(0, h);
tex = texStorage;
} else {
shader = make_shader();
}
canvas->save();
for (int y = 0; y < 3; y++) {
for (int x = 0; x < 4; x++) {
canvas->save();
canvas->translate(x * 350.0f, y * 350.0f);
switch (x) {
case 0:
canvas->drawPatch(gCubics, nullptr, nullptr, modes[y], paint);
break;
case 1:
canvas->drawPatch(gCubics, colors, nullptr, modes[y], paint);
break;
case 2:
paint.setShader(shader);
canvas->drawPatch(gCubics, nullptr, tex, modes[y], paint);
paint.setShader(nullptr);
break;
case 3:
paint.setShader(shader);
canvas->drawPatch(gCubics, colors, tex, modes[y], paint);
paint.setShader(nullptr);
break;
default:
break;
}
draw_control_points(canvas, gCubics);
canvas->restore();
}
}
canvas->restore();
}