blob: 9ea53965f4b3dc8232db32a3014a889c2981df75 [file] [log] [blame]
Robert Phillips84a81202016-11-04 11:59:10 -04001/*
2 * Copyright 2016 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 GrTextureRenderTargetProxy_DEFINED
9#define GrTextureRenderTargetProxy_DEFINED
10
Greg Danielf91aeb22019-06-18 09:58:02 -040011#include "src/gpu/GrRenderTargetProxy.h"
12#include "src/gpu/GrTextureProxy.h"
Robert Phillips84a81202016-11-04 11:59:10 -040013
14#ifdef SK_BUILD_FOR_WIN
15// Windows gives warnings about inheriting asTextureProxy/asRenderTargetProxy via dominance.
16#pragma warning(push)
17#pragma warning(disable: 4250)
18#endif
19
20// This class delays the acquisition of RenderTargets that are also textures until
21// they are actually required
22// Beware: the uniqueID of the TextureRenderTargetProxy will usually be different than
23// the uniqueID of the RenderTarget/Texture it represents!
Brian Osman086679b2018-09-10 16:26:51 -040024class GrTextureRenderTargetProxy : public GrRenderTargetProxy, public GrTextureProxy {
Robert Phillips84a81202016-11-04 11:59:10 -040025private:
Robert Phillips0bd24dc2018-01-16 08:06:32 -050026 // DDL TODO: rm the GrSurfaceProxy friending
Robert Phillips37430132016-11-09 06:50:43 -050027 friend class GrSurfaceProxy; // for ctors
Robert Phillips0bd24dc2018-01-16 08:06:32 -050028 friend class GrProxyProvider; // for ctors
Robert Phillips37430132016-11-09 06:50:43 -050029
Robert Phillips84a81202016-11-04 11:59:10 -040030 // Deferred version
Brian Salomonbeb7f522019-08-30 16:19:42 -040031 GrTextureRenderTargetProxy(const GrCaps&,
32 const GrBackendFormat&,
Brian Salomona56a7462020-02-07 14:17:25 -050033 SkISize,
Brian Salomonbeb7f522019-08-30 16:19:42 -040034 int sampleCnt,
Brian Salomon7e67dca2020-07-21 09:27:25 -040035 GrMipmapped,
Brian Salomonbeb7f522019-08-30 16:19:42 -040036 GrMipMapsStatus,
Brian Salomonbeb7f522019-08-30 16:19:42 -040037 SkBackingFit,
38 SkBudgeted,
39 GrProtected,
40 GrInternalSurfaceFlags,
Robert Phillipsf10b2a52020-05-15 10:20:04 -040041 UseAllocator,
42 GrDDLProvider creatingProvider);
Robert Phillips84a81202016-11-04 11:59:10 -040043
Chris Dalton706a6ff2017-11-29 22:01:06 -070044 // Lazy-callback version
Brian Salomonbeb7f522019-08-30 16:19:42 -040045 GrTextureRenderTargetProxy(const GrCaps&,
46 LazyInstantiateCallback&&,
47 const GrBackendFormat&,
Brian Salomona56a7462020-02-07 14:17:25 -050048 SkISize,
Brian Salomonbeb7f522019-08-30 16:19:42 -040049 int sampleCnt,
Brian Salomon7e67dca2020-07-21 09:27:25 -040050 GrMipmapped,
Brian Salomonbeb7f522019-08-30 16:19:42 -040051 GrMipMapsStatus,
Brian Salomonbeb7f522019-08-30 16:19:42 -040052 SkBackingFit,
53 SkBudgeted,
54 GrProtected,
55 GrInternalSurfaceFlags,
Robert Phillipsf10b2a52020-05-15 10:20:04 -040056 UseAllocator,
57 GrDDLProvider creatingProvider);
Chris Dalton706a6ff2017-11-29 22:01:06 -070058
Robert Phillips84a81202016-11-04 11:59:10 -040059 // Wrapped version
Brian Salomonbeb7f522019-08-30 16:19:42 -040060 GrTextureRenderTargetProxy(sk_sp<GrSurface>,
Robert Phillipsf10b2a52020-05-15 10:20:04 -040061 UseAllocator,
62 GrDDLProvider creatingProvider);
Robert Phillips84a81202016-11-04 11:59:10 -040063
Chris Dalton3f7932e2019-08-19 00:39:13 -060064 void initSurfaceFlags(const GrCaps&);
65
Robert Phillips10d17212019-04-24 14:09:10 -040066 bool instantiate(GrResourceProvider*) override;
Robert Phillips5af44de2017-07-18 14:49:38 -040067 sk_sp<GrSurface> createSurface(GrResourceProvider*) const override;
Brian Salomonbb5711a2017-05-17 13:49:59 -040068
Greg Daniel7fd7a8a2019-10-10 16:10:31 -040069 size_t onUninstantiatedGpuMemorySize(const GrCaps&) const override;
Brian Salomon63410e92020-03-23 18:32:50 -040070 LazySurfaceDesc callbackDesc() const override;
Greg Daniel849dce12018-04-24 14:32:53 -040071 SkDEBUGCODE(void onValidateSurface(const GrSurface*) override;)
Robert Phillips84a81202016-11-04 11:59:10 -040072};
73
74#ifdef SK_BUILD_FOR_WIN
75#pragma warning(pop)
76#endif
77
78#endif