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

Public Member Functions

 AnisoMipsGM ()=default
 
- 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
 
sk_sp< SkImageupdateImage (SkSurface *surf, SkColor color)
 
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 158 of file anisotropic.cpp.

Constructor & Destructor Documentation

◆ AnisoMipsGM()

skiagm::AnisoMipsGM::AnisoMipsGM ( )
default

Member Function Documentation

◆ getISize()

SkISize skiagm::AnisoMipsGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 165 of file anisotropic.cpp.

165{ return SkISize::Make(520, 260); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString skiagm::AnisoMipsGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 163 of file anisotropic.cpp.

163{ return SkString("anisomips"); }

◆ onDraw()

void skiagm::AnisoMipsGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 179 of file anisotropic.cpp.

179 {
180 auto ct = canvas->imageInfo().colorType() == kUnknown_SkColorType
182 : canvas->imageInfo().colorType();
183 auto ii = SkImageInfo::Make(kImageSize,
184 kImageSize,
185 ct,
187 canvas->imageInfo().refColorSpace());
188 // In GPU mode we want a surface that is created with mipmaps to ensure that we exercise the
189 // case where the SkSurface and SkImage share a texture. If the surface texture isn't
190 // created with MIPs then asking for a mipmapped image will cause a copy to a mipped
191 // texture.
193 if (auto rc = canvas->recordingContext()) {
196 ii,
197 /* sampleCount= */ 1,
199 /*surfaceProps=*/nullptr,
200 /*shouldCreateWithMips=*/true);
201 if (!surface) {
202 // We could be in an abandoned context situation.
203 return;
204 }
205 } else {
206 surface = canvas->makeSurface(ii);
207 if (!surface) { // could be a recording canvas.
209 }
210 }
211
212 static constexpr float kScales[] = {1.f, 0.5f, 0.25f, 0.125f};
214 static const SkSamplingOptions kSampling = SkSamplingOptions::Aniso(16);
215
216 for (bool shader : {false, true}) {
217 int c = 0;
218 canvas->save();
219 for (float sy : kScales) {
220 canvas->save();
221 for (float sx : kScales) {
222 canvas->save();
223 canvas->scale(sx, sy);
224 auto image = this->updateImage(surface.get(), kColors[c]);
225 if (shader) {
227 paint.setShader(image->makeShader(kSampling));
229 } else {
230 canvas->drawImage(image, 0, 0, kSampling);
231 }
232 canvas->restore();
233 canvas->translate(ii.width() * sx + kPad, 0);
234 c = (c + 1) % std::size(kColors);
235 }
236 canvas->restore();
237 canvas->translate(0, ii.width() * sy + kPad);
238 }
239 canvas->restore();
240 for (float sx : kScales) {
241 canvas->translate(ii.width() * sx + kPad, 0);
242 }
243 }
244 }
@ kTopLeft_GrSurfaceOrigin
Definition: GrTypes.h:148
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition: SkColorType.h:24
@ kUnknown_SkColorType
uninitialized
Definition: SkColorType.h:20
uint32_t SkColor
Definition: SkColor.h:37
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
sk_sp< SkSurface > makeSurface(const SkImageInfo &info, const SkSurfaceProps *props=nullptr)
Definition: SkCanvas.cpp:1195
virtual GrRecordingContext * recordingContext() const
Definition: SkCanvas.cpp:1637
int save()
Definition: SkCanvas.cpp:447
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
SkImageInfo imageInfo() const
Definition: SkCanvas.cpp:1206
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
SkISize dimensions() const
Definition: SkImage.h:297
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
Definition: SkImage.cpp:179
T * get() const
Definition: SkRefCnt.h:303
sk_sp< SkImage > updateImage(SkSurface *surf, SkColor color)
const Paint & paint
Definition: color_source.cc:38
VkSurfaceKHR surface
Definition: main.cc:49
sk_sp< const SkImage > image
Definition: SkRecords.h:269
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
const DlColor kColors[]
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
sk_sp< SkColorSpace > refColorSpace() const
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
SkColorType colorType() const
Definition: SkImageInfo.h:373
static SkRect Make(const SkISize &size)
Definition: SkRect.h:669
static constexpr SkSamplingOptions Aniso(int maxAniso)

◆ updateImage()

sk_sp< SkImage > skiagm::AnisoMipsGM::updateImage ( SkSurface surf,
SkColor  color 
)
inlineprotected

Definition at line 167 of file anisotropic.cpp.

167 {
168 surf->getCanvas()->clear(color);
170 paint.setColor(~color | 0xFF000000);
171 surf->getCanvas()->drawRect(SkRect::MakeLTRB(surf->width() *2/5.f,
172 surf->height()*2/5.f,
173 surf->width() *3/5.f,
174 surf->height()*3/5.f),
175 paint);
176 return surf->makeImageSnapshot()->withDefaultMipmaps();
177 }
void clear(SkColor color)
Definition: SkCanvas.h:1199
sk_sp< SkImage > withDefaultMipmaps() const
Definition: SkImage.cpp:305
SkCanvas * getCanvas()
Definition: SkSurface.cpp:82
int width() const
Definition: SkSurface.h:178
sk_sp< SkImage > makeImageSnapshot()
Definition: SkSurface.cpp:90
int height() const
Definition: SkSurface.h:184
DlColor color
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
Definition: SkRect.h:646

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