Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 (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 701 of file GrImageUtils.cpp.

◆ DoSimplify

Definition at line 118 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};

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 *rContext, const SkImage *img, SkSamplingOptions sampling, const SkTileMode tileModes[2], const SkMatrix &m, const SkRect *subset, const SkRect *domain)

◆ 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 535 of file GrImageUtils.cpp.

541 {
542 if (!rContext) {
543 return {};
544 }
545 if (sampling.useCubic && !GrValidCubicResampler(sampling.cubic)) {
546 return {};
547 }
549 (!rContext->priv().caps()->mipmapSupport() || img->dimensions().area() <= 1)) {
551 }
552
553 auto ib = static_cast<const SkImage_Base*>(img);
554 if (ib->isRasterBacked()) {
555 return raster_as_fp(rContext,
556 static_cast<const SkImage_Raster*>(ib),
557 sampling,
558 tileModes,
559 m,
560 subset,
561 domain);
562 } else if (ib->isGaneshBacked()) {
563 auto gb = static_cast<const SkImage_GaneshBase*>(img);
564 return gb->asFragmentProcessor(rContext, sampling, tileModes, m, subset, domain);
565 } else if (ib->isLazyGenerated()) {
566 // TODO: If the CPU data is extracted as planes return a FP that reconstructs the image from
567 // the planes.
568 auto mm = sampling.mipmap == SkMipmapMode::kNone ? skgpu::Mipmapped::kNo : skgpu::Mipmapped::kYes;
569 return MakeFragmentProcessorFromView(rContext,
570 std::get<0>(AsView(rContext, img, mm)),
571 img->alphaType(),
572 sampling,
573 tileModes,
574 m,
575 subset,
576 domain);
577 }
578
579 SkDEBUGFAIL("Unsupported image type to make a FragmentProcessor");
580 return {};
581}
#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
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)
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}

◆ AsView() [2/2]

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

Definition at line 414 of file GrImageUtils.cpp.

417 {
418 SkASSERT(img);
419 if (!rContext) {
420 return {};
421 }
422 if (!rContext->priv().caps()->mipmapSupport() || img->dimensions().area() <= 1) {
423 mipmapped = skgpu::Mipmapped::kNo;
424 }
425
426 auto ib = static_cast<const SkImage_Base*>(img);
427 if (ib->type() == SkImage_Base::Type::kRaster) {
429 rContext, static_cast<const SkImage_Raster*>(ib), mipmapped, policy);
430 } else if (ib->type() == SkImage_Base::Type::kRasterPinnable) {
431 auto rp = static_cast<const SkImage_RasterPinnable*>(img);
432 return rp->asView(rContext, mipmapped, policy);
433 } else if (ib->isGaneshBacked()) {
434 auto gb = static_cast<const SkImage_GaneshBase*>(img);
435 return gb->asView(rContext, mipmapped, policy);
436 } else if (ib->isLazyGenerated()) {
437 return lazy_as_view(rContext, static_cast<const SkImage_Lazy*>(ib), mipmapped, policy);
438 }
439
440 SkDEBUGFAIL("Unsupported image type to make a View");
441 return {};
442}
#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;
191 wangs_formula::VectorXform xform(matrix);
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.
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;
205 wangs_formula::VectorXform xform(matrix);
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}

◆ 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;
163 wangs_formula::VectorXform xform(matrix);
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.

◆ ColorTypeOfLockTextureProxy()

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

Definition at line 128 of file GrImageUtils.cpp.

