diff --git a/third_party/skia/src/pdf/SkPDFDevice.cpp b/third_party/skia/src/pdf/SkPDFDevice.cpp index a6d9a70dd73..f5572f5d085 100644 --- a/third_party/skia/src/pdf/SkPDFDevice.cpp +++ b/third_party/skia/src/pdf/SkPDFDevice.cpp @@ -7,6 +7,8 @@ #include "src/pdf/SkPDFDevice.h" +#include + #include "include/codec/SkCodec.h" #include "include/core/SkAlphaType.h" #include "include/core/SkBitmap.h" @@ -448,6 +450,10 @@ void SkPDFDevice::drawAnnotation(const SkRect& rect, const char key[], SkData* v return; } // Convert to path to handle non-90-degree rotations. + fprintf(stderr, + "[POC-SINK] SkPDFDevice::drawAnnotation key='%s' rect=[%g,%g,%g,%g] " + "-> SkClipStack_AsPath + outer Op() (sink #2)\n", + key, rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); SkPath path = SkPath::Rect(rect).makeTransform(this->localToDevice()); SkPath clip = SkClipStack_AsPath(this->cs()); if (auto result = Op(clip, path, kIntersect_SkPathOp)) { diff --git a/third_party/skia/src/pdf/SkPDFGraphicStackState.cpp b/third_party/skia/src/pdf/SkPDFGraphicStackState.cpp index 4bad8587d60..c2239cd71a9 100644 --- a/third_party/skia/src/pdf/SkPDFGraphicStackState.cpp +++ b/third_party/skia/src/pdf/SkPDFGraphicStackState.cpp @@ -14,6 +14,8 @@ #include "src/pdf/SkPDFUtils.h" #include "src/utils/SkClipStackUtils.h" +#include + static void emit_pdf_color(SkColor4f color, SkWStream* result) { SkASSERT(color.fA == 1); // We handle alpha elsewhere. SkPDFUtils::AppendColorComponentF(color.fR, result); @@ -85,6 +87,10 @@ static void apply_clip(const SkClipStack& stack, const SkRect& outerBounds, F fn operand.isInverseFillType() || !kHuge.contains(operand.getBounds())) { + fprintf(stderr, + "[POC-SINK] apply_clip Op(rect, operand.verbs=%d, op=%d) " + "(sink #3, per-element)\n", + operand.countVerbs(), (int)op); if (auto result = Op(SkPath::Rect(bounds), operand, op)) { operand = *result; } diff --git a/third_party/skia/src/utils/SkClipStackUtils.cpp b/third_party/skia/src/utils/SkClipStackUtils.cpp index 37f899d3a80..15df6d70f12 100644 --- a/third_party/skia/src/utils/SkClipStackUtils.cpp +++ b/third_party/skia/src/utils/SkClipStackUtils.cpp @@ -12,12 +12,36 @@ #include "include/pathops/SkPathOps.h" #include "src/core/SkClipStack.h" +#include +#include + enum class SkClipOp; +static const char* poc_process_type() { + static char buf[512] = {0}; + if (buf[0] == 0) { + FILE* f = fopen("/proc/self/cmdline", "rb"); + if (f) { + size_t n = fread(buf, 1, sizeof(buf) - 1, f); + for (size_t i = 0; i < n; ++i) { if (buf[i] == 0) buf[i] = ' '; } + buf[n] = 0; + fclose(f); + } else { + buf[0] = '?'; buf[1] = 0; + } + } + return buf; +} + SkPath SkClipStack_AsPath(const SkClipStack& cs) { SkPath path; path.setFillType(SkPathFillType::kInverseEvenOdd); + fprintf(stderr, + "[POC-SINK] SkClipStack_AsPath ENTER pid=%d cmdline=[%s]\n", + (int)getpid(), poc_process_type()); + + int op_calls = 0; SkClipStack::Iter iter(cs, SkClipStack::Iter::kBottom_IterStart); while (const SkClipStack::Element* element = iter.next()) { if (element->getDeviceSpaceType() == SkClipStack::Element::DeviceSpaceType::kShader) { @@ -36,10 +60,20 @@ SkPath SkClipStack_AsPath(const SkClipStack& cs) { // TODO: Once expanding clip ops are removed, we can switch the iterator to be top // to bottom, which allows us to break here on encountering a replace op. } else { + ++op_calls; + fprintf(stderr, + "[POC-SINK] iterated Op() call #%d: accum.verbs=%d " + "operand.verbs=%d operand.points=%d clipOp=%d\n", + op_calls, path.countVerbs(), operand.countVerbs(), + operand.countPoints(), (int)elementOp); if (auto result = Op(path, operand, (SkPathOp)elementOp)) { path = *result; } } } + fprintf(stderr, + "[POC-SINK] SkClipStack_AsPath EXIT: %d iterated Op() calls, " + "result.verbs=%d (renderer geometry -> PathOps in pid=%d)\n", + op_calls, path.countVerbs(), (int)getpid()); return path; }