Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
skbug_9819.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColorSpace.h"
#include "include/core/SkImage.h"

Go to the source code of this file.

Functions

 DEF_SIMPLE_GM (skbug_9819, c, 256, 256)
 

Function Documentation

◆ DEF_SIMPLE_GM()

DEF_SIMPLE_GM ( skbug_9819  ,
,
256  ,
256   
)

Definition at line 16 of file skbug_9819.cpp.

16 {
19 bgra;
21 bgra.allocPixels(info.makeColorType(kBGRA_8888_SkColorType));
22
23 SkColor yellow = 0xffffff00;
24 rgba.eraseColor(yellow);
25 bgra.eraseColor(yellow);
26
27 c->save();
28 c->scale(128,128);
29 c->drawImage(rgba.asImage(), 0,0);
30 c->drawImage(bgra.asImage(), 0,1);
31 c->restore();
32
33 auto grade = [&](int x, int y){
34 SkBitmap bm;
39 if (!c->readPixels(bm, x,y)) {
40 // Picture-backed canvases, that sort of thing. Just assume they're good.
41 MarkGMGood(c, x+128, y);
42 return;
43 }
44
45 // We test only luma so that grayscale destinations are also correctly graded:
46 // - yellow (good) is around 237
47 // - cyan (bad) is around 202
48 uint8_t gray = *bm.getAddr8(0,0);
49 (abs(gray - 237) > 2 ? MarkGMBad
50 : MarkGMGood)(c, x+128,y);
51 };
52
53 grade(64, 64);
54 grade(64, 192);
55}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
kUnpremul_SkAlphaType
static const uint32_t bgra[kNumPixels]
static const uint32_t rgba[kNumPixels]
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition SkAlphaType.h:29
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
Definition SkColorType.h:26
@ kGray_8_SkColorType
pixel with grayscale level in 8-bit byte
Definition SkColorType.h:35
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition SkColorType.h:24
@ kUnknown_SkColorType
uninitialized
Definition SkColorType.h:20
uint32_t SkColor
Definition SkColor.h:37
void allocPixels(const SkImageInfo &info, size_t rowBytes)
Definition SkBitmap.cpp:258
uint8_t * getAddr8(int x, int y) const
Definition SkBitmap.h:1270
static sk_sp< SkColorSpace > MakeSRGB()
void MarkGMGood(SkCanvas *canvas, SkScalar x, SkScalar y)
Definition gm.cpp:221
void MarkGMBad(SkCanvas *canvas, SkScalar x, SkScalar y)
Definition gm.cpp:238
double y
double x
SIN Vec< N, float > abs(const Vec< N, float > &x)
Definition SkVx.h:707
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)