Flutter Engine
The Flutter Engine
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
skgpu::ganesh Namespace Reference

Namespaces

namespace  DashOp
 
namespace  DrawAtlasOp
 
namespace  DrawMeshOp
 
namespace  FillRRectOp
 
namespace  LatticeOp
 
namespace  QuadPerEdgeAA
 
namespace  RegionOp
 
namespace  ShadowRRectOp
 
namespace  StrokeRectOp
 

Classes

class  AAConvexPathRenderer
 
class  AAHairLinePathRenderer
 
class  AALinearizingConvexPathRenderer
 
class  AtlasInstancedHelper
 
class  AtlasPathRenderer
 
class  AtlasRenderTask
 
class  AtlasTextOp
 
class  AtlasTextOpTools
 
class  AutoCheckFlush
 
class  ClearOp
 
class  ClipStack
 
class  DashLinePathRenderer
 
class  DefaultPathRenderer
 
class  Device
 
class  DrawableOp
 
class  DrawAtlasPathOp
 
class  FillRectOp
 
class  OpsTask
 
class  PathCurveTessellator
 
class  PathInnerTriangulateOp
 
class  PathRenderer
 
class  PathRendererChain
 
class  PathStencilCoverOp
 
class  PathTessellateBenchmark
 
class  PathTessellateOp
 
class  PathTessellator
 
class  PathWedgeTessellator
 
class  SmallPathAtlasMgr
 
class  SmallPathRenderer
 
class  SmallPathShapeData
 
class  SmallPathShapeDataKey
 
class  SoftwarePathRenderer
 
class  StencilClip
 
class  StencilMaskHelper
 
class  StrokeTessellateOp
 
class  StrokeTessellator
 
class  SurfaceContext
 
class  SurfaceDrawContext
 
class  SurfaceFillContext
 
class  TessellationPathRenderer
 
class  TessPrepareBench
 
class  TextureOp
 
class  TriangulatingPathRenderer
 
class  VertexChunkPatchAllocator
 

Typedefs

using PathStrokeList = StrokeTessellator::PathStrokeList
 
using MakePathStrokesFn = std::vector< PathStrokeList >(*)()
 
using PatchAttribs = tess::PatchAttribs
 
using DataType = SkYUVAPixmapInfo::DataType
 
using DoSimplify = GrStyledShape::DoSimplify
 

Enumerations

enum class  FillPathFlags { kNone = 0 , kStencilOnly = (1 << 0) , kWireframe = (1 << 1) }
 

Functions

static sk_sp< GrDirectContextmake_mock_context ()
 
static SkPath make_cubic_path (int maxPow2)
 
static SkPath make_conic_path ()
 
static SkPath make_quad_path (int maxPow2)
 
static SkPath make_line_path (int maxPow2)
 
 DEF_PATH_TESS_BENCH (GrPathCurveTessellator, make_cubic_path(8), SkMatrix::I())
 
 DEF_PATH_TESS_BENCH (GrPathWedgeTessellator, make_cubic_path(8), SkMatrix::I())
 
static void benchmark_wangs_formula_cubic_log2 (const SkMatrix &matrix, const SkPath &path)
 
 DEF_PATH_TESS_BENCH (wangs_formula_cubic_log2, make_cubic_path(18), SkMatrix::I())
 
 DEF_PATH_TESS_BENCH (wangs_formula_cubic_log2_scale, make_cubic_path(18), SkMatrix::Scale(1.1f, 0.9f))
 
 DEF_PATH_TESS_BENCH (wangs_formula_cubic_log2_affine, make_cubic_path(18), SkMatrix::MakeAll(.9f, 0.9f, 0, 1.1f, 1.1f, 0, 0, 0, 1))
 
static void benchmark_wangs_formula_conic (const SkMatrix &matrix, const SkPath &path)
 
static void benchmark_wangs_formula_conic_log2 (const SkMatrix &matrix, const SkPath &path)
 
 DEF_PATH_TESS_BENCH (wangs_formula_conic, make_conic_path(), SkMatrix::I())
 
 DEF_PATH_TESS_BENCH (wangs_formula_conic_log2, make_conic_path(), SkMatrix::I())
 
 DEF_PATH_TESS_BENCH (middle_out_triangulation, ToolUtils::make_star(SkRect::MakeWH(500, 500), kNumCubicsInChalkboard), SkMatrix::I())
 
static std::vector< PathStrokeListmake_simple_cubic_path ()
 
