Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
DDLTileHelper::TileData Class Reference

#include <DDLTileHelper.h>

Public Member Functions

 TileData ()
 
 ~TileData ()
 
bool initialized () const
 
void init (int id, GrDirectContext *, const GrSurfaceCharacterization &dstChar, const SkIRect &clip, const SkIRect &paddingOutsets)
 
void createDDL (const SkPicture *)
 
void dropDDL ()
 
void precompile (GrDirectContext *)
 
void drawSKPDirectly (GrDirectContext *, const SkPicture *)
 
void draw (GrDirectContext *)
 
void reset ()
 
int id () const
 
SkIRect clipRect () const
 
SkISize paddedRectSize () const
 
SkIVector padOffset () const
 
GrDeferredDisplayListddl ()
 
sk_sp< SkImagemakePromiseImageForDst (sk_sp< GrContextThreadSafeProxy >)
 
void dropCallbackContext ()
 

Static Public Member Functions

static void CreateBackendTexture (GrDirectContext *, TileData *)
 
static void DeleteBackendTexture (GrDirectContext *, TileData *)
 

Detailed Description

Definition at line 33 of file DDLTileHelper.h.

Constructor & Destructor Documentation

◆ TileData()

DDLTileHelper::TileData::TileData ( )

Definition at line 48 of file DDLTileHelper.cpp.

48{}

◆ ~TileData()

DDLTileHelper::TileData::~TileData ( )

Definition at line 49 of file DDLTileHelper.cpp.

49{}

Member Function Documentation

◆ clipRect()

SkIRect DDLTileHelper::TileData::clipRect ( ) const
inline

Definition at line 65 of file DDLTileHelper.h.

65{ return fClip; }

◆ CreateBackendTexture()

void DDLTileHelper::TileData::CreateBackendTexture ( GrDirectContext direct,
TileData tile 
)
static

Definition at line 198 of file DDLTileHelper.cpp.

198 {
199 SkASSERT(tile->fCallbackContext && !tile->fCallbackContext->promiseImageTexture());
200
201 const GrSurfaceCharacterization& c = tile->fPlaybackChar;
202 GrBackendTexture beTex =
203 direct->createBackendTexture(c.width(),
204 c.height(),
205 c.colorType(),
209 /*label=*/"DDLTile_TileData_CreateBackendTexture");
210 tile->fCallbackContext->setBackendTexture(beTex);
211}
#define SkASSERT(cond)
Definition: SkAssert.h:116
GrBackendTexture createBackendTexture(int width, int height, const GrBackendFormat &, skgpu::Mipmapped, GrRenderable, GrProtected=GrProtected::kNo, std::string_view label={})
Mipmapped
Definition: GpuTypes.h:53

◆ createDDL()

void DDLTileHelper::TileData::createDDL ( const SkPicture picture)

Definition at line 51 of file DDLTileHelper.cpp.

51 {
52 SkASSERT(!fDisplayList && picture);
53
54 auto recordingChar = fPlaybackChar.createResized(fClip.width(), fClip.height());
55 SkASSERT(recordingChar.isValid());
56
57 GrDeferredDisplayListRecorder recorder(recordingChar);
58
59 // DDL TODO: the DDLRecorder's rContext isn't initialized until getCanvas is called.
60 // Maybe set it up in the ctor?
61 SkCanvas* recordingCanvas = recorder.getCanvas();
62
63 // We always record the DDL in the (0,0) .. (clipWidth, clipHeight) coordinates
64 recordingCanvas->clipRect(SkRect::MakeWH(fClip.width(), fClip.height()));
65 recordingCanvas->translate(-fClip.fLeft, -fClip.fTop);
66
67 // Note: in this use case we only render a picture to the deferred canvas
68 // but, more generally, clients will use arbitrary draw calls.
69 recordingCanvas->drawPicture(picture);
70
71 fDisplayList = recorder.detach();
72}
GrSurfaceCharacterization createResized(int width, int height) const
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1361
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void drawPicture(const SkPicture *picture)
Definition: SkCanvas.h:1961
sk_sp< const SkPicture > picture
Definition: SkRecords.h:299
constexpr int32_t height() const
Definition: SkRect.h:165
int32_t fTop
smaller y-axis bounds
Definition: SkRect.h:34
constexpr int32_t width() const
Definition: SkRect.h:158
int32_t fLeft
smaller x-axis bounds
Definition: SkRect.h:33
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609

