Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
DrawAtlasColorsGM Class Reference
Inheritance diagram for DrawAtlasColorsGM:
skiagm::GM

Public Member Functions

 DrawAtlasColorsGM ()
 
- 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 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
 
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 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 68 of file drawatlascolor.cpp.

Constructor & Destructor Documentation

◆ DrawAtlasColorsGM()

DrawAtlasColorsGM::DrawAtlasColorsGM ( )
inline

Definition at line 70 of file drawatlascolor.cpp.

70 {
71 this->setBGColor(0xFFCCCCCC);
72 }
void setBGColor(SkColor)
Definition gm.cpp:159

Member Function Documentation

◆ getISize()

SkISize DrawAtlasColorsGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 77 of file drawatlascolor.cpp.

77 {
78 return SkISize::Make(kNumXferModes * (kAtlasSize + kPad) + kPad,
79 2 * kNumColors * (kAtlasSize + kPad) + kTextPad + kPad);
80 }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20

◆ getName()

SkString DrawAtlasColorsGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 75 of file drawatlascolor.cpp.

75{ return SkString("draw-atlas-colors"); }

◆ onDraw()

void DrawAtlasColorsGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 82 of file drawatlascolor.cpp.

82 {
83 const SkRect target = SkRect::MakeWH(SkIntToScalar(kAtlasSize), SkIntToScalar(kAtlasSize));
84
85 auto atlas = make_atlas(canvas, kAtlasSize);
86
87 const SkBlendMode gModes[] = {
117 };
118
119 SkColor gColors[] = {
122 0x88888888, // transparent grey
123 0x88000088 // transparent blue
124 };
125
126 const int numModes = std::size(gModes);
127 SkASSERT(numModes == kNumXferModes);
128 const int numColors = std::size(gColors);
129 SkASSERT(numColors == kNumColors);
130 SkRSXform xforms[numColors];
131 SkRect rects[numColors];
132 SkColor quadColors[numColors];
133
135 paint.setAntiAlias(true);
136
137 for (int i = 0; i < numColors; ++i) {
138 xforms[i].set(1.0f, 0.0f, SkIntToScalar(kPad), i*(target.width()+kPad));
139 rects[i] = target;
140 quadColors[i] = gColors[i];
141 }
142
144
145 for (int i = 0; i < numModes; ++i) {
146 const char* label = SkBlendMode_Name(gModes[i]);
147 canvas->drawString(label, i*(target.width()+kPad)+kPad, SkIntToScalar(kTextPad),
148 font, paint);
149 }
150
151 for (int i = 0; i < numModes; ++i) {
152 canvas->save();
153 canvas->translate(SkIntToScalar(i*(target.height()+kPad)),
154 SkIntToScalar(kTextPad+kPad));
155 // w/o a paint
156 canvas->drawAtlas(atlas.get(), xforms, rects, quadColors, numColors,
157 gModes[i], SkSamplingOptions(), nullptr, nullptr);
158 canvas->translate(0.0f, numColors*(target.height()+kPad));
159 // w a paint
160 canvas->drawAtlas(atlas.get(), xforms, rects, quadColors, numColors,
161 gModes[i], SkSamplingOptions(), nullptr, &paint);
162 canvas->restore();
163 }
164 }
static const SkColor gColors[]
#define SkASSERT(cond)
Definition SkAssert.h:116
SK_API const char * SkBlendMode_Name(SkBlendMode blendMode)
SkBlendMode
Definition SkBlendMode.h:38
@ kSrcOut
r = s * (1-da)
@ kExclusion
rc = s + d - two(s*d), ra = kSrcOver
@ kSaturation
saturation of source with hue and luminosity of destination
@ kColorBurn
darken destination to reflect source
@ kPlus
r = min(s + d, 1)
@ kLighten
rc = s + d - min(s*da, d*sa), ra = kSrcOver
@ kHue
hue of source with saturation and luminosity of destination
@ kDstIn
r = d * sa
@ kModulate
r = s*d
@ kMultiply
r = s*(1-da) + d*(1-sa) + s*d
@ kColorDodge
brighten destination to reflect source
@ kScreen
r = s + d - s*d
@ kSrcOver
r = s + (1-sa)*d
@ kXor
r = s*(1-da) + d*(1-sa)
@ kLuminosity
luminosity of source with hue and saturation of destination
@ kSoftLight
lighten or darken, depending on source
@ kDifference
rc = s + d - 2*(min(s*da, d*sa)), ra = kSrcOver
@ kOverlay
multiply or screen, depending on destination
@ kSrcATop
r = s*da + d*(1-sa)
@ kDstATop
r = d*sa + s*(1-da)
@ kDstOver
r = d + (1-da)*s
@ kColor
hue and saturation of source with luminosity of destination
@ kHardLight
multiply or screen, depending on source
@ kDstOut
r = d * (1-sa)
@ kDarken
rc = s + d - max(s*da, d*sa), ra = kSrcOver
@ kSrcIn
r = s * da
@ kClear
r = 0
uint32_t SkColor
Definition SkColor.h:37
constexpr SkColor SK_ColorRED
Definition SkColor.h:126
constexpr SkColor SK_ColorWHITE
Definition SkColor.h:122
#define SkIntToScalar(x)
Definition SkScalar.h:57
constexpr SkBlendMode gModes[]
void restore()
Definition SkCanvas.cpp:465
void translate(SkScalar dx, SkScalar dy)
int save()
Definition SkCanvas.cpp:451
void drawAtlas(const SkImage *atlas, const SkRSXform xform[], const SkRect tex[], const SkColor colors[], int count, SkBlendMode mode, const SkSamplingOptions &sampling, const SkRect *cullRect, const SkPaint *paint)
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition SkCanvas.h:1803
T * get() const
Definition SkRefCnt.h:303
const Paint & paint
static sk_sp< SkImage > make_atlas(SkCanvas *caller, int atlasSize)
uint32_t * target
sk_sp< const SkImage > atlas
Definition SkRecords.h:331
PODArray< SkRSXform > xforms
Definition SkRecords.h:332
sk_sp< SkTypeface > DefaultPortableTypeface()
font
Font Metadata and Metrics.
static constexpr SkRect MakeWH(float w, float h)
Definition SkRect.h:609

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