blob: eb82ca75811ff7a8196ad13efa579ed6141d7d52 [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:
33 GrTextureProxy(const GrSurfaceDesc& desc, SkBackingFit fit, SkBudgeted budgeted,
34 const void* /*srcData*/, size_t /*rowBytes*/)
35 : INHERITED(desc, fit, budgeted) {
36 // TODO: Handle 'srcData' here
37 }
38
39 // Wrapped version
40 GrTextureProxy(sk_sp<GrTexture> tex);
41
42 // For wrapped textures we store it here.
43 // For deferred proxies we will fill this in when we need to instantiate the deferred resource
44 sk_sp<GrTexture> fTexture;
45
46 typedef GrSurfaceProxy INHERITED;
47};
48
49#endif