◆ ddl()

GrDeferredDisplayList * DDLTileHelper::TileData::ddl ( )
inline

Definition at line 72 of file DDLTileHelper.h.

72{ return fDisplayList.get(); }
T * get() const
Definition: SkRefCnt.h:303

◆ DeleteBackendTexture()

void DDLTileHelper::TileData::DeleteBackendTexture ( GrDirectContext dContext,
TileData tile 
)
static

Definition at line 213 of file DDLTileHelper.cpp.

213 {
214 if (!tile->initialized() || dContext->abandoned()) {
215 return;
216 }
217
218 SkASSERT(tile->fCallbackContext);
219
220 // TODO: it seems that, on the Linux bots, backend texture creation is failing
221 // a lot (skbug.com/10142)
222 SkASSERT(!tile->fCallbackContext->promiseImageTexture() ||
223 tile->fCallbackContext->promiseImageTexture()->backendTexture().isValid());
224
225 tile->fTileSurface = nullptr;
226
227 SkASSERT(tile->fCallbackContext->unique());
228 tile->fCallbackContext.reset();
229}
bool abandoned() override

◆ draw()

void DDLTileHelper::TileData::draw ( GrDirectContext direct)

Definition at line 157 of file DDLTileHelper.cpp.

157 {
158 SkASSERT(fDisplayList && !fTileSurface);
159
160 fTileSurface = this->makeWrappedTileDest(direct);
161 if (fTileSurface) {
162 skgpu::ganesh::DrawDDL(fTileSurface, fDisplayList);
163
164 // We can't snap an image here bc, since we're using wrapped backend textures for the
165 // surfaces, that would incur a copy.
166 }
167}
SK_API bool DrawDDL(SkSurface *, sk_sp< const GrDeferredDisplayList > ddl)

◆ drawSKPDirectly()

void DDLTileHelper::TileData::drawSKPDirectly ( GrDirectContext dContext,
const SkPicture picture 
)

Definition at line 138 of file DDLTileHelper.cpp.

139 {
140 SkASSERT(!fDisplayList && !fTileSurface && picture);
141
142 fTileSurface = this->makeWrappedTileDest(dContext);
143 if (fTileSurface) {
144 SkCanvas* tileCanvas = fTileSurface->getCanvas();
145
146 SkASSERT(this->padOffset().isZero() && this->paddedRectSize() == fClip.size());
147 tileCanvas->clipRect(SkRect::MakeWH(fClip.width(), fClip.height()));
148 tileCanvas->translate(-fClip.fLeft, -fClip.fTop);
149
150 tileCanvas->drawPicture(picture);
151
152 // We can't snap an image here bc, since we're using wrapped backend textures for the
153 // surfaces, that would incur a copy.
154 }
155}
SkISize paddedRectSize() const
Definition: DDLTileHelper.h:66
SkIVector padOffset() const
Definition: DDLTileHelper.h:70
SkCanvas * getCanvas()
Definition: SkSurface.cpp:82
constexpr SkISize size() const
Definition: SkRect.h:172

◆ dropCallbackContext()

void DDLTileHelper::TileData::dropCallbackContext ( )
inline

Definition at line 75 of file DDLTileHelper.h.

75{ fCallbackContext.reset(); }
void reset(T *ptr=nullptr)
Definition: SkRefCnt.h:310

◆ dropDDL()

void DDLTileHelper::TileData::dropDDL ( )
inline

Definition at line 49 of file DDLTileHelper.h.

49{ fDisplayList.reset(); }

◆ id()

int DDLTileHelper::TileData::id ( ) const
inline

Definition at line 64 of file DDLTileHelper.h.

64{ return fID; }

◆ init()

void DDLTileHelper::TileData::init ( int  id,
GrDirectContext direct,
const GrSurfaceCharacterization dstChar,
const SkIRect clip,
const SkIRect paddingOutsets 
)

Definition at line 28 of file DDLTileHelper.cpp.

