Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Friends | List of all members
skgpu::ganesh::Device Class Referencefinal

#include <Device.h>

Inheritance diagram for skgpu::ganesh::Device:
SkDevice SkRefCnt SkRefCntBase

Public Types

enum class  InitContents { kClear , kUninit }
 
using RescaleGamma = SkImage::RescaleGamma
 
using RescaleMode = SkImage::RescaleMode
 
using ReadPixelsCallback = SkImage::ReadPixelsCallback
 
using ReadPixelsContext = SkImage::ReadPixelsContext
 

Public Member Functions

GrSurfaceProxyView readSurfaceView ()
 
GrRenderTargetProxytargetProxy ()
 
GrRecordingContextrecordingContext () const override
 
bool wait (int numSemaphores, const GrBackendSemaphore *waitSemaphores, bool deleteSemaphoresAfterWait)
 
void discard ()
 
void resolveMSAA ()
 
bool replaceBackingProxy (SkSurface::ContentChangeMode, sk_sp< GrRenderTargetProxy >, GrColorType, sk_sp< SkColorSpace >, GrSurfaceOrigin, const SkSurfaceProps &)
 
bool replaceBackingProxy (SkSurface::ContentChangeMode)
 
void asyncRescaleAndReadPixels (const SkImageInfo &info, const SkIRect &srcRect, RescaleGamma rescaleGamma, RescaleMode rescaleMode, ReadPixelsCallback callback, ReadPixelsContext context)
 
void asyncRescaleAndReadPixelsYUV420 (SkYUVColorSpace yuvColorSpace, bool readAlpha, sk_sp< SkColorSpace > dstColorSpace, const SkIRect &srcRect, SkISize dstSize, RescaleGamma rescaleGamma, RescaleMode, ReadPixelsCallback callback, ReadPixelsContext context)
 
 ~Device () override
 
SurfaceDrawContextsurfaceDrawContext ()
 
const SurfaceDrawContextsurfaceDrawContext () const
 
SurfaceFillContextsurfaceFillContext ()
 
SkStrikeDeviceInfo strikeDeviceInfo () const override
 
void clearAll ()
 
void drawPaint (const SkPaint &paint) override
 
void drawPoints (SkCanvas::PointMode mode, size_t count, const SkPoint[], const SkPaint &paint) override
 
void drawRect (const SkRect &r, const SkPaint &paint) override
 
void drawRRect (const SkRRect &r, const SkPaint &paint) override
 
void drawDRRect (const SkRRect &outer, const SkRRect &inner, const SkPaint &paint) override
 
void drawRegion (const SkRegion &r, const SkPaint &paint) override
 
void drawOval (const SkRect &oval, const SkPaint &paint) override
 
void drawArc (const SkRect &oval, SkScalar startAngle, SkScalar sweepAngle, bool useCenter, const SkPaint &paint) override
 
void drawPath (const SkPath &path, const SkPaint &paint, bool pathIsMutable) override
 
void drawVertices (const SkVertices *, sk_sp< SkBlender >, const SkPaint &, bool) override
 
void drawMesh (const SkMesh &, sk_sp< SkBlender >, const SkPaint &) override
 
void drawShadow (const SkPath &, const SkDrawShadowRec &) override
 
void drawAtlas (const SkRSXform[], const SkRect[], const SkColor[], int count, sk_sp< SkBlender >, const SkPaint &) override
 
void drawImageRect (const SkImage *, const SkRect *src, const SkRect &dst, const SkSamplingOptions &, const SkPaint &, SkCanvas::SrcRectConstraint) override
 
bool shouldDrawAsTiledImageRect () const override
 
bool drawAsTiledImageRect (SkCanvas *, const SkImage *, const SkRect *src, const SkRect &dst, const SkSamplingOptions &, const SkPaint &, SkCanvas::SrcRectConstraint) override
 
void drawImageLattice (const SkImage *, const SkCanvas::Lattice &, const SkRect &dst, SkFilterMode, const SkPaint &) override
 
void drawDrawable (SkCanvas *, SkDrawable *, const SkMatrix *) override
 
void drawDevice (SkDevice *, const SkSamplingOptions &, const SkPaint &) override
 
void drawSpecial (SkSpecialImage *, const SkMatrix &localToDevice, const SkSamplingOptions &, const SkPaint &, SkCanvas::SrcRectConstraint) override
 
void drawEdgeAAQuad (const SkRect &rect, const SkPoint clip[4], SkCanvas::QuadAAFlags aaFlags, const SkColor4f &color, SkBlendMode mode) override
 
void drawEdgeAAImageSet (const SkCanvas::ImageSetEntry[], int count, const SkPoint dstClips[], const SkMatrix preViewMatrices[], const SkSamplingOptions &, const SkPaint &, SkCanvas::SrcRectConstraint) override
 
void drawEdgeAAImage (const SkImage *, const SkRect &src, const SkRect &dst, const SkPoint dstClip[4], SkCanvas::QuadAAFlags, const SkMatrix &localToDevice, const SkSamplingOptions &, const SkPaint &, SkCanvas::SrcRectConstraint, const SkMatrix &srcToDst, SkTileMode)
 
sk_sp< sktext::gpu::SlugconvertGlyphRunListToSlug (const sktext::GlyphRunList &glyphRunList, const SkPaint &paint) override
 
void drawSlug (SkCanvas *, const sktext::gpu::Slug *slug, const SkPaint &paint) override
 
sk_sp< SkSpecialImagemakeSpecial (const SkBitmap &) override
 
sk_sp< SkSpecialImagemakeSpecial (const SkImage *) override
 
sk_sp< SkSpecialImagesnapSpecial (const SkIRect &subset, bool forceCopy=false) override
 
sk_sp< SkSpecialImagesnapSpecialScaled (const SkIRect &subset, const SkISize &dstDims) override
 
sk_sp< SkDevicecreateDevice (const CreateInfo &, const SkPaint *) override
 
sk_sp< SkSurfacemakeSurface (const SkImageInfo &, const SkSurfaceProps &) override
 
DeviceasGaneshDevice () override
 
SkIRect devClipBounds () const override
 
void pushClipStack () override
 
void popClipStack () override
 
void clipRect (const SkRect &rect, SkClipOp op, bool aa) override
 
void clipRRect (const SkRRect &rrect, SkClipOp op, bool aa) override
 
void clipPath (const SkPath &path, SkClipOp op, bool aa) override
 
void replaceClip (const SkIRect &rect) override
 
void clipRegion (const SkRegion &globalRgn, SkClipOp op) override
 
bool isClipAntiAliased () const override
 
bool isClipEmpty () const override
 
bool isClipRect () const override
 
bool isClipWideOpen () const override
 
void android_utils_clipAsRgn (SkRegion *) const override
 
bool android_utils_clipWithStencil () override
 
- Public Member Functions inherited from SkDevice
 SkDevice (const SkImageInfo &, const SkSurfaceProps &)
 
const SkImageInfoimageInfo () const
 
int width () const
 
int height () const
 
bool isOpaque () const
 
SkIRect bounds () const
 
SkISize size () const
 
const SkSurfacePropssurfaceProps () const
 
SkScalerContextFlags scalerContextFlags () const
 
bool writePixels (const SkPixmap &src, int x, int y)
 
bool readPixels (const SkPixmap &dst, int x, int y)
 
bool accessPixels (SkPixmap *pmap)
 
bool peekPixels (SkPixmap *)
 
const SkM44localToDevice44 () const
 
const SkMatrixlocalToDevice () const
 
const SkM44deviceToGlobal () const
 
const SkM44globalToDevice () const
 
SkIPoint getOrigin () const
 
bool isPixelAlignedToGlobal () const
 
SkMatrix getRelativeTransform (const SkDevice &) const
 
void setLocalToDevice (const SkM44 &localToDevice)
 
void setGlobalCTM (const SkM44 &ctm)
 
void getGlobalBounds (SkIRect *bounds) const
 
SkIRect getGlobalBounds () const
 
void clipShader (sk_sp< SkShader > sh, SkClipOp op)
 
virtual bool useDrawCoverageMaskForMaskFilters () const
 
virtual bool isNoPixelsDevice () const
 
virtual void * getRasterHandle () const
 
virtual skgpu::graphite::Recorderrecorder () const
 
virtual skgpu::graphite::DeviceasGraphiteDevice ()
 
virtual void setImmutable ()
 
void drawGlyphRunList (SkCanvas *, const sktext::GlyphRunList &glyphRunList, const SkPaint &paint)
 
virtual void drawPatch (const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], sk_sp< SkBlender >, const SkPaint &paint)
 
virtual void drawAnnotation (const SkRect &, const char[], SkData *)
 
sk_sp< SkSpecialImagesnapSpecial ()
 
virtual void drawCoverageMask (const SkSpecialImage *, const SkMatrix &maskToDevice, const SkSamplingOptions &, const SkPaint &)
 
virtual bool drawBlurredRRect (const SkRRect &, const SkPaint &, float deviceSigma)
 
void drawFilteredImage (const skif::Mapping &mapping, SkSpecialImage *src, SkColorType ct, const SkImageFilter *, const SkSamplingOptions &, const SkPaint &)
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Static Public Member Functions

static sk_sp< DeviceMake (GrRecordingContext *, GrColorType, sk_sp< GrSurfaceProxy >, sk_sp< SkColorSpace >, GrSurfaceOrigin, const SkSurfaceProps &, InitContents)
 
static sk_sp< DeviceMake (GrRecordingContext *, skgpu::Budgeted, const SkImageInfo &, SkBackingFit, int sampleCount, skgpu::Mipmapped, GrProtected, GrSurfaceOrigin, const SkSurfaceProps &, InitContents)
 

Private Member Functions

void onDrawGlyphRunList (SkCanvas *, const sktext::GlyphRunList &, const SkPaint &paint) override
 
bool onReadPixels (const SkPixmap &, int, int) override
 
bool onWritePixels (const SkPixmap &, int, int) override
 
bool onAccessPixels (SkPixmap *) override
 
sk_sp< skif::BackendcreateImageFilteringBackend (const SkSurfaceProps &surfaceProps, SkColorType colorType) const override
 
void onClipShader (sk_sp< SkShader > shader) override
 

Friends

class ::SkSurface_Ganesh
 
class skgpu::TiledTextureUtils
 

Additional Inherited Members

- Protected Member Functions inherited from SkDevice
void setDeviceCoordinateSystem (const SkM44 &deviceToGlobal, const SkM44 &globalToDevice, const SkM44 &localToDevice, int bufferOriginX, int bufferOriginY)
 
void setOrigin (const SkM44 &globalCTM, int x, int y)
 
bool checkLocalToDeviceDirty ()
 

Detailed Description

Subclass of SkDevice, which directs all drawing to the GrGpu owned by the canvas.

Definition at line 91 of file Device.h.

Member Typedef Documentation

◆ ReadPixelsCallback

Definition at line 120 of file Device.h.

◆ ReadPixelsContext

Definition at line 121 of file Device.h.

◆ RescaleGamma

Definition at line 118 of file Device.h.

◆ RescaleMode

Definition at line 119 of file Device.h.

Member Enumeration Documentation

◆ InitContents

Enumerator
kClear 
kUninit 

Definition at line 93 of file Device.h.

Constructor & Destructor Documentation

◆ ~Device()

skgpu::ganesh::Device::~Device ( )
overridedefault

Member Function Documentation

◆ android_utils_clipAsRgn()

void skgpu::ganesh::Device::android_utils_clipAsRgn ( SkRegion region) const
overridevirtual

Implements SkDevice.

Definition at line 411 of file Device.cpp.

