blob: d3bf732500304ae9c90d9081febceb2c96b2cf2b [file] [log] [blame]
Brian Salomoncfe910d2017-07-06 16:40:18 -04001/*
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 GrMockGpuCommandBuffer_DEFINED
9#define GrMockGpuCommandBuffer_DEFINED
10
11#include "GrGpuCommandBuffer.h"
12#include "GrMockGpu.h"
13
Greg Daniel500d58b2017-08-24 15:59:33 -040014class GrMockGpuTextureCommandBuffer : public GrGpuTextureCommandBuffer {
Brian Salomoncfe910d2017-07-06 16:40:18 -040015public:
Greg Daniel500d58b2017-08-24 15:59:33 -040016 GrMockGpuTextureCommandBuffer(GrTexture* texture, GrSurfaceOrigin origin)
17 : INHERITED(texture, origin) {
18 }
19
20 ~GrMockGpuTextureCommandBuffer() override {}
21
22 void copy(GrSurface* src, const SkIRect& srcRect, const SkIPoint& dstPoint) override {}
23 void insertEventMarker(const char*) override {}
24
25private:
26 void submit() override {}
27
28 typedef GrGpuTextureCommandBuffer INHERITED;
29};
30
31class GrMockGpuRTCommandBuffer : public GrGpuRTCommandBuffer {
32public:
33 GrMockGpuRTCommandBuffer(GrMockGpu* gpu, GrRenderTarget* rt, GrSurfaceOrigin origin)
Robert Phillips19e51dc2017-08-09 09:30:51 -040034 : INHERITED(rt, origin)
35 , fGpu(gpu) {
36 }
Brian Salomoncfe910d2017-07-06 16:40:18 -040037
38 GrGpu* gpu() override { return fGpu; }
Robert Phillips19e51dc2017-08-09 09:30:51 -040039 void inlineUpload(GrOpFlushState*, GrDrawOp::DeferredUploadFn&) override {}
40 void discard() override {}
41 void insertEventMarker(const char*) override {}
Robert Phillips95214472017-08-08 18:00:03 -040042 void begin() override {}
Brian Salomoncfe910d2017-07-06 16:40:18 -040043 void end() override {}
Greg Daniel500d58b2017-08-24 15:59:33 -040044 void copy(GrSurface* src, const SkIRect& srcRect, const SkIPoint& dstPoint) override {}
Brian Salomoncfe910d2017-07-06 16:40:18 -040045
46 int numDraws() const { return fNumDraws; }
47
Greg Daniel500d58b2017-08-24 15:59:33 -040048 void submit() override { fGpu->submitCommandBuffer(this); }
49
Brian Salomoncfe910d2017-07-06 16:40:18 -040050private:
Brian Salomoncfe910d2017-07-06 16:40:18 -040051 void onDraw(const GrPipeline&, const GrPrimitiveProcessor&, const GrMesh[],
52 const GrPipeline::DynamicState[], int meshCount, const SkRect& bounds) override {
53 ++fNumDraws;
54 }
Robert Phillips19e51dc2017-08-09 09:30:51 -040055 void onClear(const GrFixedClip&, GrColor) override {}
56 void onClearStencilClip(const GrFixedClip&, bool insideStencilMask) override {}
Brian Salomoncfe910d2017-07-06 16:40:18 -040057
58 GrMockGpu* fGpu;
59 int fNumDraws = 0;
60
Greg Daniel500d58b2017-08-24 15:59:33 -040061 typedef GrGpuRTCommandBuffer INHERITED;
Brian Salomoncfe910d2017-07-06 16:40:18 -040062};
63
64#endif