chromium/third_party/skia/src/gpu/ganesh/GrAuditTrail.cpp

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

#include "src/gpu/ganesh/GrAuditTrail.h"
#include "src/gpu/ganesh/ops/GrOp.h"

usingnamespaceskia_private;

const int GrAuditTrail::kGrAuditTrailInvalidID =;

void GrAuditTrail::addOp(const GrOp* op, GrRenderTargetProxy::UniqueID proxyID) {}

void GrAuditTrail::opsCombined(const GrOp* consumer, const GrOp* consumed) {}

void GrAuditTrail::copyOutFromOpsTask(OpInfo* outOpInfo, int opsTaskID) {}

void GrAuditTrail::getBoundsByClientID(TArray<OpInfo>* outInfo, int clientID) {}

void GrAuditTrail::getBoundsByOpsTaskID(OpInfo* outInfo, int opsTaskID) {}

void GrAuditTrail::fullReset() {}

#ifdef SK_ENABLE_DUMP_GPU
#include "src/utils/SkJSONWriter.h"

template <typename T>
void GrAuditTrail::JsonifyTArray(SkJSONWriter& writer, const char* name, const T& array) {
    if (array.size()) {
        writer.beginArray(name);
        for (int i = 0; i < array.size(); i++) {
            // Handle sentinel nullptrs
            if (array[i]) {
                array[i]->toJson(writer);
            }
        }
        writer.endArray();
    }
}

void GrAuditTrail::toJson(SkJSONWriter& writer) const {
    writer.beginObject();
    JsonifyTArray(writer, "Ops", fOpsTask);
    writer.endObject();
}

void GrAuditTrail::toJson(SkJSONWriter& writer, int clientID) const {
    writer.beginObject();
    Ops** ops = fClientIDLookup.find(clientID);
    if (ops) {
        JsonifyTArray(writer, "Ops", **ops);
    }
    writer.endObject();
}

static void skrect_to_json(SkJSONWriter& writer, const char* name, const SkRect& rect) {
    writer.beginObject(name);
    writer.appendFloat("Left", rect.fLeft);
    writer.appendFloat("Right", rect.fRight);
    writer.appendFloat("Top", rect.fTop);
    writer.appendFloat("Bottom", rect.fBottom);
    writer.endObject();
}

void GrAuditTrail::Op::toJson(SkJSONWriter& writer) const {
    writer.beginObject();
    writer.appendString("Name", fName);
    writer.appendS32("ClientID", fClientID);
    writer.appendS32("OpsTaskID", fOpsTaskID);
    writer.appendS32("ChildID", fChildID);
    skrect_to_json(writer, "Bounds", fBounds);
    if (fStackTrace.size()) {
        writer.beginArray("Stack");
        for (int i = 0; i < fStackTrace.size(); i++) {
            writer.appendString(fStackTrace[i]);
        }
        writer.endArray();
    }
    writer.endObject();
}

void GrAuditTrail::OpNode::toJson(SkJSONWriter& writer) const {
    writer.beginObject();
    writer.appendU32("ProxyID", fProxyUniqueID.asUInt());
    skrect_to_json(writer, "Bounds", fBounds);
    JsonifyTArray(writer, "Ops", fChildren);
    writer.endObject();
}
#else
template <typename T>
void GrAuditTrail::JsonifyTArray(SkJSONWriter& writer, const char* name, const T& array) {}
void GrAuditTrail::toJson(SkJSONWriter& writer) const {}
void GrAuditTrail::toJson(SkJSONWriter& writer, int clientID) const {}
void GrAuditTrail::Op::toJson(SkJSONWriter& writer) const {}
void GrAuditTrail::OpNode::toJson(SkJSONWriter& writer) const {}
#endif // SK_ENABLE_DUMP_GPU