411 {
413 // Assume wide open and then perform intersect/difference operations reducing the region
415 const SkRegion deviceBounds(bounds);
416 for (const ClipStack::Element& e : fClip) {
417 SkRegion tmp;
418 if (e.fShape.isRect() && e.fLocalToDevice.isIdentity()) {
419 tmp.setRect(e.fShape.rect().roundOut());
420 } else {
421 SkPath tmpPath;
422 e.fShape.asPath(&tmpPath);
423 tmpPath.transform(e.fLocalToDevice);
424 tmp.setPath(tmpPath, deviceBounds);
425 }
426
427 region->op(tmp, (SkRegion::Op) e.fOp);
428 }
429}
SkIRect bounds() const
Definition SkDevice.h:125
void transform(const SkMatrix &matrix, SkPath *dst, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
Definition SkPath.cpp:1647
bool op(const SkIRect &rect, Op op)
Definition SkRegion.h:384
bool setRect(const SkIRect &rect)
Definition SkRegion.cpp:192
bool setPath(const SkPath &path, const SkRegion &clip)
SkIRect getConservativeBounds() const override
ClipOpAndAA opAA SkRegion region
Definition SkRecords.h:238

◆ android_utils_clipWithStencil()

bool skgpu::ganesh::Device::android_utils_clipWithStencil ( )
overridevirtual

Reimplemented from SkDevice.

Definition at line 1465 of file Device.cpp.

1465 {
1467 this->android_utils_clipAsRgn(&clipRegion);
1468 if (clipRegion.isEmpty()) {
1469 return false;
1470 }
1471 auto sdc = fSurfaceDrawContext.get();
1472 SkASSERT(sdc);
1473 GrPaint grPaint;
1475 static constexpr GrUserStencilSettings kDrawToStencil(
1477 0x1,
1479 0x1,
1482 0x1>()
1483 );
1484 // Regions don't actually need AA, but in DMSAA mode everything is antialiased.
1485 GrAA aa = GrAA(fSurfaceDrawContext->alwaysAntialias());
1486 sdc->drawRegion(nullptr, std::move(grPaint), aa, SkMatrix::I(), clipRegion,
1487 GrStyle::SimpleFill(), &kDrawToStencil);
1488 return true;
1489}
GrAA
#define SkASSERT(cond)
Definition SkAssert.h:116
static const GrDisableColorXPFactory * Get()
void setXPFactory(const GrXPFactory *xpFactory)
Definition GrPaint.h:53
static const GrStyle & SimpleFill()
Definition GrStyle.h:30
static const SkMatrix & I()
void android_utils_clipAsRgn(SkRegion *) const override
Definition Device.cpp:411
void clipRegion(const SkRegion &globalRgn, SkClipOp op) override
Definition Device.cpp:394
static constexpr Init< Ref, Test, TestMask, PassOp, FailOp, WriteMask > StaticInit()

◆ asGaneshDevice()

Device * skgpu::ganesh::Device::asGaneshDevice ( )
inlineoverridevirtual

Reimplemented from SkDevice.

Definition at line 259 of file Device.h.

259{ return this; }

◆ asyncRescaleAndReadPixels()

void skgpu::ganesh::Device::asyncRescaleAndReadPixels ( const SkImageInfo info,
const SkIRect srcRect,
RescaleGamma  rescaleGamma,
RescaleMode  rescaleMode,
ReadPixelsCallback  callback,
ReadPixelsContext  context 
)

Definition at line 1373 of file Device.cpp.

1378 {
1379 auto* sdc = fSurfaceDrawContext.get();
1380 // Context TODO: Elevate direct context requirement to public API.
1381 auto dContext = sdc->recordingContext()->asDirectContext();
1382 if (!dContext) {
1383 return;
1384 }
1385 sdc->asyncRescaleAndReadPixels(dContext, info, srcRect, rescaleGamma, rescaleMode, callback,
1386 context);
1387}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback

◆ asyncRescaleAndReadPixelsYUV420()

void skgpu::ganesh::Device::asyncRescaleAndReadPixelsYUV420 ( SkYUVColorSpace  yuvColorSpace,
bool  readAlpha,
sk_sp< SkColorSpace dstColorSpace,
const SkIRect srcRect,
SkISize  dstSize,
RescaleGamma  rescaleGamma,
RescaleMode  rescaleMode,
ReadPixelsCallback  callback,
ReadPixelsContext  context 
)

Definition at line 1389 of file Device.cpp.

1397 {
1398 auto* sdc = fSurfaceDrawContext.get();
1399 // Context TODO: Elevate direct context requirement to public API.
1400 auto dContext = sdc->recordingContext()->asDirectContext();
1401 if (!dContext) {
1402 return;
1403 }
1404 sdc->asyncRescaleAndReadPixelsYUV420(dContext,
1405 yuvColorSpace,
1406 readAlpha,
1407 std::move(dstColorSpace),
1408 srcRect,
1409 dstSize,
1410 rescaleGamma,
1411 rescaleMode,
1412 callback,
1413 context);
1414}

◆ clearAll()

void skgpu::ganesh::Device::clearAll ( )

Definition at line 373 of file Device.cpp.

373 {
375 GR_CREATE_TRACE_MARKER_CONTEXT("skgpu::ganesh::Device", "clearAll", fContext.get());
376
377 SkIRect rect = SkIRect::MakeWH(this->width(), this->height());
378 fSurfaceDrawContext->clearAtLeast(rect, SK_PMColor4fTRANSPARENT);
379}
#define GR_CREATE_TRACE_MARKER_CONTEXT(classname, op, context)
Definition GrTracing.h:18
constexpr SkPMColor4f SK_PMColor4fTRANSPARENT
int height() const
Definition SkDevice.h:120
int width() const
Definition SkDevice.h:119
T * get() const
Definition SkRefCnt.h:303
#define ASSERT_SINGLE_OWNER
Definition Device.cpp:120
sk_sp< SkBlender > blender SkRect rect
Definition SkRecords.h:350
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
Definition SkRect.h:56

◆ clipPath()

void skgpu::ganesh::Device::clipPath ( const SkPath path,
SkClipOp  op,
bool  aa 
)
overridevirtual

Implements SkDevice.

Definition at line 383 of file Device.cpp.

383 {
384#if defined(GR_TEST_UTILS)
385 if (fContext->priv().options().fAllPathsVolatile && !path.isVolatile()) {
386 this->clipPath(SkPath(path).setIsVolatile(true), op, aa);
387 return;
388 }
389#endif
391 fClip.clipPath(this->localToDevice(), path, GrAA(aa), op);
392}
const GrContextOptions & options() const
GrRecordingContextPriv priv()
const SkMatrix & localToDevice() const
Definition SkDevice.h:179
void clipPath(const SkMatrix &ctm, const SkPath &path, GrAA aa, SkClipOp op)
Definition ClipStack.h:80
void clipPath(const SkPath &path, SkClipOp op, bool aa) override
Definition Device.cpp:383
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition switches.h:57

◆ clipRect()

void skgpu::ganesh::Device::clipRect ( const SkRect rect,
SkClipOp  op,
bool  aa 
)
inlineoverridevirtual

Implements SkDevice.

Definition at line 266 of file Device.h.

266 {
268 fClip.clipRect(this->localToDevice(), rect, GrAA(aa), op);
269 }
void clipRect(const SkMatrix &ctm, const SkRect &rect, GrAA aa, SkClipOp op)
Definition ClipStack.h:74

◆ clipRegion()

void skgpu::ganesh::Device::clipRegion ( const SkRegion globalRgn,
SkClipOp  op 
)
overridevirtual

Implements SkDevice.

Definition at line 394 of file Device.cpp.

394 {
396
397 // Regions don't actually need AA, but in DMSAA mode every clip element is antialiased.
398 GrAA aa = GrAA(fSurfaceDrawContext->alwaysAntialias());
399
400 if (globalRgn.isEmpty()) {
401 fClip.clipRect(SkMatrix::I(), SkRect::MakeEmpty(), aa, op);
402 } else if (globalRgn.isRect()) {
403 fClip.clipRect(this->globalToDevice().asM33(), SkRect::Make(globalRgn.getBounds()), aa, op);
404 } else {
405 SkPath path;
406 globalRgn.getBoundaryPath(&path);
407 fClip.clipPath(this->globalToDevice().asM33(), path, aa, op);
408 }
409}
const SkM44 & globalToDevice() const
Definition SkDevice.h:191
bool getBoundaryPath(SkPath *path) const
bool isRect() const
Definition SkRegion.h:152
const SkIRect & getBounds() const
Definition SkRegion.h:165
bool isEmpty() const
Definition SkRegion.h:146
static SkRect Make(const SkISize &size)
Definition SkRect.h:669
static constexpr SkRect MakeEmpty()
Definition SkRect.h:595

◆ clipRRect()

void skgpu::ganesh::Device::clipRRect ( const SkRRect rrect,
SkClipOp  op,
bool  aa 
)
inlineoverridevirtual

Implements SkDevice.

Definition at line 270 of file Device.h.

270 {
272 fClip.clipRRect(this->localToDevice(), rrect, GrAA(aa), op);
273 }
void clipRRect(const SkMatrix &ctm, const SkRRect &rrect, GrAA aa, SkClipOp op)
Definition ClipStack.h:77

◆ convertGlyphRunListToSlug()

sk_sp< sktext::gpu::Slug > skgpu::ganesh::Device::convertGlyphRunListToSlug ( const sktext::GlyphRunList glyphRunList,
const SkPaint paint 
)
overridevirtual

Reimplemented from SkDevice.

Definition at line 1495 of file Device.cpp.

1496 {
1498 glyphRunList,
1499 paint,
1500 this->strikeDeviceInfo(),
1502}
static SkStrikeCache * GlobalStrikeCache()
SkStrikeDeviceInfo strikeDeviceInfo() const override
Definition Device.cpp:1491
static sk_sp< SlugImpl > Make(const SkMatrix &viewMatrix, const sktext::GlyphRunList &glyphRunList, const SkPaint &paint, SkStrikeDeviceInfo strikeDeviceInfo, sktext::StrikeForGPUCacheInterface *strikeCache)
Definition SlugImpl.cpp:74
const Paint & paint

◆ createDevice()

sk_sp< SkDevice > skgpu::ganesh::Device::createDevice ( const CreateInfo ,
const SkPaint  
)
overridevirtual

Create a new device based on CreateInfo. If the paint is not null, then it represents a preview of how the new device will be composed with its creator device (this).

The subclass may be handed this device in drawDevice(), so it must always return a device that it knows how to draw, and that it knows how to identify if it is not of the same subclass (since drawDevice is passed a SkDevice*). If the subclass cannot fulfill that contract (e.g. PDF cannot support some settings on the paint) it should return NULL, and the caller may then decide to explicitly create a bitmapdevice, knowing that later it could not call drawDevice with it (but it could call drawSprite or drawBitmap).

Reimplemented from SkDevice.

Definition at line 1418 of file Device.cpp.

1418 {
1420
1421 SkSurfaceProps props =
1422 this->surfaceProps().cloneWithPixelGeometry(cinfo.fPixelGeometry);
1423
1424 SkASSERT(cinfo.fInfo.colorType() != kRGBA_1010102_SkColorType);
1425
1427 fContext.get(),
1428 SkColorTypeToGrColorType(cinfo.fInfo.colorType()),
1429 cinfo.fInfo.refColorSpace(),
1431 cinfo.fInfo.dimensions(),
1432 props,
1433 fSurfaceDrawContext->numSamples(),
1434 skgpu::Mipmapped::kNo,
1435 fSurfaceDrawContext->asSurfaceProxy()->isProtected(),
1436 fSurfaceDrawContext->origin(),
1438 if (!sdc) {
1439 return nullptr;
1440 }
1441
1442 // Skia's convention is to only clear a device if it is non-opaque.
1443 InitContents init = cinfo.fInfo.isOpaque() ? InitContents::kUninit : InitContents::kClear;
1444
1445 return Device::Make(std::move(sdc), cinfo.fInfo.alphaType(), init);
1446}
static constexpr GrColorType SkColorTypeToGrColorType(SkColorType ct)
@ kRGBA_1010102_SkColorType
10 bits for red, green, blue; 2 bits for alpha; in 32-bit word
Definition SkColorType.h:27
const SkSurfaceProps & surfaceProps() const
Definition SkDevice.h:131
SkSurfaceProps cloneWithPixelGeometry(SkPixelGeometry newPixelGeometry) const
static sk_sp< Device > Make(GrRecordingContext *, GrColorType, sk_sp< GrSurfaceProxy >, sk_sp< SkColorSpace >, GrSurfaceOrigin, const SkSurfaceProps &, InitContents)
Definition Device.cpp:212
static std::unique_ptr< SurfaceDrawContext > MakeWithFallback(GrRecordingContext *, GrColorType, sk_sp< SkColorSpace >, SkBackingFit, SkISize dimensions, const SkSurfaceProps &, int sampleCnt, skgpu::Mipmapped, skgpu::Protected, GrSurfaceOrigin=kBottomLeft_GrSurfaceOrigin, skgpu::Budgeted=skgpu::Budgeted::kYes)
init(device_serial, adb_binary)
Definition _adb_path.py:12

◆ createImageFilteringBackend()

sk_sp< skif::Backend > skgpu::ganesh::Device::createImageFilteringBackend ( const SkSurfaceProps surfaceProps,
SkColorType  colorType 
) const
overrideprivatevirtual

Reimplemented from SkDevice.

Definition at line 835 of file Device.cpp.

836 {
838 fContext, fSurfaceDrawContext->origin(), surfaceProps, colorType);
839}
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
sk_sp< Backend > MakeGaneshBackend(sk_sp< GrRecordingContext > context, GrSurfaceOrigin origin, const SkSurfaceProps &surfaceProps, SkColorType colorType)

◆ devClipBounds()

SkIRect skgpu::ganesh::Device::devClipBounds ( ) const
inlineoverridevirtual

Returns the bounding box of the current clip, in this device's coordinate space. No pixels outside of these bounds will be touched by draws unless the clip is further modified (at which point this will return the updated bounds).

Implements SkDevice.

Definition at line 261 of file Device.h.

261{ return fClip.getConservativeBounds(); }

◆ discard()

void skgpu::ganesh::Device::discard ( )

Definition at line 1300 of file Device.cpp.

