Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Color_Type_RGB_101010.cpp
Go to the documentation of this file.
1// Copyright 2019 Google LLC.
2// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
4// HASH=92f81aa0459230459600a01e79ccff29
5REG_FIDDLE(Color_Type_RGB_101010, 256, 96, false, 0) {
6void draw(SkCanvas* canvas) {
7 canvas->scale(16, 16);
10 bitmap.allocPixels(imageInfo);
11 SkCanvas offscreen(bitmap);
12 offscreen.clear(SK_ColorGREEN);
13 canvas->drawImage(bitmap.asImage(), 0, 0);
14 auto pack101010x = [](unsigned r, unsigned g, unsigned b) -> uint32_t {
15 return (r << 0) | (g << 10) | (b << 20);
16 };
17 uint32_t redBits[] = { pack101010x(0x3FF, 0x000, 0x000), pack101010x(0x2ff, 0x000, 0x000),
18 pack101010x(0x1ff, 0x000, 0x000), pack101010x(0x0ff, 0x000, 0x000) };
19 uint32_t blueBits[] = { pack101010x(0x000, 0x000, 0x3FF), pack101010x(0x000, 0x000, 0x2ff),
20 pack101010x(0x000, 0x000, 0x1ff), pack101010x(0x000, 0x000, 0x0ff) };
21 if (bitmap.installPixels(imageInfo, (void*) redBits, imageInfo.minRowBytes())) {
22 canvas->drawImage(bitmap.asImage(), 2, 2);
23 }
24 SkPixmap bluePixmap(imageInfo, &blueBits, imageInfo.minRowBytes());
25 if (bitmap.installPixels(imageInfo, (void*) blueBits, imageInfo.minRowBytes())) {
26 canvas->drawImage(bitmap.asImage(), 4, 4);
27 }
28}
29} // END FIDDLE
@ kOpaque_SkAlphaType
pixel is opaque
Definition SkAlphaType.h:28
@ kRGB_101010x_SkColorType
pixel with 10 bits each for red, green, blue; in 32-bit word
Definition SkColorType.h:29
constexpr SkColor SK_ColorGREEN
Definition SkColor.h:131
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition aaclip.cpp:27
void clear(SkColor color)
Definition SkCanvas.h:1199
void scale(SkScalar sx, SkScalar sy)
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition SkCanvas.h:1528
#define REG_FIDDLE(NAME, W, H, TEXT, I)
Definition examples.h:60
static bool b
size_t minRowBytes() const
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)