blob: 863f989b0f7b141bc0e5582510e07b707f21168c [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
Greg Daniel2d41d0d2019-08-26 11:08:51 -04008#ifndef GrMockOpsRenderPass_DEFINED
9#define GrMockOpsRenderPass_DEFINED
Brian Salomoncfe910d2017-07-06 16:40:18 -040010
Greg Daniel2d41d0d2019-08-26 11:08:51 -040011#include "src/gpu/GrOpsRenderPass.h"
Chris Dalton30eea6c2019-08-21 10:22:50 -060012
13#include "src/gpu/GrTexturePriv.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050014#include "src/gpu/mock/GrMockGpu.h"
Brian Salomoncfe910d2017-07-06 16:40:18 -040015
Greg Daniel2d41d0d2019-08-26 11:08:51 -040016class GrMockOpsRenderPass : public GrOpsRenderPass {
Brian Salomoncfe910d2017-07-06 16:40:18 -040017public:
Greg Daniel2d41d0d2019-08-26 11:08:51 -040018 GrMockOpsRenderPass(GrMockGpu* gpu, GrRenderTarget* rt, GrSurfaceOrigin origin,
19 LoadAndStoreInfo colorInfo)
Robert Phillips19e51dc2017-08-09 09:30:51 -040020 : INHERITED(rt, origin)
Chris Dalton30eea6c2019-08-21 10:22:50 -060021 , fGpu(gpu)
22 , fColorLoadOp(colorInfo.fLoadOp) {
Robert Phillips19e51dc2017-08-09 09:30:51 -040023 }
Brian Salomoncfe910d2017-07-06 16:40:18 -040024
25 GrGpu* gpu() override { return fGpu; }
Brian Salomon943ed792017-10-30 09:37:55 -040026 void inlineUpload(GrOpFlushState*, GrDeferredTextureUploadFn&) override {}
Robert Phillips19e51dc2017-08-09 09:30:51 -040027 void insertEventMarker(const char*) override {}
Chris Dalton30eea6c2019-08-21 10:22:50 -060028 void begin() override {
29 if (GrLoadOp::kClear == fColorLoadOp) {
30 this->markRenderTargetDirty();
31 }
32 }
Brian Salomoncfe910d2017-07-06 16:40:18 -040033 void end() override {}
34
35 int numDraws() const { return fNumDraws; }
36
37private:
Brian Salomon49348902018-06-26 09:12:38 -040038 void onDraw(const GrPrimitiveProcessor&, const GrPipeline&,
39 const GrPipeline::FixedDynamicState*, const GrPipeline::DynamicStateArrays*,
40 const GrMesh[], int meshCount, const SkRect& bounds) override {
Chris Dalton30eea6c2019-08-21 10:22:50 -060041 this->markRenderTargetDirty();
Brian Salomoncfe910d2017-07-06 16:40:18 -040042 ++fNumDraws;
43 }
Chris Dalton30eea6c2019-08-21 10:22:50 -060044 void onClear(const GrFixedClip&, const SkPMColor4f&) override {
45 this->markRenderTargetDirty();
46 }
Robert Phillips19e51dc2017-08-09 09:30:51 -040047 void onClearStencilClip(const GrFixedClip&, bool insideStencilMask) override {}
Brian Salomoncfe910d2017-07-06 16:40:18 -040048
Chris Dalton30eea6c2019-08-21 10:22:50 -060049 void markRenderTargetDirty() {
50 if (auto* tex = fRenderTarget->asTexture()) {
51 tex->texturePriv().markMipMapsDirty();
52 }
53 fRenderTarget->flagAsNeedingResolve();
54 }
55
Brian Salomoncfe910d2017-07-06 16:40:18 -040056 GrMockGpu* fGpu;
Chris Dalton30eea6c2019-08-21 10:22:50 -060057 GrLoadOp fColorLoadOp;
Brian Salomoncfe910d2017-07-06 16:40:18 -040058 int fNumDraws = 0;
59
Greg Daniel2d41d0d2019-08-26 11:08:51 -040060 typedef GrOpsRenderPass INHERITED;
Brian Salomoncfe910d2017-07-06 16:40:18 -040061};
62
63#endif