1300 {
1301 fSurfaceDrawContext->discard();
1302}

◆ drawArc()

void skgpu::ganesh::Device::drawArc ( const SkRect oval,
SkScalar  startAngle,
SkScalar  sweepAngle,
bool  useCenter,
const SkPaint paint 
)
overridevirtual

By the time this is called we know that abs(sweepAngle) is in the range [0, 360).

Reimplemented from SkDevice.

Definition at line 775 of file Device.cpp.

779 {
781 GR_CREATE_TRACE_MARKER_CONTEXT("skgpu::ganesh::Device", "drawArc", fContext.get());
782 if (paint.getMaskFilter()) {
783 this->SkDevice::drawArc(oval, startAngle, sweepAngle, useCenter, paint);
784 return;
785 }
786 GrPaint grPaint;
788 fSurfaceDrawContext->colorInfo(),
789 paint,
790 this->localToDevice(),
791 fSurfaceDrawContext->surfaceProps(),
792 &grPaint)) {
793 return;
794 }
795
796 fSurfaceDrawContext->drawArc(this->clip(), std::move(grPaint),
797 fSurfaceDrawContext->chooseAA(paint), this->localToDevice(), oval,
798 startAngle, sweepAngle, useCenter, GrStyle(paint));
799}
bool SkPaintToGrPaint(GrRecordingContext *context, const GrColorInfo &dstColorInfo, const SkPaint &skPaint, const SkMatrix &ctm, const SkSurfaceProps &surfaceProps, GrPaint *grPaint)
Definition SkGr.cpp:553
virtual void drawArc(const SkRect &oval, SkScalar startAngle, SkScalar sweepAngle, bool useCenter, const SkPaint &paint)
Definition SkDevice.cpp:133
GrRecordingContext * recordingContext() const override
Definition Device.h:101

◆ drawAsTiledImageRect()

bool skgpu::ganesh::Device::drawAsTiledImageRect ( SkCanvas canvas,
const SkImage image,
const SkRect src,
const SkRect dst,
const SkSamplingOptions sampling,
const SkPaint paint,
SkCanvas::SrcRectConstraint  constraint 
)
overridevirtual

Reimplemented from SkDevice.

Definition at line 1000 of file Device.cpp.

1006 {
1007 GrRecordingContext* rCtx = canvas->recordingContext();
1008 if (!rCtx) {
1009 return false;
1010 }
1012
1013 GrAA aa = fSurfaceDrawContext->chooseAA(paint);
1015 : SkCanvas::kNone_QuadAAFlags;
1016
1017 // NOTE: if the context is not a direct context, it doesn't have access to the resource
1018 // cache, and theoretically, the resource cache's limits could be being changed on
1019 // another thread, so even having access to just the limit wouldn't be a reliable
1020 // test during recording here.
1021 size_t cacheSize = 0;
1022 if (auto dCtx = GrAsDirectContext(rCtx)) {
1023 cacheSize = dCtx->getResourceCacheLimit();
1024 }
1025 size_t maxTextureSize = rCtx->maxTextureSize();
1026#if defined(GR_TEST_UTILS)
1027 if (gOverrideMaxTextureSizeGanesh) {
1028 maxTextureSize = gOverrideMaxTextureSizeGanesh;
1029 }
1030 gNumTilesDrawnGanesh.store(0, std::memory_order_relaxed);
1031#endif
1032
1033 [[maybe_unused]] auto [wasTiled, numTiles] = TiledTextureUtils::DrawAsTiledImageRect(
1034 canvas,
1035 image,
1036 src ? *src : SkRect::MakeIWH(image->width(), image->height()),
1037 dst,
1038 aaFlags,
1039 sampling,
1040 &paint,
1041 constraint,
1042 cacheSize,
1043 maxTextureSize);
1044#if defined(GR_TEST_UTILS)
1045 gNumTilesDrawnGanesh.store(numTiles, std::memory_order_relaxed);
1046#endif
1047 return wasTiled;
1048}
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
SK_API int maxTextureSize() const
virtual GrRecordingContext * recordingContext() const
@ kAll_QuadAAFlags
Definition SkCanvas.h:1665
static std::tuple< bool, size_t > DrawAsTiledImageRect(SkCanvas *, const SkImage *, const SkRect &srcRect, const SkRect &dstRect, SkCanvas::QuadAAFlags, const SkSamplingOptions &, const SkPaint *, SkCanvas::SrcRectConstraint, size_t cacheSize, size_t maxTextureSize)
sk_sp< SkImage > image
Definition examples.cpp:29
SkSamplingOptions sampling
Definition SkRecords.h:337
dst
Definition cp.py:12

◆ drawAtlas()

void skgpu::ganesh::Device::drawAtlas ( const SkRSXform  xform[],
const SkRect  texRect[],
const SkColor  colors[],
int  count,
sk_sp< SkBlender blender,
const SkPaint paint 
)
overridevirtual

Reimplemented from SkDevice.

Definition at line 1198 of file Device.cpp.

1203 {
1205 GR_CREATE_TRACE_MARKER_CONTEXT("skgpu::ganesh::Device", "drawAtlas", fContext.get());
1206
1207 GrPaint grPaint;
1208 if (colors) {
1210 fSurfaceDrawContext->colorInfo(),
1211 paint,
1212 this->localToDevice(),
1213 blender.get(),
1214 fSurfaceDrawContext->surfaceProps(),
1215 &grPaint)) {
1216 return;
1217 }
1218 } else {
1220 fSurfaceDrawContext->colorInfo(),
1221 paint,
1222 this->localToDevice(),
1223 fSurfaceDrawContext->surfaceProps(),
1224 &grPaint)) {
1225 return;
1226 }
1227 }
1228
1229 fSurfaceDrawContext->drawAtlas(this->clip(), std::move(grPaint), this->localToDevice(), count,
1230 xform, texRect, colors);
1231}
int count
bool SkPaintToGrPaintWithBlend(GrRecordingContext *context, const GrColorInfo &dstColorInfo, const SkPaint &skPaint, const SkMatrix &ctm, SkBlender *primColorBlender, const SkSurfaceProps &surfaceProps, GrPaint *grPaint)
Definition SkGr.cpp:589

◆ drawDevice()

void skgpu::ganesh::Device::drawDevice ( SkDevice device,
const SkSamplingOptions sampling,
const SkPaint paint 
)
overridevirtual

The SkDevice passed will be an SkDevice which was returned by a call to onCreateDevice on this device with kNeverTile_TileExpectation.

The default implementation calls snapSpecial() and drawSpecial() with the relative transform from the input device to this device. The provided SkPaint cannot have a mask filter or image filter, and any shader is ignored.

Reimplemented from SkDevice.

Definition at line 967 of file Device.cpp.

969 {
971 // clear of the source device must occur before CHECK_SHOULD_DRAW
972 GR_CREATE_TRACE_MARKER_CONTEXT("skgpu::ganesh::Device", "drawDevice", fContext.get());
973 this->SkDevice::drawDevice(device, sampling, paint);
974}
virtual void drawDevice(SkDevice *, const SkSamplingOptions &, const SkPaint &)
Definition SkDevice.cpp:330

◆ drawDrawable()

void skgpu::ganesh::Device::drawDrawable ( SkCanvas canvas,
SkDrawable drawable,
const SkMatrix matrix 
)
overridevirtual

Reimplemented from SkDevice.

Definition at line 1261 of file Device.cpp.

1261 {
1263
1264 GrBackendApi api = this->recordingContext()->backend();
1265 if (GrBackendApi::kVulkan == api) {
1266 const SkMatrix& ctm = this->localToDevice();
1267 const SkMatrix& combinedMatrix = matrix ? SkMatrix::Concat(ctm, *matrix) : ctm;
1268 std::unique_ptr<SkDrawable::GpuDrawHandler> gpuDraw =
1269 drawable->snapGpuDrawHandler(api, combinedMatrix, this->devClipBounds(),
1270 this->imageInfo());
1271 if (gpuDraw) {
1272 fSurfaceDrawContext->drawDrawable(
1273 std::move(gpuDraw), combinedMatrix.mapRect(drawable->getBounds()));
1274 return;
1275 }
1276 }
1277 this->SkDevice::drawDrawable(canvas, drawable, matrix);
1278}
GrBackendApi
Definition GrTypes.h:95
SK_API GrBackendApi backend() const
const SkImageInfo & imageInfo() const
Definition SkDevice.h:117
virtual void drawDrawable(SkCanvas *, SkDrawable *, const SkMatrix *)
Definition SkDevice.cpp:299
SkRect getBounds()
std::unique_ptr< GpuDrawHandler > snapGpuDrawHandler(GrBackendApi backendApi, const SkMatrix &matrix, const SkIRect &clipBounds, const SkImageInfo &bufferInfo)
Definition SkDrawable.h:89
static SkMatrix Concat(const SkMatrix &a, const SkMatrix &b)
Definition SkMatrix.h:1775
bool mapRect(SkRect *dst, const SkRect &src, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
SkIRect devClipBounds() const override
Definition Device.h:261
unsigned useCenter Optional< SkMatrix > matrix
Definition SkRecords.h:258

◆ drawDRRect()

void skgpu::ganesh::Device::drawDRRect ( const SkRRect outer,
const SkRRect inner,
const SkPaint paint 
)
overridevirtual

Reimplemented from SkDevice.

Definition at line 672 of file Device.cpp.

672 {
674 GR_CREATE_TRACE_MARKER_CONTEXT("skgpu::ganesh::Device", "drawDRRect", fContext.get());
675 if (outer.isEmpty()) {
676 return;
677 }
678
679 if (inner.isEmpty()) {
680 return this->drawRRect(outer, paint);
681 }
682
683 SkStrokeRec stroke(paint);
684
685 if (stroke.isFillStyle() && !paint.getMaskFilter() && !paint.getPathEffect()) {
686 // For axis-aligned filled DRRects, just draw a regular rrect with inner clipped out using a
687 // coverage FP instead of using path rendering.
688 if (auto fp = make_inverse_rrect_fp(this->localToDevice(), inner,
689 fSurfaceDrawContext->chooseAA(paint),
690 *fSurfaceDrawContext->caps()->shaderCaps())) {
691 GrPaint grPaint;
693 fSurfaceDrawContext->colorInfo(),
694 paint,
695 this->localToDevice(),
696 fSurfaceDrawContext->surfaceProps(),
697 &grPaint)) {
698 return;
699 }
701 grPaint.setCoverageFragmentProcessor(std::move(fp));
702 fSurfaceDrawContext->drawRRect(this->clip(), std::move(grPaint),
703 fSurfaceDrawContext->chooseAA(paint),
704 this->localToDevice(), outer, GrStyle());
705 return;
706 }
707 }
708
709 SkPath path;
710 path.setIsVolatile(true);
711 path.addRRect(outer);
712 path.addRRect(inner);
713 path.setFillType(SkPathFillType::kEvenOdd);
714
715 // TODO: We are losing the possible mutability of the path here but this should probably be
716 // fixed by upgrading GrStyledShape to handle DRRects.
717 GrStyledShape shape(path, paint);
718
719 GrBlurUtils::DrawShapeWithMaskFilter(fContext.get(), fSurfaceDrawContext.get(), this->clip(),
720 paint, this->localToDevice(), shape);
721}
int hasCoverageFragmentProcessor() const
Definition GrPaint.h:83
void setCoverageFragmentProcessor(std::unique_ptr< GrFragmentProcessor > fp)
Definition GrPaint.h:75
bool isEmpty() const
Definition SkRRect.h:83
void drawRRect(const SkRRect &r, const SkPaint &paint) override
Definition Device.cpp:633
void DrawShapeWithMaskFilter(GrRecordingContext *rContext, skgpu::ganesh::SurfaceDrawContext *sdc, const GrClip *clip, const GrStyledShape &shape, GrPaint &&paint, const SkMatrix &viewMatrix, const SkMaskFilter *mf)

◆ drawEdgeAAImage()

void skgpu::ganesh::Device::drawEdgeAAImage ( const SkImage image,
const SkRect src,
const SkRect dst,
const SkPoint  dstClip[4],
SkCanvas::QuadAAFlags  canvasAAFlags,
const SkMatrix localToDevice,
const SkSamplingOptions sampling,
const SkPaint paint,
SkCanvas::SrcRectConstraint  constraint,
const SkMatrix srcToDst,
SkTileMode  tm 
)

Definition at line 215 of file Device_drawTexture.cpp.