32 {
33 fID = id;
34 fClip = clip;
35 fPaddingOutsets = paddingOutsets;
36
37 fPlaybackChar = dstSurfaceCharacterization.createResized(this->paddedRectSize().width(),
38 this->paddedRectSize().height());
39 SkASSERT(fPlaybackChar.isValid());
40
41 SkDEBUGCODE(const GrCaps* caps = direct->priv().caps());
42 SkASSERT(caps->isFormatTexturable(fPlaybackChar.backendFormat(),
43 fPlaybackChar.backendFormat().textureType()));
44
45 fCallbackContext.reset(new PromiseImageCallbackContext(direct, fPlaybackChar.backendFormat()));
46}
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition: SkPath.cpp:3892
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
const GrCaps * caps() const
Definition: GrCaps.h:57
GrDirectContextPriv priv()
int32_t height
int32_t width

◆ initialized()

bool DDLTileHelper::TileData::initialized ( ) const
inline

Definition at line 38 of file DDLTileHelper.h.

38{ return fID != -1; }

◆ makePromiseImageForDst()

sk_sp< SkImage > DDLTileHelper::TileData::makePromiseImageForDst ( sk_sp< GrContextThreadSafeProxy threadSafeProxy)

Definition at line 176 of file DDLTileHelper.cpp.

177 {
178 SkASSERT(fCallbackContext);
179
180 // The promise image gets a ref on the promise callback context
181 sk_sp<SkImage> promiseImage =
182 SkImages::PromiseTextureFrom(std::move(threadSafeProxy),
183 fCallbackContext->backendFormat(),
184 this->paddedRectSize(),
187 fPlaybackChar.colorType(),
189 fPlaybackChar.refColorSpace(),
192 (void*)this->refCallbackContext().release());
193 fCallbackContext->wasAddedToImage();
194
195 return promiseImage;
196}
@ kBottomLeft_GrSurfaceOrigin
Definition: GrTypes.h:149
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
sk_sp< SkColorSpace > refColorSpace() const
static sk_sp< GrPromiseImageTexture > PromiseImageFulfillProc(void *textureContext)
const GrBackendFormat & backendFormat() const
static void PromiseImageReleaseProc(void *textureContext)
SK_API sk_sp< SkImage > PromiseTextureFrom(skgpu::graphite::Recorder *, SkISize dimensions, const skgpu::graphite::TextureInfo &, const SkColorInfo &, skgpu::Origin origin, skgpu::graphite::Volatile, GraphitePromiseTextureFulfillProc, GraphitePromiseImageReleaseProc, GraphitePromiseTextureReleaseProc, GraphitePromiseImageContext, std::string_view label={})

◆ paddedRectSize()

SkISize DDLTileHelper::TileData::paddedRectSize ( ) const
inline

Definition at line 66 of file DDLTileHelper.h.

66 {
67 return { fClip.width() + fPaddingOutsets.fLeft + fPaddingOutsets.fRight,
68 fClip.height() + fPaddingOutsets.fTop + fPaddingOutsets.fBottom };
69 }
int32_t fBottom
larger y-axis bounds
Definition: SkRect.h:36
int32_t fRight
larger x-axis bounds
Definition: SkRect.h:35

◆ padOffset()

SkIVector DDLTileHelper::TileData::padOffset ( ) const
inline

Definition at line 70 of file DDLTileHelper.h.

70{ return { fPaddingOutsets.fLeft, fPaddingOutsets.fTop }; }

◆ precompile()

void DDLTileHelper::TileData::precompile ( GrDirectContext direct)

Definition at line 105 of file DDLTileHelper.cpp.

105 {
106 if (!this->initialized()) {
107 return;
108 }
109
110 SkASSERT(fDisplayList);
111
112 GrDeferredDisplayList::ProgramIterator iter(direct, fDisplayList.get());
113 for (; !iter.done(); iter.next()) {
114 iter.compile();
115 }
116}
bool initialized() const
Definition: DDLTileHelper.h:38

◆ reset()

void DDLTileHelper::TileData::reset ( )

Definition at line 169 of file DDLTileHelper.cpp.

169 {
170 // TODO: when DDLs are re-renderable we don't need to do this
171 fDisplayList = nullptr;
172
173 fTileSurface = nullptr;
174}

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