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
17
void draw(SkCanvas* canvas) {
std::vector<int32_t> srcPixels;
srcPixels.resize(source.height() * source.rowBytes());
for (int y = 0; y < 4; ++y) {
for (int x = 0; x < 4; ++x) {
SkPixmap pixmap(SkImageInfo::MakeN32Premul(source.width() / 4, source.height() / 4),
&srcPixels.front() + x * source.height() * source.width() / 4 +
y * source.width() / 4, source.rowBytes());
source.readPixels(pixmap, x * source.width() / 4, y * source.height() / 4);
}
}
canvas->scale(.5f, .5f);
SkBitmap bitmap;
bitmap.installPixels(SkImageInfo::MakeN32Premul(source.width(), source.height()),
&srcPixels.front(), source.rowBytes());
canvas->drawImage(bitmap.asImage(), 0, 0);
}