Flutter Engine
The Flutter Engine
Classes | Functions
3d.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkData.h"
#include "include/core/SkPicture.h"
#include "include/core/SkPictureRecorder.h"
#include <cmath>

Go to the source code of this file.

Classes

struct  Info
 

Functions

static SkM44 inv (const SkM44 &m)
 
static SkM44 make_ctm (const Info &info, const SkM44 &model, SkSize size)
 
static void do_draw (SkCanvas *canvas, SkColor color)
 
 DEF_SIMPLE_GM (sk3d_simple, real_canvas, 300, 300)
 

Function Documentation

◆ DEF_SIMPLE_GM()

DEF_SIMPLE_GM ( sk3d_simple  ,
real_canvas  ,
300  ,
300   
)

Definition at line 65 of file 3d.cpp.

65 {
66 do_draw(real_canvas, 0xFFFF0000);
67
68 SkPictureRecorder recorder;
69 SkCanvas* canvas = recorder.beginRecording(300, 300);
70
71 do_draw(canvas, 0x880000FF);
72
73 auto pic = recorder.finishRecordingAsPicture();
74 real_canvas->drawPicture(pic);
75}
static void do_draw(SkCanvas *canvas, SkColor color)
Definition: 3d.cpp:47
SkCanvas * beginRecording(const SkRect &bounds, sk_sp< SkBBoxHierarchy > bbh)
sk_sp< SkPicture > finishRecordingAsPicture()

◆ do_draw()

static void do_draw ( SkCanvas canvas,
SkColor  color 
)
static

Definition at line 47 of file 3d.cpp.

47 {
48 SkAutoCanvasRestore acr(canvas, true);
49
50 Info info;
51
52 SkM44 m = SkM44::Rotate({0, 1, 0}, SK_ScalarPI/6);
53
54 canvas->concat(make_ctm(info, m, {300, 300}));
55
56 canvas->translate(150, 150);
58 paint.setColor(color);
59 canvas->drawRect({-100, -100, 100, 100}, paint);
60}
static SkM44 make_ctm(const Info &info, const SkM44 &model, SkSize size)
Definition: 3d.cpp:34
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
#define SK_ScalarPI
Definition: SkScalar.h:21
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void concat(const SkMatrix &matrix)
Definition: SkCanvas.cpp:1318
Definition: SkM44.h:150
static SkM44 Rotate(SkV3 axis, SkScalar radians)
Definition: SkM44.h:239
const Paint & paint
Definition: color_source.cc:38
DlColor color
Definition: 3d.cpp:16

◆ inv()

static SkM44 inv ( const SkM44 m)
static

Definition at line 26 of file 3d.cpp.

26 {
28 if (!m.invert(&inverse)) {
29 inverse.setIdentity();
30 }
31 return inverse;
32}
@ kUninitialized_Constructor
Definition: SkM44.h:167

◆ make_ctm()

static SkM44 make_ctm ( const Info info,
const SkM44 model,
SkSize  size 
)
static

Definition at line 34 of file 3d.cpp.

34 {
35 SkM44 camera, perspective, viewport;
36
37 SkScalar w = size.width();
38 SkScalar h = size.height();
39
40 perspective = SkM44::Perspective(info.fNear, info.fFar, info.fAngle);
41 camera = SkM44::LookAt(info.fEye, info.fCOA, info.fUp);
42 viewport.setScale(w*0.5f, h*0.5f, 1);//.postTranslate(r.centerX(), r.centerY(), 0);
43
44 return viewport * perspective * camera * model * inv(viewport);
45}
static SkM44 inv(const SkM44 &m)
Definition: 3d.cpp:26
static SkM44 LookAt(const SkV3 &eye, const SkV3 &center, const SkV3 &up)
Definition: SkM44.cpp:331
SkM44 & setScale(SkScalar x, SkScalar y, SkScalar z=1)
Definition: SkM44.h:309
static SkM44 Perspective(float near, float far, float angle)
Definition: SkM44.cpp:343
float SkScalar
Definition: extension.cpp:12
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
SkScalar w
SkScalar h