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

Public Member Functions

 ImageGM ()
 
 ~ImageGM () override
 
- 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
 
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 131 of file image.cpp.

Constructor & Destructor Documentation

◆ ImageGM()

ImageGM::ImageGM ( )
inline

Definition at line 141 of file image.cpp.

141 {
142 fBufferSize = RB * H;
143 fBuffer = sk_malloc_throw(fBufferSize);
144 fSize.set(SkIntToScalar(W), SkIntToScalar(H));
145 }
static void * sk_malloc_throw(size_t size)
Definition: SkMalloc.h:67
#define SkIntToScalar(x)
Definition: SkScalar.h:57
Definition: SkMD5.cpp:130
void set(SkScalar w, SkScalar h)
Definition: SkSize.h:64

◆ ~ImageGM()

ImageGM::~ImageGM ( )
inlineoverride

Definition at line 147 of file image.cpp.

147 {
148 sk_free(fBuffer);
149 }
SK_API void sk_free(void *)

Member Function Documentation

◆ getISize()

SkISize ImageGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 154 of file image.cpp.

154{ return SkISize::Make(960, 1200); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString ImageGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 152 of file image.cpp.

152{ return SkString("image-surface"); }

◆ onDraw()

void ImageGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 156 of file image.cpp.

156 {
157 canvas->scale(2, 2);
158
160
161 canvas->drawString("Original Img", 10, 60, font, SkPaint());
162 canvas->drawString("Modified Img", 10, 140, font, SkPaint());
163 canvas->drawString("Cur Surface", 10, 220, font, SkPaint());
164 canvas->drawString("Full Crop", 10, 300, font, SkPaint());
165 canvas->drawString("Over-crop", 10, 380, font, SkPaint());
166 canvas->drawString("Upper-left", 10, 460, font, SkPaint());
167 canvas->drawString("No Crop", 10, 540, font, SkPaint());
168
169 canvas->drawString("Pre-Alloc Img", 80, 10, font, SkPaint());
170 canvas->drawString("New Alloc Img", 160, 10, font, SkPaint());
171 canvas->drawString( "GPU", 265, 10, font, SkPaint());
172
173 canvas->translate(80, 20);
174
175 // since we draw into this directly, we need to start fresh
176 sk_bzero(fBuffer, fBufferSize);
177
179 sk_sp<SkSurface> surf0(SkSurfaces::WrapPixels(info, fBuffer, RB));
181 sk_sp<SkSurface> surf2(
183
184 test_surface(canvas, surf0.get(), true);
185 canvas->translate(80, 0);
186 test_surface(canvas, surf1.get(), true);
187 if (surf2) {
188 canvas->translate(80, 0);
189 test_surface(canvas, surf2.get(), true);
190 }
191 }
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
sk_bzero(glyphs, sizeof(glyphs))
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
virtual GrRecordingContext * recordingContext() const
Definition: SkCanvas.cpp:1637
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition: SkCanvas.h:1803
Definition: SkFont.h:35
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
SK_API sk_sp< SkSurface > WrapPixels(const SkImageInfo &imageInfo, void *pixels, size_t rowBytes, const SkSurfaceProps *surfaceProps=nullptr)
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)
sk_sp< SkTypeface > DefaultPortableTypeface()
font
Font Metadata and Metrics.
static SkImageInfo MakeN32Premul(int width, int height)
static void test_surface(SkCanvas *canvas, SkSurface *surf, bool usePaint)
Definition: image.cpp:84

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