Flutter Engine
The Flutter Engine
Classes | Functions
bitmaprect.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkBlendMode.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkImage.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPoint.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkSamplingOptions.h"
#include "include/core/SkSize.h"
#include "include/core/SkString.h"
#include "include/core/SkSurface.h"
#include "include/core/SkTileMode.h"
#include "include/core/SkTypes.h"
#include "include/effects/SkGradientShader.h"
#include "tools/GpuToolUtils.h"
#include "tools/ToolUtils.h"
#include <cstddef>
#include <iterator>

Go to the source code of this file.

Classes

class  DrawBitmapRect2
 
class  DrawBitmapRect3
 
class  DrawBitmapRect4
 
class  BitmapRectRounding
 

Functions

static sk_sp< SkImagemake_image (SkCanvas *destCanvas)
 
static void make_3x3_bitmap (SkBitmap *bitmap)
 
static sk_sp< SkImagemake_big_bitmap (SkCanvas *canvas)
 

Function Documentation

◆ make_3x3_bitmap()

static void make_3x3_bitmap ( SkBitmap bitmap)
static

Definition at line 106 of file bitmaprect.cpp.

106 {
107 const int xSize = 3;
108 const int ySize = 3;
109
110 const SkColor textureData[xSize][ySize] = {
114 };
115
116 bitmap->allocN32Pixels(xSize, ySize, true);
117 SkCanvas canvas(*bitmap);
119
120 for (int y = 0; y < ySize; y++) {
121 for (int x = 0; x < xSize; x++) {
122 paint.setColor(textureData[x][y]);
123 canvas.drawIRect(SkIRect::MakeXYWH(x, y, 1, 1), paint);
124 }
125 }
126}
constexpr SkColor SK_ColorYELLOW
Definition: SkColor.h:139
constexpr SkColor SK_ColorMAGENTA
Definition: SkColor.h:147
uint32_t SkColor
Definition: SkColor.h:37
constexpr SkColor SK_ColorCYAN
Definition: SkColor.h:143
constexpr SkColor SK_ColorGRAY
Definition: SkColor.h:113
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
const Paint & paint
Definition: color_source.cc:38
double y
double x
Definition: bitmap.py:1
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
Definition: SkRect.h:104

◆ make_big_bitmap()

static sk_sp< SkImage > make_big_bitmap ( SkCanvas canvas)
static

Definition at line 168 of file bitmaprect.cpp.

168 {
169
170 constexpr int gXSize = 4096;
171 constexpr int gYSize = 4096;
172 constexpr int gBorderWidth = 10;
173
175 bitmap.allocN32Pixels(gXSize, gYSize);
176 for (int y = 0; y < gYSize; ++y) {
177 for (int x = 0; x < gXSize; ++x) {
178 if (x <= gBorderWidth || x >= gXSize-gBorderWidth ||
179 y <= gBorderWidth || y >= gYSize-gBorderWidth) {
180 *bitmap.getAddr32(x, y) = SkPreMultiplyColor(0x88FFFFFF);
181 } else {
182 *bitmap.getAddr32(x, y) = SkPreMultiplyColor(0x88FF0000);
183 }
184 }
185 }
186 bitmap.setImmutable();
187 return ToolUtils::MakeTextureImage(canvas, bitmap.asImage());
188}
SK_API SkPMColor SkPreMultiplyColor(SkColor c)
Definition: SkColor.cpp:21
sk_sp< SkImage > MakeTextureImage(SkCanvas *canvas, sk_sp< SkImage > orig)

◆ make_image()

static sk_sp< SkImage > make_image ( SkCanvas destCanvas)
static

Definition at line 31 of file bitmaprect.cpp.

31 {
33 auto tmpCanvas = surf->getCanvas();
34
35 tmpCanvas->drawColor(SK_ColorRED);
37 paint.setAntiAlias(true);
38 const SkPoint pts[] = { { 0, 0 }, { 64, 64 } };
40 paint.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkTileMode::kClamp));
41 tmpCanvas->drawCircle(32, 32, 32, paint);
42
43 return ToolUtils::MakeTextureImage(destCanvas, surf->makeImageSnapshot());
44}
static sk_sp< SkShader > MakeLinear(const SkPoint pts[2], const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
PODArray< SkColor > colors
Definition: SkRecords.h:276
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
static SkImageInfo MakeN32Premul(int width, int height)