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 14 class GrMockGpuTextureCommandBuffer : public GrGpuTextureCommandBuffer { 15 public: GrMockGpuTextureCommandBuffer(GrTexture * texture,GrSurfaceOrigin origin)16 GrMockGpuTextureCommandBuffer(GrTexture* texture, GrSurfaceOrigin origin) 17 : INHERITED(texture, origin) { 18 } 19 ~GrMockGpuTextureCommandBuffer()20 ~GrMockGpuTextureCommandBuffer() override {} 21 copy(GrSurface * src,GrSurfaceOrigin srcOrigin,const SkIRect & srcRect,const SkIPoint & dstPoint)22 void copy(GrSurface* src, GrSurfaceOrigin srcOrigin, const SkIRect& srcRect, 23 const SkIPoint& dstPoint) override {} insertEventMarker(const char *)24 void insertEventMarker(const char*) override {} 25 26 private: submit()27 void submit() override {} 28 29 typedef GrGpuTextureCommandBuffer INHERITED; 30 }; 31 32 class GrMockGpuRTCommandBuffer : public GrGpuRTCommandBuffer { 33 public: GrMockGpuRTCommandBuffer(GrMockGpu * gpu,GrRenderTarget * rt,GrSurfaceOrigin origin)34 GrMockGpuRTCommandBuffer(GrMockGpu* gpu, GrRenderTarget* rt, GrSurfaceOrigin origin) 35 : INHERITED(rt, origin) 36 , fGpu(gpu) { 37 } 38 gpu()39 GrGpu* gpu() override { return fGpu; } inlineUpload(GrOpFlushState *,GrDeferredTextureUploadFn &)40 void inlineUpload(GrOpFlushState*, GrDeferredTextureUploadFn&) override {} discard()41 void discard() override {} insertEventMarker(const char *)42 void insertEventMarker(const char*) override {} begin()43 void begin() override {} end()44 void end() override {} copy(GrSurface * src,GrSurfaceOrigin srcOrigin,const SkIRect & srcRect,const SkIPoint & dstPoint)45 void copy(GrSurface* src, GrSurfaceOrigin srcOrigin, const SkIRect& srcRect, 46 const SkIPoint& dstPoint) override {} 47 numDraws()48 int numDraws() const { return fNumDraws; } 49 submit()50 void submit() override { fGpu->submitCommandBuffer(this); } 51 52 private: onDraw(const GrPipeline &,const GrPrimitiveProcessor &,const GrMesh[],const GrPipeline::DynamicState[],int meshCount,const SkRect & bounds)53 void onDraw(const GrPipeline&, const GrPrimitiveProcessor&, const GrMesh[], 54 const GrPipeline::DynamicState[], int meshCount, const SkRect& bounds) override { 55 ++fNumDraws; 56 } onClear(const GrFixedClip &,GrColor)57 void onClear(const GrFixedClip&, GrColor) override {} onClearStencilClip(const GrFixedClip &,bool insideStencilMask)58 void onClearStencilClip(const GrFixedClip&, bool insideStencilMask) override {} 59 60 GrMockGpu* fGpu; 61 int fNumDraws = 0; 62 63 typedef GrGpuRTCommandBuffer INHERITED; 64 }; 65 66 #endif 67