225 {
226 GrRecordingContext* rContext = fContext.get();
227 SurfaceDrawContext* sdc = fSurfaceDrawContext.get();
228 const GrClip* clip = this->clip();
229
230 GrQuadAAFlags aaFlags = SkToGrQuadAAFlags(canvasAAFlags);
231 auto ib = as_IB(image);
232 if (tm == SkTileMode::kClamp && !ib->isYUVA() && can_use_draw_texture(paint, sampling)) {
233 // We've done enough checks above to allow us to pass ClampNearest() and not check for
234 // scaling adjustments.
235 auto [view, ct] = skgpu::ganesh::AsView(rContext, image, skgpu::Mipmapped::kNo);
236 if (!view) {
237 return;
238 }
240 info = info.makeColorType(ct);
241 draw_texture(sdc,
242 clip,
244 paint,
246 src,
247 dst,
248 dstClip,
249 aaFlags,
250 constraint,
251 std::move(view),
252 info);
253 return;
254 }
255
256 const SkMaskFilter* mf = paint.getMaskFilter();
257
258 // The shader expects proper local coords, so we can't replace local coords with texture coords
259 // if the shader will be used. If we have a mask filter we will change the underlying geometry
260 // that is rendered.
261 bool canUseTextureCoordsAsLocalCoords = !use_shader(image->isAlphaOnly(), paint) && !mf;
262
263 // Specifying the texture coords as local coordinates is an attempt to enable more GrDrawOp
264 // combining by not baking anything about the srcRect, dstRect, or ctm, into the texture
265 // FP. In the future this should be an opaque optimization enabled by the combination of
266 // GrDrawOp/GP and FP.
268 mf = nullptr;
269 }
270
271 bool restrictToSubset = SkCanvas::kStrict_SrcRectConstraint == constraint;
272
273 // If we have to outset for AA then we will generate texture coords outside the src rect. The
274 // same happens for any mask filter that extends the bounds rendered in the dst.
275 // This is conservative as a mask filter does not have to expand the bounds rendered.
276 bool coordsAllInsideSrcRect = aaFlags == GrQuadAAFlags::kNone && !mf;
277
278 // Check for optimization to drop the src rect constraint when using linear filtering.
279 // TODO: Just rely on image to handle this.
281 restrictToSubset && sampling.mipmap == SkMipmapMode::kNone && coordsAllInsideSrcRect &&
282 !ib->isYUVA()) {
283 SkMatrix combinedMatrix;
284 combinedMatrix.setConcat(localToDevice, srcToDst);
285 if (can_ignore_linear_filtering_subset(src, combinedMatrix, sdc->numSamples())) {
286 restrictToSubset = false;
287 }
288 }
289
290 SkMatrix textureMatrix;
291 if (canUseTextureCoordsAsLocalCoords) {
292 textureMatrix = SkMatrix::I();
293 } else {
294 if (!srcToDst.invert(&textureMatrix)) {
295 return;
296 }
297 }
298 const SkRect* subset = restrictToSubset ? &src : nullptr;
299 const SkRect* domain = coordsAllInsideSrcRect ? &src : nullptr;
300 SkTileMode tileModes[] = {tm, tm};
301 std::unique_ptr<GrFragmentProcessor> fp = skgpu::ganesh::AsFragmentProcessor(
302 rContext, image, sampling, tileModes, textureMatrix, subset, domain);
304 std::move(fp), image->imageInfo().colorInfo(), sdc->colorInfo());
305 if (image->isAlphaOnly()) {
306 if (const auto* shader = as_SB(paint.getShader())) {
307 auto shaderFP = GrFragmentProcessors::Make(shader,
308 GrFPArgs(rContext,
309 &sdc->colorInfo(),
310 sdc->surfaceProps(),
313 if (!shaderFP) {
314 return;
315 }
316 fp = GrBlendFragmentProcessor::Make<SkBlendMode::kDstIn>(std::move(fp),
317 std::move(shaderFP));
318 } else {
319 // Multiply the input (paint) color by the texture (alpha)
321 }
322 }
323
324 GrPaint grPaint;
325 if (!SkPaintToGrPaintReplaceShader(rContext,
326 sdc->colorInfo(),
327 paint,
329 std::move(fp),
330 sdc->surfaceProps(),
331 &grPaint)) {
332 return;
333 }
334
335 if (!mf) {
336 // Can draw the image directly (any mask filter on the paint was converted to an FP already)
337 if (dstClip) {
338 SkPoint srcClipPoints[4];
339 SkPoint* srcClip = nullptr;
340 if (canUseTextureCoordsAsLocalCoords) {
341 // Calculate texture coordinates that match the dst clip
342 GrMapRectPoints(dst, src, dstClip, srcClipPoints, 4);
343 srcClip = srcClipPoints;
344 }
345 sdc->fillQuadWithEdgeAA(clip, std::move(grPaint), aaFlags, localToDevice,
346 dstClip, srcClip);
347 } else {
348 // Provide explicit texture coords when possible, otherwise rely on texture matrix
349 sdc->fillRectWithEdgeAA(clip, std::move(grPaint), aaFlags, localToDevice, dst,
350 canUseTextureCoordsAsLocalCoords ? &src : nullptr);
351 }
352 } else {
353 // Must draw the mask filter as a GrStyledShape. For now, this loses the per-edge AA
354 // information since it always draws with AA, but that should not be noticeable since the
355 // mask filter is probably a blur.
356 GrStyledShape shape;
357 if (dstClip) {
358 // Represent it as an SkPath formed from the dstClip
359 SkPath path;
360 path.addPoly(dstClip, 4, true);
361 shape = GrStyledShape(path);
362 } else {
363 shape = GrStyledShape(dst);
364 }
365
367 rContext, sdc, clip, shape, std::move(grPaint), localToDevice, mf);
368 }
369}
static void GrMapRectPoints(const SkRect &inRect, const SkRect &outRect, const SkPoint inPts[], SkPoint outPts[], int ptCount)
Definition GrRect.h:37
GrQuadAAFlags
static GrQuadAAFlags SkToGrQuadAAFlags(unsigned flags)
bool SkPaintToGrPaintReplaceShader(GrRecordingContext *context, const GrColorInfo &dstColorInfo, const SkPaint &skPaint, const SkMatrix &ctm, std::unique_ptr< GrFragmentProcessor > shaderFP, const SkSurfaceProps &surfaceProps, GrPaint *grPaint)
Definition SkGr.cpp:570
static SkImage_Base * as_IB(SkImage *image)
SkShaderBase * as_SB(SkShader *shader)
SkTileMode
Definition SkTileMode.h:13
static std::unique_ptr< GrFragmentProcessor > Make(std::unique_ptr< GrFragmentProcessor > child, SkColorSpace *src, SkAlphaType srcAT, SkColorSpace *dst, SkAlphaType dstAT)
static std::unique_ptr< GrFragmentProcessor > MulInputByChildAlpha(std::unique_ptr< GrFragmentProcessor > child)
@ kStrict_SrcRectConstraint
sample only inside bounds; slower
Definition SkCanvas.h:1542
bool isAlphaOnly() const
Definition SkImage.cpp:239
const SkImageInfo & imageInfo() const
Definition SkImage.h:279
bool invert(SkMatrix *inverse) const
Definition SkMatrix.h:1206
SkMatrix & setConcat(const SkMatrix &a, const SkMatrix &b)
Definition SkMatrix.cpp:603
const GrColorInfo & colorInfo() const
void fillQuadWithEdgeAA(const GrClip *clip, GrPaint &&paint, GrQuadAAFlags edgeAA, const SkMatrix &viewMatrix, const SkPoint points[4], const SkPoint optionalLocalPoints[4])
void fillRectWithEdgeAA(const GrClip *clip, GrPaint &&paint, GrQuadAAFlags edgeAA, const SkMatrix &viewMatrix, const SkRect &rect, const SkRect *optionalLocalRect=nullptr)
const SkSurfaceProps & surfaceProps() const
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)
std::unique_ptr< GrFragmentProcessor > Make(const SkMaskFilter *maskfilter, const GrFPArgs &args, const SkMatrix &ctm)
bool IsSupported(const SkMaskFilter *maskfilter)
const uint32_t fp
std::unique_ptr< GrFragmentProcessor > AsFragmentProcessor(GrRecordingContext *rContext, const SkImage *img, SkSamplingOptions sampling, const SkTileMode tileModes[2], const SkMatrix &m, const SkRect *subset, const SkRect *domain)
std::tuple< GrSurfaceProxyView, GrColorType > AsView(GrRecordingContext *rContext, const SkImage *img, skgpu::Mipmapped mipmapped, GrImageTexGenPolicy policy)
const SkColorInfo & colorInfo() const
const SkFilterMode filter
const SkMipmapMode mipmap

◆ drawEdgeAAImageSet()

void skgpu::ganesh::Device::drawEdgeAAImageSet ( const SkCanvas::ImageSetEntry  set[],
int  count,
const SkPoint  dstClips[],
const SkMatrix  preViewMatrices[],
const SkSamplingOptions sampling,
const SkPaint paint,
SkCanvas::SrcRectConstraint  constraint 
)
overridevirtual

Reimplemented from SkDevice.

Definition at line 475 of file Device_drawTexture.cpp.

478 {
479 SkASSERT(count > 0);
480 if (!can_use_draw_texture(paint, sampling)) {
481 // Send every entry through drawImageQuad() to handle the more complicated paint
482 int dstClipIndex = 0;
483 for (int i = 0; i < count; ++i) {
484 // Only no clip or quad clip are supported
485 SkASSERT(!set[i].fHasClip || dstClips);
486 SkASSERT(set[i].fMatrixIndex < 0 || preViewMatrices);
487
489 if (set[i].fAlpha != 1.f) {
490 auto paintAlpha = paint.getAlphaf();
491 entryPaint.writable()->setAlphaf(paintAlpha * set[i].fAlpha);
492 }
493 this->drawImageQuadDirect(
494 set[i].fImage.get(), set[i].fSrcRect, set[i].fDstRect,
495 set[i].fHasClip ? dstClips + dstClipIndex : nullptr,
496 static_cast<SkCanvas::QuadAAFlags>(set[i].fAAFlags),
497 set[i].fMatrixIndex < 0 ? nullptr : preViewMatrices + set[i].fMatrixIndex,
498 sampling, *entryPaint, constraint);
499 dstClipIndex += 4 * set[i].fHasClip;
500 }
501 return;
502 }
503
505 ? GrSamplerState::Filter::kNearest
506 : GrSamplerState::Filter::kLinear;
507 SkBlendMode mode = paint.getBlendMode_or(SkBlendMode::kSrcOver);
508
510 // We accumulate compatible proxies until we find an an incompatible one or reach the end and
511 // issue the accumulated 'n' draws starting at 'base'. 'p' represents the number of proxy
512 // switches that occur within the 'n' entries.
513 int base = 0, n = 0, p = 0;
514 auto draw = [&](int nextBase) {
515 if (n > 0) {
516 auto textureXform = GrColorSpaceXform::Make(set[base].fImage->imageInfo().colorInfo(),
517 fSurfaceDrawContext->colorInfo());
518 fSurfaceDrawContext->drawTextureSet(this->clip(),
519 textures.get() + base,
520 n,
521 p,
522 filter,
523 GrSamplerState::MipmapMode::kNone,
524 mode,
525 constraint,
526 this->localToDevice(),
527 std::move(textureXform));
528 }
529 base = nextBase;
530 n = 0;
531 p = 0;
532 };
533 int dstClipIndex = 0;
534 for (int i = 0; i < count; ++i) {
535 SkASSERT(!set[i].fHasClip || dstClips);
536 SkASSERT(set[i].fMatrixIndex < 0 || preViewMatrices);
537
538 // Manage the dst clip pointer tracking before any continues are used so we don't lose
539 // our place in the dstClips array.
540 const SkPoint* clip = set[i].fHasClip ? dstClips + dstClipIndex : nullptr;
541 dstClipIndex += 4 * set[i].fHasClip;
542
543 // The default SkDevice implementation is based on drawImageRect which does not allow
544 // non-sorted src rects. TODO: Decide this is OK or make sure we handle it.
545 if (!set[i].fSrcRect.isSorted()) {
546 draw(i + 1);
547 continue;
548 }
549
551 const SkImage_Base* image = as_IB(set[i].fImage.get());
552 // Extract view from image, but skip YUV images so they get processed through
553 // drawImageQuad and the proper effect to dynamically sample their planes.
554 if (!image->isYUVA()) {
555 std::tie(view, std::ignore) =
556 skgpu::ganesh::AsView(this->recordingContext(), image, skgpu::Mipmapped::kNo);
557 if (image->isAlphaOnly()) {
559 skgpu::Swizzle("aaaa"));
560 view = {view.detachProxy(), view.origin(), swizzle};
561 }
562 }
563
564 if (!view) {
565 // This image can't go through the texture op, send through general image pipeline
566 // after flushing current batch.
567 draw(i + 1);
569 if (set[i].fAlpha != 1.f) {
570 auto paintAlpha = paint.getAlphaf();
571 entryPaint.writable()->setAlphaf(paintAlpha * set[i].fAlpha);
572 }
573 this->drawImageQuadDirect(
574 image, set[i].fSrcRect, set[i].fDstRect, clip,
575 static_cast<SkCanvas::QuadAAFlags>(set[i].fAAFlags),
576 set[i].fMatrixIndex < 0 ? nullptr : preViewMatrices + set[i].fMatrixIndex,
577 sampling, *entryPaint, constraint);
578 continue;
579 }
580
581 textures[i].fProxyView = std::move(view);
582 textures[i].fSrcAlphaType = image->alphaType();
583 textures[i].fSrcRect = set[i].fSrcRect;
584 textures[i].fDstRect = set[i].fDstRect;
585 textures[i].fDstClipQuad = clip;
586 textures[i].fPreViewMatrix =
587 set[i].fMatrixIndex < 0 ? nullptr : preViewMatrices + set[i].fMatrixIndex;
588 textures[i].fColor = texture_color(paint.getColor4f(), set[i].fAlpha,
590 fSurfaceDrawContext->colorInfo());
591 textures[i].fAAFlags = SkToGrQuadAAFlags(set[i].fAAFlags);
592
593 if (n > 0 &&
595 textures[i].fProxyView.proxy(),
596 textures[base].fProxyView.proxy()) ||
597 textures[i].fProxyView.swizzle() != textures[base].fProxyView.swizzle() ||
598 set[i].fImage->alphaType() != set[base].fImage->alphaType() ||
599 !SkColorSpace::Equals(set[i].fImage->colorSpace(), set[base].fImage->colorSpace()))) {
600 draw(i);
601 }
602 // Whether or not we submitted a draw in the above if(), this ith entry is in the current
603 // set being accumulated so increment n, and increment p if proxies are different.
604 ++n;
605 if (n == 1 || textures[i - 1].fProxyView.proxy() != textures[i].fProxyView.proxy()) {
606 // First proxy or a different proxy (that is compatible, otherwise we'd have drawn up
607 // to i - 1).
608 ++p;
609 }
610 }
611 draw(count);
612}
SkBlendMode
Definition SkBlendMode.h:38
@ kSrcOver
r = s + (1-sa)*d
SkFilterMode
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition aaclip.cpp:27
static sk_sp< GrColorSpaceXform > Make(SkColorSpace *src, SkAlphaType srcAT, SkColorSpace *dst, SkAlphaType dstAT)
skgpu::Swizzle swizzle() const
sk_sp< GrSurfaceProxy > detachProxy()
GrSurfaceOrigin origin() const
static bool ProxiesAreCompatibleAsDynamicState(const GrSurfaceProxy *first, const GrSurfaceProxy *second)
static bool Equals(const SkColorSpace *, const SkColorSpace *)
SkAlphaType alphaType() const
Definition SkImage.cpp:154
SkColorType colorType() const
Definition SkImage.cpp:152
static constexpr Swizzle Concat(const Swizzle &a, const Swizzle &b)
Definition Swizzle.h:156
std::vector< std::shared_ptr< FakeTexture > > textures
PODArray< SkPoint > dstClips
Definition SkRecords.h:364
PODArray< SkMatrix > preViewMatrices
Definition SkRecords.h:365
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 mode
Definition switches.h:228
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not set
Definition switches.h:76

