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

Public Member Functions

 LazyTilingGM (GrSurfaceOrigin origin)
 

Protected Member Functions

SkString getName () const override
 
SkISize getISize () override
 
DrawResult onGpuSetup (SkCanvas *canvas, SkString *errorMsg, GraphiteTestContext *) override
 
DrawResult onDraw (GrRecordingContext *rContext, SkCanvas *canvas, SkString *errorMsg) override
 

Detailed Description

Definition at line 178 of file lazytiling.cpp.

Constructor & Destructor Documentation

◆ LazyTilingGM()

skiagm::LazyTilingGM::LazyTilingGM ( GrSurfaceOrigin  origin)
inline

Definition at line 180 of file lazytiling.cpp.

181 : fOrigin(origin)
182 , fContentRect(SkIRect::MakeXYWH(kLeftContentOffset, kTopContentOffset,
183 kContentSize, kContentSize)) {
184 this->setBGColor(0xFFCCCCCC);
185 }
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
Definition SkRect.h:104

Member Function Documentation

◆ getISize()

SkISize skiagm::LazyTilingGM::getISize ( )
inlineoverrideprotected

Definition at line 192 of file lazytiling.cpp.

192{ return SkISize::Make(kTotalWidth, kTotalHeight); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20

◆ getName()

SkString skiagm::LazyTilingGM::getName ( ) const
inlineoverrideprotected

Definition at line 188 of file lazytiling.cpp.

188 {
189 return SkStringPrintf("lazytiling_%s", fOrigin == kTopLeft_GrSurfaceOrigin ? "tl" : "bl");
190 }
@ kTopLeft_GrSurfaceOrigin
Definition GrTypes.h:148
SK_API SkString static SkString SkStringPrintf()
Definition SkString.h:287

◆ onDraw()

DrawResult skiagm::LazyTilingGM::onDraw ( GrRecordingContext rContext,
SkCanvas canvas,
SkString errorMsg 
)
inlineoverrideprotected

Definition at line 214 of file lazytiling.cpp.

214 {
216 if (!sdc) {
217 *errorMsg = kErrorMsg_DrawSkippedGpuOnly;
218 return DrawResult::kSkip;
219 }
220
221 int y = kPad;
222 for (auto yMode : { SkTileMode::kClamp, SkTileMode::kRepeat,
224 int x = kPad;
225 for (auto xMode : { SkTileMode::kClamp, SkTileMode::kRepeat,
227 SkIRect cellRect = SkIRect::MakeXYWH(x, y, 2*kContentSize, 2*kContentSize);
228 SkRect contentRect = SkRect::MakeXYWH(x+kContentSize/2, y+kContentSize/2,
229 kContentSize, kContentSize);
230
231 SkMatrix texMatrix = SkMatrix::RectToRect(contentRect, SkRect::Make(fContentRect));
232
233 draw_texture(rContext->priv().caps(),
234 sdc,
235 fView,
236 fContentRect,
237 cellRect,
238 texMatrix,
240 SkTileModeToWrapMode(yMode));
241
242 x += 2*kContentSize+kPad;
243 }
244
245 y += 2*kContentSize+kPad;
246 }
247
248 return DrawResult::kOk;
249 }
static constexpr GrSamplerState::WrapMode SkTileModeToWrapMode(SkTileMode tileMode)
Definition SkGr.h:77
const GrCaps * caps() const
GrRecordingContextPriv priv()
static SkMatrix RectToRect(const SkRect &src, const SkRect &dst, ScaleToFit mode=kFill_ScaleToFit)
Definition SkMatrix.h:157
static void draw_texture(const GrCaps *caps, skgpu::ganesh::SurfaceDrawContext *sdc, const GrSurfaceProxyView &src, const SkIRect &srcRect, const SkIRect &drawRect, const SkMatrix &mat, GrSamplerState::WrapMode xTileMode, GrSamplerState::WrapMode yTileMode)
double y
double x
SurfaceDrawContext * TopDeviceSurfaceDrawContext(const SkCanvas *canvas)
Definition GrCanvas.cpp:20
static SkRect Make(const SkISize &size)
Definition SkRect.h:669
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition SkRect.h:659

◆ onGpuSetup()

DrawResult skiagm::LazyTilingGM::onGpuSetup ( SkCanvas canvas,
SkString errorMsg,
GraphiteTestContext *   
)
inlineoverrideprotected

Definition at line 194 of file lazytiling.cpp.

194 {
195 auto dContext = GrAsDirectContext(canvas->recordingContext());
196 if (!dContext || dContext->abandoned()) {
197 return DrawResult::kSkip;
198 }
199
200 auto bm = create_bitmap(fContentRect,
201 { kLeftContentOffset + kContentSize + kRightContentPadding,
202 kTopContentOffset + kContentSize + kBottomContentPadding },
203 fOrigin);
204
205 fView = create_view(dContext, bm, fOrigin);
206 if (!fView.proxy()) {
207 *errorMsg = "Failed to create proxy";
208 return DrawResult::kFail;
209 }
210
211 return DrawResult::kOk;
212 }
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
GrSurfaceProxy * proxy() const
virtual GrRecordingContext * recordingContext() const
static GrSurfaceProxyView create_view(GrDirectContext *dContext, const SkBitmap &src, GrSurfaceOrigin origin)
static SkBitmap create_bitmap(SkIRect contentRect, SkISize fullSize, GrSurfaceOrigin origin)

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