56#define SKDEBUGCANVAS_VERSION 1
57#define SKDEBUGCANVAS_ATTRIBUTE_VERSION "version"
58#define SKDEBUGCANVAS_ATTRIBUTE_COMMANDS "commands"
59#define SKDEBUGCANVAS_ATTRIBUTE_AUDITTRAIL "auditTrail"
63 static constexpr char kOffscreenLayerDraw[] =
"OffscreenLayerDraw";
64 static constexpr char kSurfaceID[] =
"SurfaceID";
65 static constexpr char kAndroidClip[] =
"AndroidDeviceClipRestriction";
114 , fOverdrawViz(false)
116 , fDrawGpuOpBounds(false)
117 , fShowAndroidClip(false)
119 , fnextDrawPictureLayerId(-1)
120 , fnextDrawImageRectLayerId(-1)
121 , fAndroidClip(
SkRect::MakeEmpty()) {
132 largeIRect.
inset(1024, 1024);
148 fCommandVector.
reset();
154 if (!fCommandVector.
empty()) {
155 this->
drawTo(canvas, fCommandVector.
size() - 1);
163 int saveCount = originalCanvas->
save();
169 SkCanvas* finalCanvas = fOverdrawViz ? &filterCanvas : originalCanvas;
171#if defined(SK_GANESH)
176 if (fDrawGpuOpBounds || m != -1) {
178 at = this->getAuditTrail(originalCanvas);
182 for (
int i = 0; i <= index; i++) {
183#if defined(SK_GANESH)
195 if (fCommandVector[i]->isVisible()) {
196 fCommandVector[i]->execute(finalCanvas);
198#if defined(SK_GANESH)
220 drawArrow(finalCanvas, {-50, 0}, {50, 0}, originXPaint);
221 drawArrow(finalCanvas, {0, -50}, {0, 50}, originYPaint);
225 if (fShowAndroidClip) {
228 androidClipPaint.
setARGB(80, 255, 100, 0);
229 finalCanvas->
drawRect(fAndroidClip, androidClipPaint);
232#if defined(SK_GANESH)
265 paint.setStrokeWidth(1);
266 for (
int i = 0; i < childrenBounds.
size(); i++) {
267 if (childrenBounds[i].fProxyUniqueID != proxyID) {
271 paint.setColor(kTotalBounds);
273 for (
int j = 0; j < childrenBounds[i].fOps.
size(); j++) {
276 paint.setColor(kOtherOpBounds);
278 paint.setColor(kCommandOpBounds);
284 this->cleanupAuditTrail(at);
291 delete fCommandVector[index];
292 fCommandVector.
remove(index);
297 return fCommandVector[index];
300#if defined(SK_GANESH)
305 at = ctx->priv().auditTrail();
310void DebugCanvas::drawAndCollectOps(
SkCanvas* canvas) {
315 for (
int i = 0; i < this->
getSize(); i++) {
317 fCommandVector[i]->execute(canvas);
343#if defined(SK_GANESH)
344 this->drawAndCollectOps(canvas);
352 for (
int i = 0; i < this->
getSize(); i++) {
356#if defined(SK_GANESH)
366#if defined(SK_GANESH)
367 this->cleanupAuditTrail(at);
372#if defined(SK_GANESH)
373 this->drawAndCollectOps(canvas);
379 this->cleanupAuditTrail(at);
432 if (tokens.size() == 2) {
433 if (tokens[0].
equals(kOffscreenLayerDraw)) {
436 fnextDrawPictureLayerId = std::stoi(tokens[1].c_str());
437 fnextDrawPictureDirtyRect = rect.roundOut();
439 }
else if (tokens[0].
equals(kSurfaceID)) {
441 fnextDrawImageRectLayerId = std::stoi(tokens[1].c_str());
445 if (strcmp(kAndroidClip,
key) == 0) {
476 if (fnextDrawImageRectLayerId != -1 && fLayerManager) {
486 fLayerManager, fnextDrawImageRectLayerId, fFrame, src, dst, sampling,
492 fnextDrawImageRectLayerId = -1;
526 if (fnextDrawPictureLayerId != -1 && fLayerManager) {
528 fnextDrawPictureDirtyRect);
535 fnextDrawPictureLayerId = -1;
562 this->addDrawCommand(
577 this->addDrawCommand(
590 this->addDrawCommand(
618 set,
count, dstClips, preViewMatrices, sampling,
paint, constraint));
650 fCommandVector[index]->setVisible(toggle);
655 std::map<int, std::vector<int>> m;
657 for (
int i = 0; i < this->
getSize(); i++) {
661 switch (command->getOpType()) {
676 if (imageIndex >= 0) {
677 m[imageIndex].push_back(i);
#define SKDEBUGCANVAS_ATTRIBUTE_COMMANDS
#define SKDEBUGCANVAS_ATTRIBUTE_AUDITTRAIL
#define SKDEBUGCANVAS_VERSION
#define SKDEBUGCANVAS_ATTRIBUTE_VERSION
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
@ kSrcOver
r = s + (1-sa)*d
constexpr SkColor SK_ColorTRANSPARENT
constexpr SkColor SK_ColorRED
static constexpr SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
#define SkColorGetA(color)
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
static bool equals(T *a, T *b)
static bool left(const SkPoint &p0, const SkPoint &p1)
sk_sp< T > sk_ref_sp(T *obj)
#define SkScalarATan2(y, x)
void SkStrSplit(const char *str, const char *delimiters, SkStrSplitMode splitMode, TArray< SkString > *out)
static constexpr bool SkToBool(const T &x)
void onClipRegion(const SkRegion ®ion, SkClipOp) override
DrawCommand * getDrawCommandAt(int index) const
void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], SkBlendMode, const SkPaint &paint) override
SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec &) override
void onDrawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint) override
void onResetClip() override
void setOverdrawViz(bool overdrawViz)
DebugCanvas(int width, int height)
void onDrawRect(const SkRect &, const SkPaint &) override
void didScale(SkScalar, SkScalar) override
void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint &) override
void onDrawPath(const SkPath &, const SkPaint &) override
void onClipPath(const SkPath &, SkClipOp, ClipEdgeStyle) override
void didConcat44(const SkM44 &) override
void onDrawRRect(const SkRRect &, const SkPaint &) override
void onDrawAnnotation(const SkRect &, const char[], SkData *) override
void onDrawPicture(const SkPicture *, const SkMatrix *, const SkPaint *) override
std::map< int, std::vector< int > > getImageIdToCommandMap(UrlDataManager &udm) const
void onDrawAtlas2(const SkImage *, const SkRSXform[], const SkRect[], const SkColor[], int, SkBlendMode, const SkSamplingOptions &, const SkRect *, const SkPaint *) override
void onClipRRect(const SkRRect &, SkClipOp, ClipEdgeStyle) override
void onDrawDrawable(SkDrawable *, const SkMatrix *) override
void didTranslate(SkScalar, SkScalar) override
void drawTo(SkCanvas *canvas, int index, int m=-1)
void onDrawEdgeAAQuad(const SkRect &, const SkPoint[4], QuadAAFlags, const SkColor4f &, SkBlendMode) override
void onDrawEdgeAAImageSet2(const ImageSetEntry[], int count, const SkPoint[], const SkMatrix[], const SkSamplingOptions &, const SkPaint *, SrcRectConstraint) override
bool onDoSaveBehind(const SkRect *) override
void onClipRect(const SkRect &, SkClipOp, ClipEdgeStyle) override
void onDrawPaint(const SkPaint &) override
void onDrawDRRect(const SkRRect &, const SkRRect &, const SkPaint &) override
void toggleCommand(int index, bool toggle)
void onDrawImageRect2(const SkImage *, const SkRect &, const SkRect &, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint) override
void toJSONOpsTask(SkJSONWriter &writer, SkCanvas *)
void onDrawShadowRec(const SkPath &, const SkDrawShadowRec &) override
void onDrawRegion(const SkRegion &, const SkPaint &) override
void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager, SkCanvas *)
void onClipShader(sk_sp< SkShader >, SkClipOp) override
void onDrawImageLattice2(const SkImage *, const Lattice &, const SkRect &, SkFilterMode, const SkPaint *) override
void onDrawOval(const SkRect &, const SkPaint &) override
void onDrawImage2(const SkImage *, SkScalar, SkScalar, const SkSamplingOptions &, const SkPaint *) override
void onDrawBehind(const SkPaint &) override
void onDrawVerticesObject(const SkVertices *, SkBlendMode, const SkPaint &) override
void draw(SkCanvas *canvas)
void onDrawArc(const SkRect &, SkScalar, SkScalar, bool, const SkPaint &) override
void deleteDrawCommandAt(int index)
void didSetM44(const SkM44 &) override
void willRestore() override
void storeSkPicture(int nodeId, int frame, const sk_sp< SkPicture > &picture, SkIRect dirty)
DebugPaintFilterCanvas(SkCanvas *canvas)
void onDrawPicture(const SkPicture *picture, const SkMatrix *matrix, const SkPaint *paint) override
bool onFilter(SkPaint &paint) const override
@ kDrawImageLattice_OpType
virtual void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const
void getBoundsByOpsTaskID(OpInfo *outInfo, int opsTaskID)
void getBoundsByClientID(skia_private::TArray< OpInfo > *outInfo, int clientID)
void toJson(SkJSONWriter &writer) const
UniqueID uniqueID() const
static void ResetClip(SkCanvas *canvas)
void drawRect(const SkRect &rect, const SkPaint &paint)
void translate(SkScalar dx, SkScalar dy)
virtual void onDrawPicture(const SkPicture *picture, const SkMatrix *matrix, const SkPaint *paint)
virtual GrRecordingContext * recordingContext() const
virtual void didSetM44(const SkM44 &)
void drawPaint(const SkPaint &paint)
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint &paint)
virtual SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec &)
virtual void onClipRect(const SkRect &rect, SkClipOp op, ClipEdgeStyle edgeStyle)
SkM44 getLocalToDevice() const
@ kNoLayer_SaveLayerStrategy
virtual void willRestore()
void rotate(SkScalar degrees)
void restoreToCount(int saveCount)
SkIRect getDeviceClipBounds() const
virtual void didConcat44(const SkM44 &)
void drawPath(const SkPath &path, const SkPaint &paint)
void appendS32(int32_t value)
void beginArray(const char *name=nullptr, bool multiline=true)
void beginObject(const char *name=nullptr, bool multiline=true)
void appendName(const char *name)
static SkM44 Translate(SkScalar x, SkScalar y, SkScalar z=0)
static SkM44 Scale(SkScalar x, SkScalar y, SkScalar z=1)
void setColor(SkColor color)
@ kStroke_Style
set to stroke geometry
void setARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
static SkPath Polygon(const SkPoint pts[], int count, bool isClosed, SkPathFillType=SkPathFillType::kWinding, bool isVolatile=false)
virtual SkRect cullRect() const =0
virtual void playback(SkCanvas *canvas, AbortCallback *callback=nullptr) const =0
static SkIRect MakeILarge()
void push_back(const T &v)
void remove(int index, int count=1)
GrRenderTargetProxy * TopDeviceTargetProxy(const SkCanvas *canvas)
void inset(int32_t dx, int32_t dy)
static SkRect Make(const SkISize &size)
void roundOut(SkIRect *dst) const