Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | List of all members
CrBug224618GM Class Reference
Inheritance diagram for CrBug224618GM:
skiagm::GM

Public Member Functions

 CrBug224618GM ()
 
- Public Member Functions inherited from skiagm::GM
 GM (SkColor backgroundColor=SK_ColorWHITE)
 
virtual ~GM ()
 
void setMode (Mode mode)
 
Mode getMode () const
 
DrawResult gpuSetup (SkCanvas *, SkString *errorMsg, GraphiteTestContext *=nullptr)
 
void gpuTeardown ()
 
void onceBeforeDraw ()
 
DrawResult draw (SkCanvas *canvas)
 
DrawResult draw (SkCanvas *, SkString *errorMsg)
 
void drawBackground (SkCanvas *)
 
DrawResult drawContent (SkCanvas *canvas)
 
DrawResult drawContent (SkCanvas *, SkString *errorMsg)
 
virtual SkISize getISize ()=0
 
virtual SkString getName () const =0
 
virtual bool runAsBench () const
 
SkScalar width ()
 
SkScalar height ()
 
SkColor getBGColor () const
 
void setBGColor (SkColor)
 
void drawSizeBounds (SkCanvas *, SkColor)
 
bool animate (double)
 
virtual bool onChar (SkUnichar)
 
bool getControls (SkMetaData *controls)
 
void setControls (const SkMetaData &controls)
 
virtual void modifyGrContextOptions (GrContextOptions *)
 
virtual void modifyGraphiteContextOptions (skgpu::graphite::ContextOptions *) const
 
virtual bool isBazelOnly () const
 
virtual std::map< std::string, std::string > getGoldKeys () const
 

Protected Member Functions

SkString getName () const override
 
SkISize getISize () override
 
bool onAnimate (double nanos) override
 
void onOnceBeforeDraw () override
 
void onDraw (SkCanvas *canvas) override
 
- Protected Member Functions inherited from skiagm::GM
virtual DrawResult onGpuSetup (SkCanvas *, SkString *, GraphiteTestContext *)
 
virtual void onGpuTeardown ()
 
virtual void onOnceBeforeDraw ()
 
virtual DrawResult onDraw (SkCanvas *, SkString *errorMsg)
 
virtual void onDraw (SkCanvas *)
 
virtual bool onAnimate (double)
 
virtual bool onGetControls (SkMetaData *)
 
virtual void onSetControls (const SkMetaData &)
 
GraphiteTestContextgraphiteTestContext () const
 

Additional Inherited Members

- Public Types inherited from skiagm::GM
enum  Mode { kGM_Mode , kSample_Mode , kBench_Mode }
 
using DrawResult = skiagm::DrawResult
 
using GraphiteTestContext = skiatest::graphite::GraphiteTestContext
 
- Static Public Attributes inherited from skiagm::GM
static constexpr char kErrorMsg_DrawSkippedGpuOnly []
 

Detailed Description

Definition at line 18 of file crbug_224618.cpp.

Constructor & Destructor Documentation

◆ CrBug224618GM()

CrBug224618GM::CrBug224618GM ( )
inline

Definition at line 20 of file crbug_224618.cpp.

20: fTime(0.f) {}

Member Function Documentation

◆ getISize()

SkISize CrBug224618GM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 25 of file crbug_224618.cpp.