128 {
130 GrBackendFormat format = caps->getDefaultBackendFormat(ct, GrRenderable::kNo);
131 if (!format.isValid()) {
133 }
134 return ct;
135}
GrColorType
static constexpr GrColorType SkColorTypeToGrColorType(SkColorType ct)
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) {
94 case skgpu::ContextType::kGL:
95 case skgpu::ContextType::kGLES:
96 case skgpu::ContextType::kANGLE_D3D9_ES2:
97 case skgpu::ContextType::kANGLE_D3D11_ES2:
98 case skgpu::ContextType::kANGLE_D3D11_ES3:
99 case skgpu::ContextType::kANGLE_GL_ES2:
100 case skgpu::ContextType::kANGLE_GL_ES3:
101 case skgpu::ContextType::kANGLE_Metal_ES2:
102 case skgpu::ContextType::kANGLE_Metal_ES3:
104
105 case ContextType::kVulkan:
107
108 case ContextType::kMetal:
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

◆ CopyView()

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

Definition at line 84 of file GrImageUtils.cpp.

88 {
92 return GrSurfaceProxyView::Copy(context,
93 std::move(src),
94 mipmapped,
96 budgeted,
97 /*label=*/label);
98}
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
@ kSrcOver
r = s + (1-sa)*d
int countVerbs() const
Definition SkPath.cpp:546
static constexpr Swizzle RGBA()
Definition Swizzle.h:66

◆ 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);
235 tess::AffineMatrix m(gAlmostIdentity);
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}
static const uint8_t buffer[]
static constexpr int kNumCubicsInChalkboard

◆ 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.

185 {
187}

◆ 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.

180 {
182}

◆ 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
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 666 of file GrImageUtils.cpp.

668 {
669 SkASSERT(rContext);
670 SkASSERT(imageUniqueID != SK_InvalidUniqueID);
671
672 if (!view || view.proxy()->asTextureProxy()->mipmapped() == skgpu::Mipmapped::kYes) {
673 return view;
674 }
675 GrProxyProvider* proxyProvider = rContext->priv().proxyProvider();
676
677 skgpu::UniqueKey baseKey;
678 GrMakeKeyFromImageID(&baseKey, imageUniqueID, SkIRect::MakeSize(view.dimensions()));
679 SkASSERT(baseKey.isValid());
680 skgpu::UniqueKey mipmappedKey;
681 static const skgpu::UniqueKey::Domain kMipmappedDomain = skgpu::UniqueKey::GenerateDomain();
682 { // No extra values beyond the domain are required. Must name the var to please
683 // clang-tidy.
684 skgpu::UniqueKey::Builder b(&mipmappedKey, baseKey, kMipmappedDomain, 0);
685 }
686 SkASSERT(mipmappedKey.isValid());
687 if (sk_sp<GrTextureProxy> cachedMippedView =
688 proxyProvider->findOrCreateProxyByUniqueKey(mipmappedKey)) {
689 return {std::move(cachedMippedView), view.origin(), view.swizzle()};
690 }
691
692 auto copy = GrCopyBaseMipMapToView(rContext, view);
693 if (!copy) {
694 return view;
695 }
696 // TODO: If we move listeners up from SkImage_Lazy to SkImage_Base then add one here.
697 proxyProvider->assignUniqueKeyToProxy(mipmappedKey, copy.asTextureProxy());
698 return copy;
699}
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 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()
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 237 of file GrImageUtils.cpp.

240 {
241 SkASSERT(ctx);
242 SkASSERT(img);
243
248 budgeted,
249 img->imageInfo(),
250 0,
252 img->props(),
253 mipmapped == skgpu::Mipmapped::kYes);
254 if (!surface) {
255 return {};
256 }
257
258 img->replay(surface->getCanvas());
259
260 sk_sp<SkImage> image(surface->makeImageSnapshot());
261 if (!image) {
262 return {};
263 }
264
265 auto [view, ct] = AsView(ctx, image, mipmapped);
266 SkASSERT(view);
267 SkASSERT(mipmapped == skgpu::Mipmapped::kNo ||
268 view.asTextureProxy()->mipmapped() == skgpu::Mipmapped::kYes);
269 return view;
270}
@ kTopLeft_GrSurfaceOrigin
Definition GrTypes.h:148
const SkSurfaceProps * props() const
void replay(SkCanvas *) const
const SkImageInfo & imageInfo() const
Definition SkImage.h:279
sk_sp< SkImage > image
Definition examples.cpp:29
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:3824
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 137 of file GrImageUtils.cpp.