◆ drawEdgeAAQuad()

void skgpu::ganesh::Device::drawEdgeAAQuad ( const SkRect rect,
const SkPoint  clip[4],
SkCanvas::QuadAAFlags  aaFlags,
const SkColor4f color,
SkBlendMode  mode 
)
overridevirtual

Reimplemented from SkDevice.

Definition at line 597 of file Device.cpp.

601 {
603 GR_CREATE_TRACE_MARKER_CONTEXT("skgpu::ganesh::Device", "drawEdgeAAQuad", fContext.get());
604
605 SkPMColor4f dstColor = SkColor4fPrepForDst(color, fSurfaceDrawContext->colorInfo()).premul();
606
607 GrPaint grPaint;
608 grPaint.setColor4f(dstColor);
609 if (mode != SkBlendMode::kSrcOver) {
611 }
612
613 if (clip) {
614 // Use fillQuadWithEdgeAA
615 fSurfaceDrawContext->fillQuadWithEdgeAA(this->clip(),
616 std::move(grPaint),
617 SkToGrQuadAAFlags(aaFlags),
618 this->localToDevice(),
619 clip,
620 nullptr);
621 } else {
622 // Use fillRectWithEdgeAA to preserve mathematical properties of dst being rectangular
623 fSurfaceDrawContext->fillRectWithEdgeAA(this->clip(),
624 std::move(grPaint),
625 SkToGrQuadAAFlags(aaFlags),
626 this->localToDevice(),
627 rect);
628 }
629}
SkColor4f color
SkColor4f SkColor4fPrepForDst(SkColor4f color, const GrColorInfo &colorInfo)
Definition SkGr.cpp:283
void setColor4f(const SkPMColor4f &color)
Definition GrPaint.h:50
static const GrXPFactory * FromBlendMode(SkBlendMode)

◆ drawImageLattice()

void skgpu::ganesh::Device::drawImageLattice ( const SkImage image,
const SkCanvas::Lattice lattice,
const SkRect dst,
SkFilterMode  filter,
const SkPaint paint 
)
overridevirtual

Reimplemented from SkDevice.

Definition at line 1094 of file Device.cpp.

1098 {
1100 auto iter = std::make_unique<SkLatticeIter>(lattice, dst);
1101
1102 auto [view, ct] = skgpu::ganesh::AsView(this->recordingContext(), image, skgpu::Mipmapped::kNo);
1103 if (view) {
1104 GrColorInfo colorInfo(ct, image->alphaType(), image->refColorSpace());
1105 this->drawViewLattice(
1106 std::move(view), std::move(colorInfo), std::move(iter), dst, filter, paint);
1107 }
1108}
sk_sp< SkColorSpace > refColorSpace() const
Definition SkImage.cpp:158

◆ drawImageRect()

void skgpu::ganesh::Device::drawImageRect ( const SkImage image,
const SkRect src,
const SkRect dst,
const SkSamplingOptions sampling,
const SkPaint paint,
SkCanvas::SrcRectConstraint  constraint 
)
overridevirtual

Implements SkDevice.

Definition at line 976 of file Device.cpp.

981 {
983
984 GrAA aa = fSurfaceDrawContext->chooseAA(paint);
986 : SkCanvas::kNone_QuadAAFlags;
987
988 this->drawImageQuadDirect(image,
989 src ? *src
990 : SkRect::MakeIWH(image->width(), image->height()),
991 dst,
992 /* dstClip= */ nullptr,
993 aaFlags,
994 /* preViewMatrix= */ nullptr,
995 sampling,
996 paint,
997 constraint);
998}

◆ drawMesh()

void skgpu::ganesh::Device::drawMesh ( const SkMesh mesh,
sk_sp< SkBlender blender,
const SkPaint paint 
)
overridevirtual

Implements SkDevice.

Definition at line 1145 of file Device.cpp.

1145 {
1147 GR_CREATE_TRACE_MARKER_CONTEXT("skgpu::ganesh::Device", "drawMesh", fContext.get());
1148 if (!mesh.isValid()) {
1149 return;
1150 }
1151
1152 GrPaint grPaint;
1153 if (!init_vertices_paint(fContext.get(),
1154 fSurfaceDrawContext->colorInfo(),
1155 paint,
1156 this->localToDevice(),
1157 blender.get(),
1159 fSurfaceDrawContext->surfaceProps(),
1160 &grPaint)) {
1161 return;
1162 }
1163
1165 if (!init_mesh_child_effects(fContext.get(),
1166 fSurfaceDrawContext->colorInfo(),
1167 fSurfaceDrawContext->surfaceProps(),
1168 mesh,
1169 &meshChildFPs)) {
1170 return;
1171 }
1172 fSurfaceDrawContext->drawMesh(this->clip(), std::move(grPaint), this->localToDevice(), mesh,
1173 std::move(meshChildFPs));
1174}
bool isValid() const
Definition SkMesh.cpp:753
SkMeshSpecification * spec() const
Definition SkMesh.h:348
SkMesh mesh
Definition SkRecords.h:345
static bool HasColors(const SkMeshSpecification &spec)
Definition SkMeshPriv.h:30

◆ drawOval()

void skgpu::ganesh::Device::drawOval ( const SkRect oval,
const SkPaint paint 
)
overridevirtual

Implements SkDevice.

Definition at line 750 of file Device.cpp.

750 {
752 GR_CREATE_TRACE_MARKER_CONTEXT("skgpu::ganesh::Device", "drawOval", fContext.get());
753
754 if (paint.getMaskFilter()) {
755 // The RRect path can handle special case blurring
756 SkRRect rr = SkRRect::MakeOval(oval);
757 return this->drawRRect(rr, paint);
758 }
759
760 GrPaint grPaint;
762 fSurfaceDrawContext->colorInfo(),
763 paint,
764 this->localToDevice(),
765 fSurfaceDrawContext->surfaceProps(),
766 &grPaint)) {
767 return;
768 }
769
770 fSurfaceDrawContext->drawOval(this->clip(), std::move(grPaint),
771 fSurfaceDrawContext->chooseAA(paint), this->localToDevice(), oval,
772 GrStyle(paint));
773}
static SkRRect MakeOval(const SkRect &oval)
Definition SkRRect.h:162

◆ drawPaint()

void skgpu::ganesh::Device::drawPaint ( const SkPaint paint)
overridevirtual

Implements SkDevice.

Definition at line 443 of file Device.cpp.

443 {
445 GR_CREATE_TRACE_MARKER_CONTEXT("skgpu::ganesh::Device", "drawPaint", fContext.get());
446
447 GrPaint grPaint;
449 fSurfaceDrawContext->colorInfo(),
450 paint,
451 this->localToDevice(),
452 fSurfaceDrawContext->surfaceProps(),
453 &grPaint)) {
454 return;
455 }
456
457 fSurfaceDrawContext->drawPaint(this->clip(), std::move(grPaint), this->localToDevice());
458}

◆ drawPath()

void skgpu::ganesh::Device::drawPath ( const SkPath path,
const SkPaint paint,
bool  pathIsMutable 
)
overridevirtual

If pathIsMutable, then the implementation is allowed to cast path to a non-const pointer and modify it in place (as an optimization). Canvas may do this to implement helpers such as drawOval, by placing a temp path on the stack to hold the representation of the oval.

Implements SkDevice.

Definition at line 803 of file Device.cpp.

803 {
804#if defined(GR_TEST_UTILS)
805 if (fContext->priv().options().fAllPathsVolatile && !origSrcPath.isVolatile()) {
806 this->drawPath(SkPath(origSrcPath).setIsVolatile(true), paint, true);
807 return;
808 }
809#endif
811 GR_CREATE_TRACE_MARKER_CONTEXT("skgpu::ganesh::Device", "drawPath", fContext.get());
812 if (!paint.getMaskFilter()) {
813 GrPaint grPaint;
815 fSurfaceDrawContext->colorInfo(),
816 paint,
817 this->localToDevice(),
818 fSurfaceDrawContext->surfaceProps(),
819 &grPaint)) {
820 return;
821 }
822 fSurfaceDrawContext->drawPath(this->clip(), std::move(grPaint),
823 fSurfaceDrawContext->chooseAA(paint), this->localToDevice(),
824 origSrcPath, GrStyle(paint));
825 return;
826 }
827
828 // TODO: losing possible mutability of 'origSrcPath' here
829 GrStyledShape shape(origSrcPath, paint);
830
831 GrBlurUtils::DrawShapeWithMaskFilter(fContext.get(), fSurfaceDrawContext.get(), this->clip(),
832 paint, this->localToDevice(), shape);
833}
void drawPath(const SkPath &path, const SkPaint &paint, bool pathIsMutable) override
Definition Device.cpp:803

◆ drawPoints()

void skgpu::ganesh::Device::drawPoints ( SkCanvas::PointMode  mode,
size_t  count,
const SkPoint  pts[],
const SkPaint paint 
)
overridevirtual

Implements SkDevice.

Definition at line 460 of file Device.cpp.

