Brian Salomon | cfe910d | 2017-07-06 16:40:18 -0400 | [diff] [blame] | 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 GrMockGpuCommandBuffer_DEFINED |
| 9 | #define GrMockGpuCommandBuffer_DEFINED |
| 10 | |
| 11 | #include "GrGpuCommandBuffer.h" |
| 12 | #include "GrMockGpu.h" |
| 13 | |
Greg Daniel | 500d58b | 2017-08-24 15:59:33 -0400 | [diff] [blame^] | 14 | class GrMockGpuTextureCommandBuffer : public GrGpuTextureCommandBuffer { |
Brian Salomon | cfe910d | 2017-07-06 16:40:18 -0400 | [diff] [blame] | 15 | public: |
Greg Daniel | 500d58b | 2017-08-24 15:59:33 -0400 | [diff] [blame^] | 16 | 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 | |
| 25 | private: |
| 26 | void submit() override {} |
| 27 | |
| 28 | typedef GrGpuTextureCommandBuffer INHERITED; |
| 29 | }; |
| 30 | |
| 31 | class GrMockGpuRTCommandBuffer : public GrGpuRTCommandBuffer { |
| 32 | public: |
| 33 | GrMockGpuRTCommandBuffer(GrMockGpu* gpu, GrRenderTarget* rt, GrSurfaceOrigin origin) |
Robert Phillips | 19e51dc | 2017-08-09 09:30:51 -0400 | [diff] [blame] | 34 | : INHERITED(rt, origin) |
| 35 | , fGpu(gpu) { |
| 36 | } |
Brian Salomon | cfe910d | 2017-07-06 16:40:18 -0400 | [diff] [blame] | 37 | |
| 38 | GrGpu* gpu() override { return fGpu; } |
Robert Phillips | 19e51dc | 2017-08-09 09:30:51 -0400 | [diff] [blame] | 39 | void inlineUpload(GrOpFlushState*, GrDrawOp::DeferredUploadFn&) override {} |
| 40 | void discard() override {} |
| 41 | void insertEventMarker(const char*) override {} |
Robert Phillips | 9521447 | 2017-08-08 18:00:03 -0400 | [diff] [blame] | 42 | void begin() override {} |
Brian Salomon | cfe910d | 2017-07-06 16:40:18 -0400 | [diff] [blame] | 43 | void end() override {} |
Greg Daniel | 500d58b | 2017-08-24 15:59:33 -0400 | [diff] [blame^] | 44 | void copy(GrSurface* src, const SkIRect& srcRect, const SkIPoint& dstPoint) override {} |
Brian Salomon | cfe910d | 2017-07-06 16:40:18 -0400 | [diff] [blame] | 45 | |
| 46 | int numDraws() const { return fNumDraws; } |
| 47 | |
Greg Daniel | 500d58b | 2017-08-24 15:59:33 -0400 | [diff] [blame^] | 48 | void submit() override { fGpu->submitCommandBuffer(this); } |
| 49 | |
Brian Salomon | cfe910d | 2017-07-06 16:40:18 -0400 | [diff] [blame] | 50 | private: |
Brian Salomon | cfe910d | 2017-07-06 16:40:18 -0400 | [diff] [blame] | 51 | void onDraw(const GrPipeline&, const GrPrimitiveProcessor&, const GrMesh[], |
| 52 | const GrPipeline::DynamicState[], int meshCount, const SkRect& bounds) override { |
| 53 | ++fNumDraws; |
| 54 | } |
Robert Phillips | 19e51dc | 2017-08-09 09:30:51 -0400 | [diff] [blame] | 55 | void onClear(const GrFixedClip&, GrColor) override {} |
| 56 | void onClearStencilClip(const GrFixedClip&, bool insideStencilMask) override {} |
Brian Salomon | cfe910d | 2017-07-06 16:40:18 -0400 | [diff] [blame] | 57 | |
| 58 | GrMockGpu* fGpu; |
| 59 | int fNumDraws = 0; |
| 60 | |
Greg Daniel | 500d58b | 2017-08-24 15:59:33 -0400 | [diff] [blame^] | 61 | typedef GrGpuRTCommandBuffer INHERITED; |
Brian Salomon | cfe910d | 2017-07-06 16:40:18 -0400 | [diff] [blame] | 62 | }; |
| 63 | |
| 64 | #endif |