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 "GrRenderTargetProxy.h"
12#include "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!
24class GrTextureRenderTargetProxy : public GrTextureProxy, public GrRenderTargetProxy {
25private:
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 GrSurfaceDesc&, GrMipMapped,
32                               SkBackingFit, SkBudgeted, uint32_t flags);
33
34    // Lazy-callback version
35    GrTextureRenderTargetProxy(LazyInstantiateCallback&&, LazyInstantiationType,
36                               const GrSurfaceDesc& desc, GrMipMapped, SkBackingFit, SkBudgeted,
37                               uint32_t flags, GrRenderTargetFlags);
38
39    // Wrapped version
40    GrTextureRenderTargetProxy(sk_sp<GrSurface>, GrSurfaceOrigin);
41
42    bool instantiate(GrResourceProvider*) override;
43    sk_sp<GrSurface> createSurface(GrResourceProvider*) const override;
44
45    size_t onUninstantiatedGpuMemorySize() const override;
46
47    SkDEBUGCODE(void validateLazySurface(const GrSurface*) override;)
48};
49
50#ifdef SK_BUILD_FOR_WIN
51#pragma warning(pop)
52#endif
53
54#endif
55