chromium/third_party/skia/src/core/SkRasterPipelineOpContexts.h

/*
 * Copyright 2023 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkRasterPipelineOpContexts_DEFINED
#define SkRasterPipelineOpContexts_DEFINED

#include <algorithm>
#include <cstddef>
#include <cstdint>

namespace SkSL { class TraceHook; }

// The largest number of pixels we handle at a time. We have a separate value for the largest number
// of pixels we handle in the highp pipeline. Many of the context structs in this file are only used
// by stages that have no lowp implementation. They can therefore use the (smaller) highp value to
// save memory in the arena.
inline static constexpr int SkRasterPipeline_kMaxStride =;
inline static constexpr int SkRasterPipeline_kMaxStride_highp =;

// How much space to allocate for each MemoryCtx scratch buffer, as part of tail-pixel handling.
inline static constexpr size_t SkRasterPipeline_MaxScratchPerPatch =;        // 4 == largest lowp bpp (RGBA_8888)

// These structs hold the context data for many of the Raster Pipeline ops.
struct SkRasterPipeline_MemoryCtx {};

// Raster Pipeline typically processes N (4, 8, 16) pixels at a time, in SIMT fashion. If the
// number of pixels in a row isn't evenly divisible by N, there will be leftover pixels; this is
// called the "tail". To avoid reading or writing past the end of any source or destination buffers
// when we reach the tail:
//
//   1) Source buffers have their tail contents copied to a scratch buffer that is at least N wide.
//      In practice, each scratch buffer uses SkRasterPipeline_MaxScratchPerPatch bytes.
//   2) Each MemoryCtx in the pipeline is patched, such that access to them (at the current scanline
//      and x-offset) will land in the scratch buffer.
//   3) Pipeline is run as normal (with all memory access happening safely in the scratch buffers).
//   4) Destination buffers have their tail contents copied back from the scratch buffer.
//   5) Each MemoryCtx is "un-patched".
//
// To do all of this, the pipeline creates a MemoryCtxPatch for each unique MemoryCtx referenced by
// the pipeline.
struct SkRasterPipeline_MemoryCtxInfo {};

struct SkRasterPipeline_MemoryCtxPatch {};

struct SkRasterPipeline_GatherCtx {};

// State shared by save_xy, accumulate, and bilinear_* / bicubic_*.
struct SkRasterPipeline_SamplerCtx {};

struct SkRasterPipeline_TileCtx {};

struct SkRasterPipeline_DecalTileCtx {};

enum class SkPerlinNoiseShaderType;

struct SkRasterPipeline_PerlinNoiseCtx {};

// State used by mipmap_linear_*
struct SkRasterPipeline_MipmapCtx {};

struct SkRasterPipeline_CoordClampCtx {};

struct SkRasterPipeline_CallbackCtx {};

// state shared by stack_checkpoint and stack_rewind
struct SkRasterPipelineStage;

struct SkRasterPipeline_RewindCtx {};

struct SkRasterPipeline_GradientCtx {};

struct SkRasterPipeline_EvenlySpaced2StopGradientCtx {};

struct SkRasterPipeline_2PtConicalCtx {};

struct SkRasterPipeline_UniformColorCtx {};

struct SkRasterPipeline_EmbossCtx {};

struct SkRasterPipeline_TablesCtx {};

SkRPOffset;

struct SkRasterPipeline_InitLaneMasksCtx {};

struct SkRasterPipeline_ConstantCtx {};

struct SkRasterPipeline_UniformCtx {};

struct SkRasterPipeline_BinaryOpCtx {};

struct SkRasterPipeline_TernaryOpCtx {};

struct SkRasterPipeline_MatrixMultiplyCtx {};

struct SkRasterPipeline_SwizzleCtx {};

struct SkRasterPipeline_ShuffleCtx {};

struct SkRasterPipeline_SwizzleCopyCtx {};

struct SkRasterPipeline_CopyIndirectCtx {};

struct SkRasterPipeline_SwizzleCopyIndirectCtx : public SkRasterPipeline_CopyIndirectCtx {};

struct SkRasterPipeline_BranchCtx {};

struct SkRasterPipeline_BranchIfAllLanesActiveCtx : public SkRasterPipeline_BranchCtx {};

struct SkRasterPipeline_BranchIfEqualCtx : public SkRasterPipeline_BranchCtx {};

struct SkRasterPipeline_CaseOpCtx {};

struct SkRasterPipeline_TraceFuncCtx {};

struct SkRasterPipeline_TraceScopeCtx {};

struct SkRasterPipeline_TraceLineCtx {};

struct SkRasterPipeline_TraceVarCtx {};

#endif  // SkRasterPipelineOpContexts_DEFINED