Flutter Engine
The Flutter Engine
Classes | Functions
bitmapfilters.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkFont.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkPaint.h"
#include "include/core/SkScalar.h"
#include "include/core/SkSize.h"
#include "include/core/SkString.h"
#include "include/core/SkTypeface.h"
#include "include/core/SkTypes.h"
#include "tools/ToolUtils.h"
#include "tools/fonts/FontToolUtils.h"

Go to the source code of this file.

Classes

class  FilterGM
 
class  TestExtractAlphaGM
 

Functions

static void make_bm (SkBitmap *bm)
 
static SkScalar draw_bm (SkCanvas *canvas, sk_sp< SkImage > img, SkScalar x, SkScalar y, const SkSamplingOptions &sampling, SkPaint *paint)
 
static SkScalar draw_set (SkCanvas *c, sk_sp< SkImage > img, SkScalar x, SkPaint *p)
 
static SkScalar draw_row (SkCanvas *canvas, sk_sp< SkImage > img)
 

Function Documentation

◆ draw_bm()

static SkScalar draw_bm ( SkCanvas canvas,
sk_sp< SkImage img,
SkScalar  x,
SkScalar  y,
const SkSamplingOptions sampling,
SkPaint paint 
)
static

Definition at line 40 of file bitmapfilters.cpp.

41 {
42 canvas->drawImage(img, x, y, sampling, paint);
43 return SkIntToScalar(img->width()) * 5/4;
44}
#define SkIntToScalar(x)
Definition: SkScalar.h:57
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
int width() const
Definition: SkImage.h:285
const Paint & paint
Definition: color_source.cc:38
double y
double x
SkSamplingOptions sampling
Definition: SkRecords.h:337

◆ draw_row()

static SkScalar draw_row ( SkCanvas canvas,
sk_sp< SkImage img 
)
static

Definition at line 53 of file bitmapfilters.cpp.

53 {
54 SkAutoCanvasRestore acr(canvas, true);
55
57 paint.setAntiAlias(true);
58
59 SkScalar x = 0;
60 const int scale = 32;
61
63 const char* name = ToolUtils::colortype_name(img->colorType());
64 canvas->drawString(name, x, SkIntToScalar(img->height())*scale*5/8, font, paint);
65 canvas->translate(SkIntToScalar(48), 0);
66
68
69 x += draw_set(canvas, img, 0, &paint);
70 paint.reset();
71 paint.setAlphaf(0.5f);
72 draw_set(canvas, img, x, &paint);
73 return x * scale / 3;
74}
static SkScalar draw_set(SkCanvas *c, sk_sp< SkImage > img, SkScalar x, SkPaint *p)
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition: SkCanvas.h:1803
Definition: SkFont.h:35
SkColorType colorType() const
Definition: SkImage.cpp:152
int height() const
Definition: SkImage.h:291
float SkScalar
Definition: extension.cpp:12
SkFont DefaultPortableFont()
const char * colortype_name(SkColorType ct)
Definition: ToolUtils.cpp:65
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
font
Font Metadata and Metrics.
const Scalar scale

◆ draw_set()

static SkScalar draw_set ( SkCanvas c,
sk_sp< SkImage img,
SkScalar  x,
SkPaint p 
)
static

Definition at line 46 of file bitmapfilters.cpp.

46 {
47 x += draw_bm(c, img, x, 0, SkSamplingOptions(), p);
49 p->setDither(true);
50 return x + draw_bm(c, img, x, 0, SkSamplingOptions(SkFilterMode::kLinear), p);
51}
static SkScalar draw_bm(SkCanvas *canvas, sk_sp< SkImage > img, SkScalar x, SkScalar y, const SkSamplingOptions &sampling, SkPaint *paint)
SkSamplingOptions(SkFilterMode::kLinear))

◆ make_bm()

static void make_bm ( SkBitmap bm)
static

Definition at line 23 of file bitmapfilters.cpp.

23 {
24 const SkColor colors[4] = {
27 };
28 SkPMColor colorsPM[4];
29 for (size_t i = 0; i < std::size(colors); ++i) {
30 colorsPM[i] = SkPreMultiplyColor(colors[i]);
31 }
32 bm->allocN32Pixels(2, 2, true);
33
34 *bm->getAddr32(0, 0) = colorsPM[0];
35 *bm->getAddr32(1, 0) = colorsPM[1];
36 *bm->getAddr32(0, 1) = colorsPM[2];
37 *bm->getAddr32(1, 1) = colorsPM[3];
38}
SK_API SkPMColor SkPreMultiplyColor(SkColor c)
Definition: SkColor.cpp:21
uint32_t SkColor
Definition: SkColor.h:37
uint32_t SkPMColor
Definition: SkColor.h:205
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
void allocN32Pixels(int width, int height, bool isOpaque=false)
Definition: SkBitmap.cpp:232
uint32_t * getAddr32(int x, int y) const
Definition: SkBitmap.h:1260
PODArray< SkColor > colors
Definition: SkRecords.h:276
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259