463 {
465 GR_CREATE_TRACE_MARKER_CONTEXT("skgpu::ganesh::Device", "drawPoints", fContext.get());
466 SkScalar width = paint.getStrokeWidth();
467 if (width < 0) {
468 return;
469 }
470
471 GrAA aa = fSurfaceDrawContext->chooseAA(paint);
472
473 if (count == 2 && mode == SkCanvas::kLines_PointMode) {
474 if (paint.getPathEffect()) {
475 // Probably a dashed line. Draw as a path.
476 GrPaint grPaint;
478 fSurfaceDrawContext->colorInfo(),
479 paint,
480 this->localToDevice(),
481 fSurfaceDrawContext->surfaceProps(),
482 &grPaint)) {
483 SkPath path;
484 path.setIsVolatile(true);
485 path.moveTo(pts[0]);
486 path.lineTo(pts[1]);
487 fSurfaceDrawContext->drawPath(this->clip(),
488 std::move(grPaint),
489 aa,
490 this->localToDevice(),
491 path,
493 }
494 return;
495 }
496 if (!paint.getMaskFilter() &&
497 paint.getStrokeWidth() > 0 && // drawStrokedLine doesn't support hairlines.
498 paint.getStrokeCap() != SkPaint::kRound_Cap) { // drawStrokedLine doesn't do round caps.
499 // Simple stroked line. Bypass path rendering.
500 GrPaint grPaint;
502 fSurfaceDrawContext->colorInfo(),
503 paint,
504 this->localToDevice(),
505 fSurfaceDrawContext->surfaceProps(),
506 &grPaint)) {
507 fSurfaceDrawContext->drawStrokedLine(this->clip(),
508 std::move(grPaint),
509 aa,
510 this->localToDevice(),
511 pts,
513 }
514 return;
515 }
516 }
517
518 const GrCaps* caps = fContext->priv().caps();
519 SkScalar scales[2];
520 bool isHairline =
521 ((0 == width) ||
522 (1 == width && this->localToDevice().getMinMaxScales(scales) &&
523 SkScalarNearlyEqual(scales[0], 1.f) && SkScalarNearlyEqual(scales[1], 1.f))) &&
524
525 // Don't do this as a hairline draw, which will emit line primitives, if
526 // lines are not permitted by caps.
528 caps->avoidLineDraws());
529
530 // we only handle non-coverage-aa hairlines and paints without path effects or mask filters,
531 // else we let the SkDraw call our drawPath()
532 if (!isHairline ||
533 paint.getPathEffect() ||
534 paint.getMaskFilter() ||
535 fSurfaceDrawContext->chooseAAType(aa) == GrAAType::kCoverage) {
538 // don't need to set fBlitterChoose, as it should never get used
539 draw.fDst = SkPixmap(SkImageInfo::MakeUnknown(this->width(), this->height()), nullptr, 0);
540 draw.fCTM = &this->localToDevice();
541 draw.fRC = &rc;
542 draw.drawDevicePoints(mode, count, pts, paint, this);
543 return;
544 }
545
546 GrPaint grPaint;
548 fSurfaceDrawContext->colorInfo(),
549 paint,
550 this->localToDevice(),
551 fSurfaceDrawContext->surfaceProps(),
552 &grPaint)) {
553 return;
554 }
555
556 static constexpr SkVertices::VertexMode kIgnoredMode = SkVertices::kTriangles_VertexMode;
557 sk_sp<SkVertices> vertices = SkVertices::MakeCopy(kIgnoredMode, SkToS32(count), pts, nullptr,
558 nullptr);
559
560 GrPrimitiveType primitiveType = point_mode_to_primitive_type(mode);
561 fSurfaceDrawContext->drawVertices(this->clip(), std::move(grPaint), this->localToDevice(),
562 std::move(vertices), &primitiveType);
563}
GrPrimitiveType
Definition GrTypesPriv.h:42
static bool SkScalarNearlyEqual(SkScalar x, SkScalar y, SkScalar tolerance=SK_ScalarNearlyZero)
Definition SkScalar.h:107
constexpr int32_t SkToS32(S x)
Definition SkTo.h:25
const GrCaps * caps() const
bool avoidLineDraws() const
Definition GrCaps.h:555
@ kLines_PointMode
draw each pair of points as a line segment
Definition SkCanvas.h:1242
@ kPolygon_PointMode
draw the array of points as a open polygon
Definition SkCanvas.h:1243
const SkRasterClip * fRC
Definition SkDrawBase.h:154
SkPixmap fDst
Definition SkDrawBase.h:151
const SkMatrix * fCTM
Definition SkDrawBase.h:153
bool getMinMaxScales(SkScalar scaleFactors[2]) const
@ kRound_Cap
adds circle
Definition SkPaint.h:335
@ kStroke_Style
set to stroke geometry
Definition SkPaint.h:194
static sk_sp< SkVertices > MakeCopy(VertexMode mode, int vertexCount, const SkPoint positions[], const SkPoint texs[], const SkColor colors[], int indexCount, const uint16_t indices[])
@ kTriangles_VertexMode
Definition SkVertices.h:31
float SkScalar
Definition extension.cpp:12
static SkImageInfo MakeUnknown()

◆ drawRect()

void skgpu::ganesh::Device::drawRect ( const SkRect r,
const SkPaint paint 
)
overridevirtual

Implements SkDevice.

Definition at line 567 of file Device.cpp.

567 {
569 GR_CREATE_TRACE_MARKER_CONTEXT("skgpu::ganesh::Device", "drawRect", fContext.get());
570
571 GrStyle style(paint);
572
573 // A couple reasons we might need to call drawPath.
574 if (paint.getMaskFilter() || paint.getPathEffect()) {
575 GrStyledShape shape(rect, style);
576
577 GrBlurUtils::DrawShapeWithMaskFilter(fContext.get(), fSurfaceDrawContext.get(),
578 this->clip(), paint, this->localToDevice(), shape);
579 return;
580 }
581
582 GrPaint grPaint;
584 fSurfaceDrawContext->colorInfo(),
585 paint,
586 this->localToDevice(),
587 fSurfaceDrawContext->surfaceProps(),
588 &grPaint)) {
589 return;
590 }
591
592 fSurfaceDrawContext->drawRect(this->clip(), std::move(grPaint),
593 fSurfaceDrawContext->chooseAA(paint), this->localToDevice(), rect,
594 &style);
595}

◆ drawRegion()

void skgpu::ganesh::Device::drawRegion ( const SkRegion r,
const SkPaint paint 
)
overridevirtual

Reimplemented from SkDevice.

Definition at line 725 of file Device.cpp.

725 {
727
728 if (paint.getMaskFilter()) {
729 SkPath path;
730 region.getBoundaryPath(&path);
731 path.setIsVolatile(true);
732 return this->drawPath(path, paint, true);
733 }
734
735 GrPaint grPaint;
737 fSurfaceDrawContext->colorInfo(),
738 paint,
739 this->localToDevice(),
740 fSurfaceDrawContext->surfaceProps(),
741 &grPaint)) {
742 return;
743 }
744
745 fSurfaceDrawContext->drawRegion(this->clip(), std::move(grPaint),
746 fSurfaceDrawContext->chooseAA(paint), this->localToDevice(),
747 region, GrStyle(paint));
748}

◆ drawRRect()

void skgpu::ganesh::Device::drawRRect ( const SkRRect r,
const SkPaint paint 
)
overridevirtual

Implements SkDevice.

Definition at line 633 of file Device.cpp.

633 {
635 GR_CREATE_TRACE_MARKER_CONTEXT("skgpu::ganesh::Device", "drawRRect", fContext.get());
636
637 auto mf = paint.getMaskFilter();
638 if (mf) {
640 mf = nullptr; // already handled in SkPaintToGrPaint
641 }
642 }
643
644 GrStyle style(paint);
645
646 if (mf || style.pathEffect()) {
647 // A path effect will presumably transform this rrect into something else.
648 GrStyledShape shape(rrect, style);
649
650 GrBlurUtils::DrawShapeWithMaskFilter(fContext.get(), fSurfaceDrawContext.get(),
651 this->clip(), paint, this->localToDevice(), shape);
652 return;
653 }
654
655 SkASSERT(!style.pathEffect());
656
657 GrPaint grPaint;
659 fSurfaceDrawContext->colorInfo(),
660 paint,
661 this->localToDevice(),
662 fSurfaceDrawContext->surfaceProps(),
663 &grPaint)) {
664 return;
665 }
666
667 fSurfaceDrawContext->drawRRect(this->clip(), std::move(grPaint),
668 fSurfaceDrawContext->chooseAA(paint), this->localToDevice(),
669 rrect, style);
670}

◆ drawShadow()

void skgpu::ganesh::Device::drawShadow ( const SkPath path,
const SkDrawShadowRec rec 
)
overridevirtual

Reimplemented from SkDevice.

Definition at line 1179 of file Device.cpp.

1179 {
1180#if defined(GR_TEST_UTILS)
1181 if (fContext->priv().options().fAllPathsVolatile && !path.isVolatile()) {
1182 this->drawShadow(SkPath(path).setIsVolatile(true), rec);
1183 return;
1184 }
1185#endif
1187 GR_CREATE_TRACE_MARKER_CONTEXT("skgpu::ganesh::Device", "drawShadow", fContext.get());
1188
1189 if (!fSurfaceDrawContext->drawFastShadow(this->clip(), this->localToDevice(), path, rec)) {
1190 // failed to find an accelerated case
1191 this->SkDevice::drawShadow(path, rec);
1192 }
1193}
virtual void drawShadow(const SkPath &, const SkDrawShadowRec &)
void drawShadow(const SkPath &, const SkDrawShadowRec &) override
Definition Device.cpp:1179

◆ drawSlug()

void skgpu::ganesh::Device::drawSlug ( SkCanvas canvas,
const sktext::gpu::Slug slug,
const SkPaint paint 
)
overridevirtual

Reimplemented from SkDevice.

Definition at line 1504 of file Device.cpp.

1504 {
1505 SkASSERT(canvas);
1506 SkASSERT(slug);
1507 const sktext::gpu::SlugImpl* slugImpl = static_cast<const sktext::gpu::SlugImpl*>(slug);
1508#if defined(SK_DEBUG)
1509 if (!fContext->priv().options().fSupportBilerpFromGlyphAtlas) {
1510 // We can draw a slug if the atlas has padding or if the creation matrix and the
1511 // drawing matrix are the same. If they are the same, then the Slug will use the direct
1512 // drawing code and not use bi-lerp.
1513 SkMatrix slugMatrix = slugImpl->initialPositionMatrix();
1514 SkMatrix positionMatrix = this->localToDevice();
1515 positionMatrix.preTranslate(slugImpl->origin().x(), slugImpl->origin().y());
1516 SkASSERT(slugMatrix == positionMatrix);
1517 }
1518#endif
1519 auto atlasDelegate = [&](const sktext::gpu::AtlasSubRun* subRun,
1520 SkPoint drawOrigin,
1521 const SkPaint& paint,
1522 sk_sp<SkRefCnt> subRunStorage,
1524 auto[drawingClip, op] = subRun->makeAtlasTextOp(
1525 this->clip(), this->localToDevice(), drawOrigin, paint,
1526 std::move(subRunStorage), fSurfaceDrawContext.get());
1527 if (op != nullptr) {
1528 fSurfaceDrawContext->addDrawOp(drawingClip, std::move(op));
1529 }
1530 };
1531
1532 slugImpl->subRuns()->draw(canvas, slugImpl->origin(), paint, slugImpl, atlasDelegate);
1533}
SkMatrix & preTranslate(SkScalar dx, SkScalar dy)
Definition SkMatrix.cpp:263
const gpu::SubRunContainerOwner & subRuns() const
Definition SlugImpl.h:57
const SkMatrix & initialPositionMatrix() const
Definition SlugImpl.h:54
SkPoint origin() const
Definition SlugImpl.h:55
constexpr float y() const
constexpr float x() const

◆ drawSpecial()

void skgpu::ganesh::Device::drawSpecial ( SkSpecialImage ,
const SkMatrix localToDevice,
const SkSamplingOptions ,
const SkPaint ,
SkCanvas::SrcRectConstraint  constraint 
)
overridevirtual

Draw the special image's subset to this device, subject to the given matrix transform instead of the device's current local to device matrix.

If 'constraint' is kFast, the rendered geometry of the image still reflects the extent of the SkSpecialImage's subset, but it's assumed that the pixel data beyond the subset is valid (e.g. SkSpecialImage::makeSubset() was called to crop a larger image).

Reimplemented from SkDevice.

Definition at line 371 of file Device_drawTexture.cpp.