137 {
138 SkASSERT(img->generator());
139 if (!img->generator()->isTextureGenerator()) {
141 }
142 // origin should be thread safe
143 return static_cast<const GrTextureGenerator*>(img->generator()->fGenerator.get())->origin();
144}
std::unique_ptr< SkImageGenerator > fGenerator
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 406 of file GrImageUtils.cpp.

409 {
410 GrColorType ct = ColorTypeOfLockTextureProxy(context->priv().caps(), img->colorType());
411 return {LockTextureProxyView(context, img, policy, mipmapped), ct};
412}
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 279 of file GrImageUtils.cpp.

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

451 {
452 if (!view) {
453 return nullptr;
454 }
455 const GrCaps& caps = *rContext->priv().caps();
456 auto wmx = SkTileModeToWrapMode(tileModes[0]);
457 auto wmy = SkTileModeToWrapMode(tileModes[1]);
458 if (sampling.useCubic) {
459 if (subset) {
460 if (domain) {
461 return GrBicubicEffect::MakeSubset(std::move(view),
462 at,
463 m,
464 wmx,
465 wmy,
466 *subset,
467 *domain,
468 sampling.cubic,
470 *rContext->priv().caps());
471 }
472 return GrBicubicEffect::MakeSubset(std::move(view),
473 at,
474 m,
475 wmx,
476 wmy,
477 *subset,
478 sampling.cubic,
480 *rContext->priv().caps());
481 }
482 return GrBicubicEffect::Make(std::move(view),
483 at,
484 m,
485 wmx,
486 wmy,
489 *rContext->priv().caps());
490 }
491 if (sampling.isAniso()) {
492 if (!rContext->priv().caps()->anisoSupport()) {
493 // Fallback to linear
494 sampling = SkSamplingPriv::AnisoFallback(view.mipmapped() == skgpu::Mipmapped::kYes);
495 }
496 } else if (view.mipmapped() == skgpu::Mipmapped::kNo) {
498 }
499 GrSamplerState sampler;
500 if (sampling.isAniso()) {
501 sampler = GrSamplerState::Aniso(wmx, wmy, sampling.maxAniso, view.mipmapped());
502 } else {
503 sampler = GrSamplerState(wmx, wmy, sampling.filter, sampling.mipmap);
504 }
505 if (subset) {
506 if (domain) {
508 std::move(view), at, m, sampler, *subset, *domain, caps);
509 }
510 return GrTextureEffect::MakeSubset(std::move(view), at, m, sampler, *subset, caps);
511 } else {
512 return GrTextureEffect::Make(std::move(view), at, m, sampler, caps);
513 }
514}
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;
80 SkPath path;
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 =
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}
Type::kYUV Type::kRGBA() int(0.7 *637)
@ kCanMap_MapFlag
Definition GrCaps.h:199
static sk_sp< GrDirectContext > MakeMock(const GrMockOptions *, const GrContextOptions &)
uint32_t fMapBufferFlags
bool fDrawInstancedSupport
ConfigOptions fConfigOptions[kGrColorTypeCnt]

◆ 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);
305 stroke.setStrokeParams(SkPaint::kButt_Cap, SkPaint::kBevel_Join, 0);
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
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
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

◆ 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;
70 SkPath path;
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);
254 stroke.setStrokeParams(SkPaint::kButt_Cap, SkPaint::kMiter_Join, 4);
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:678

◆ 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 583 of file GrImageUtils.cpp.

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

◆ 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",
79 skgpu::Mipmapped::kNo);
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)

◆ 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 516 of file GrImageUtils.cpp.