static std::vector< PathStrokeListmake_motionmark_paths ()
 
 DEF_BENCH (return new TessPrepareBench(make_simple_cubic_path, PatchAttribs::kNone, 1, "GrStrokeFixedCountTessellator");) DEF_BENCH(return new TessPrepareBench(make_simple_cubic_path
 
SkIRect TopLayerBounds (const SkCanvas *)
 
GrBackendRenderTarget TopLayerBackendRenderTarget (const SkCanvas *)
 
bool PinAsTexture (GrRecordingContext *, SkImage *)
 
void UnpinTexture (GrRecordingContext *, SkImage *)
 
SK_API GrSemaphoresSubmitted Flush (sk_sp< SkSurface >)
 
SK_API GrSemaphoresSubmitted Flush (SkSurface *)
 
SK_API void FlushAndSubmit (sk_sp< SkSurface >)
 
SK_API void FlushAndSubmit (SkSurface *)
 
SK_API bool DrawDDL (SkSurface *, sk_sp< const GrDeferredDisplayList > ddl)
 
SK_API bool DrawDDL (sk_sp< SkSurface >, sk_sp< const GrDeferredDisplayList > ddl)
 
SurfaceDrawContextTopDeviceSurfaceDrawContext (const SkCanvas *canvas)
 
SurfaceFillContextTopDeviceSurfaceFillContext (const SkCanvas *canvas)
 
GrRenderTargetProxyTopDeviceTargetProxy (const SkCanvas *canvas)
 
GrSurfaceProxyView CopyView (GrRecordingContext *context, GrSurfaceProxyView src, skgpu::Mipmapped mipmapped, GrImageTexGenPolicy policy, std::string_view label)
 
std::tuple< GrSurfaceProxyView, GrColorTypeRasterAsView (GrRecordingContext *rContext, const SkImage_Raster *raster, skgpu::Mipmapped mipmapped, GrImageTexGenPolicy policy)
 
GrColorType ColorTypeOfLockTextureProxy (const GrCaps *caps, SkColorType sct)
 
static GrSurfaceOrigin get_origin (const SkImage_Lazy *img)
 
static GrSurfaceProxyView texture_proxy_view_from_planes (GrRecordingContext *ctx, const SkImage_Lazy *img, skgpu::Budgeted budgeted)
 
static GrSurfaceProxyView generate_picture_texture (GrRecordingContext *ctx, const SkImage_Picture *img, skgpu::Mipmapped mipmapped, GrImageTexGenPolicy texGenPolicy)
 
GrSurfaceProxyView LockTextureProxyView (GrRecordingContext *rContext, const SkImage_Lazy *img, GrImageTexGenPolicy texGenPolicy, skgpu::Mipmapped mipmapped)
 
static std::tuple< GrSurfaceProxyView, GrColorTypelazy_as_view (GrRecordingContext *context, const SkImage_Lazy *img, skgpu::Mipmapped mipmapped, GrImageTexGenPolicy policy)
 
std::tuple< GrSurfaceProxyView, GrColorTypeAsView (GrRecordingContext *rContext, const SkImage *img, skgpu::Mipmapped mipmapped, GrImageTexGenPolicy policy)
 
static std::unique_ptr< GrFragmentProcessormake_fp_from_view (GrRecordingContext *rContext, GrSurfaceProxyView view, SkAlphaType at, SkSamplingOptions sampling, const SkTileMode tileModes[2], const SkMatrix &m, const SkRect *subset, const SkRect *domain)
 
std::unique_ptr< GrFragmentProcessorraster_as_fp (GrRecordingContext *rContext, const SkImage_Raster *img, SkSamplingOptions sampling, const SkTileMode tileModes[2], const SkMatrix &m, const SkRect *subset, const SkRect *domain)
 
std::unique_ptr< GrFragmentProcessorAsFragmentProcessor (GrRecordingContext *rContext, const SkImage *img, SkSamplingOptions sampling, const SkTileMode tileModes[2], const SkMatrix &m, const SkRect *subset, const SkRect *domain)
 
std::unique_ptr< GrFragmentProcessorMakeFragmentProcessorFromView (GrRecordingContext *rContext, GrSurfaceProxyView view, SkAlphaType at, SkSamplingOptions sampling, const SkTileMode tileModes[2], const SkMatrix &m, const SkRect *subset, const SkRect *domain)
 
GrSurfaceProxyView FindOrMakeCachedMipmappedView (GrRecordingContext *rContext, GrSurfaceProxyView view, uint32_t imageUniqueID)
 
SkYUVAPixmapInfo::SupportedDataTypes SupportedTextureFormats (const GrImageContext &context)
 
std::tuple< GrSurfaceProxyView, GrColorTypeAsView (GrRecordingContext *ctx, const sk_sp< const SkImage > &img, skgpu::Mipmapped mm, GrImageTexGenPolicy policy=GrImageTexGenPolicy::kDraw)
 
std::unique_ptr< GrFragmentProcessorAsFragmentProcessor (GrRecordingContext *ctx, const sk_sp< const SkImage > &img, SkSamplingOptions opt, const SkTileMode tm[2], const SkMatrix &m, const SkRect *subset=nullptr, const SkRect *domain=nullptr)
 
 SKGPU_DECLARE_STATIC_UNIQUE_KEY (gUnitQuadBufferKey)
 
 SKGPU_DECLARE_STATIC_UNIQUE_KEY (gHullVertexBufferKey)
 
static constexpr GrUserStencilSettings kMarkStencil (GrUserStencilSettings::StaticInit< 0x0001, GrUserStencilTest::kLessIfInClip, 0x0000, GrUserStencilOp::kZero, GrUserStencilOp::kReplace, 0xffff >())
 
static constexpr GrUserStencilSettings kTestAndResetStencil (GrUserStencilSettings::StaticInit< 0x0000, GrUserStencilTest::kLessIfInClip, 0x0001, GrUserStencilOp::kZero, GrUserStencilOp::kReplace, 0xffff >())
 
std::tuple< bool, bool > FilterAndMipmapHaveNoEffect (const GrQuad &srcQuad, const GrQuad &dstQuad)
 
static bool alpha_types_compatible (SkAlphaType srcAlphaType, SkAlphaType dstAlphaType)
 
static SkIRect get_clip_bounds (const SurfaceDrawContext *sdc, const GrClip *clip)
 
 SKGPU_DECLARE_STATIC_UNIQUE_KEY (gFixedCountCurveVertexBufferKey)
 
 SKGPU_DECLARE_STATIC_UNIQUE_KEY (gFixedCountCurveIndexBufferKey)
 
 SKGPU_DECLARE_STATIC_UNIQUE_KEY (gFixedCountWedgesVertexBufferKey)
 
 SKGPU_DECLARE_STATIC_UNIQUE_KEY (gFixedCountWedgesIndexBufferKey)
 
 SKGPU_DECLARE_STATIC_UNIQUE_KEY (gVertexIDFallbackBufferKey)
 
GrBackendApi ContextTypeBackend (skgpu::ContextType type)
 

Variables

static constexpr int kNumCubicsInChalkboard = 47182
 
static const SkMatrix gAlmostIdentity
 
 GrStrokeFixedCountTessellator_one_chop
 
static constexpr int kElementStackIncrement = 8
 
static constexpr int kSaveStackIncrement = 8
 
static constexpr int kMaskStackIncrement = 4
 
static constexpr int kMaxAnalyticFPs = 4
 
static constexpr int kNumStackMasks = 4
 
static constexpr auto kAtlasAlpha8Type = GrColorType::kAlpha_8
 
static constexpr int kAtlasInitialSize = 512
 
static constexpr auto kAtlasAlgorithm = GrDynamicAtlas::RectanizerAlgorithm::kPow2
 
static constexpr int kAtlasMaxPathHeight = 256
 
static constexpr int kAtlasMaxPathHeightWithMSAAFallback = 128
 
static constexpr int kAtlasMaxPathWidth = 1024
 
static constexpr int kVerticesPerGlyph = 4
 
static constexpr int kIndicesPerGlyph = 6
 
static thread_local void * gCache = nullptr
 

Typedef Documentation

◆ DataType

Definition at line 706 of file GrImageUtils.cpp.

◆ DoSimplify

Definition at line 119 of file SurfaceDrawContext.cpp.

◆ MakePathStrokesFn

using skgpu::ganesh::MakePathStrokesFn = typedef std::vector<PathStrokeList>(*)()

Definition at line 244 of file TessellateBench.cpp.

◆ PatchAttribs

Definition at line 311 of file TessellateBench.cpp.

◆ PathStrokeList

Definition at line 243 of file TessellateBench.cpp.

Enumeration Type Documentation

◆ FillPathFlags

enum class skgpu::ganesh::FillPathFlags
strong
Enumerator
kNone 
kStencilOnly 
kWireframe 

Definition at line 16 of file FillPathFlags.h.

16 {
17 kNone = 0,
18 kStencilOnly = (1 << 0),
19 kWireframe = (1 << 1)
20};
@ kNone
Definition: layer.h:53

Function Documentation

◆ alpha_types_compatible()

static bool skgpu::ganesh::alpha_types_compatible ( SkAlphaType  srcAlphaType,
SkAlphaType  dstAlphaType 
)
static

Definition at line 64 of file SurfaceContext.cpp.

64 {
65 // If both alpha types are kUnknown things make sense. If not, it's too underspecified.
66 return (srcAlphaType == kUnknown_SkAlphaType) == (dstAlphaType == kUnknown_SkAlphaType);
67}
@ kUnknown_SkAlphaType
uninitialized
Definition: SkAlphaType.h:27

◆ AsFragmentProcessor() [1/2]

std::unique_ptr< GrFragmentProcessor > skgpu::ganesh::AsFragmentProcessor ( GrRecordingContext ctx,
const sk_sp< const SkImage > &  img,
SkSamplingOptions  opt,
const SkTileMode  tm[2],
const SkMatrix m,
const SkRect subset = nullptr,
const SkRect domain = nullptr 
)
inline

Definition at line 100 of file GrImageUtils.h.

106 {
107 return AsFragmentProcessor(ctx, img.get(), opt, tm, m, subset, domain);
108}
T * get() const
Definition: SkRefCnt.h:303
std::unique_ptr< GrFragmentProcessor > AsFragmentProcessor(GrRecordingContext *ctx, const sk_sp< const SkImage > &img, SkSamplingOptions opt, const SkTileMode tm[2], const SkMatrix &m, const SkRect *subset=nullptr, const SkRect *domain=nullptr)
Definition: GrImageUtils.h:100

◆ AsFragmentProcessor() [2/2]

std::unique_ptr< GrFragmentProcessor > skgpu::ganesh::AsFragmentProcessor ( GrRecordingContext ,
const SkImage ,
SkSamplingOptions  ,
const  SkTileMode[2],
const SkMatrix ,
const SkRect subset = nullptr,
const SkRect domain = nullptr 
)

Returns a GrFragmentProcessor that can be used with the passed GrRecordingContext to draw the image. SkSamplingOptions indicates the filter and SkTileMode[] indicates the x and y tile modes. The passed matrix is applied to the coordinates before sampling the image. Optional 'subset' indicates whether the tile modes should be applied to a subset of the image Optional 'domain' is a bound on the coordinates of the image that will be required and can be used to optimize the shader if 'subset' is also specified.

Definition at line 540 of file GrImageUtils.cpp.

546 {
547 if (!rContext) {
548 return {};
549 }
551 return {};
552 }
554 (!rContext->priv().caps()->mipmapSupport() || img->dimensions().area() <= 1)) {
556 }
557
558 auto ib = static_cast<const SkImage_Base*>(img);
559 if (ib->isRasterBacked()) {
560 return raster_as_fp(rContext,
561 static_cast<const SkImage_Raster*>(ib),
562 sampling,
563 tileModes,
564 m,
565 subset,
566 domain);
567 } else if (ib->isGaneshBacked()) {
568 auto gb = static_cast<const SkImage_GaneshBase*>(img);
569 return gb->asFragmentProcessor(rContext, sampling, tileModes, m, subset, domain);
570 } else if (ib->isLazyGenerated()) {
571 // TODO: If the CPU data is extracted as planes return a FP that reconstructs the image from
572 // the planes.
574 return MakeFragmentProcessorFromView(rContext,
575 std::get<0>(AsView(rContext, img, mm)),
576 img->alphaType(),
577 sampling,
578 tileModes,
579 m,
580 subset,
581 domain);
582 }
583
584 SkDEBUGFAIL("Unsupported image type to make a FragmentProcessor");
585 return {};
586}
#define SkDEBUGFAIL(message)
Definition: SkAssert.h:118
static bool GrValidCubicResampler(SkCubicResampler cubic)
Definition: SkGr.h:211
const GrCaps * caps() const
bool mipmapSupport() const
Definition: GrCaps.h:72
GrRecordingContextPriv priv()
virtual std::unique_ptr< GrFragmentProcessor > asFragmentProcessor(GrRecordingContext *, SkSamplingOptions, const SkTileMode[2], const SkMatrix &, const SkRect *, const SkRect *) const =0
SkISize dimensions() const
Definition: SkImage.h:297
SkAlphaType alphaType() const
Definition: SkImage.cpp:154
SkSamplingOptions sampling
Definition: SkRecords.h:337
const myers::Point & get< 0 >(const myers::Segment &s)
Definition: Myers.h:80
std::unique_ptr< GrFragmentProcessor > raster_as_fp(GrRecordingContext *rContext, const SkImage_Raster *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)
std::unique_ptr< GrFragmentProcessor > MakeFragmentProcessorFromView(GrRecordingContext *rContext, GrSurfaceProxyView view, SkAlphaType at, SkSamplingOptions sampling, const SkTileMode tileModes[2], const SkMatrix &m, const SkRect *subset, const SkRect *domain)
SkSamplingOptions(SkFilterMode::kLinear))
constexpr int64_t area() const
Definition: SkSize.h:39
const SkCubicResampler cubic
const SkFilterMode filter
const SkMipmapMode mipmap

◆ AsView() [1/2]

std::tuple< GrSurfaceProxyView, GrColorType > skgpu::ganesh::AsView ( GrRecordingContext ctx,
const sk_sp< const SkImage > &  img,
skgpu::Mipmapped  mm,
GrImageTexGenPolicy  policy = GrImageTexGenPolicy::kDraw 
)
inline

Definition at line 50 of file GrImageUtils.h.

54 {
55 return AsView(ctx, img.get(), mm, policy);
56}
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 keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network policy
Definition: switches.h:248
std::tuple< GrSurfaceProxyView, GrColorType > AsView(GrRecordingContext *ctx, const sk_sp< const SkImage > &img, skgpu::Mipmapped mm, GrImageTexGenPolicy policy=GrImageTexGenPolicy::kDraw)
Definition: GrImageUtils.h:50

◆ AsView() [2/2]

std::tuple< GrSurfaceProxyView, GrColorType > skgpu::ganesh::AsView ( GrRecordingContext rContext,
const SkImage img,
skgpu::Mipmapped  mipmapped,
GrImageTexGenPolicy  policy 
)

Definition at line 419 of file GrImageUtils.cpp.

422 {
423 SkASSERT(img);
424 if (!rContext) {
425 return {};
426 }
427 if (!rContext->priv().caps()->mipmapSupport() || img->dimensions().area() <= 1) {
428 mipmapped = skgpu::Mipmapped::kNo;
429 }
430
431 auto ib = static_cast<const SkImage_Base*>(img);
432 if (ib->type() == SkImage_Base::Type::kRaster) {
434 rContext, static_cast<const SkImage_Raster*>(ib), mipmapped, policy);
435 } else if (ib->type() == SkImage_Base::Type::kRasterPinnable) {
436 auto rp = static_cast<const SkImage_RasterPinnable*>(img);
437 return rp->asView(rContext, mipmapped, policy);
438 } else if (ib->isGaneshBacked()) {
439 auto gb = static_cast<const SkImage_GaneshBase*>(img);
440 return gb->asView(rContext, mipmapped, policy);
441 } else if (ib->isLazyGenerated()) {
442 return lazy_as_view(rContext, static_cast<const SkImage_Lazy*>(ib), mipmapped, policy);
443 }
444
445 SkDEBUGFAIL("Unsupported image type to make a View");
446 return {};
447}
#define SkASSERT(cond)
Definition: SkAssert.h:116
virtual std::tuple< GrSurfaceProxyView, GrColorType > asView(GrRecordingContext *, skgpu::Mipmapped, GrImageTexGenPolicy) const =0
std::tuple< GrSurfaceProxyView, GrColorType > asView(GrRecordingContext *, skgpu::Mipmapped, GrImageTexGenPolicy) const
std::tuple< GrSurfaceProxyView, GrColorType > RasterAsView(GrRecordingContext *rContext, const SkImage_Raster *raster, skgpu::Mipmapped mipmapped, GrImageTexGenPolicy policy)
static std::tuple< GrSurfaceProxyView, GrColorType > lazy_as_view(GrRecordingContext *context, const SkImage_Lazy *img, skgpu::Mipmapped mipmapped, GrImageTexGenPolicy policy)

◆ benchmark_wangs_formula_conic()

static void skgpu::ganesh::benchmark_wangs_formula_conic ( const SkMatrix matrix,
const SkPath path 
)
static

Definition at line 189 of file TessellateBench.cpp.

