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

Public Member Functions

 ImageSourceGM ()
 
- 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 onOnceBeforeDraw () override
 
void onDraw (SkCanvas *canvas) override
 
- Protected Member Functions inherited from skiagm::GM
virtual DrawResult onGpuSetup (SkCanvas *, SkString *, GraphiteTestContext *)
 
virtual void onGpuTeardown ()
 
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 39 of file imagesource.cpp.

Constructor & Destructor Documentation

◆ ImageSourceGM()

ImageSourceGM::ImageSourceGM ( )
inline

Definition at line 41 of file imagesource.cpp.

41{ }

Member Function Documentation

◆ getISize()

SkISize ImageSourceGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 46 of file imagesource.cpp.

46{ return SkISize::Make(500, 150); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20

◆ getName()

SkString ImageSourceGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 44 of file imagesource.cpp.

44{ return SkString("imagesource"); }

◆ onDraw()

void ImageSourceGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 52 of file imagesource.cpp.

52 {
53 canvas->clear(SK_ColorBLACK);
54
55 const SkRect srcRect = SkRect::MakeXYWH(20, 20, 30, 30);
56 const SkRect dstRect = SkRect::MakeXYWH(0, 10, 60, 60);
57 const SkRect clipRect = SkRect::MakeXYWH(0, 0, 100, 100);
58 const SkRect bounds = SkRect::MakeIWH(fImage->width(), fImage->height());
59 const SkSamplingOptions sampling({1/3.0f, 1/3.0f});
60
61 {
62 // Draw an unscaled bitmap.
64 fill_rect_filtered(canvas, clipRect, std::move(imageSource));
65 canvas->translate(SkIntToScalar(100), 0);
66 }
67 {
68 // Draw an unscaled subset of the source bitmap (srcRect -> srcRect).
69 sk_sp<SkImageFilter> imageSourceSrcRect(
70 SkImageFilters::Image(fImage, srcRect, srcRect, sampling));
71 fill_rect_filtered(canvas, clipRect, std::move(imageSourceSrcRect));
72 canvas->translate(SkIntToScalar(100), 0);
73 }
74 {
75 // Draw a subset of the bitmap scaled to a destination rect (srcRect -> dstRect).
76 sk_sp<SkImageFilter> imageSourceSrcRectDstRect(
77 SkImageFilters::Image(fImage, srcRect, dstRect, sampling));
78 fill_rect_filtered(canvas, clipRect, std::move(imageSourceSrcRectDstRect));
79 canvas->translate(SkIntToScalar(100), 0);
80 }
81 {
82 // Draw the entire bitmap scaled to a destination rect (bounds -> dstRect).
83 sk_sp<SkImageFilter> imageSourceDstRectOnly(
84 SkImageFilters::Image(fImage, bounds, dstRect, sampling));
85 fill_rect_filtered(canvas, clipRect, std::move(imageSourceDstRectOnly));
86 canvas->translate(SkIntToScalar(100), 0);
87 }
88 }
constexpr SkColor SK_ColorBLACK
Definition SkColor.h:103
#define SkIntToScalar(x)
Definition SkScalar.h:57
void translate(SkScalar dx, SkScalar dy)
void clear(SkColor color)
Definition SkCanvas.h:1199
static sk_sp< SkImageFilter > Image(sk_sp< SkImage > image, const SkRect &srcRect, const SkRect &dstRect, const SkSamplingOptions &sampling)
int width() const
Definition SkImage.h:285
int height() const
Definition SkImage.h:291
static void fill_rect_filtered(SkCanvas *canvas, const SkRect &clipRect, sk_sp< SkImageFilter > filter)
Optional< SkRect > bounds
Definition SkRecords.h:189
clipRect(r.rect, r.opAA.op(), r.opAA.aa())) template<> void Draw
SkSamplingOptions sampling
Definition SkRecords.h:337
static SkRect MakeIWH(int w, int h)
Definition SkRect.h:623
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition SkRect.h:659

◆ onOnceBeforeDraw()

void ImageSourceGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 48 of file imagesource.cpp.

48 {
49 fImage = ToolUtils::CreateStringImage(100, 100, 0xFFFFFFFF, 20, 70, 96, "e");
50 }
sk_sp< SkImage > CreateStringImage(int w, int h, SkColor c, int x, int y, int textSize, const char *str)

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