375 {
376 SkASSERT(!paint.getMaskFilter() && !paint.getImageFilter());
377 SkASSERT(special->isGaneshBacked());
378
379 SkRect src = SkRect::Make(special->subset());
380 SkRect dst = SkRect::MakeWH(special->width(), special->height());
381 SkMatrix srcToDst = SkMatrix::RectToRect(src, dst);
382
383 SkSamplingOptions sampling = SkSamplingOptions(downgrade_to_filter(origSampling));
384 GrAA aa = fSurfaceDrawContext->chooseAA(paint);
386 : SkCanvas::kNone_QuadAAFlags;
387
388 GrSurfaceProxyView view = SkSpecialImages::AsView(this->recordingContext(), special);
389 if (!view) {
390 // This shouldn't happen since we shouldn't be mixing SkSpecialImage subclasses but
391 // returning early should avoid problems in release builds.
392 SkASSERT(false);
393 return;
394 }
395
396 if (constraint == SkCanvas::kFast_SrcRectConstraint) {
397 // If 'fast' was requested, we assume the caller has done sufficient analysis to know the
398 // logical dimensions are safe (which is true for FilterResult, the only current caller that
399 // passes in 'fast'). Without exactify'ing the proxy, GrTextureEffect would re-introduce
400 // subset clamping.
401 view.proxy()->priv().exactify();
402 }
403
404 SkImage_Ganesh image(sk_ref_sp(special->getContext()),
405 special->uniqueID(),
406 std::move(view),
407 special->colorInfo());
408 // In most cases this ought to hit draw_texture since there won't be a color filter,
409 // alpha-only texture+shader, or a high filter quality.
410 this->drawEdgeAAImage(&image,
411 src,
412 dst,
413 /* dstClip= */nullptr,
414 aaFlags,
416 sampling,
417 paint,
418 constraint,
419 srcToDst,
421}
sk_sp< T > sk_ref_sp(T *obj)
Definition SkRefCnt.h:381
GrSurfaceProxy * proxy() const
GrSurfaceProxyPriv priv()
@ kFast_SrcRectConstraint
sample outside bounds; faster
Definition SkCanvas.h:1543
static SkMatrix RectToRect(const SkRect &src, const SkRect &dst, ScaleToFit mode=kFill_ScaleToFit)
Definition SkMatrix.h:157
void drawEdgeAAImage(const SkImage *, const SkRect &src, const SkRect &dst, const SkPoint dstClip[4], SkCanvas::QuadAAFlags, const SkMatrix &localToDevice, const SkSamplingOptions &, const SkPaint &, SkCanvas::SrcRectConstraint, const SkMatrix &srcToDst, SkTileMode)
static constexpr SkRect MakeWH(float w, float h)
Definition SkRect.h:609

◆ drawVertices()

void skgpu::ganesh::Device::drawVertices ( const SkVertices ,
sk_sp< SkBlender ,
const SkPaint ,
bool  skipColorXform 
)
overridevirtual

If skipColorXform is true, then the implementation should assume that the provided vertex colors are already in the destination color space.

Implements SkDevice.

Definition at line 1110 of file Device.cpp.

1113 {
1115 GR_CREATE_TRACE_MARKER_CONTEXT("skgpu::ganesh::Device", "drawVertices", fContext.get());
1116 SkASSERT(vertices);
1117
1118#ifdef SK_LEGACY_IGNORE_DRAW_VERTICES_BLEND_WITH_NO_SHADER
1119 if (!paint.getShader()) {
1121 }
1122#endif
1123
1124 SkVerticesPriv info(vertices->priv());
1125
1126 GrPaint grPaint;
1127 if (!init_vertices_paint(fContext.get(),
1128 fSurfaceDrawContext->colorInfo(),
1129 paint,
1130 this->localToDevice(),
1131 blender.get(),
1132 info.hasColors(),
1133 fSurfaceDrawContext->surfaceProps(),
1134 &grPaint)) {
1135 return;
1136 }
1137 fSurfaceDrawContext->drawVertices(this->clip(),
1138 std::move(grPaint),
1139 this->localToDevice(),
1140 sk_ref_sp(const_cast<SkVertices*>(vertices)),
1141 nullptr,
1142 skipColorXform);
1143}
const sk_sp< Effect > & get() const
static sk_sp< SkBlender > Mode(SkBlendMode mode)

◆ isClipAntiAliased()

bool skgpu::ganesh::Device::isClipAntiAliased ( ) const
overridevirtual

Implements SkDevice.

Definition at line 431 of file Device.cpp.

431 {
432 for (const ClipStack::Element& e : fClip) {
433 if (e.fAA == GrAA::kYes) {
434 return true;
435 }
436 SkASSERT(!fSurfaceDrawContext->alwaysAntialias());
437 }
438 return false;
439}

◆ isClipEmpty()

bool skgpu::ganesh::Device::isClipEmpty ( ) const
inlineoverridevirtual

Implements SkDevice.

Definition at line 285 of file Device.h.

285 {
286 return fClip.clipState() == ClipStack::ClipState::kEmpty;
287 }
ClipState clipState() const
Definition ClipStack.h:62

◆ isClipRect()

bool skgpu::ganesh::Device::isClipRect ( ) const
inlineoverridevirtual

◆ isClipWideOpen()

bool skgpu::ganesh::Device::isClipWideOpen ( ) const
inlineoverridevirtual

Implements SkDevice.

Definition at line 294 of file Device.h.

294 {
296 }

◆ Make() [1/2]

sk_sp< Device > skgpu::ganesh::Device::Make ( GrRecordingContext rContext,
GrColorType  colorType,
sk_sp< GrSurfaceProxy proxy,
sk_sp< SkColorSpace colorSpace,
GrSurfaceOrigin  origin,
const SkSurfaceProps surfaceProps,
InitContents  init 
)
static

This factory uses the color space, origin, surface properties, and initialization method along with the provided proxy to create the gpu device.

Definition at line 212 of file Device.cpp.

218 {
219 auto sdc = SurfaceDrawContext::Make(rContext,
220 colorType,
221 std::move(proxy),
222 std::move(colorSpace),
223 origin,
225
226 return Device::Make(std::move(sdc), kPremul_SkAlphaType, init);
227}
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition SkAlphaType.h:29
static std::unique_ptr< SurfaceDrawContext > Make(GrRecordingContext *, GrColorType, sk_sp< GrSurfaceProxy >, sk_sp< SkColorSpace >, GrSurfaceOrigin, const SkSurfaceProps &)

◆ Make() [2/2]

sk_sp< Device > skgpu::ganesh::Device::Make ( GrRecordingContext rContext,
skgpu::Budgeted  budgeted,
const SkImageInfo ii,
SkBackingFit  fit,
int  sampleCount,
skgpu::Mipmapped  mipmapped,
GrProtected  isProtected,
GrSurfaceOrigin  origin,
const SkSurfaceProps props,
InitContents  init 
)
static

This factory uses the budgeted, imageInfo, fit, sampleCount, mipmapped, and isProtected parameters to create a proxy to back the gpu device. The color space (from the image info), origin, surface properties, and initialization method are then used (with the created proxy) to create the device.

Definition at line 281 of file Device.cpp.

290 {
291 if (!rContext) {
292 return nullptr;
293 }
294
295 auto sdc = SurfaceDrawContext::Make(rContext,
297 ii.refColorSpace(),
298 fit,
299 ii.dimensions(),
300 props,
301 /*label=*/"MakeDevice",
302 sampleCount,
303 mipmapped,
304 isProtected,
305 origin,
306 budgeted);
307
308 return Device::Make(std::move(sdc), ii.alphaType(), init);
309}
sk_sp< SkColorSpace > refColorSpace() const
SkISize dimensions() const
SkAlphaType alphaType() const
SkColorType colorType() const

◆ makeSpecial() [1/2]

sk_sp< SkSpecialImage > skgpu::ganesh::Device::makeSpecial ( const SkBitmap bitmap)
overridevirtual

Reimplemented from SkDevice.

Definition at line 841 of file Device.cpp.

841 {
843
844 // TODO: this makes a tight copy of 'bitmap' but it doesn't have to be (given SkSpecialImage's
845 // semantics). Since this is cached we would have to bake the fit into the cache key though.
846 auto view = std::get<0>(
847 GrMakeCachedBitmapProxyView(fContext.get(), bitmap, /*label=*/"Device_MakeSpecial"));
848 if (!view) {
849 return nullptr;
850 }
851
852 const SkIRect rect = SkIRect::MakeSize(view.proxy()->dimensions());
853
854 // GrMakeCachedBitmapProxyView creates a tight copy of 'bitmap' so we don't have to subset
855 // the special image
856 return SkSpecialImages::MakeDeferredFromGpu(fContext.get(),
857 rect,
858 bitmap.getGenerationID(),
859 std::move(view),
860 {SkColorTypeToGrColorType(bitmap.colorType()),
861 kPremul_SkAlphaType,
862 bitmap.refColorSpace()},
863 this->surfaceProps());
864}
std::tuple< GrSurfaceProxyView, GrColorType > GrMakeCachedBitmapProxyView(GrRecordingContext *rContext, const SkBitmap &bitmap, std::string_view label, skgpu::Mipmapped mipmapped)
Definition SkGr.cpp:188
static constexpr SkIRect MakeSize(const SkISize &size)
Definition SkRect.h:66

◆ makeSpecial() [2/2]

sk_sp< SkSpecialImage > skgpu::ganesh::Device::makeSpecial ( const SkImage image)
overridevirtual

Reimplemented from SkDevice.

Definition at line 866 of file Device.cpp.

866 {
868
869 SkPixmap pm;
870 if (image->isTextureBacked()) {
871 auto [view, ct] =
872 skgpu::ganesh::AsView(this->recordingContext(), image, skgpu::Mipmapped::kNo);
873 SkASSERT(view);
874
875 return SkSpecialImages::MakeDeferredFromGpu(
876 fContext.get(),
878 image->uniqueID(),
879 std::move(view),
880 {ct, kPremul_SkAlphaType, image->refColorSpace()},
881 this->surfaceProps());
882 } else if (image->peekPixels(&pm)) {
883 SkBitmap bm;
884
885 bm.installPixels(pm);
886 return this->makeSpecial(bm);
887 } else {
888 return nullptr;
889 }
890}
bool installPixels(const SkImageInfo &info, void *pixels, size_t rowBytes, void(*releaseProc)(void *addr, void *context), void *context)
Definition SkBitmap.cpp:323
uint32_t uniqueID() const
Definition SkImage.h:311
bool peekPixels(SkPixmap *pixmap) const
Definition SkImage.cpp:34
int width() const
Definition SkImage.h:285
virtual bool isTextureBacked() const =0
int height() const
Definition SkImage.h:291
sk_sp< SkSpecialImage > makeSpecial(const SkBitmap &) override
Definition Device.cpp:841

◆ makeSurface()

sk_sp< SkSurface > skgpu::ganesh::Device::makeSurface ( const SkImageInfo info,
const SkSurfaceProps props 
)
overridevirtual

Reimplemented from SkDevice.

Definition at line 1448 of file Device.cpp.

1448 {
1450 // TODO: Change the signature of newSurface to take a budgeted parameter.
1452 bool isProtected = this->targetProxy()->isProtected() == GrProtected::kYes;
1453 return SkSurfaces::RenderTarget(fContext.get(),
1454 kBudgeted,
1455 info,
1456 fSurfaceDrawContext->numSamples(),
1457 fSurfaceDrawContext->origin(),
1458 &props,
1459 /* shouldCreateWithMips= */ false,
1460 isProtected);
1461}
GrProtected isProtected() const
GrRenderTargetProxy * targetProxy()
Definition Device.cpp:1287
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)
Budgeted
Definition GpuTypes.h:35

◆ onAccessPixels()

bool skgpu::ganesh::Device::onAccessPixels ( SkPixmap pmap)
overrideprivatevirtual

Reimplemented from SkDevice.

Definition at line 353 of file Device.cpp.

353 {
355 return false;
356}

◆ onClipShader()

void skgpu::ganesh::Device::onClipShader ( sk_sp< SkShader shader)
inlineoverrideprivatevirtual

Implements SkDevice.

Definition at line 336 of file Device.h.

336 {
337 fClip.clipShader(std::move(shader));
338 }
void clipShader(sk_sp< SkShader > shader)

◆ onDrawGlyphRunList()

void skgpu::ganesh::Device::onDrawGlyphRunList ( SkCanvas canvas,
const sktext::GlyphRunList glyphRunList,
const SkPaint paint 
)
overrideprivatevirtual

Implements SkDevice.

Definition at line 1235 of file Device.cpp.

1237 {
1239 GR_CREATE_TRACE_MARKER_CONTEXT("skgpu::ganesh::Device", "drawGlyphRunList", fContext.get());
1240 SkASSERT(!glyphRunList.hasRSXForm());
1241
1242 if (glyphRunList.blob() == nullptr) {
1243 // If the glyphRunList does not have an associated text blob, then it was created by one of
1244 // the direct draw APIs (drawGlyphs, etc.). Use a Slug to draw the glyphs.
1245 auto slug = this->convertGlyphRunListToSlug(glyphRunList, paint);
1246 if (slug != nullptr) {
1247 this->drawSlug(canvas, slug.get(), paint);
1248 }
1249 } else {
1250 fSurfaceDrawContext->drawGlyphRunList(canvas,
1251 this->clip(),
1252 this->localToDevice(),
1253 glyphRunList,
1254 this->strikeDeviceInfo(),
1255 paint);
1256 }
1257}
sk_sp< sktext::gpu::Slug > convertGlyphRunListToSlug(const sktext::GlyphRunList &glyphRunList, const SkPaint &paint) override
Definition Device.cpp:1495
void drawSlug(SkCanvas *, const sktext::gpu::Slug *slug, const SkPaint &paint) override
Definition Device.cpp:1504
const SkTextBlob * blob() const
Definition GlyphRun.h:117
bool hasRSXForm() const
Definition GlyphRun.h:105

◆ onReadPixels()

bool skgpu::ganesh::Device::onReadPixels ( const SkPixmap pm,
int  x,
int  y 
)
overrideprivatevirtual

Reimplemented from SkDevice.

Definition at line 329 of file Device.cpp.

329 {
331
332 // Context TODO: Elevate direct context requirement to public API
333 auto dContext = fContext->asDirectContext();
334 if (!dContext || !SkImageInfoValidConversion(pm.info(), this->imageInfo())) {
335 return false;
336 }
337
338 return fSurfaceDrawContext->readPixels(dContext, pm, {x, y});
339}
static bool SkImageInfoValidConversion(const SkImageInfo &dst, const SkImageInfo &src)
virtual GrDirectContext * asDirectContext()
const SkImageInfo & info() const
Definition SkPixmap.h:135
double y
double x

◆ onWritePixels()

bool skgpu::ganesh::Device::onWritePixels ( const SkPixmap pm,
int  x,
int  y 
)
overrideprivatevirtual

Reimplemented from SkDevice.

Definition at line 341 of file Device.cpp.

341 {
343
344 // Context TODO: Elevate direct context requirement to public API
345 auto dContext = fContext->asDirectContext();
346 if (!dContext || !SkImageInfoValidConversion(this->imageInfo(), pm.info())) {
347 return false;
348 }
349
350 return fSurfaceDrawContext->writePixels(dContext, pm, {x, y});
351}

◆ popClipStack()

void skgpu::ganesh::Device::popClipStack ( )
inlineoverridevirtual

Implements SkDevice.

Definition at line 264 of file Device.h.

264{ fClip.restore(); }

◆ pushClipStack()

void skgpu::ganesh::Device::pushClipStack ( )
inlineoverridevirtual

Implements SkDevice.

Definition at line 263 of file Device.h.

263{ fClip.save(); }

◆ readSurfaceView()

GrSurfaceProxyView skgpu::ganesh::Device::readSurfaceView ( )

Definition at line 1283 of file Device.cpp.

1283 {
1284 return this->surfaceFillContext()->readSurfaceView();
1285}
SurfaceFillContext * surfaceFillContext()
Definition Device.cpp:368
GrSurfaceProxyView readSurfaceView()

◆ recordingContext()

GrRecordingContext * skgpu::ganesh::Device::recordingContext ( ) const
inlineoverridevirtual

Reimplemented from SkDevice.

Definition at line 101 of file Device.h.

101{ return fContext.get(); }

◆ replaceBackingProxy() [1/2]

bool skgpu::ganesh::Device::replaceBackingProxy ( SkSurface::ContentChangeMode  mode)

Definition at line 1338 of file Device.cpp.

1338 {
1340
1341 const SkImageInfo& ii = this->imageInfo();
1342 GrRenderTargetProxy* oldRTP = this->targetProxy();
1343 GrSurfaceProxyView oldView = this->readSurfaceView();
1344
1345 auto grColorType = SkColorTypeToGrColorType(ii.colorType());
1346 auto format = fContext->priv().caps()->getDefaultBackendFormat(grColorType, GrRenderable::kYes);
1347 if (!format.isValid()) {
1348 return false;
1349 }
1350
1351 GrProxyProvider* proxyProvider = fContext->priv().proxyProvider();
1352 // This entry point is used by SkSurface_Ganesh::onCopyOnWrite so it must create a
1353 // kExact-backed render target proxy
1354 sk_sp<GrTextureProxy> proxy =
1355 proxyProvider->createProxy(format,
1356 ii.dimensions(),
1357 GrRenderable::kYes,
1358 oldRTP->numSamples(),
1359 oldView.mipmapped(),
1361 oldRTP->isBudgeted(),
1362 GrProtected::kNo,
1363 /*label=*/"BaseDevice_ReplaceBackingProxy");
1364 if (!proxy) {
1365 return false;
1366 }
1367
1368 return this->replaceBackingProxy(mode, sk_ref_sp(proxy->asRenderTargetProxy()),
1369 grColorType, ii.refColorSpace(), oldView.origin(),
1370 this->surfaceProps());
1371}
GrBackendFormat getDefaultBackendFormat(GrColorType, GrRenderable) const
Definition GrCaps.cpp:400
sk_sp< GrTextureProxy > createProxy(const GrBackendFormat &, SkISize dimensions, GrRenderable, int renderTargetSampleCnt, skgpu::Mipmapped, SkBackingFit, skgpu::Budgeted, GrProtected, std::string_view label, GrInternalSurfaceFlags=GrInternalSurfaceFlags::kNone, UseAllocator useAllocator=UseAllocator::kYes)
GrProxyProvider * proxyProvider()
skgpu::Mipmapped mipmapped() const
skgpu::Budgeted isBudgeted() const
GrSurfaceProxyView readSurfaceView()
Definition Device.cpp:1283
bool replaceBackingProxy(SkSurface::ContentChangeMode, sk_sp< GrRenderTargetProxy >, GrColorType, sk_sp< SkColorSpace >, GrSurfaceOrigin, const SkSurfaceProps &)
Definition Device.cpp:1308
uint32_t uint32_t * format

◆ replaceBackingProxy() [2/2]

bool skgpu::ganesh::Device::replaceBackingProxy ( SkSurface::ContentChangeMode  mode,
sk_sp< GrRenderTargetProxy newRTP,
GrColorType  grColorType,
sk_sp< SkColorSpace colorSpace,
GrSurfaceOrigin  origin,
const SkSurfaceProps props 
)

Definition at line 1308 of file Device.cpp.

1313 {
1314 auto sdc = SurfaceDrawContext::Make(fContext.get(), grColorType, std::move(newRTP),
1315 std::move(colorSpace), origin, props);
1316 if (!sdc) {
1317 return false;
1318 }
1319
1320 SkASSERT(sdc->dimensions() == fSurfaceDrawContext->dimensions());
1321 SkASSERT(sdc->numSamples() == fSurfaceDrawContext->numSamples());
1322 SkASSERT(sdc->asSurfaceProxy()->priv().isExact());
1324 if (fContext->abandoned()) {
1325 return false;
1326 }
1327
1328 SkASSERT(fSurfaceDrawContext->asTextureProxy());
1329 SkAssertResult(sdc->blitTexture(fSurfaceDrawContext->readSurfaceView(),
1330 SkIRect::MakeWH(this->width(), this->height()),
1331 SkIPoint::Make(0, 0)));
1332 }
1333
1334 fSurfaceDrawContext = std::move(sdc);
1335 return true;
1336}
#define SkAssertResult(cond)
Definition SkAssert.h:123
bool abandoned() override
@ kRetain_ContentChangeMode
preserves surface on change
Definition SkSurface.h:205
static constexpr SkIPoint Make(int32_t x, int32_t y)