189 {
190 int sum = 0;
192 for (auto [verb, pts, w] : SkPathPriv::Iterate(path)) {
193 if (verb == SkPathVerb::kConic) {
194 sum += wangs_formula::conic(4, pts, *w, xform);
195 }
196 }
197 // Don't let the compiler optimize away wangs_formula::conic.
198 if (sum <= 0) {
199 SK_ABORT("sum should be > 0.");
200 }
201}
#define SK_ABORT(message,...)
Definition: SkAssert.h:70
@ kConic
SkPath::RawIter returns 3 points + 1 weight.
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
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
AI float conic(float tolerance, const SkPoint pts[], float w, const VectorXform &vectorXform=VectorXform())
Definition: WangsFormula.h:287
SkScalar w

◆ benchmark_wangs_formula_conic_log2()

static void skgpu::ganesh::benchmark_wangs_formula_conic_log2 ( const SkMatrix matrix,
const SkPath path 
)
static

Definition at line 203 of file TessellateBench.cpp.

203 {
204 int sum = 0;
206 for (auto [verb, pts, w] : SkPathPriv::Iterate(path)) {
207 if (verb == SkPathVerb::kConic) {
208 sum += wangs_formula::conic_log2(4, pts, *w, xform);
209 }
210 }
211 // Don't let the compiler optimize away wangs_formula::conic.
212 if (sum <= 0) {
213 SK_ABORT("sum should be > 0.");
214 }
215}
AI int conic_log2(float tolerance, const SkPoint pts[], float w, const VectorXform &vectorXform=VectorXform())
Definition: WangsFormula.h:296

◆ benchmark_wangs_formula_cubic_log2()

static void skgpu::ganesh::benchmark_wangs_formula_cubic_log2 ( const SkMatrix matrix,
const SkPath path 
)
static

Definition at line 161 of file TessellateBench.cpp.

161 {
162 int sum = 0;
164 for (auto [verb, pts, w] : SkPathPriv::Iterate(path)) {
165 if (verb == SkPathVerb::kCubic) {
166 sum += wangs_formula::cubic_log2(4, pts, xform);
167 }
168 }
169 // Don't let the compiler optimize away wangs_formula::cubic_log2.
170 if (sum <= 0) {
171 SK_ABORT("sum should be > 0.");
172 }
173}
@ kCubic
SkPath::RawIter returns 4 points.
AI int cubic_log2(float precision, const SkPoint pts[], const VectorXform &vectorXform=VectorXform())
Definition: WangsFormula.h:203

◆ ColorTypeOfLockTextureProxy()

GrColorType skgpu::ganesh::ColorTypeOfLockTextureProxy ( const GrCaps caps,
SkColorType  sct 
)

Definition at line 133 of file GrImageUtils.cpp.

133 {
136 if (!format.isValid()) {
138 }
139 return ct;
140}
GrColorType
Definition: GrTypesPriv.h:540
static constexpr GrColorType SkColorTypeToGrColorType(SkColorType ct)
Definition: GrTypesPriv.h:629
GrBackendFormat getDefaultBackendFormat(GrColorType, GrRenderable) const
Definition: GrCaps.cpp:400
uint32_t uint32_t * format

◆ ContextTypeBackend()

GrBackendApi skgpu::ganesh::ContextTypeBackend ( skgpu::ContextType  type)

Definition at line 92 of file ContextType.cpp.

92 {
93 switch (type) {
104
107
110
111 case ContextType::kDirect3D:
113
114 case ContextType::kDawn_D3D11:
115 case ContextType::kDawn_D3D12:
116 case ContextType::kDawn_Metal:
117 case ContextType::kDawn_Vulkan:
118 case ContextType::kDawn_OpenGL:
119 case ContextType::kDawn_OpenGLES:
121
122 case ContextType::kMock:
123 return GrBackendApi::kMock;
124 }
126}
#define SkUNREACHABLE
Definition: SkAssert.h:135
GLenum type
@ kGLES
OpenGL context.
@ kANGLE_GL_ES2
ANGLE on Direct3D11 OpenGL ES 3 context.
@ kANGLE_GL_ES3
ANGLE on OpenGL OpenGL ES 2 context.
@ kANGLE_D3D11_ES2
ANGLE on Direct3D9 OpenGL ES 2 context.
@ kVulkan
ANGLE on Metal ES 3 context.
@ kANGLE_D3D11_ES3
ANGLE on Direct3D11 OpenGL ES 2 context.
@ kANGLE_D3D9_ES2
OpenGL ES context.
@ kANGLE_Metal_ES2
ANGLE on OpenGL OpenGL ES 3 context.
@ kANGLE_Metal_ES3
ANGLE on Metal ES 2 context.

◆ CopyView()

GrSurfaceProxyView skgpu::ganesh::CopyView ( GrRecordingContext context,
GrSurfaceProxyView  src,
skgpu::Mipmapped  mipmapped,
GrImageTexGenPolicy  policy,
std::string_view  label 
)

Definition at line 89 of file GrImageUtils.cpp.

93 {
97 return GrSurfaceProxyView::Copy(context,
98 std::move(src),
99 mipmapped,
101 budgeted,
102 /*label=*/label);
103}
static GrSurfaceProxyView Copy(GrRecordingContext *context, GrSurfaceProxyView src, skgpu::Mipmapped mipmapped, SkIRect srcRect, SkBackingFit fit, skgpu::Budgeted budgeted, std::string_view label)
Budgeted
Definition: GpuTypes.h:35

◆ DEF_BENCH()

skgpu::ganesh::DEF_BENCH ( return new TessPrepareBench(make_simple_cubic_path, PatchAttribs::kNone, 1, "GrStrokeFixedCountTessellator");   )
new

◆ DEF_PATH_TESS_BENCH() [1/8]

skgpu::ganesh::DEF_PATH_TESS_BENCH ( GrPathCurveTessellator  ,
make_cubic_path(8)  ,
SkMatrix::I()   
)

Definition at line 137 of file TessellateBench.cpp.

137 {
138 SkArenaAlloc arena(1024);
141 auto tess = PathCurveTessellator::Make(&arena,
142 fTarget->caps().shaderCaps()->fInfinitySupport);
143 tess->prepare(fTarget.get(),
144 fMatrix,
145 {gAlmostIdentity, fPath, SK_PMColor4fTRANSPARENT},
146 fPath.countVerbs());
147}
SkPath fPath
SkMatrix fMatrix
Definition: FillRRectOp.cpp:74
@ kSrcOver
r = s + (1-sa)*d
int countVerbs() const
Definition: SkPath.cpp:556
static constexpr Swizzle RGBA()
Definition: Swizzle.h:66
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
static TessellatorLibtess tess

◆ DEF_PATH_TESS_BENCH() [2/8]

skgpu::ganesh::DEF_PATH_TESS_BENCH ( GrPathWedgeTessellator  ,
make_cubic_path(8)  ,
SkMatrix::I()   
)

Definition at line 149 of file TessellateBench.cpp.

149 {
150 SkArenaAlloc arena(1024);
153 auto tess = PathWedgeTessellator::Make(&arena,
154 fTarget->caps().shaderCaps()->fInfinitySupport);
155 tess->prepare(fTarget.get(),
156 fMatrix,
157 {gAlmostIdentity, fPath, SK_PMColor4fTRANSPARENT},
158 fPath.countVerbs());
159}

◆ DEF_PATH_TESS_BENCH() [3/8]