522 {
523 auto mm =
524 sampling.mipmap == SkMipmapMode::kNone ? skgpu::Mipmapped::kNo : skgpu::Mipmapped::kYes;
525 return make_fp_from_view(rContext,
526 std::get<0>(AsView(rContext, img, mm)),
527 img->alphaType(),
528 sampling,
529 tileModes,
530 m,
531 subset,
532 domain);
533}
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 100 of file GrImageUtils.cpp.

103 {
104 if (policy == GrImageTexGenPolicy::kDraw) {
105 // If the draw doesn't require mipmaps but this SkImage has them go ahead and make a
106 // mipmapped texture. There are three reasons for this:
107 // 1) Avoiding another texture creation if a later draw requires mipmaps.
108 // 2) Ensuring we upload the bitmap's levels instead of generating on the GPU from the base.
109 if (raster->hasMipmaps()) {
110 mipmapped = skgpu::Mipmapped::kYes;
111 }
112 return GrMakeCachedBitmapProxyView(rContext,
113 raster->bitmap(),
114 /*label=*/"TextureForImageRasterWithPolicyEqualKDraw",
115 mipmapped);
116 }
117 auto budgeted = (policy == GrImageTexGenPolicy::kNew_Uncached_Unbudgeted)
119 : skgpu::Budgeted::kYes;
121 rContext, raster->bitmap(), mipmapped, SkBackingFit::kExact, budgeted);
122}
@ kYes
Do pre-clip the geometry before applying the (perspective) matrix.
SkBitmap bitmap() const
bool hasMipmaps() const
Definition SkImage.cpp:292

◆ SKGPU_DECLARE_STATIC_UNIQUE_KEY() [1/6]

skgpu::ganesh::SKGPU_DECLARE_STATIC_UNIQUE_KEY ( gFixedCountCurveIndexBufferKey  )

◆ SKGPU_DECLARE_STATIC_UNIQUE_KEY() [2/6]

skgpu::ganesh::SKGPU_DECLARE_STATIC_UNIQUE_KEY ( gFixedCountCurveVertexBufferKey  )

◆ SKGPU_DECLARE_STATIC_UNIQUE_KEY() [3/6]

skgpu::ganesh::SKGPU_DECLARE_STATIC_UNIQUE_KEY ( gFixedCountWedgesIndexBufferKey  )

◆ SKGPU_DECLARE_STATIC_UNIQUE_KEY() [4/6]

skgpu::ganesh::SKGPU_DECLARE_STATIC_UNIQUE_KEY ( gFixedCountWedgesVertexBufferKey  )

◆ SKGPU_DECLARE_STATIC_UNIQUE_KEY() [5/6]

skgpu::ganesh::SKGPU_DECLARE_STATIC_UNIQUE_KEY ( gHullVertexBufferKey  )

◆ SKGPU_DECLARE_STATIC_UNIQUE_KEY() [6/6]

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 703 of file GrImageUtils.cpp.

703 {
705 const auto isValid = [&context](DataType dt, int n) {
707 GrRenderable::kNo).isValid();
708 };
709 for (int n = 1; n <= 4; ++n) {
710 if (isValid(DataType::kUnorm8, n)) {
711 dataTypes.enableDataType(DataType::kUnorm8, n);
712 }
713 if (isValid(DataType::kUnorm16, n)) {
714 dataTypes.enableDataType(DataType::kUnorm16, n);
715 }
716 if (isValid(DataType::kFloat16, n)) {
717 dataTypes.enableDataType(DataType::kFloat16, n);
718 }
719 if (isValid(DataType::kUnorm10_Unorm2, n)) {
720 dataTypes.enableDataType(DataType::kUnorm10_Unorm2, n);
721 }
722 }
723 return dataTypes;
724}
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 147 of file GrImageUtils.cpp.