◆ replaceClip()

void skgpu::ganesh::Device::replaceClip ( const SkIRect rect)
inlineoverridevirtual

Implements SkDevice.

Definition at line 276 of file Device.h.

276 {
277 // Transform from "global/canvas" coordinates to relative to this device
278 SkRect deviceRect = SkMatrixPriv::MapRect(this->globalToDevice(), SkRect::Make(rect));
279 fClip.replaceClip(deviceRect.round());
280 }
static SkRect MapRect(const SkM44 &m, const SkRect &r)
Definition SkM44.cpp:216
void replaceClip(const SkIRect &rect)
void round(SkIRect *dst) const
Definition SkRect.h:1228

◆ resolveMSAA()

void skgpu::ganesh::Device::resolveMSAA ( )

Definition at line 1304 of file Device.cpp.

1304 {
1305 fSurfaceDrawContext->resolveMSAA();
1306}

◆ shouldDrawAsTiledImageRect()

bool skgpu::ganesh::Device::shouldDrawAsTiledImageRect ( ) const
inlineoverridevirtual

Reimplemented from SkDevice.

Definition at line 203 of file Device.h.

203{ return true; }

◆ snapSpecial()

sk_sp< SkSpecialImage > skgpu::ganesh::Device::snapSpecial ( const SkIRect subset,
bool  forceCopy = false 
)
overridevirtual

Reimplemented from SkDevice.

Definition at line 892 of file Device.cpp.

892 {
894
895 auto sdc = fSurfaceDrawContext.get();
896
897 // If we are wrapping a vulkan secondary command buffer, then we can't snap off a special image
898 // since it would require us to make a copy of the underlying VkImage which we don't have access
899 // to. Additionaly we can't stop and start the render pass that is used with the secondary
900 // command buffer.
901 if (sdc->wrapsVkSecondaryCB()) {
902 return nullptr;
903 }
904
905 SkASSERT(sdc->asSurfaceProxy());
906
907 SkIRect finalSubset = subset;
908 GrSurfaceProxyView view = sdc->readSurfaceView();
909 if (forceCopy || !view.asTextureProxy()) {
910 // When the device doesn't have a texture, or a copy is requested, we create a temporary
911 // texture that matches the device contents
912 view = GrSurfaceProxyView::Copy(fContext.get(),
913 std::move(view),
914 skgpu::Mipmapped::kNo, // Don't auto generate mips
915 subset,
918 /*label=*/"Device_SnapSpecial"); // Always budgeted
919 if (!view) {
920 return nullptr;
921 }
922 // Since this copied only the requested subset, the special image wrapping the proxy no
923 // longer needs the original subset.
924 finalSubset = SkIRect::MakeSize(view.dimensions());
925 }
926
927 return SkSpecialImages::MakeDeferredFromGpu(fContext.get(),
928 finalSubset,
930 std::move(view),
931 GrColorInfo(this->imageInfo().colorInfo()),
932 this->surfaceProps());
933}
@ kNeedNewImageUniqueID_SpecialImage
GrTextureProxy * asTextureProxy() const
SkISize dimensions() const
static GrSurfaceProxyView Copy(GrRecordingContext *context, GrSurfaceProxyView src, skgpu::Mipmapped mipmapped, SkIRect srcRect, SkBackingFit fit, skgpu::Budgeted budgeted, std::string_view label)

◆ snapSpecialScaled()

sk_sp< SkSpecialImage > skgpu::ganesh::Device::snapSpecialScaled ( const SkIRect subset,
const SkISize dstDims 
)
overridevirtual

Reimplemented from SkDevice.

Definition at line 935 of file Device.cpp.

935 {
937
938 auto sdc = fSurfaceDrawContext.get();
939
940 // If we are wrapping a vulkan secondary command buffer, then we can't snap off a special image
941 // since it would require us to make a copy of the underlying VkImage which we don't have access
942 // to. Additionaly we can't stop and start the render pass that is used with the secondary
943 // command buffer.
944 if (sdc->wrapsVkSecondaryCB()) {
945 return nullptr;
946 }
947
948 SkASSERT(sdc->asSurfaceProxy());
949
950 auto scaledContext = sdc->rescale(sdc->imageInfo().makeDimensions(dstDims),
951 sdc->origin(),
952 subset,
953 RescaleGamma::kSrc,
954 RescaleMode::kLinear);
955 if (!scaledContext) {
956 return nullptr;
957 }
958
959 return SkSpecialImages::MakeDeferredFromGpu(fContext.get(),
960 SkIRect::MakeSize(dstDims),
962 scaledContext->readSurfaceView(),
963 GrColorInfo(this->imageInfo().colorInfo()),
964 this->surfaceProps());
965}

◆ strikeDeviceInfo()

SkStrikeDeviceInfo skgpu::ganesh::Device::strikeDeviceInfo ( ) const
overridevirtual

Reimplemented from SkDevice.

Definition at line 1491 of file Device.cpp.

1491 {
1492 return {this->surfaceProps(), this->scalerContextFlags(), &fSDFTControl};
1493}
SkScalerContextFlags scalerContextFlags() const
Definition SkDevice.cpp:503

◆ surfaceDrawContext() [1/2]

SurfaceDrawContext * skgpu::ganesh::Device::surfaceDrawContext ( )

Definition at line 358 of file Device.cpp.

358 {
360 return fSurfaceDrawContext.get();
361}

◆ surfaceDrawContext() [2/2]

const SurfaceDrawContext * skgpu::ganesh::Device::surfaceDrawContext ( ) const

Definition at line 363 of file Device.cpp.

363 {
365 return fSurfaceDrawContext.get();
366}

◆ surfaceFillContext()

SurfaceFillContext * skgpu::ganesh::Device::surfaceFillContext ( )

Definition at line 368 of file Device.cpp.

368 {
370 return fSurfaceDrawContext.get();
371}

◆ targetProxy()

GrRenderTargetProxy * skgpu::ganesh::Device::targetProxy ( )

Definition at line 1287 of file Device.cpp.

1287 {
1288 return this->readSurfaceView().asRenderTargetProxy();
1289}
GrRenderTargetProxy * asRenderTargetProxy() const

◆ wait()

bool skgpu::ganesh::Device::wait ( int  numSemaphores,
const GrBackendSemaphore waitSemaphores,
bool  deleteSemaphoresAfterWait 
)

Definition at line 1291 of file Device.cpp.

1293 {
1295
1296 return fSurfaceDrawContext->waitOnSemaphores(numSemaphores, waitSemaphores,
1297 deleteSemaphoresAfterWait);
1298}

Friends And Related Symbol Documentation

◆ ::SkSurface_Ganesh

friend class ::SkSurface_Ganesh
friend

Definition at line 363 of file Device.h.

◆ skgpu::TiledTextureUtils

friend class skgpu::TiledTextureUtils
friend

Definition at line 364 of file Device.h.


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