skgpu::ganesh::DEF_PATH_TESS_BENCH ( middle_out_triangulation  ,
ToolUtils::make_star(SkRect::MakeWH(500, 500), kNumCubicsInChalkboard ,
SkMatrix::I()   
)

Definition at line 225 of file TessellateBench.cpp.

227 {
228 // Conservative estimate of triangulation (see PathStencilCoverOp)
229 const int maxVerts = 3 * (kNumCubicsInChalkboard - 2);
230
232 int baseVertex;
233 VertexWriter vertexWriter = fTarget->makeVertexWriter(
234 sizeof(SkPoint), maxVerts, &buffer, &baseVertex);
236 for (tess::PathMiddleOutFanIter it(fPath); !it.done();) {
237 for (auto [p0, p1, p2] : it.nextStack()) {
238 vertexWriter << m.map2Points(p0, p1) << m.mapPoint(p2);
239 }
240 }
241}
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 defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
static constexpr int kNumCubicsInChalkboard
static const SkMatrix gAlmostIdentity

◆ DEF_PATH_TESS_BENCH() [4/8]

skgpu::ganesh::DEF_PATH_TESS_BENCH ( wangs_formula_conic  ,
make_conic_path()  ,
SkMatrix::I()   
)

Definition at line 217 of file TessellateBench.cpp.

217 {
219}
static void benchmark_wangs_formula_conic(const SkMatrix &matrix, const SkPath &path)

◆ DEF_PATH_TESS_BENCH() [5/8]

skgpu::ganesh::DEF_PATH_TESS_BENCH ( wangs_formula_conic_log2  ,
make_conic_path()  ,
SkMatrix::I()   
)

Definition at line 221 of file TessellateBench.cpp.

221 {
223}
static void benchmark_wangs_formula_conic_log2(const SkMatrix &matrix, const SkPath &path)

◆ DEF_PATH_TESS_BENCH() [6/8]

skgpu::ganesh::DEF_PATH_TESS_BENCH ( wangs_formula_cubic_log2  ,
make_cubic_path(18)  ,
SkMatrix::I()   
)

Definition at line 175 of file TessellateBench.cpp.

175 {
177}
static void benchmark_wangs_formula_cubic_log2(const SkMatrix &matrix, const SkPath &path)

◆ DEF_PATH_TESS_BENCH() [7/8]

skgpu::ganesh::DEF_PATH_TESS_BENCH ( wangs_formula_cubic_log2_affine  ,
make_cubic_path(18)  ,
SkMatrix::MakeAll(.9f, 0.9f, 0, 1.1f, 1.1f, 0, 0, 0, 1)   
)

Definition at line 184 of file TessellateBench.cpp.

◆ DEF_PATH_TESS_BENCH() [8/8]

skgpu::ganesh::DEF_PATH_TESS_BENCH ( wangs_formula_cubic_log2_scale  ,
make_cubic_path(18)  ,
SkMatrix::Scale(1.1f, 0.9f)   
)

Definition at line 179 of file TessellateBench.cpp.

◆ DrawDDL() [1/2]

bool skgpu::ganesh::DrawDDL ( sk_sp< SkSurface surface,
sk_sp< const GrDeferredDisplayList ddl 
)

Definition at line 76 of file GrDeferredDisplayList.cpp.

76 {
77 return DrawDDL(surface.get(), ddl);
78}
VkSurfaceKHR surface
Definition: main.cc:49
SK_API bool DrawDDL(SkSurface *, sk_sp< const GrDeferredDisplayList > ddl)

◆ DrawDDL() [2/2]

bool skgpu::ganesh::DrawDDL ( SkSurface surface,
sk_sp< const GrDeferredDisplayList ddl 
)

Draws the deferred display list created via a GrDeferredDisplayListRecorder. If the deferred display list is not compatible with the surface, the draw is skipped and false is return.

The xOffset and yOffset parameters are experimental and, if not both zero, will cause the draw to be ignored. When implemented, if xOffset or yOffset are non-zero, the DDL will be drawn offset by that amount into the surface.

Parameters
SkSurfaceThe surface to apply the commands to, cannot be nullptr.
ddldrawing commands, cannot be nullptr.
Returns
false if ddl is not compatible

example: https://fiddle.skia.org/c/@Surface_draw_2

Definition at line 64 of file GrDeferredDisplayList.cpp.

64 {
65 if (!surface || !ddl) {
66 return false;
67 }
68 auto sb = asSB(surface);
69 if (!sb->isGaneshBacked()) {
70 return false;
71 }
72 auto gs = static_cast<SkSurface_Ganesh*>(surface);
73 return gs->draw(ddl);
74}
static SkSurface_Base * asSB(SkSurface *surface)
bool draw(sk_sp< const GrDeferredDisplayList >)

◆ FilterAndMipmapHaveNoEffect()

std::tuple< bool, bool > skgpu::ganesh::FilterAndMipmapHaveNoEffect ( const GrQuad srcQuad,
const GrQuad dstQuad 
)

Tests if filtering will have any effect in the drawing of the 'srcQuad' to the 'dstquad'. We return false when filtering has no impact drawing operations as they are effectively blits.

Definition at line 1114 of file TextureOp.cpp.

1115 {
1116 // If not axis-aligned in src or dst, then always say it has an effect
1117 if (srcQuad.quadType() != GrQuad::Type::kAxisAligned ||
1118 dstQuad.quadType() != GrQuad::Type::kAxisAligned) {
1119 return {true, true};
1120 }
1121
1122 SkRect srcRect;
1123 SkRect dstRect;
1124 if (srcQuad.asRect(&srcRect) && dstQuad.asRect(&dstRect)) {
1125 // Disable filtering when there is no scaling (width and height are the same), and the
1126 // top-left corners have the same fraction (so src and dst snap to the pixel grid
1127 // identically).
1128 SkASSERT(srcRect.isSorted());
1129 bool filter = srcRect.width() != dstRect.width() || srcRect.height() != dstRect.height() ||
1130 SkScalarFraction(srcRect.fLeft) != SkScalarFraction(dstRect.fLeft) ||
1131 SkScalarFraction(srcRect.fTop) != SkScalarFraction(dstRect.fTop);
1132 bool mm = srcRect.width() > dstRect.width() || srcRect.height() > dstRect.height();
1133 return {filter, mm};
1134 }
1135 // Extract edge lengths
1136 SkSize srcSize = axis_aligned_quad_size(srcQuad);
1137 SkSize dstSize = axis_aligned_quad_size(dstQuad);
1138 // Although the quads are axis-aligned, the local coordinate system is transformed such
1139 // that fractionally-aligned sample centers will not align with the device coordinate system
1140 // So disable filtering when edges are the same length and both srcQuad and dstQuad
1141 // 0th vertex is integer aligned.
1142 bool filter = srcSize != dstSize || !SkScalarIsInt(srcQuad.x(0)) ||
1143 !SkScalarIsInt(srcQuad.y(0)) || !SkScalarIsInt(dstQuad.x(0)) ||
1144 !SkScalarIsInt(dstQuad.y(0));
1145 bool mm = srcSize.fWidth > dstSize.fWidth || srcSize.fHeight > dstSize.fHeight;
1146 return {filter, mm};
1147}
static bool SkScalarIsInt(SkScalar x)
Definition: SkScalar.h:80
static SkScalar SkScalarFraction(SkScalar x)
Definition: SkScalar.h:67
float y(int i) const
Definition: GrQuad.h:109
Type quadType() const
Definition: GrQuad.h:118
float x(int i) const
Definition: GrQuad.h:108
bool asRect(SkRect *rect) const
Definition: GrQuad.cpp:141
SkScalar fLeft
smaller x-axis bounds
Definition: extension.cpp:14
constexpr float height() const
Definition: SkRect.h:769
constexpr float width() const
Definition: SkRect.h:762
bool isSorted() const
Definition: SkRect.h:705
SkScalar fTop
smaller y-axis bounds
Definition: extension.cpp:15
Definition: SkSize.h:52
SkScalar fHeight
Definition: SkSize.h:54
SkScalar fWidth
Definition: SkSize.h:53

◆ FindOrMakeCachedMipmappedView()

GrSurfaceProxyView skgpu::ganesh::FindOrMakeCachedMipmappedView ( GrRecordingContext ,
GrSurfaceProxyView  ,
uint32_t  imageUniqueID 
)

Returns input view if it is already mipmapped. Otherwise, attempts to make a mipmapped view with the same contents. If the mipmapped copy is successfully created it will be cached using the image unique ID. A subsequent call with the same unique ID will return the cached view if it has not been purged. The view is cached with a key domain specific to this function.

Definition at line 671 of file GrImageUtils.cpp.

673 {
674 SkASSERT(rContext);
675 SkASSERT(imageUniqueID != SK_InvalidUniqueID);
676
677 if (!view || view.proxy()->asTextureProxy()->mipmapped() == skgpu::Mipmapped::kYes) {
678 return view;
679 }
680 GrProxyProvider* proxyProvider = rContext->priv().proxyProvider();
681
682 skgpu::UniqueKey baseKey;
683 GrMakeKeyFromImageID(&baseKey, imageUniqueID, SkIRect::MakeSize(view.dimensions()));
684 SkASSERT(baseKey.isValid());
685 skgpu::UniqueKey mipmappedKey;
686 static const skgpu::UniqueKey::Domain kMipmappedDomain = skgpu::UniqueKey::GenerateDomain();
687 { // No extra values beyond the domain are required. Must name the var to please
688 // clang-tidy.
689 skgpu::UniqueKey::Builder b(&mipmappedKey, baseKey, kMipmappedDomain, 0);
690 }
691 SkASSERT(mipmappedKey.isValid());
692 if (sk_sp<GrTextureProxy> cachedMippedView =
693 proxyProvider->findOrCreateProxyByUniqueKey(mipmappedKey)) {
694 return {std::move(cachedMippedView), view.origin(), view.swizzle()};
695 }
696
697 auto copy = GrCopyBaseMipMapToView(rContext, view);
698 if (!copy) {
699 return view;
700 }
701 // TODO: If we move listeners up from SkImage_Lazy to SkImage_Base then add one here.
702 proxyProvider->assignUniqueKeyToProxy(mipmappedKey, copy.asTextureProxy());
703 return copy;
704}
GrSurfaceProxyView GrCopyBaseMipMapToView(GrRecordingContext *context, GrSurfaceProxyView src, skgpu::Budgeted budgeted)
Definition: SkGr.cpp:136
void GrMakeKeyFromImageID(skgpu::UniqueKey *key, uint32_t imageID, const SkIRect &imageBounds)
Definition: SkGr.cpp:60
static void copy(void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
Definition: SkSwizzler.cpp:31
static constexpr uint32_t SK_InvalidUniqueID
Definition: SkTypes.h:196
bool assignUniqueKeyToProxy(const skgpu::UniqueKey &, GrTextureProxy *)
sk_sp< GrTextureProxy > findOrCreateProxyByUniqueKey(const skgpu::UniqueKey &, UseAllocator=UseAllocator::kYes)
GrProxyProvider * proxyProvider()
skgpu::Swizzle swizzle() const
SkISize dimensions() const
GrSurfaceOrigin origin() const
GrSurfaceProxy * proxy() const
virtual GrTextureProxy * asTextureProxy()
skgpu::Mipmapped mipmapped() const
bool isValid() const
Definition: ResourceKey.h:55
static Domain GenerateDomain()
Definition: ResourceKey.cpp:27
static bool b
Definition: copy.py:1
static constexpr SkIRect MakeSize(const SkISize &size)
Definition: SkRect.h:66

◆ Flush() [1/2]

GrSemaphoresSubmitted skgpu::ganesh::Flush ( sk_sp< SkSurface surface)

Definition at line 787 of file SkSurface_Ganesh.cpp.

787 {
788 if (!surface) {
790 }
791 if (auto rContext = surface->recordingContext(); rContext != nullptr) {
792 return rContext->asDirectContext()->flush(surface.get(), {});
793 }
795}

◆ Flush() [2/2]

GrSemaphoresSubmitted skgpu::ganesh::Flush ( SkSurface surface)

Definition at line 777 of file SkSurface_Ganesh.cpp.

777 {
778 if (!surface) {
780 }
781 if (auto rContext = surface->recordingContext(); rContext != nullptr) {
782 return rContext->asDirectContext()->flush(surface, {});
783 }
785}

◆ FlushAndSubmit() [1/2]

void skgpu::ganesh::FlushAndSubmit ( sk_sp< SkSurface surface)

Definition at line 806 of file SkSurface_Ganesh.cpp.

806 {
807 if (!surface) {
808 return;
809 }
810 if (auto rContext = surface->recordingContext(); rContext != nullptr) {
811 rContext->asDirectContext()->flushAndSubmit(surface.get(), GrSyncCpu::kNo);
812 }
813}

◆ FlushAndSubmit() [2/2]

void skgpu::ganesh::FlushAndSubmit ( SkSurface surface)

Definition at line 797 of file SkSurface_Ganesh.cpp.

797 {
798 if (!surface) {
799 return;
800 }
801 if (auto rContext = surface->recordingContext(); rContext != nullptr) {
802 rContext->asDirectContext()->flushAndSubmit(surface, GrSyncCpu::kNo);
803 }
804}

◆ generate_picture_texture()

static GrSurfaceProxyView skgpu::ganesh::generate_picture_texture ( GrRecordingContext ctx,
const SkImage_Picture img,
skgpu::Mipmapped  mipmapped,
GrImageTexGenPolicy  texGenPolicy 
)
static

Definition at line 242 of file GrImageUtils.cpp.

245 {
246 SkASSERT(ctx);
247 SkASSERT(img);
248
253 budgeted,
254 img->imageInfo(),
255 0,
257 img->props(),
258 mipmapped == skgpu::Mipmapped::kYes);
259 if (!surface) {
260 return {};
261 }
262
263 img->replay(surface->getCanvas());
264
265 sk_sp<SkImage> image(surface->makeImageSnapshot());
266 if (!image) {
267 return {};
268 }
269
270 auto [view, ct] = AsView(ctx, image, mipmapped);
271 SkASSERT(view);
272 SkASSERT(mipmapped == skgpu::Mipmapped::kNo ||
273 view.asTextureProxy()->mipmapped() == skgpu::Mipmapped::kYes);
274 return view;
275}
@ kTopLeft_GrSurfaceOrigin
Definition: GrTypes.h:148
const SkSurfaceProps * props() const
void replay(SkCanvas *) const
const SkImageInfo & imageInfo() const
Definition: SkImage.h:279
sk_sp< const SkImage > image
Definition: SkRecords.h:269
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)

◆ get_clip_bounds()

static SkIRect skgpu::ganesh::get_clip_bounds ( const SurfaceDrawContext sdc,
const GrClip clip 
)
static

Definition at line 1585 of file SurfaceDrawContext.cpp.

1585 {
1586 return clip ? clip->getConservativeBounds() : SkIRect::MakeWH(sdc->width(), sdc->height());
1587}
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition: SkPath.cpp:3892
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
Definition: SkRect.h:56

