Flutter Engine
The Flutter Engine
Functions
Alpha_Constants_a.cpp File Reference
#include "tools/fiddle/examples.h"

Go to the source code of this file.

Functions

 REG_FIDDLE (Alpha_Constants_a, 256, 128, false, 1)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( Alpha_Constants_a  ,
256  ,
128  ,
false  ,
 
)

Definition at line 4 of file Alpha_Constants_a.cpp.

4 {
5void draw(SkCanvas* canvas) {
6 std::vector<int32_t> srcPixels;
7 srcPixels.resize(source.height() * source.rowBytes());
9 &srcPixels.front(), source.rowBytes());
10 source.readPixels(pixmap, 0, 0);
11 for (int y = 0; y < 16; ++y) {
12 for (int x = 0; x < 16; ++x) {
13 int32_t* blockStart = &srcPixels.front() + y * source.width() * 16 + x * 16;
14 size_t transparentCount = 0;
15 for (int fillY = 0; fillY < source.height() / 16; ++fillY) {
16 for (int fillX = 0; fillX < source.width() / 16; ++fillX) {
17 const SkColor color = SkUnPreMultiply::PMColorToColor(blockStart[fillX]);
18 transparentCount += SkColorGetA(color) == SK_AlphaTRANSPARENT;
19 }
20 blockStart += source.width();
21 }
22 if (transparentCount > 200) {
23 blockStart = &srcPixels.front() + y * source.width() * 16 + x * 16;
24 for (int fillY = 0; fillY < source.height() / 16; ++fillY) {
25 for (int fillX = 0; fillX < source.width() / 16; ++fillX) {
26 blockStart[fillX] = SK_ColorRED;
27 }
28 blockStart += source.width();
29 }
30 }
31 }
32 }
33 canvas->drawImage(SkImages::RasterFromPixmapCopy(pixmap), 0, 0);
34}
35} // END FIDDLE
uint32_t SkColor
Definition: SkColor.h:37
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
#define SkColorGetA(color)
Definition: SkColor.h:61
constexpr SkAlpha SK_AlphaTRANSPARENT
Definition: SkColor.h:89
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
int width() const
Definition: SkBitmap.h:149
size_t rowBytes() const
Definition: SkBitmap.h:238
bool readPixels(const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY) const
Definition: SkBitmap.cpp:488
int height() const
Definition: SkBitmap.h:158
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
static SkColor PMColorToColor(SkPMColor c)
DlColor color
SkBitmap source
Definition: examples.cpp:28
double y
double x
SK_API sk_sp< SkImage > RasterFromPixmapCopy(const SkPixmap &pixmap)
static SkImageInfo MakeN32Premul(int width, int height)