Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Typedefs | Functions | Variables
verylargebitmap.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/SkColorSpace.h"
#include "include/core/SkImage.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPicture.h"
#include "include/core/SkPictureRecorder.h"
#include "include/core/SkPoint.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkScalar.h"
#include "include/core/SkShader.h"
#include "include/core/SkSize.h"
#include "include/core/SkString.h"
#include "include/core/SkSurface.h"
#include "include/core/SkTileMode.h"
#include "include/core/SkTiledImageUtils.h"
#include "include/effects/SkGradientShader.h"
#include "tools/ToolUtils.h"

Go to the source code of this file.

Classes

class  VeryLargeBitmapGM
 

Typedefs

typedef sk_sp< SkImage >(* ImageMakerProc) (int width, int height, SkColor colors[2])
 

Functions

static void draw (SkCanvas *canvas, int width, int height, SkColor colors[2])
 
static sk_sp< SkImagemake_raster_image (int width, int height, SkColor colors[2])
 
static sk_sp< SkImagemake_picture_image (int width, int height, SkColor colors[2])
 
static void show_image (SkCanvas *canvas, int width, int height, SkColor colors[2], ImageMakerProc proc, bool manuallyTile)
 
 DEF_GM (return new VeryLargeBitmapGM(make_raster_image, "verylargebitmap", false);) DEF_GM(return new VeryLargeBitmapGM(make_raster_image
 
 DEF_GM (return new VeryLargeBitmapGM(make_picture_image, "verylarge_picture_image", false);) DEF_GM(return new VeryLargeBitmapGM(make_picture_image
 

Variables

 verylargebitmap
 
 true
 
 verylarge_picture_image
 

Typedef Documentation

◆ ImageMakerProc

typedef sk_sp< SkImage >(* ImageMakerProc) (int width, int height, SkColor colors[2])

Definition at line 57 of file verylargebitmap.cpp.

Function Documentation

◆ DEF_GM() [1/2]

DEF_GM ( return new VeryLargeBitmapGM(make_picture_image, "verylarge_picture_image", false);   )
new

◆ DEF_GM() [2/2]

DEF_GM ( return new VeryLargeBitmapGM(make_raster_image, "verylargebitmap", false);   )
new

◆ draw()

static void draw ( SkCanvas canvas,
int  width,
int  height,
SkColor  colors[2] 
)
static

Definition at line 30 of file verylargebitmap.cpp.

30 {
32 const SkScalar radius = 40;
34 paint.setShader(SkGradientShader::MakeRadial(center, radius, colors, nullptr, 2,
36 paint.setBlendMode(SkBlendMode::kSrc);
37 canvas->drawPaint(paint);
38}
#define SkIntToScalar(x)
Definition SkScalar.h:57
static SkScalar center(float pos0, float pos1)
void drawPaint(const SkPaint &paint)
static sk_sp< SkShader > MakeRadial(const SkPoint &center, SkScalar radius, const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
const Paint & paint
float SkScalar
Definition extension.cpp:12
int32_t height
int32_t width

◆ make_picture_image()

static sk_sp< SkImage > make_picture_image ( int  width,
int  height,
SkColor  colors[2] 
)
static

Definition at line 46 of file verylargebitmap.cpp.

46 {
47 SkPictureRecorder recorder;
50 {width, height},
51 nullptr,
52 nullptr,
55}
static sk_sp< SkColorSpace > MakeSRGB()
SkCanvas * beginRecording(const SkRect &bounds, sk_sp< SkBBoxHierarchy > bbh)
sk_sp< SkPicture > finishRecordingAsPicture()
SK_API sk_sp< SkImage > DeferredFromPicture(sk_sp< SkPicture > picture, const SkISize &dimensions, const SkMatrix *matrix, const SkPaint *paint, BitDepth bitDepth, sk_sp< SkColorSpace > colorSpace, SkSurfaceProps props)
@ kU8
uses 8-bit unsigned int per color component
static SkRect MakeIWH(int w, int h)
Definition SkRect.h:623
static void draw(SkCanvas *canvas, int width, int height, SkColor colors[2])

◆ make_raster_image()

static sk_sp< SkImage > make_raster_image ( int  width,
int  height,
SkColor  colors[2] 
)
static

Definition at line 40 of file verylargebitmap.cpp.

40 {
42 draw(surface->getCanvas(), width, height, colors);
43 return surface->makeImageSnapshot();
44}
VkSurfaceKHR surface
Definition main.cc:49
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
static SkImageInfo MakeN32Premul(int width, int height)

◆ show_image()

static void show_image ( SkCanvas canvas,
int  width,
int  height,
SkColor  colors[2],
ImageMakerProc  proc,
bool  manuallyTile 
)
static

Definition at line 59 of file verylargebitmap.cpp.

60 {
61 sk_sp<SkImage> image = proc(width, height, colors);
62 if (!image) {
63 return;
64 }
65
66 SkPaint borderPaint;
67
69
70 SkRect dstRect = SkRect::MakeWH(128.f, 128.f);
71
72 canvas->save();
73 canvas->clipRect(dstRect);
74 if (manuallyTile) {
76 } else {
77 canvas->drawImage(image, 0, 0);
78 }
79 canvas->restore();
80 canvas->drawRect(dstRect, borderPaint);
81
82 dstRect.offset(SkIntToScalar(150), 0);
83 int hw = width / 2;
84 int hh = height / 2;
85 SkRect subset = SkRect::MakeLTRB(hw - 64, hh - 32, hw + 64, hh + 32);
86 if (manuallyTile) {
87 SkTiledImageUtils::DrawImageRect(canvas, image, subset, dstRect, {}, nullptr,
89 } else {
90 canvas->drawImageRect(image, subset, dstRect, {}, nullptr,
92 }
93 canvas->drawRect(dstRect, borderPaint);
94
95 dstRect.offset(SkIntToScalar(150), 0);
96 if (manuallyTile) {
98 } else {
99 canvas->drawImageRect(image, dstRect, {});
100 }
101 canvas->drawRect(dstRect, borderPaint);
102}
void drawRect(const SkRect &rect, const SkPaint &paint)
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
void restore()
Definition SkCanvas.cpp:465
@ kStrict_SrcRectConstraint
sample only inside bounds; slower
Definition SkCanvas.h:1542
void drawImageRect(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
int save()
Definition SkCanvas.cpp:451
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition SkCanvas.h:1528
void setStyle(Style style)
Definition SkPaint.cpp:105
@ kStroke_Style
set to stroke geometry
Definition SkPaint.h:194
sk_sp< SkImage > image
Definition examples.cpp:29
void DrawImage(SkCanvas *canvas, const SkImage *image, SkScalar x, SkScalar y, const SkSamplingOptions &sampling={}, const SkPaint *paint=nullptr, SkCanvas::SrcRectConstraint constraint=SkCanvas::kFast_SrcRectConstraint)
SK_API void DrawImageRect(SkCanvas *canvas, const SkImage *image, const SkRect &src, const SkRect &dst, const SkSamplingOptions &sampling={}, const SkPaint *paint=nullptr, SkCanvas::SrcRectConstraint constraint=SkCanvas::kFast_SrcRectConstraint)
void offset(float dx, float dy)
Definition SkRect.h:1016
static constexpr SkRect MakeWH(float w, float h)
Definition SkRect.h:609
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
Definition SkRect.h:646

Variable Documentation

◆ true

true

Definition at line 163 of file verylargebitmap.cpp.

◆ verylarge_picture_image

verylarge_picture_image

Definition at line 166 of file verylargebitmap.cpp.

◆ verylargebitmap

verylargebitmap

Definition at line 162 of file verylargebitmap.cpp.