Flutter Engine
The Flutter Engine
Classes | Functions
drawatlascolor.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkBlendMode.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkFont.h"
#include "include/core/SkImage.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkPaint.h"
#include "include/core/SkRSXform.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkScalar.h"
#include "include/core/SkSize.h"
#include "include/core/SkString.h"
#include "include/core/SkSurface.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  DrawAtlasColorsGM
 

Functions

static sk_sp< SkImagemake_atlas (SkCanvas *caller, int atlasSize)
 

Function Documentation

◆ make_atlas()

static sk_sp< SkImage > make_atlas ( SkCanvas caller,
int  atlasSize 
)
static

Definition at line 33 of file drawatlascolor.cpp.

33 {
34 const int kBlockSize = atlasSize/2;
35
36 SkImageInfo info = SkImageInfo::MakeN32Premul(atlasSize, atlasSize);
37 auto surface(ToolUtils::makeSurface(caller, info));
38 SkCanvas* canvas = surface->getCanvas();
39
41 paint.setBlendMode(SkBlendMode::kSrc);
42
43 paint.setColor(SK_ColorWHITE);
44 SkRect r = SkRect::MakeXYWH(0, 0,
46 canvas->drawRect(r, paint);
47
48 paint.setColor(SK_ColorRED);
51 canvas->drawRect(r, paint);
52
53 paint.setColor(SK_ColorGREEN);
56 canvas->drawRect(r, paint);
57
58 paint.setColor(SK_ColorTRANSPARENT);
61 canvas->drawRect(r, paint);
62
63 return surface->makeImageSnapshot();
64}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
constexpr SkColor SK_ColorTRANSPARENT
Definition: SkColor.h:99
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
#define SkIntToScalar(x)
Definition: SkScalar.h:57
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
const Paint & paint
Definition: color_source.cc:38
VkSurfaceKHR surface
Definition: main.cc:49
sk_sp< SkSurface > makeSurface(SkCanvas *canvas, const SkImageInfo &info, const SkSurfaceProps *props)
Definition: ToolUtils.cpp:512
static constexpr intptr_t kBlockSize
Definition: page.h:33
static SkImageInfo MakeN32Premul(int width, int height)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659