blob: a206e76e37a4cafeac166e3d3d000cf0928197bb [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
Robert Phillips84a81202016-11-04 11:59:10 -040014class GrCaps;
robertphillips76948d42016-05-04 12:47:41 -070015class GrTextureProvider;
16
17// This class delays the acquisition of textures until they are actually required
Robert Phillips84a81202016-11-04 11:59:10 -040018class GrTextureProxy : virtual public GrSurfaceProxy {
robertphillips76948d42016-05-04 12:47:41 -070019public:
robertphillips76948d42016-05-04 12:47:41 -070020 GrTextureProxy* asTextureProxy() override { return this; }
21 const GrTextureProxy* asTextureProxy() const override { return this; }
22
23 // Actually instantiate the backing texture, if necessary
Robert Phillips8bc06d02016-11-01 17:28:40 -040024 GrTexture* instantiate(GrTextureProvider*);
robertphillips76948d42016-05-04 12:47:41 -070025
Robert Phillips84a81202016-11-04 11:59:10 -040026protected:
Robert Phillips37430132016-11-09 06:50:43 -050027 friend class GrSurfaceProxy; // for ctors
28
robertphillips8abb3702016-08-31 14:04:06 -070029 // Deferred version
30 GrTextureProxy(const GrSurfaceDesc& srcDesc, SkBackingFit, SkBudgeted,
31 const void* srcData, size_t srcRowBytes);
robertphillips76948d42016-05-04 12:47:41 -070032 // Wrapped version
Robert Phillips37430132016-11-09 06:50:43 -050033 GrTextureProxy(sk_sp<GrSurface>);
robertphillips76948d42016-05-04 12:47:41 -070034
Robert Phillips84a81202016-11-04 11:59:10 -040035private:
Robert Phillips8bc06d02016-11-01 17:28:40 -040036 size_t onGpuMemorySize() const override;
37
Robert Phillipsc7635fa2016-10-28 13:25:24 -040038 // For wrapped proxies the GrTexture pointer is stored in GrIORefProxy.
39 // For deferred proxies that pointer will be filled n when we need to instantiate
40 // the deferred resource
robertphillips76948d42016-05-04 12:47:41 -070041
42 typedef GrSurfaceProxy INHERITED;
43};
44
45#endif