◆ get_origin()

static GrSurfaceOrigin skgpu::ganesh::get_origin ( const SkImage_Lazy img)
static

Definition at line 142 of file GrImageUtils.cpp.

142 {
143 SkASSERT(img->generator());
144 if (!img->generator()->isTextureGenerator()) {
146 }
147 // origin should be thread safe
148 return static_cast<const GrTextureGenerator*>(img->generator()->fGenerator.get())->origin();
149}
std::unique_ptr< SkImageGenerator > fGenerator
Definition: SkImage_Lazy.h:117
bool isTextureGenerator()
sk_sp< SharedGenerator > generator() const

◆ kMarkStencil()

static constexpr GrUserStencilSettings skgpu::ganesh::kMarkStencil ( GrUserStencilSettings::StaticInit< 0x0001, GrUserStencilTest::kLessIfInClip, 0x0000, GrUserStencilOp::kZero, GrUserStencilOp::kReplace, 0xffff >  ())
staticconstexpr

◆ kTestAndResetStencil()

static constexpr GrUserStencilSettings skgpu::ganesh::kTestAndResetStencil ( GrUserStencilSettings::StaticInit< 0x0000, GrUserStencilTest::kLessIfInClip, 0x0001, GrUserStencilOp::kZero, GrUserStencilOp::kReplace, 0xffff >  ())
staticconstexpr

◆ lazy_as_view()

static std::tuple< GrSurfaceProxyView, GrColorType > skgpu::ganesh::lazy_as_view ( GrRecordingContext context,
const SkImage_Lazy img,
skgpu::Mipmapped  mipmapped,
GrImageTexGenPolicy  policy 
)
static

Definition at line 411 of file GrImageUtils.cpp.

414 {
415 GrColorType ct = ColorTypeOfLockTextureProxy(context->priv().caps(), img->colorType());
416 return {LockTextureProxyView(context, img, policy, mipmapped), ct};
417}
SkColorType colorType() const
Definition: SkImage.cpp:152
GrColorType ColorTypeOfLockTextureProxy(const GrCaps *caps, SkColorType sct)
GrSurfaceProxyView LockTextureProxyView(GrRecordingContext *rContext, const SkImage_Lazy *img, GrImageTexGenPolicy texGenPolicy, skgpu::Mipmapped mipmapped)

◆ LockTextureProxyView()

GrSurfaceProxyView skgpu::ganesh::LockTextureProxyView ( GrRecordingContext rContext,
const SkImage_Lazy img,
GrImageTexGenPolicy  texGenPolicy,
skgpu::Mipmapped  mipmapped 
)

Definition at line 284 of file GrImageUtils.cpp.

287 {
288 // Values representing the various texture lock paths we can take. Used for logging the path
289 // taken to a histogram.
290 enum LockTexturePath {
291 kFailure_LockTexturePath,
292 kPreExisting_LockTexturePath,
293 kNative_LockTexturePath,
294 kCompressed_LockTexturePath, // Deprecated
295 kYUV_LockTexturePath,
296 kRGBA_LockTexturePath,
297 };
298
299 enum { kLockTexturePathCount = kRGBA_LockTexturePath + 1 };
300
302 if (texGenPolicy == GrImageTexGenPolicy::kDraw) {
304 }
305
306 const GrCaps* caps = rContext->priv().caps();
307 GrProxyProvider* proxyProvider = rContext->priv().proxyProvider();
308
309 auto installKey = [&](const GrSurfaceProxyView& view) {
310 SkASSERT(view && view.asTextureProxy());
311 if (key.isValid()) {
312 auto listener = GrMakeUniqueKeyInvalidationListener(&key, rContext->priv().contextID());
313 img->addUniqueIDListener(std::move(listener));
314 proxyProvider->assignUniqueKeyToProxy(key, view.asTextureProxy());
315 }
316 };
317
318 auto ct = ColorTypeOfLockTextureProxy(caps, img->colorType());
319
320 // 1. Check the cache for a pre-existing one.
321 if (key.isValid()) {
322 auto proxy = proxyProvider->findOrCreateProxyByUniqueKey(key);
323 if (proxy) {
324 skgpu::Swizzle swizzle = caps->getReadSwizzle(proxy->backendFormat(), ct);
325 GrSurfaceOrigin origin = get_origin(img);
326 GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
327 if (mipmapped == skgpu::Mipmapped::kNo ||
328 view.asTextureProxy()->mipmapped() == skgpu::Mipmapped::kYes) {
329 return view;
330 } else {
331 // We need a mipped proxy, but we found a cached proxy that wasn't mipped. Thus we
332 // generate a new mipped surface and copy the original proxy into the base layer. We
333 // will then let the gpu generate the rest of the mips.
334 auto mippedView = GrCopyBaseMipMapToView(rContext, view);
335 if (!mippedView) {
336 // We failed to make a mipped proxy with the base copied into it. This could
337 // have been from failure to make the proxy or failure to do the copy. Thus we
338 // will fall back to just using the non mipped proxy; See skbug.com/7094.
339 return view;
340 }
341 proxyProvider->removeUniqueKeyFromProxy(view.asTextureProxy());
342 installKey(mippedView);
343 return mippedView;
344 }
345 }
346 }
347
348 // 2. Ask the generator to natively create one (if it knows how)
349 {
351 if (auto view = generate_picture_texture(rContext,
352 static_cast<const SkImage_Picture*>(img),
353 mipmapped,
354 texGenPolicy)) {
355 installKey(view);
356 return view;
357 }
358 } else if (img->generator()->isTextureGenerator()) {
359 auto sharedGenerator = img->generator();
360 SkAutoMutexExclusive mutex(sharedGenerator->fMutex);
361 auto textureGen = static_cast<GrTextureGenerator*>(sharedGenerator->fGenerator.get());
362 if (auto view = textureGen->generateTexture(rContext,
363 img->imageInfo(),
364 mipmapped,
365 texGenPolicy)) {
366 installKey(view);
367 return view;
368 }
369 }
370 }
371
372 // 3. Ask the generator to return YUV planes, which the GPU can convert. If we will be mipping
373 // the texture we skip this step so the CPU generate non-planar MIP maps for us.
374 if (mipmapped == skgpu::Mipmapped::kNo &&
375 !rContext->priv().options().fDisableGpuYUVConversion) {
376 // TODO: Update to create the mipped surface in the textureProxyViewFromPlanes generator and
377 // draw the base layer directly into the mipped surface.
381 auto view = texture_proxy_view_from_planes(rContext, img, budgeted);
382 if (view) {
383 installKey(view);
384 return view;
385 }
386 }
387
388 // 4. Ask the generator to return a bitmap, which the GPU can convert.
389 auto hint = texGenPolicy == GrImageTexGenPolicy::kDraw ? SkImage::CachingHint::kAllow_CachingHint
390 : SkImage::CachingHint::kDisallow_CachingHint;
391 if (SkBitmap bitmap; img->getROPixels(nullptr, &bitmap, hint)) {
392 // We always make an uncached bitmap here because we will cache it based on passed in policy
393 // with *our* key, not a key derived from bitmap. We're just making the proxy here.
394 auto budgeted = texGenPolicy == GrImageTexGenPolicy::kNew_Uncached_Unbudgeted
397 auto view = std::get<0>(GrMakeUncachedBitmapProxyView(rContext,
398 bitmap,
399 mipmapped,
401 budgeted));
402 if (view) {
403 installKey(view);
404 return view;
405 }
406 }
407
408 return {};
409}
GrSurfaceOrigin
Definition: GrTypes.h:147
std::tuple< GrSurfaceProxyView, GrColorType > GrMakeUncachedBitmapProxyView(GrRecordingContext *rContext, const SkBitmap &bitmap, skgpu::Mipmapped mipmapped, SkBackingFit fit, skgpu::Budgeted budgeted)
Definition: SkGr.cpp:253
sk_sp< SkIDChangeListener > GrMakeUniqueKeyInvalidationListener(skgpu::UniqueKey *key, uint32_t contextID)
Definition: SkGr.cpp:75
const GrContextOptions & options() const
uint32_t contextID() const
Definition: GrCaps.h:57
skgpu::Swizzle getReadSwizzle(const GrBackendFormat &format, GrColorType colorType) const
Definition: GrCaps.cpp:443
void removeUniqueKeyFromProxy(GrTextureProxy *)
bool getROPixels(GrDirectContext *, SkBitmap *, CachingHint) const override
void addUniqueIDListener(sk_sp< SkIDChangeListener >) const
SkImage_Base::Type type() const override
Definition: SkImage_Lazy.h:73
uint32_t uniqueID() const
Definition: SkImage.h:311
Definition: bitmap.py:1
static GrSurfaceOrigin get_origin(const SkImage_Lazy *img)
static GrSurfaceProxyView texture_proxy_view_from_planes(GrRecordingContext *ctx, const SkImage_Lazy *img, skgpu::Budgeted budgeted)
static GrSurfaceProxyView generate_picture_texture(GrRecordingContext *ctx, const SkImage_Picture *img, skgpu::Mipmapped mipmapped, GrImageTexGenPolicy texGenPolicy)

◆ make_conic_path()

static SkPath skgpu::ganesh::make_conic_path ( )
static

Definition at line 55 of file TessellateBench.cpp.

55 {
56 SkRandom rand;
58 for (int i = 0; i < kNumCubicsInChalkboard / 40; ++i) {
59 for (int j = -10; j <= 10; j++) {
60 const float x = std::ldexp(rand.nextF(), (i % 18)) / 1e3f;
61 const float w = std::ldexp(1 + rand.nextF(), j);
62 path.conicTo(111.625f * x, 308.188f * x, 764.62f * x, -435.688f * x, w);
63 }
64 }
65 return path;
66}
Definition: SkPath.h:59
float nextF()
Definition: SkRandom.h:55
double x

◆ make_cubic_path()

static SkPath skgpu::ganesh::make_cubic_path ( int  maxPow2)
static

Definition at line 44 of file TessellateBench.cpp.

44 {
45 SkRandom rand;
47 for (int i = 0; i < kNumCubicsInChalkboard/2; ++i) {
48 float x = std::ldexp(rand.nextF(), (i % maxPow2)) / 1e3f;
49 path.cubicTo(111.625f*x, 308.188f*x, 764.62f*x, -435.688f*x, 742.63f*x, 85.187f*x);
50 path.cubicTo(764.62f*x, -435.688f*x, 111.625f*x, 308.188f*x, 0, 0);
51 }
52 return path;
53}

◆ make_fp_from_view()

static std::unique_ptr< GrFragmentProcessor > skgpu::ganesh::make_fp_from_view ( GrRecordingContext rContext,
GrSurfaceProxyView  view,
SkAlphaType  at,
SkSamplingOptions  sampling,
const SkTileMode  tileModes[2],
const SkMatrix m,
const SkRect subset,
const SkRect domain 
)
static

Definition at line 449 of file GrImageUtils.cpp.

