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