aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/mock/GrMockGpuCommandBuffer.h
blob: d923903cc1c5af360a897509dbc567a77d1f9aa4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
 * Copyright 2017 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef GrMockGpuCommandBuffer_DEFINED
#define GrMockGpuCommandBuffer_DEFINED

#include "GrGpuCommandBuffer.h"
#include "GrMockGpu.h"

class GrMockGpuCommandBuffer : public GrGpuCommandBuffer {
public:
    GrMockGpuCommandBuffer(GrMockGpu* gpu) : fGpu(gpu) {}

    GrGpu* gpu() override { return fGpu; }
    void inlineUpload(GrOpFlushState*, GrDrawOp::DeferredUploadFn&,
                      GrRenderTargetProxy*) override {}
    void discard(GrRenderTargetProxy*) override {}
    void end() override {}

    int numDraws() const { return fNumDraws; }

private:
    void onSubmit() override { fGpu->submitCommandBuffer(this); }
    void onDraw(const GrPipeline&, const GrPrimitiveProcessor&, const GrMesh[],
                const GrPipeline::DynamicState[], int meshCount, const SkRect& bounds) override {
        ++fNumDraws;
    }
    void onClear(GrRenderTargetProxy*, const GrFixedClip&, GrColor) override {}
    void onClearStencilClip(GrRenderTargetProxy*, const GrFixedClip&,
                            bool insideStencilMask) override {}
    GrRenderTarget* renderTarget() override { return nullptr; }

    GrMockGpu* fGpu;
    int fNumDraws = 0;

    typedef GrGpuCommandBuffer INHERITED;
};

#endif