456 {
457 if (!view) {
458 return nullptr;
459 }
460 const GrCaps& caps = *rContext->priv().caps();
461 auto wmx = SkTileModeToWrapMode(tileModes[0]);
462 auto wmy = SkTileModeToWrapMode(tileModes[1]);
463 if (sampling.useCubic) {
464 if (subset) {
465 if (domain) {
466 return GrBicubicEffect::MakeSubset(std::move(view),
467 at,
468 m,
469 wmx,
470 wmy,
471 *subset,
472 *domain,
475 *rContext->priv().caps());
476 }
477 return GrBicubicEffect::MakeSubset(std::move(view),
478 at,
479 m,
480 wmx,
481 wmy,
482 *subset,
485 *rContext->priv().caps());
486 }
487 return GrBicubicEffect::Make(std::move(view),
488 at,
489 m,
490 wmx,
491 wmy,
494 *rContext->priv().caps());
495 }
496 if (sampling.isAniso()) {
497 if (!rContext->priv().caps()->anisoSupport()) {
498 // Fallback to linear
500 }
501 } else if (view.mipmapped() == skgpu::Mipmapped::kNo) {
503 }
504 GrSamplerState sampler;
505 if (sampling.isAniso()) {
506 sampler = GrSamplerState::Aniso(wmx, wmy, sampling.maxAniso, view.mipmapped());
507 } else {
508 sampler = GrSamplerState(wmx, wmy, sampling.filter, sampling.mipmap);
509 }
510 if (subset) {
511 if (domain) {
513 std::move(view), at, m, sampler, *subset, *domain, caps);
514 }
515 return GrTextureEffect::MakeSubset(std::move(view), at, m, sampler, *subset, caps);
516 } else {
517 return GrTextureEffect::Make(std::move(view), at, m, sampler, caps);
518 }
519}
static constexpr GrSamplerState::WrapMode SkTileModeToWrapMode(SkTileMode tileMode)
Definition: SkGr.h:77
static std::unique_ptr< GrFragmentProcessor > Make(GrSurfaceProxyView view, SkAlphaType, const SkMatrix &, SkCubicResampler, Direction)
static std::unique_ptr< GrFragmentProcessor > MakeSubset(GrSurfaceProxyView view, SkAlphaType, const SkMatrix &, const GrSamplerState::WrapMode wrapX, const GrSamplerState::WrapMode wrapY, const SkRect &subset, SkCubicResampler, Direction, const GrCaps &)
bool anisoSupport() const
Definition: GrCaps.h:74
static constexpr GrSamplerState Aniso(WrapMode wrapX, WrapMode wrapY, int maxAniso, skgpu::Mipmapped viewIsMipped)
skgpu::Mipmapped mipmapped() const
static std::unique_ptr< GrFragmentProcessor > MakeSubset(GrSurfaceProxyView, SkAlphaType, const SkMatrix &, GrSamplerState, const SkRect &subset, const GrCaps &caps, const float border[4]=kDefaultBorder, bool alwaysUseShaderTileMode=false)
static std::unique_ptr< GrFragmentProcessor > Make(GrSurfaceProxyView, SkAlphaType, const SkMatrix &=SkMatrix::I(), GrSamplerState::Filter=GrSamplerState::Filter::kNearest, GrSamplerState::MipmapMode mipmapMode=GrSamplerState::MipmapMode::kNone)
static SkSamplingOptions AnisoFallback(bool imageIsMipped)

◆ make_line_path()

static SkPath skgpu::ganesh::make_line_path ( int  maxPow2)
static

Definition at line 78 of file TessellateBench.cpp.

78 {
79 SkRandom rand;
81 for (int i = 0; i < kNumCubicsInChalkboard; ++i) {
82 float x = std::ldexp(rand.nextF(), (i % maxPow2)) / 1e3f;
83 path.lineTo(764.62f * x, -435.688f * x);
84 }
85 return path;
86}

◆ make_mock_context()

static sk_sp< GrDirectContext > skgpu::ganesh::make_mock_context ( )
static

Definition at line 29 of file TessellateBench.cpp.

29 {
30 GrMockOptions mockOptions;
31 mockOptions.fDrawInstancedSupport = true;
33 mockOptions.fConfigOptions[(int)GrColorType::kAlpha_8].fRenderability =
34 GrMockOptions::ConfigOptions::Renderability::kMSAA;
35 mockOptions.fConfigOptions[(int)GrColorType::kAlpha_8].fTexturable = true;
36 mockOptions.fIntegerSupport = true;
37
38 GrContextOptions ctxOptions;
39 ctxOptions.fGpuPathRenderers = GpuPathRenderers::kTessellation;
40
41 return GrDirectContext::MakeMock(&mockOptions, ctxOptions);
42}
@ kCanMap_MapFlag
Definition: GrCaps.h:199
static sk_sp< GrDirectContext > MakeMock(const GrMockOptions *, const GrContextOptions &)
uint32_t fMapBufferFlags
Definition: GrMockTypes.h:146
bool fIntegerSupport
Definition: GrMockTypes.h:155
bool fDrawInstancedSupport
Definition: GrMockTypes.h:144
ConfigOptions fConfigOptions[kGrColorTypeCnt]
Definition: GrMockTypes.h:151

◆ make_motionmark_paths()

static std::vector< PathStrokeList > skgpu::ganesh::make_motionmark_paths ( )
static

Definition at line 259 of file TessellateBench.cpp.

259 {
260 std::vector<PathStrokeList> pathStrokes;
261 SkRandom rand;
262 for (int i = 0; i < 8702; ++i) {
263 // The number of paths with a given number of verbs in the MotionMark bench gets cut in half
264 // every time the number of verbs increases by 1.
265 int numVerbs = 28 - SkNextLog2(rand.nextRangeU(0, (1 << 27) - 1));
266 SkPath path;
267 for (int j = 0; j < numVerbs; ++j) {
268 switch (rand.nextU() & 3) {
269 case 0:
270 case 1:
271 path.lineTo(rand.nextRangeF(0, 150), rand.nextRangeF(0, 150));
272 break;
273 case 2:
274 if (rand.nextULessThan(10) == 0) {
275 // Cusp.
276 auto [x, y] = (path.isEmpty())
277 ? SkPoint{0,0}
278 : SkPathPriv::PointData(path)[path.countPoints() - 1];
279 path.quadTo(x + rand.nextRangeF(0, 150), y, x - rand.nextRangeF(0, 150), y);
280 } else {
281 path.quadTo(rand.nextRangeF(0, 150), rand.nextRangeF(0, 150),
282 rand.nextRangeF(0, 150), rand.nextRangeF(0, 150));
283 }
284 break;
285 case 3:
286 if (rand.nextULessThan(10) == 0) {
287 // Cusp.
288 float y = (path.isEmpty())
289 ? 0 : SkPathPriv::PointData(path)[path.countPoints() - 1].fY;
290 path.cubicTo(rand.nextRangeF(0, 150), y, rand.nextRangeF(0, 150), y,
291 rand.nextRangeF(0, 150), y);
292 } else {
293 path.cubicTo(rand.nextRangeF(0, 150), rand.nextRangeF(0, 150),
294 rand.nextRangeF(0, 150), rand.nextRangeF(0, 150),
295 rand.nextRangeF(0, 150), rand.nextRangeF(0, 150));
296 }
297 break;
298 }
299 }
301 // The number of paths with a given stroke width in the MotionMark bench gets cut in half
302 // every time the stroke width increases by 1.
303 float strokeWidth = 21 - log2f(rand.nextRangeF(0, 1 << 20));
304 stroke.setStrokeStyle(strokeWidth);
306 pathStrokes.emplace_back(path, stroke, SK_PMColor4fWHITE);
307 }
308 return pathStrokes;
309}
static const int strokeWidth
Definition: BlurTest.cpp:60
constexpr SkPMColor4f SK_PMColor4fWHITE
Definition: SkColorData.h:380
static int SkNextLog2(uint32_t value)
Definition: SkMathPriv.h:238
@ kButt_Cap
no stroke extension
Definition: SkPaint.h:334
@ kBevel_Join
connects outside edges
Definition: SkPaint.h:361
static const SkPoint * PointData(const SkPath &path)
Definition: SkPathPriv.h:203
uint32_t nextU()
Definition: SkRandom.h:42
uint32_t nextULessThan(uint32_t count)
Definition: SkRandom.h:93
float nextRangeF(float min, float max)
Definition: SkRandom.h:64
uint32_t nextRangeU(uint32_t min, uint32_t max)
Definition: SkRandom.h:80
double y
float fY
y-axis value
Definition: SkPoint_impl.h:165

◆ make_quad_path()

static SkPath skgpu::ganesh::make_quad_path ( int  maxPow2)
static

Definition at line 68 of file TessellateBench.cpp.

68 {
69 SkRandom rand;
71 for (int i = 0; i < kNumCubicsInChalkboard; ++i) {
72 float x = std::ldexp(rand.nextF(), (i % maxPow2)) / 1e3f;
73 path.quadTo(111.625f * x, 308.188f * x, 764.62f * x, -435.688f * x);
74 }
75 return path;
76}

◆ make_simple_cubic_path()

static std::vector< PathStrokeList > skgpu::ganesh::make_simple_cubic_path ( )
static

Definition at line 246 of file TessellateBench.cpp.

246 {
247 auto path = SkPath().moveTo(0, 0);
248 for (int i = 0; i < kNumCubicsInChalkboard/2; ++i) {
249 path.cubicTo(100, 0, 50, 100, 100, 100);
250 path.cubicTo(0, -100, 200, 100, 0, 0);
251 }
253 stroke.setStrokeStyle(8);
255 return {{path, stroke, SK_PMColor4fWHITE}};
256}
@ kMiter_Join
extends to miter limit
Definition: SkPaint.h:359
SkPath & moveTo(SkScalar x, SkScalar y)
Definition: SkPath.cpp:688

◆ MakeFragmentProcessorFromView()

std::unique_ptr< GrFragmentProcessor > skgpu::ganesh::MakeFragmentProcessorFromView ( GrRecordingContext rContext,
GrSurfaceProxyView  view,
SkAlphaType  at,
SkSamplingOptions  sampling,
const SkTileMode  tileModes[2],
const SkMatrix m,
const SkRect subset,
const SkRect domain 
)

Definition at line 588 of file GrImageUtils.cpp.