25{ return SkISize::Make(kMaxVW, kMaxVW); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString CrBug224618GM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 23 of file crbug_224618.cpp.

23{ return SkString("crbug_224618"); }

◆ onAnimate()

bool CrBug224618GM::onAnimate ( double  nanos)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 29 of file crbug_224618.cpp.

29 {
30 fTime = TimeUtils::Scaled(1e-9f * nanos, 0.5f);
31 return true;
32 }
static float Scaled(float time, float speed, float period=0)
Definition: TimeUtils.h:27

◆ onDraw()

void CrBug224618GM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 49 of file crbug_224618.cpp.

49 {
50 SkScalar viewportWidth = SkScalarMod(fTime, 10.f) / 10.f * (kMaxVW - kMinVW) + kMinVW;
51 SkScalar radius = viewportWidth / 2.f; // round?
52 // See https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/perspective
53 SkM44 proj{1.f, 0.f, 0.f, 0.f,
54 0.f, 1.f, 0.f, 0.f,
55 0.f, 0.f, 1.f, 0.f,
56 0.f, 0.f, -1.f / radius, 1.f};
57 SkM44 zoom = SkM44::Translate(0.f, 0.f, radius);
58 SkM44 postZoom = SkM44::Translate(0.f, 0.f, -radius - 1.f);
59 SkM44 rotateHorizontal = SkM44::Rotate({0, 1, 0}, 2.356194490192345f);
60
61 // w in degrees will need to be converted to radians
62 SkV4 axisAngles[6] = {
63 {0.f, 1.f, 0.f, -90.f}, // rotateY(-90deg)
64 {1.f, 0.f, 0.f, 0.f}, // <none>
65 {0.f, 1.f, 0.f, 90.f}, // rotateY(90deg)
66 {0.f, 1.f, 0.f, 180.f}, // rotateY(180deg)
67 {1.f, 0.f, 0.f, -90.f}, // rotateX(-90deg)
68 {1.f, 0.f, 0.f, 90.f}, // rotateX(90deg)
69 };
70 SkColor faceColors[6] = {
75 SkColorSetARGB(0xFF, 0xFF, 0xA5, 0x00), // orange css
76 SkColorSetARGB(0xFF, 0x80, 0x00, 0x80) // purple css
77 };
78
79 for (int i = 0; i < 6; ++i) {
80 SkM44 model = SkM44::Rotate({axisAngles[i].x, axisAngles[i].y, axisAngles[i].z},
81 SkDegreesToRadians(axisAngles[i].w));
82 model = SkM44::Translate(radius, radius) * proj * // project and place content
83 zoom * rotateHorizontal * model * postZoom * // main model matrix
84 SkM44::Translate(-radius, -radius); // center content
85
86 canvas->save();
87 canvas->concat(model);
88
89 SkPaint fillPaint;
90 fillPaint.setAntiAlias(true);
91 fillPaint.setColor(faceColors[i]);
92
93 // Leverages FillRectOp on GPU backend
94 canvas->drawRect(SkRect::MakeWH(viewportWidth, viewportWidth), fillPaint);
95
96 // Leverages TextureOp on GPU backend, to ensure sure both quad paths handle clipping
97 canvas->drawImageRect(fCubeImage.get(),
98 SkRect::MakeWH(fCubeImage->width(), fCubeImage->height()),
99 SkRect::MakeWH(viewportWidth, viewportWidth),
102
103 canvas->restore();
104 }
105 }
constexpr SkColor SK_ColorYELLOW
Definition: SkColor.h:139
uint32_t SkColor
Definition: SkColor.h:37
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
static constexpr SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
Definition: SkColor.h:49
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
#define SkDegreesToRadians(degrees)
Definition: SkScalar.h:77
#define SkScalarMod(x, y)
Definition: SkScalar.h:41
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void restore()
Definition: SkCanvas.cpp:461
@ kFast_SrcRectConstraint
sample outside bounds; faster
Definition: SkCanvas.h:1543
void drawImageRect(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
Definition: SkCanvas.cpp:2333
int save()
Definition: SkCanvas.cpp:447
void concat(const SkMatrix &matrix)
Definition: SkCanvas.cpp:1318
int width() const
Definition: SkImage.h:285
int height() const
Definition: SkImage.h:291
Definition: SkM44.h:150
static SkM44 Rotate(SkV3 axis, SkScalar radians)
Definition: SkM44.h:239
static SkM44 Translate(SkScalar x, SkScalar y, SkScalar z=0)
Definition: SkM44.h:225
void setColor(SkColor color)
Definition: SkPaint.cpp:119
void setAntiAlias(bool aa)
Definition: SkPaint.h:170
T * get() const
Definition: SkRefCnt.h:303
float SkScalar
Definition: extension.cpp:12
SkScalar w
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609
Definition: SkM44.h:98

◆ onOnceBeforeDraw()

void CrBug224618GM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 34 of file crbug_224618.cpp.

34 {
35 static const SkColor kColors[2] = {SK_ColorTRANSPARENT, SkColorSetARGB(128, 255, 255, 255)};
37 {200.f, 200.f}, 25.f, kColors, nullptr, 2, SkTileMode::kMirror,
39
41
42 SkPaint bgPaint;
43 bgPaint.setShader(gradient);
44 surface->getCanvas()->drawPaint(bgPaint);
45
46 fCubeImage = surface->makeImageSnapshot();
47 }
constexpr SkColor SK_ColorTRANSPARENT
Definition: SkColor.h:99
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)
void setShader(sk_sp< SkShader > shader)
VkSurfaceKHR surface
Definition: main.cc:49
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
const DlColor kColors[]
static SkImageInfo MakeN32Premul(int width, int height)

The documentation for this class was generated from the following file: