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 GrMockAttachment_DEFINED 9 #define GrMockAttachment_DEFINED 10 11 #include "include/core/SkSize.h" 12 #include "include/core/SkTextureCompressionType.h" 13 #include "include/gpu/GpuTypes.h" 14 #include "include/gpu/ganesh/GrBackendSurface.h" 15 #include "include/private/base/SkAssert.h" 16 #include "include/private/gpu/ganesh/GrTypesPriv.h" 17 #include "src/gpu/ganesh/GrAttachment.h" 18 #include "src/gpu/ganesh/mock/GrMockGpu.h" 19 20 #include <string_view> 21 22 class GrMockAttachment : public GrAttachment { 23 public: GrMockAttachment(GrMockGpu * gpu,SkISize dimensions,UsageFlags supportedUsages,int sampleCnt,std::string_view label)24 GrMockAttachment(GrMockGpu* gpu, 25 SkISize dimensions, 26 UsageFlags supportedUsages, 27 int sampleCnt, 28 std::string_view label) 29 : INHERITED(gpu, 30 dimensions, 31 supportedUsages, 32 sampleCnt, 33 skgpu::Mipmapped::kNo, 34 skgpu::Protected::kNo, 35 label) { 36 SkASSERT(supportedUsages == UsageFlags::kStencilAttachment); 37 this->registerWithCache(skgpu::Budgeted::kYes); 38 } 39 backendFormat()40 GrBackendFormat backendFormat() const override { 41 return GrBackendFormat::MakeMock(GrColorType::kUnknown, SkTextureCompressionType::kNone, 42 /*isStencilFormat*/ true); 43 } 44 45 private: 46 using INHERITED = GrAttachment; 47 }; 48 49 #endif 50