596 {
597 if (!view) {
598 return nullptr;
599 }
600 const GrCaps& caps = *rContext->priv().caps();
601 auto wmx = SkTileModeToWrapMode(tileModes[0]);
602 auto wmy = SkTileModeToWrapMode(tileModes[1]);
603 if (sampling.useCubic) {
604 if (subset) {
605 if (domain) {
606 return GrBicubicEffect::MakeSubset(std::move(view),
607 at,
608 m,
609 wmx,
610 wmy,
611 *subset,
612 *domain,
615 *rContext->priv().caps());
616 }
617 return GrBicubicEffect::MakeSubset(std::move(view),
618 at,
619 m,
620 wmx,
621 wmy,
622 *subset,
625 *rContext->priv().caps());
626 }
627 return GrBicubicEffect::Make(std::move(view),
628 at,
629 m,
630 wmx,
631 wmy,
634 *rContext->priv().caps());
635 }
636 if (sampling.isAniso()) {
637 if (!rContext->priv().caps()->anisoSupport()) {
638 // Fallback to linear
640 }
641 } else if (view.mipmapped() == skgpu::Mipmapped::kNo) {
643 }
644 GrSamplerState sampler;
645 if (sampling.isAniso()) {
646 sampler = GrSamplerState::Aniso(wmx, wmy, sampling.maxAniso, view.mipmapped());
647 } else {
648 sampler = GrSamplerState(wmx, wmy, sampling.filter, sampling.mipmap);
649 }
650 if (subset) {
651 if (domain) {
652 return GrTextureEffect::MakeSubset(std::move(view),
653 at,
654 m,
655 sampler,
656 *subset,
657 *domain,
658 caps);
659 }
660 return GrTextureEffect::MakeSubset(std::move(view),
661 at,
662 m,
663 sampler,
664 *subset,
665 caps);
666 } else {
667 return GrTextureEffect::Make(std::move(view), at, m, sampler, caps);
668 }
669}

◆ PinAsTexture()

bool skgpu::ganesh::PinAsTexture ( GrRecordingContext rContext,
SkImage img 
)

Will attempt to upload and lock the contents of the image as a texture, so that subsequent draws to a gpu-target will come from that texture (and not by looking at the original image src). In particular this is intended to use the texture even if the image's original content changes subsequent to this call (i.e. the src is mutable!).

Only compatible with SkImages created from SkImages::PinnableRasterFromBitmap.

All successful calls must be balanced by an equal number of calls to UnpinTexture().

Once in this "pinned" state, the image has all of the same thread restrictions that exist for a natively created gpu image (e.g. SkImage::MakeFromTexture)

  • all drawing, pinning, unpinning must happen in the same thread as the GrContext.
Returns
true if the image was successfully uploaded and locked into a texture

Definition at line 66 of file SkImage_RasterPinnable.cpp.

66 {
67 auto ib = as_IB(img);
68 if (ib->type() != SkImage_Base::Type::kRasterPinnable) {
69 // Cannot pin images which are not of subclass SkImage_RasterPinnable
70 return false;
71 }
72 auto raster = static_cast<SkImage_RasterPinnable*>(ib);
73 if (!raster->fPinnedData) {
74 auto data = std::make_unique<PinnedData>();
75 std::tie(data->fPinnedView, data->fPinnedColorType) =
77 raster->bitmap(),
78 /*label=*/"ganesh_PinAsTexture",
80 if (!data->fPinnedView) {
81 return false;
82 }
83 data->fPinnedUniqueID = raster->bitmap().getGenerationID();
84 data->fPinnedContextID = rContext->priv().contextID();
85 raster->fPinnedData.swap(data);
86 } else {
87 SkASSERT(raster->fPinnedData->fPinnedCount > 0);
88 SkASSERT(raster->fPinnedData->fPinnedUniqueID != 0);
89 if (rContext->priv().contextID() != raster->fPinnedData->fPinnedContextID) {
90 return false;
91 }
92 }
93 // Note: we only increment if the texture was successfully pinned
94 raster->fPinnedData->fPinnedCount++;
95 return true;
96}
std::tuple< GrSurfaceProxyView, GrColorType > GrMakeCachedBitmapProxyView(GrRecordingContext *rContext, const SkBitmap &bitmap, std::string_view label, skgpu::Mipmapped mipmapped)
Definition: SkGr.cpp:188
static SkImage_Base * as_IB(SkImage *image)
Definition: SkImage_Base.h:201
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ raster_as_fp()

std::unique_ptr< GrFragmentProcessor > skgpu::ganesh::raster_as_fp ( GrRecordingContext rContext,
const SkImage_Raster img,
SkSamplingOptions  sampling,
const SkTileMode  tileModes[2],
const SkMatrix m,
const SkRect subset,
const SkRect domain 
)

Definition at line 521 of file GrImageUtils.cpp.

527 {
528 auto mm =
530 return make_fp_from_view(rContext,
531 std::get<0>(AsView(rContext, img, mm)),
532 img->alphaType(),
533 sampling,
534 tileModes,
535 m,
536 subset,
537 domain);
538}
static std::unique_ptr< GrFragmentProcessor > make_fp_from_view(GrRecordingContext *rContext, GrSurfaceProxyView view, SkAlphaType at, SkSamplingOptions sampling, const SkTileMode tileModes[2], const SkMatrix &m, const SkRect *subset, const SkRect *domain)

◆ RasterAsView()

std::tuple< GrSurfaceProxyView, GrColorType > skgpu::ganesh::RasterAsView ( GrRecordingContext rContext,
const SkImage_Raster raster,
skgpu::Mipmapped  mipmapped,
GrImageTexGenPolicy  policy 
)

Definition at line 105 of file GrImageUtils.cpp.

108 {
110 // If the draw doesn't require mipmaps but this SkImage has them go ahead and make a
111 // mipmapped texture. There are three reasons for this:
112 // 1) Avoiding another texture creation if a later draw requires mipmaps.
113 // 2) Ensuring we upload the bitmap's levels instead of generating on the GPU from the base.
114 if (raster->hasMipmaps()) {
115 mipmapped = skgpu::Mipmapped::kYes;
116 }
117 return GrMakeCachedBitmapProxyView(rContext,
118 raster->bitmap(),
119 /*label=*/"TextureForImageRasterWithPolicyEqualKDraw",
120 mipmapped);
121 }
126 rContext, raster->bitmap(), mipmapped, SkBackingFit::kExact, budgeted);
127}
SkBitmap bitmap() const
bool hasMipmaps() const
Definition: SkImage.cpp:292

◆ SKGPU_DECLARE_STATIC_UNIQUE_KEY() [1/7]

skgpu::ganesh::SKGPU_DECLARE_STATIC_UNIQUE_KEY ( gFixedCountCurveIndexBufferKey  )

◆ SKGPU_DECLARE_STATIC_UNIQUE_KEY() [2/7]

skgpu::ganesh::SKGPU_DECLARE_STATIC_UNIQUE_KEY ( gFixedCountCurveVertexBufferKey  )

◆ SKGPU_DECLARE_STATIC_UNIQUE_KEY() [3/7]

skgpu::ganesh::SKGPU_DECLARE_STATIC_UNIQUE_KEY ( gFixedCountWedgesIndexBufferKey  )

◆ SKGPU_DECLARE_STATIC_UNIQUE_KEY() [4/7]

skgpu::ganesh::SKGPU_DECLARE_STATIC_UNIQUE_KEY ( gFixedCountWedgesVertexBufferKey  )

◆ SKGPU_DECLARE_STATIC_UNIQUE_KEY() [5/7]

skgpu::ganesh::SKGPU_DECLARE_STATIC_UNIQUE_KEY ( gHullVertexBufferKey  )

◆ SKGPU_DECLARE_STATIC_UNIQUE_KEY() [6/7]

skgpu::ganesh::SKGPU_DECLARE_STATIC_UNIQUE_KEY ( gUnitQuadBufferKey  )

◆ SKGPU_DECLARE_STATIC_UNIQUE_KEY() [7/7]

skgpu::ganesh::SKGPU_DECLARE_STATIC_UNIQUE_KEY ( gVertexIDFallbackBufferKey  )

◆ SupportedTextureFormats()

SkYUVAPixmapInfo::SupportedDataTypes skgpu::ganesh::SupportedTextureFormats ( const GrImageContext )

Init based on texture formats supported by the context.

Definition at line 708 of file GrImageUtils.cpp.

708 {
710 const auto isValid = [&context](DataType dt, int n) {
712 GrRenderable::kNo).isValid();
713 };
714 for (int n = 1; n <= 4; ++n) {
715 if (isValid(DataType::kUnorm8, n)) {
716 dataTypes.enableDataType(DataType::kUnorm8, n);
717 }
718 if (isValid(DataType::kUnorm16, n)) {
719 dataTypes.enableDataType(DataType::kUnorm16, n);
720 }
721 if (isValid(DataType::kFloat16, n)) {
722 dataTypes.enableDataType(DataType::kFloat16, n);
723 }
724 if (isValid(DataType::kUnorm10_Unorm2, n)) {
725 dataTypes.enableDataType(DataType::kUnorm10_Unorm2, n);
726 }
727 }
728 return dataTypes;
729}
SK_API GrBackendFormat defaultBackendFormat(SkColorType, GrRenderable) const
void enableDataType(DataType, int numChannels)
static constexpr SkColorType DefaultColorTypeForDataType(DataType dataType, int numChannels)

◆ texture_proxy_view_from_planes()

static GrSurfaceProxyView skgpu::ganesh::texture_proxy_view_from_planes ( GrRecordingContext ctx,
const SkImage_Lazy img,
skgpu::Budgeted  budgeted 
)
static

Definition at line 152 of file GrImageUtils.cpp.

