blob: 5b4eeef7bc95dc90bc399d343baa1a275255911c [file] [log] [blame]
robertphillips76948d42016-05-04 12:47:41 -07001/*
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 GrTextureProxy_DEFINED
9#define GrTextureProxy_DEFINED
10
11#include "GrSurfaceProxy.h"
12#include "GrTexture.h"
13
14class GrTextureProvider;
15
16// This class delays the acquisition of textures until they are actually required
17class GrTextureProxy : public GrSurfaceProxy {
18public:
19 // TODO: need to refine ownership semantics of 'srcData' if we're in completely
20 // deferred mode
21 static sk_sp<GrTextureProxy> Make(const GrSurfaceDesc&, SkBackingFit, SkBudgeted,
22 const void* srcData = nullptr, size_t rowBytes = 0);
23 static sk_sp<GrTextureProxy> Make(sk_sp<GrTexture>);
24
25 // TODO: add asRenderTargetProxy variants
26 GrTextureProxy* asTextureProxy() override { return this; }
27 const GrTextureProxy* asTextureProxy() const override { return this; }
28
29 // Actually instantiate the backing texture, if necessary
30 GrTexture* instantiate(GrTextureProvider* texProvider);
31
32private:
robertphillips8abb3702016-08-31 14:04:06 -070033 // Deferred version
34 GrTextureProxy(const GrSurfaceDesc& srcDesc, SkBackingFit, SkBudgeted,
35 const void* srcData, size_t srcRowBytes);
robertphillips76948d42016-05-04 12:47:41 -070036 // Wrapped version
37 GrTextureProxy(sk_sp<GrTexture> tex);
38
Robert Phillipsc7635fa2016-10-28 13:25:24 -040039 // For wrapped proxies the GrTexture pointer is stored in GrIORefProxy.
40 // For deferred proxies that pointer will be filled n when we need to instantiate
41 // the deferred resource
robertphillips76948d42016-05-04 12:47:41 -070042
43 typedef GrSurfaceProxy INHERITED;
44};
45
46#endif