Options
These globals are now defined:
double duration; // The requested duration of the animation. double frame; // A value in [0, 1] of where we are in the animation.
This global is now defined:
GrBackendRenderTarget backEndRenderTarget;
GrBackendTexture backEndTextureRenderTarget;
Optional source image
These globals are now defined:
SkBitmap source; sk_sp<SkImage> image; GrBackendTexture backEndTexture; // GPU Only.
Note:
Adding comments with SK_FOLD_START and SK_FOLD_END creates foldable code
blocks.
These blocks will be folded by default and are useful for highlighting specific lines of code.
You can also use the keyboard shortcuts Ctrl+S and Ctrl+E in the code editor to set them.
These blocks will be folded by default and are useful for highlighting specific lines of code.
You can also use the keyboard shortcuts Ctrl+S and Ctrl+E in the code editor to set them.
xxxxxxxxxx
39
void draw(SkCanvas* canvas) {
GrContext* context = canvas->getGrContext();
if(!context)
return;
SkScalar ss = 2.0;
SkImageInfo texInfo = SkImageInfo::MakeN32(256, 256, kOpaque_SkAlphaType);
SkImageInfo renInfo = SkImageInfo::MakeN32(256 * ss, 256 * ss, kOpaque_SkAlphaType);
sk_sp<SkSurface> texSurface(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, texInfo));
sk_sp<SkSurface> renSurface(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, renInfo));
SkCanvas* texCanvas = texSurface->getCanvas();
SkCanvas* renCanvas = renSurface->getCanvas();
SkPaint cirPaint;
cirPaint.setAntiAlias(true);
cirPaint.setColor(SK_ColorBLUE);
texCanvas->clear(SK_ColorRED);
texCanvas->drawCircle(128, 128, 128, cirPaint);
sk_sp<SkImage> texture(texSurface->makeImageSnapshot());
SkPaint triPaint;
triPaint.setShader(texture->makeShader(SkTileMode::kClamp, SkTileMode::kClamp, nullptr));
SkPoint pts[] = {{0, 0}, {256 * ss, 0}, {0, 220 * ss}};
SkPoint cds[] = {{0, 0}, {256, 0}, {0, 256}};
auto verts = SkVertices::MakeCopy(SkVertices::kTriangles_VertexMode, 3, pts, cds, nullptr);
renCanvas->drawVertices(verts.get(), SkBlendMode::kSrc, triPaint);
sk_sp<SkImage> render(renSurface->makeImageSnapshot());
SkPaint paint;
paint.setFilterQuality(kLow_SkFilterQuality);
canvas->scale(1.0 / ss, 1.0 / ss);
canvas->drawImage(render, 0, 0, &paint);
}