1 /* 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 11 #include "src/gpu/GrRenderTargetProxy.h" 12 #include "src/gpu/GrTextureProxy.h" 13 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! 24 class GrTextureRenderTargetProxy : public GrRenderTargetProxy, public GrTextureProxy { 25 private: 26 // DDL TODO: rm the GrSurfaceProxy friending 27 friend class GrSurfaceProxy; // for ctors 28 friend class GrProxyProvider; // for ctors 29 30 // Deferred version 31 GrTextureRenderTargetProxy(const GrCaps&, const GrBackendFormat&, const GrSurfaceDesc&, 32 int sampleCnt, GrSurfaceOrigin, GrMipMapped, GrMipMapsStatus, 33 const GrSwizzle& textureSwizzle, const GrSwizzle& outputSwizzle, 34 SkBackingFit, SkBudgeted, GrProtected, GrInternalSurfaceFlags); 35 36 // Lazy-callback version 37 GrTextureRenderTargetProxy(LazyInstantiateCallback&&, LazyInstantiationType, 38 const GrBackendFormat&, const GrSurfaceDesc& desc, int sampleCnt, 39 GrSurfaceOrigin, GrMipMapped, GrMipMapsStatus, 40 const GrSwizzle& textureSwizzle, const GrSwizzle& outputSwizzle, 41 SkBackingFit, SkBudgeted, GrProtected, GrInternalSurfaceFlags); 42 43 // Wrapped version 44 GrTextureRenderTargetProxy(sk_sp<GrSurface>, GrSurfaceOrigin, const GrSwizzle& textureSwizzle, 45 const GrSwizzle& outputSwizzle); 46 47 bool instantiate(GrResourceProvider*) override; 48 sk_sp<GrSurface> createSurface(GrResourceProvider*) const override; 49 50 size_t onUninstantiatedGpuMemorySize() const override; 51 52 SkDEBUGCODE(void onValidateSurface(const GrSurface*) override;) 53 }; 54 55 #ifdef SK_BUILD_FOR_WIN 56 #pragma warning(pop) 57 #endif 58 59 #endif 60