xref: /aosp_15_r20/external/skia/src/gpu/ganesh/mock/GrMockSurfaceProxy.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2021 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 GrMockSurfaceProxy_DEFINED
9 #define GrMockSurfaceProxy_DEFINED
10 
11 #include "include/core/SkRefCnt.h"
12 #include "include/core/SkSize.h"
13 #include "include/core/SkString.h"
14 #include "include/core/SkTextureCompressionType.h"
15 #include "include/gpu/GpuTypes.h"
16 #include "include/gpu/ganesh/GrBackendSurface.h"
17 #include "include/private/base/SkAssert.h"
18 #include "include/private/base/SkDebug.h"
19 #include "include/private/gpu/ganesh/GrTypesPriv.h"
20 #include "src/gpu/SkBackingFit.h"
21 #include "src/gpu/ganesh/GrSurfaceProxy.h"
22 
23 #include <cstddef>
24 #include <string_view>
25 #include <utility>
26 
27 class GrResourceProvider;
28 class GrSurface;
29 
30 class GrMockSurfaceProxy : public GrSurfaceProxy {
31 public:
GrMockSurfaceProxy(SkString name,std::string_view label)32     GrMockSurfaceProxy(SkString name, std::string_view label)
33             : GrSurfaceProxy(GrBackendFormat::MakeMock(GrColorType::kRGBA_8888,
34                                                        SkTextureCompressionType::kNone),
35                              SkISize::Make(1, 1),
36                              SkBackingFit::kExact,
37                              skgpu::Budgeted::kNo,
38                              skgpu::Protected::kNo,
39                              GrInternalSurfaceFlags::kNone,
40                              UseAllocator::kNo,
41                              label) {
42         SkDEBUGCODE(this->setDebugName(std::move(name)));
43     }
44 
instantiate(GrResourceProvider *)45     bool instantiate(GrResourceProvider*) override { return false; }
SkDEBUGCODE(void onValidateSurface (const GrSurface *)override{} )46     SkDEBUGCODE(void onValidateSurface(const GrSurface*) override {} )
47     size_t onUninstantiatedGpuMemorySize() const override { return 0; }
48 
49 protected:
createSurface(GrResourceProvider *)50     sk_sp<GrSurface> createSurface(GrResourceProvider*) const override { return nullptr; }
51 
52 private:
callbackDesc()53     LazySurfaceDesc callbackDesc() const override { SkUNREACHABLE; }
54 };
55 
56 #endif
57