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