1/*
2 * Copyright 2017 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef GrDebugMarkerOp_DEFINED
9#define GrDebugMarkerOp_DEFINED
10
11#include "GrGpuCommandBuffer.h"
12#include "GrOp.h"
13#include "GrOpFlushState.h"
14#include "GrRenderTargetProxy.h"
15
16class GrDebugMarkerOp final : public GrOp {
17public:
18    DEFINE_OP_CLASS_ID
19
20    static std::unique_ptr<GrOp> Make(GrRenderTargetProxy* proxy, const SkString& str) {
21        return std::unique_ptr<GrOp>(new GrDebugMarkerOp(proxy, str));
22    }
23
24    const char* name() const override { return "DebugMarker"; }
25
26    SkString dumpInfo() const override {
27        SkString string;
28        string.append(INHERITED::dumpInfo());
29        return string;
30    }
31
32private:
33    GrDebugMarkerOp(GrRenderTargetProxy* proxy, const SkString& str)
34            : INHERITED(ClassID())
35            , fStr(str) {
36        // Make this cover the whole screen so it can't be reordered around
37        this->makeFullScreen(proxy);
38    }
39
40    bool onCombineIfPossible(GrOp* that, const GrCaps& caps) override { return false; }
41
42    void onPrepare(GrOpFlushState*) override {}
43
44    void onExecute(GrOpFlushState* state) override {
45        //SkDebugf("%s\n", fStr.c_str());
46        if (state->caps().gpuTracingSupport()) {
47            state->commandBuffer()->insertEventMarker(fStr.c_str());
48        }
49    }
50
51    SkString fStr;
52
53    typedef GrOp INHERITED;
54};
55
56#endif
57