154 {
155 auto supportedDataTypes = SupportedTextureFormats(*ctx);
156 SkYUVAPixmaps yuvaPixmaps;
157 sk_sp<SkCachedData> dataStorage = img->getPlanes(supportedDataTypes, &yuvaPixmaps);
158 if (!dataStorage) {
159 return {};
160 }
161
163 GrColorType pixmapColorTypes[SkYUVAInfo::kMaxPlanes];
164 for (int i = 0; i < yuvaPixmaps.numPlanes(); ++i) {
165 // If the sizes of the components are not all the same we choose to create exact-match
166 // textures for the smaller ones rather than add a texture domain to the draw.
167 // TODO: revisit this decision to improve texture reuse?
168 SkBackingFit fit = yuvaPixmaps.plane(i).dimensions() == img->dimensions()
171
172 // We grab a ref to cached yuv data. When the SkBitmap we create below goes away it will
173 // call releaseProc which will release this ref.
174 // DDL TODO: Currently we end up creating a lazy proxy that will hold onto a ref to the
175 // SkImage in its lambda. This means that we'll keep the ref on the YUV data around for the
176 // life time of the proxy and not just upload. For non-DDL draws we should look into
177 // releasing this SkImage after uploads (by deleting the lambda after instantiation).
178 auto releaseProc = [](void*, void* data) {
179 auto cachedData = static_cast<SkCachedData*>(data);
180 SkASSERT(cachedData);
181 cachedData->unref();
182 };
184 bitmap.installPixels(yuvaPixmaps.plane(i).info(),
185 yuvaPixmaps.plane(i).writable_addr(),
186 yuvaPixmaps.plane(i).rowBytes(),
188 SkRef(dataStorage.get()));
189 bitmap.setImmutable();
190
191 std::tie(views[i], std::ignore) =
193 if (!views[i]) {
194 return {};
195 }
196 pixmapColorTypes[i] = SkColorTypeToGrColorType(bitmap.colorType());
197 }
198
199 // TODO: investigate preallocating mip maps here
202 /*color space*/ nullptr,
203 img->dimensions());
204
205 auto sfc = ctx->priv().makeSFC(info,
206 "ImageLazy_TextureProxyViewFromPlanes",
208 1,
212 budgeted);
213 if (!sfc) {
214 return {};
215 }
216
217 GrYUVATextureProxies yuvaProxies(yuvaPixmaps.yuvaInfo(), views, pixmapColorTypes);
218 SkAssertResult(yuvaProxies.isValid());
219
220 std::unique_ptr<GrFragmentProcessor> fp = GrYUVtoRGBEffect::Make(
221 yuvaProxies,
223 *ctx->priv().caps());
224
225 // The pixels after yuv->rgb will be in the generator's color space.
226 // If onMakeColorTypeAndColorSpace has been called then this will not match this image's
227 // color space. To correct this, apply a color space conversion from the generator's color
228 // space to this image's color space.
229 SkColorSpace* srcColorSpace = img->generator()->getInfo().colorSpace();
230 SkColorSpace* dstColorSpace = img->colorSpace();
231
232 // If the caller expects the pixels in a different color space than the one from the image,
233 // apply a color conversion to do this.
235 srcColorSpace, kOpaque_SkAlphaType,
236 dstColorSpace, kOpaque_SkAlphaType);
237 sfc->fillWithFP(std::move(fp));
238
239 return sfc->readSurfaceView();
240}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
@ kOpaque_SkAlphaType
pixel is opaque
Definition: SkAlphaType.h:28
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
SkBackingFit
Definition: SkBackingFit.h:16
static void releaseProc(const void *ptr, void *context)
static T * SkRef(T *obj)
Definition: SkRefCnt.h:132
static std::unique_ptr< GrFragmentProcessor > Make(std::unique_ptr< GrFragmentProcessor > child, SkColorSpace *src, SkAlphaType srcAT, SkColorSpace *dst, SkAlphaType dstAT)
std::unique_ptr< skgpu::ganesh::SurfaceFillContext > makeSFC(GrImageInfo, std::string_view label, SkBackingFit=SkBackingFit::kExact, int sampleCount=1, skgpu::Mipmapped=skgpu::Mipmapped::kNo, skgpu::Protected=skgpu::Protected::kNo, GrSurfaceOrigin=kTopLeft_GrSurfaceOrigin, skgpu::Budgeted=skgpu::Budgeted::kYes)
static std::unique_ptr< GrFragmentProcessor > Make(const GrYUVATextureProxies &yuvaProxies, GrSamplerState samplerState, const GrCaps &, const SkMatrix &localMatrix=SkMatrix::I(), const SkRect *subset=nullptr, const SkRect *domain=nullptr)
const SkImageInfo & getInfo() const
sk_sp< SkCachedData > getPlanes(const SkYUVAPixmapInfo::SupportedDataTypes &supportedDataTypes, SkYUVAPixmaps *pixmaps) const
SkColorSpace * colorSpace() const
Definition: SkImage.cpp:156
size_t rowBytes() const
Definition: SkPixmap.h:145
const SkImageInfo & info() const
Definition: SkPixmap.h:135
void * writable_addr() const
Definition: SkPixmap.h:483
SkISize dimensions() const
Definition: SkPixmap.h:171
static constexpr int kMaxPlanes
Definition: SkYUVAInfo.h:98
const SkYUVAInfo & yuvaInfo() const
const SkPixmap & plane(int i) const
int numPlanes() const
const uint32_t fp
SkYUVAPixmapInfo::SupportedDataTypes SupportedTextureFormats(const GrImageContext &context)
SkColorSpace * colorSpace() const

◆ TopDeviceSurfaceDrawContext()

SurfaceDrawContext * skgpu::ganesh::TopDeviceSurfaceDrawContext ( const SkCanvas canvas)

Definition at line 20 of file GrCanvas.cpp.

20 {
21 if (auto gpuDevice = SkCanvasPriv::TopDevice(canvas)->asGaneshDevice()) {
22 return gpuDevice->surfaceDrawContext();
23 }
24 return nullptr;
25}
static SkDevice * TopDevice(const SkCanvas *canvas)
Definition: SkCanvasPriv.h:65

◆ TopDeviceSurfaceFillContext()

SurfaceFillContext * skgpu::ganesh::TopDeviceSurfaceFillContext ( const SkCanvas canvas)

Definition at line 27 of file GrCanvas.cpp.

27 {
28 if (auto gpuDevice = SkCanvasPriv::TopDevice(canvas)->asGaneshDevice()) {
29 return gpuDevice->surfaceFillContext();
30 }
31 return nullptr;
32}

◆ TopDeviceTargetProxy()

GrRenderTargetProxy * skgpu::ganesh::TopDeviceTargetProxy ( const SkCanvas canvas)

Definition at line 34 of file GrCanvas.cpp.

34 {
35 if (auto gpuDevice = SkCanvasPriv::TopDevice(canvas)->asGaneshDevice()) {
36 return gpuDevice->targetProxy();
37 }
38 return nullptr;
39}

◆ TopLayerBackendRenderTarget()

GrBackendRenderTarget skgpu::ganesh::TopLayerBackendRenderTarget ( const SkCanvas canvas)

Definition at line 45 of file GrCanvas.cpp.

45 {
46 auto proxy = TopDeviceTargetProxy(canvas);
47 if (!proxy) {
48 return {};
49 }
50 const GrRenderTarget* renderTarget = proxy->peekRenderTarget();
51 return renderTarget ? renderTarget->getBackendRenderTarget() : GrBackendRenderTarget();
52}
virtual GrBackendRenderTarget getBackendRenderTarget() const =0
GrRenderTargetProxy * TopDeviceTargetProxy(const SkCanvas *canvas)
Definition: GrCanvas.cpp:34

◆ TopLayerBounds()

SkIRect skgpu::ganesh::TopLayerBounds ( const SkCanvas canvas)

Definition at line 41 of file GrCanvas.cpp.

41 {
43}
void getGlobalBounds(SkIRect *bounds) const
Definition: SkDevice.h:225

◆ UnpinTexture()

void skgpu::ganesh::UnpinTexture ( GrRecordingContext ,
SkImage img 
)

The balancing call to a successful invocation of PinAsTexture. When a balanced number of calls have been made, then the "pinned" texture is free to be purged, etc. This also means that a subsequent "pin" call will look at the original content again, and if its uniqueID/generationID has changed, then a newer texture will be uploaded/pinned.

Only compatible with SkImages created from SkImages::PinnableRasterFromBitmap.

The context passed to unpin must match the one passed to pin.

Definition at line 98 of file SkImage_RasterPinnable.cpp.

98 {
99 auto ib = as_IB(img);
100 if (ib->type() != SkImage_Base::Type::kRasterPinnable) {
101 // Cannot pin images which are not of subclass SkImage_RasterPinnable
102 return;
103 }
104 auto raster = static_cast<SkImage_RasterPinnable*>(ib);
105 if (!raster->fPinnedData) {
106 SkASSERT(false);
107 return;
108 }
109
110 SkASSERT(raster->fPinnedData->fPinnedCount > 0);
111 SkASSERT(raster->fPinnedData->fPinnedUniqueID != 0);
112 // It would be good to check rContext->priv().contextID() != fPinnedContextID
113 // but Android used to (maybe still does) call Unpin with a freed context ptr
114
115 raster->fPinnedData->fPinnedCount--;
116 if (raster->fPinnedData->fPinnedCount <= 0) {
117 raster->fPinnedData.reset(nullptr);
118 }
119}

Variable Documentation

◆ gAlmostIdentity

const SkMatrix skgpu::ganesh::gAlmostIdentity
static
Initial value:
1.0001f, 0.0001f, 0.0001f,
-.0001f, 0.9999f, -.0001f,
0, 0, 1)
static SkMatrix MakeAll(SkScalar scaleX, SkScalar skewX, SkScalar transX, SkScalar skewY, SkScalar scaleY, SkScalar transY, SkScalar pers0, SkScalar pers1, SkScalar pers2)
Definition: SkMatrix.h:179

Definition at line 132 of file TessellateBench.cpp.

◆ gCache

thread_local void* skgpu::ganesh::gCache = nullptr
static

Definition at line 62 of file AtlasTextOp.cpp.

◆ GrStrokeFixedCountTessellator_one_chop

skgpu::ganesh::GrStrokeFixedCountTessellator_one_chop

Definition at line 375 of file TessellateBench.cpp.

◆ kAtlasAlgorithm

constexpr auto skgpu::ganesh::kAtlasAlgorithm = GrDynamicAtlas::RectanizerAlgorithm::kPow2
staticconstexpr

Definition at line 93 of file AtlasPathRenderer.cpp.

◆ kAtlasAlpha8Type

constexpr auto skgpu::ganesh::kAtlasAlpha8Type = GrColorType::kAlpha_8
staticconstexpr

Definition at line 87 of file AtlasPathRenderer.cpp.

◆ kAtlasInitialSize

constexpr int skgpu::ganesh::kAtlasInitialSize = 512
staticconstexpr

Definition at line 88 of file AtlasPathRenderer.cpp.

◆ kAtlasMaxPathHeight

constexpr int skgpu::ganesh::kAtlasMaxPathHeight = 256
staticconstexpr

Definition at line 96 of file AtlasPathRenderer.cpp.

◆ kAtlasMaxPathHeightWithMSAAFallback

constexpr int skgpu::ganesh::kAtlasMaxPathHeightWithMSAAFallback = 128
staticconstexpr

Definition at line 100 of file AtlasPathRenderer.cpp.

◆ kAtlasMaxPathWidth

constexpr int skgpu::ganesh::kAtlasMaxPathWidth = 1024
staticconstexpr

Definition at line 105 of file AtlasPathRenderer.cpp.

◆ kElementStackIncrement

constexpr int skgpu::ganesh::kElementStackIncrement = 8
staticconstexpr

Definition at line 1134 of file ClipStack.cpp.

◆ kIndicesPerGlyph

constexpr int skgpu::ganesh::kIndicesPerGlyph = 6
inlinestaticconstexpr

Definition at line 59 of file AtlasTextOp.cpp.

◆ kMaskStackIncrement

constexpr int skgpu::ganesh::kMaskStackIncrement = 4
staticconstexpr

Definition at line 1136 of file ClipStack.cpp.

◆ kMaxAnalyticFPs

constexpr int skgpu::ganesh::kMaxAnalyticFPs = 4
staticconstexpr

Definition at line 1141 of file ClipStack.cpp.

◆ kNumCubicsInChalkboard

constexpr int skgpu::ganesh::kNumCubicsInChalkboard = 47182
staticconstexpr

Definition at line 27 of file TessellateBench.cpp.

◆ kNumStackMasks

constexpr int skgpu::ganesh::kNumStackMasks = 4
staticconstexpr

Definition at line 1145 of file ClipStack.cpp.

◆ kSaveStackIncrement

constexpr int skgpu::ganesh::kSaveStackIncrement = 8
staticconstexpr

Definition at line 1135 of file ClipStack.cpp.

◆ kVerticesPerGlyph

constexpr int skgpu::ganesh::kVerticesPerGlyph = 4
inlinestaticconstexpr

Definition at line 58 of file AtlasTextOp.cpp.