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
24
void draw(SkCanvas* canvas) {
canvas->scale(16, 16);
SkBitmap bitmap;
SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kRGB_565_SkColorType, kOpaque_SkAlphaType);
bitmap.allocPixels(imageInfo);
SkCanvas offscreen(bitmap);
offscreen.clear(SK_ColorGREEN);
canvas->drawImage(bitmap.asImage(), 0, 0);
auto pack565 = [](unsigned r, unsigned g, unsigned b) -> uint16_t {
return (b << 0) | (g << 5) | (r << 11);
};
uint16_t red565[] = { pack565(0x1F, 0x00, 0x00), pack565(0x17, 0x00, 0x00),
pack565(0x0F, 0x00, 0x00), pack565(0x07, 0x00, 0x00) };
uint16_t blue565[] = { pack565(0x00, 0x00, 0x1F), pack565(0x00, 0x00, 0x17),
pack565(0x00, 0x00, 0x0F), pack565(0x00, 0x00, 0x07) };
SkPixmap redPixmap(imageInfo, &red565, imageInfo.minRowBytes());
if (bitmap.writePixels(redPixmap, 0, 0)) {
canvas->drawImage(bitmap.asImage(), 2, 2);
}
SkPixmap bluePixmap(imageInfo, &blue565, imageInfo.minRowBytes());
if (bitmap.writePixels(bluePixmap, 0, 0)) {
canvas->drawImage(bitmap.asImage(), 4, 4);
}
}