149 {
150 auto supportedDataTypes = SupportedTextureFormats(*ctx);
151 SkYUVAPixmaps yuvaPixmaps;
152 sk_sp<SkCachedData> dataStorage = img->getPlanes(supportedDataTypes, &yuvaPixmaps);
153 if (!dataStorage) {
154 return {};
155 }
156
158 GrColorType pixmapColorTypes[SkYUVAInfo::kMaxPlanes];
159 for (int i = 0; i < yuvaPixmaps.numPlanes(); ++i) {
160 // If the sizes of the components are not all the same we choose to create exact-match
161 // textures for the smaller ones rather than add a texture domain to the draw.
162 // TODO: revisit this decision to improve texture reuse?
163 SkBackingFit fit = yuvaPixmaps.plane(i).dimensions() == img->dimensions()
166
167 // We grab a ref to cached yuv data. When the SkBitmap we create below goes away it will
168 // call releaseProc which will release this ref.
169 // DDL TODO: Currently we end up creating a lazy proxy that will hold onto a ref to the
170 // SkImage in its lambda. This means that we'll keep the ref on the YUV data around for the
171 // life time of the proxy and not just upload. For non-DDL draws we should look into
172 // releasing this SkImage after uploads (by deleting the lambda after instantiation).
173 auto releaseProc = [](void*, void* data) {
174 auto cachedData = static_cast<SkCachedData*>(data);
175 SkASSERT(cachedData);
176 cachedData->unref();
177 };
179 bitmap.installPixels(yuvaPixmaps.plane(i).info(),
180 yuvaPixmaps.plane(i).writable_addr(),
181 yuvaPixmaps.plane(i).rowBytes(),
183 SkRef(dataStorage.get()));
184 bitmap.setImmutable();
185
186 std::tie(views[i], std::ignore) =
187 GrMakeUncachedBitmapProxyView(ctx, bitmap, skgpu::Mipmapped::kNo, fit);
188 if (!views[i]) {
189 return {};
190 }
191 pixmapColorTypes[i] = SkColorTypeToGrColorType(bitmap.colorType());
192 }
193
194 // TODO: investigate preallocating mip maps here
197 /*color space*/ nullptr,
198 img->dimensions());
199
200 auto sfc = ctx->priv().makeSFC(info,
201 "ImageLazy_TextureProxyViewFromPlanes",
203 1,
204 skgpu::Mipmapped::kNo,
205 GrProtected::kNo,
207 budgeted);
208 if (!sfc) {
209 return {};
210 }
211
212 GrYUVATextureProxies yuvaProxies(yuvaPixmaps.yuvaInfo(), views, pixmapColorTypes);
213 SkAssertResult(yuvaProxies.isValid());
214
215 std::unique_ptr<GrFragmentProcessor> fp = GrYUVtoRGBEffect::Make(
216 yuvaProxies,
217 GrSamplerState::Filter::kNearest,
218 *ctx->priv().caps());
219
220 // The pixels after yuv->rgb will be in the generator's color space.
221 // If onMakeColorTypeAndColorSpace has been called then this will not match this image's
222 // color space. To correct this, apply a color space conversion from the generator's color
223 // space to this image's color space.
224 SkColorSpace* srcColorSpace = img->generator()->getInfo().colorSpace();
225 SkColorSpace* dstColorSpace = img->colorSpace();
226
227 // If the caller expects the pixels in a different color space than the one from the image,
228 // apply a color conversion to do this.
229 fp = GrColorSpaceXformEffect::Make(std::move(fp),
230 srcColorSpace, kOpaque_SkAlphaType,
231 dstColorSpace, kOpaque_SkAlphaType);
232 sfc->fillWithFP(std::move(fp));
233
234 return sfc->readSurfaceView();
235}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
@ kOpaque_SkAlphaType
pixel is opaque
Definition SkAlphaType.h:28
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition SkAlphaType.h:29
#define SkAssertResult(cond)
Definition SkAssert.h:123
SkBackingFit
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)

◆ 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 59 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 56 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 55 of file AtlasTextOp.cpp.