#include "src/gpu/graphite/Device.h"
#include "include/gpu/graphite/Recorder.h"
#include "include/gpu/graphite/Recording.h"
#include "include/gpu/graphite/Surface.h"
#include "src/gpu/AtlasTypes.h"
#include "src/gpu/BlurUtils.h"
#include "src/gpu/SkBackingFit.h"
#include "src/gpu/graphite/AtlasProvider.h"
#include "src/gpu/graphite/Buffer.h"
#include "src/gpu/graphite/Caps.h"
#include "src/gpu/graphite/CommandBuffer.h"
#include "src/gpu/graphite/ContextOptionsPriv.h"
#include "src/gpu/graphite/ContextPriv.h"
#include "src/gpu/graphite/ContextUtils.h"
#include "src/gpu/graphite/DrawContext.h"
#include "src/gpu/graphite/DrawList.h"
#include "src/gpu/graphite/DrawParams.h"
#include "src/gpu/graphite/Image_Graphite.h"
#include "src/gpu/graphite/Log.h"
#include "src/gpu/graphite/PathAtlas.h"
#include "src/gpu/graphite/RasterPathAtlas.h"
#include "src/gpu/graphite/RecorderPriv.h"
#include "src/gpu/graphite/Renderer.h"
#include "src/gpu/graphite/RendererProvider.h"
#include "src/gpu/graphite/ResourceTypes.h"
#include "src/gpu/graphite/SharedContext.h"
#include "src/gpu/graphite/SpecialImage_Graphite.h"
#include "src/gpu/graphite/Surface_Graphite.h"
#include "src/gpu/graphite/TextureProxy.h"
#include "src/gpu/graphite/TextureUtils.h"
#include "src/gpu/graphite/geom/BoundsManager.h"
#include "src/gpu/graphite/geom/Geometry.h"
#include "src/gpu/graphite/geom/IntersectionTree.h"
#include "src/gpu/graphite/geom/Shape.h"
#include "src/gpu/graphite/geom/Transform_graphite.h"
#include "src/gpu/graphite/text/TextAtlasManager.h"
#include "include/core/SkColorSpace.h"
#include "include/core/SkPath.h"
#include "include/core/SkPathEffect.h"
#include "include/core/SkStrokeRec.h"
#include "src/core/SkBlenderBase.h"
#include "src/core/SkBlurMaskFilterImpl.h"
#include "src/core/SkColorSpacePriv.h"
#include "src/core/SkConvertPixels.h"
#include "src/core/SkImageFilterTypes.h"
#include "src/core/SkImageInfoPriv.h"
#include "src/core/SkImagePriv.h"
#include "src/core/SkMatrixPriv.h"
#include "src/core/SkPaintPriv.h"
#include "src/core/SkRRectPriv.h"
#include "src/core/SkSpecialImage.h"
#include "src/core/SkStrikeCache.h"
#include "src/core/SkTraceEvent.h"
#include "src/core/SkVerticesPriv.h"
#include "src/gpu/TiledTextureUtils.h"
#include "src/text/GlyphRun.h"
#include "src/text/gpu/GlyphVector.h"
#include "src/text/gpu/SlugImpl.h"
#include "src/text/gpu/SubRunContainer.h"
#include "src/text/gpu/TextBlobRedrawCoordinator.h"
#include "src/text/gpu/VertexFiller.h"
#include <functional>
#include <tuple>
#include <unordered_map>
#include <vector>
RescaleGamma;
RescaleMode;
ReadPixelsCallback;
ReadPixelsContext;
#if defined(GPU_TEST_UTILS)
int gOverrideMaxTextureSizeGraphite = 0;
std::atomic<int> gNumTilesDrawnGraphite{0};
#endif
namespace skgpu::graphite {
#define ASSERT_SINGLE_OWNER …
namespace {
const SkStrokeRec& DefaultFillStyle() { … }
bool blender_depends_on_dst(const SkBlender* blender, bool srcIsTransparent) { … }
bool paint_depends_on_dst(SkColor4f color,
const SkShader* shader,
const SkColorFilter* colorFilter,
const SkBlender* finalBlender,
const SkBlender* primitiveBlender) { … }
bool paint_depends_on_dst(const PaintParams& paintParams) { … }
bool paint_depends_on_dst(const SkPaint& paint) { … }
std::optional<SkColor4f> extract_paint_color(const SkPaint& paint,
const SkColorInfo& dstColorInfo) { … }
Rect snap_rect_to_pixels(const Transform& localToDevice,
const Rect& rect,
float* strokeWidth=nullptr) { … }
void snap_src_and_dst_rect_to_pixels(const Transform& localToDevice,
SkRect* srcRect,
SkRect* dstRect) { … }
Rect get_inner_bounds(const Geometry& geometry, const Transform& localToDevice) { … }
SkIRect rect_to_pixelbounds(const Rect& r) { … }
bool is_simple_shape(const Shape& shape, SkStrokeRec::Style type) { … }
bool use_compute_atlas_when_available(PathRendererStrategy strategy) { … }
}
class Device::IntersectionTreeSet { … };
sk_sp<Device> Device::Make(Recorder* recorder,
const SkImageInfo& ii,
skgpu::Budgeted budgeted,
Mipmapped mipmapped,
SkBackingFit backingFit,
const SkSurfaceProps& props,
LoadOp initialLoadOp,
std::string_view label,
bool registerWithRecorder) { … }
sk_sp<Device> Device::Make(Recorder* recorder,
sk_sp<TextureProxy> target,
SkISize deviceSize,
const SkColorInfo& colorInfo,
const SkSurfaceProps& props,
LoadOp initialLoadOp,
bool registerWithRecorder) { … }
static constexpr int kGridCellSize = …;
static constexpr int kMaxBruteForceN = …;
static constexpr int kMaxGridSize = …;
Device::Device(Recorder* recorder, sk_sp<DrawContext> dc)
: … { … }
Device::~Device() { … }
void Device::setImmutable() { … }
const Transform& Device::localToDeviceTransform() { … }
SkStrikeDeviceInfo Device::strikeDeviceInfo() const { … }
sk_sp<SkDevice> Device::createDevice(const CreateInfo& info, const SkPaint*) { … }
sk_sp<SkSurface> Device::makeSurface(const SkImageInfo& ii, const SkSurfaceProps& props) { … }
sk_sp<Image> Device::makeImageCopy(const SkIRect& subset,
Budgeted budgeted,
Mipmapped mipmapped,
SkBackingFit backingFit) { … }
bool Device::onReadPixels(const SkPixmap& pm, int srcX, int srcY) { … }
bool Device::onWritePixels(const SkPixmap& src, int x, int y) { … }
bool Device::isClipAntiAliased() const { … }
SkIRect Device::devClipBounds() const { … }
void Device::android_utils_clipAsRgn(SkRegion* region) const { … }
void Device::clipRect(const SkRect& rect, SkClipOp op, bool aa) { … }
void Device::clipRRect(const SkRRect& rrect, SkClipOp op, bool aa) { … }
void Device::clipPath(const SkPath& path, SkClipOp op, bool aa) { … }
void Device::onClipShader(sk_sp<SkShader> shader) { … }
void Device::clipRegion(const SkRegion& globalRgn, SkClipOp op) { … }
void Device::replaceClip(const SkIRect& rect) { … }
void Device::drawPaint(const SkPaint& paint) { … }
void Device::drawRect(const SkRect& r, const SkPaint& paint) { … }
void Device::drawVertices(const SkVertices* vertices, sk_sp<SkBlender> blender,
const SkPaint& paint, bool skipColorXform) { … }
bool Device::drawAsTiledImageRect(SkCanvas* canvas,
const SkImage* image,
const SkRect* src,
const SkRect& dst,
const SkSamplingOptions& sampling,
const SkPaint& paint,
SkCanvas::SrcRectConstraint constraint) { … }
void Device::drawOval(const SkRect& oval, const SkPaint& paint) { … }
void Device::drawRRect(const SkRRect& rr, const SkPaint& paint) { … }
void Device::drawPath(const SkPath& path, const SkPaint& paint, bool pathIsMutable) { … }
void Device::drawPoints(SkCanvas::PointMode mode, size_t count,
const SkPoint* points, const SkPaint& paint) { … }
void Device::drawEdgeAAQuad(const SkRect& rect,
const SkPoint clip[4],
SkCanvas::QuadAAFlags aaFlags,
const SkColor4f& color,
SkBlendMode mode) { … }
void Device::drawEdgeAAImageSet(const SkCanvas::ImageSetEntry set[], int count,
const SkPoint dstClips[], const SkMatrix preViewMatrices[],
const SkSamplingOptions& sampling, const SkPaint& paint,
SkCanvas::SrcRectConstraint constraint) { … }
void Device::drawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
const SkSamplingOptions& sampling, const SkPaint& paint,
SkCanvas::SrcRectConstraint constraint) { … }
sktext::gpu::AtlasDrawDelegate Device::atlasDelegate() { … }
void Device::onDrawGlyphRunList(SkCanvas* canvas,
const sktext::GlyphRunList& glyphRunList,
const SkPaint& paint) { … }
void Device::drawAtlasSubRun(const sktext::gpu::AtlasSubRun* subRun,
SkPoint drawOrigin,
const SkPaint& paint,
sk_sp<SkRefCnt> subRunStorage,
sktext::gpu::RendererData rendererData) { … }
void Device::drawGeometry(const Transform& localToDevice,
const Geometry& geometry,
const SkPaint& paint,
const SkStrokeRec& style,
SkEnumBitMask<DrawFlags> flags,
sk_sp<SkBlender> primitiveBlender,
bool skipColorXform) { … }
void Device::drawClipShape(const Transform& localToDevice,
const Shape& shape,
const Clip& clip,
DrawOrder order) { … }
std::pair<const Renderer*, PathAtlas*> Device::chooseRenderer(const Transform& localToDevice,
const Geometry& geometry,
const SkStrokeRec& style,
bool requireMSAA) const { … }
sk_sp<Task> Device::lastDrawTask() const { … }
void Device::flushPendingWorkToRecorder() { … }
void Device::internalFlush() { … }
bool Device::needsFlushBeforeDraw(int numNewRenderSteps, DstReadRequirement dstReadReq) const { … }
void Device::drawSpecial(SkSpecialImage* special,
const SkMatrix& localToDevice,
const SkSamplingOptions& sampling,
const SkPaint& paint,
SkCanvas::SrcRectConstraint constraint) { … }
void Device::drawCoverageMask(const SkSpecialImage* mask,
const SkMatrix& localToDevice,
const SkSamplingOptions& sampling,
const SkPaint& paint) { … }
sk_sp<SkSpecialImage> Device::makeSpecial(const SkBitmap&) { … }
sk_sp<SkSpecialImage> Device::makeSpecial(const SkImage*) { … }
sk_sp<SkSpecialImage> Device::snapSpecial(const SkIRect& subset, bool forceCopy) { … }
sk_sp<skif::Backend> Device::createImageFilteringBackend(const SkSurfaceProps& surfaceProps,
SkColorType colorType) const { … }
TextureProxy* Device::target() { … }
TextureProxyView Device::readSurfaceView() const { … }
bool Device::isScratchDevice() const { … }
sk_sp<sktext::gpu::Slug> Device::convertGlyphRunListToSlug(const sktext::GlyphRunList& glyphRunList,
const SkPaint& paint) { … }
void Device::drawSlug(SkCanvas* canvas, const sktext::gpu::Slug* slug, const SkPaint& paint) { … }
bool Device::drawBlurredRRect(const SkRRect& rrect, const SkPaint& paint, float deviceSigma) { … }
}