blob: 9383ec7fac25a1135e94dbf83e76cde176f4f9b6 [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;
Brian Osman32342f02017-03-04 08:12:46 -050015class GrResourceProvider;
Brian Osman45580d32016-11-23 09:37:01 -050016class GrTextureOpList;
robertphillips76948d42016-05-04 12:47:41 -070017
18// This class delays the acquisition of textures until they are actually required
Robert Phillips84a81202016-11-04 11:59:10 -040019class GrTextureProxy : virtual public GrSurfaceProxy {
robertphillips76948d42016-05-04 12:47:41 -070020public:
robertphillips76948d42016-05-04 12:47:41 -070021 GrTextureProxy* asTextureProxy() override { return this; }
22 const GrTextureProxy* asTextureProxy() const override { return this; }
23
24 // Actually instantiate the backing texture, if necessary
Brian Osman32342f02017-03-04 08:12:46 -050025 GrTexture* instantiate(GrResourceProvider*);
robertphillips76948d42016-05-04 12:47:41 -070026
Robert Phillips84a81202016-11-04 11:59:10 -040027protected:
Robert Phillips37430132016-11-09 06:50:43 -050028 friend class GrSurfaceProxy; // for ctors
29
robertphillips8abb3702016-08-31 14:04:06 -070030 // Deferred version
31 GrTextureProxy(const GrSurfaceDesc& srcDesc, SkBackingFit, SkBudgeted,
Robert Phillipsc787e492017-02-28 11:26:32 -050032 const void* srcData, size_t srcRowBytes, uint32_t flags);
robertphillips76948d42016-05-04 12:47:41 -070033 // Wrapped version
Robert Phillips37430132016-11-09 06:50:43 -050034 GrTextureProxy(sk_sp<GrSurface>);
robertphillips76948d42016-05-04 12:47:41 -070035
Robert Phillips84a81202016-11-04 11:59:10 -040036private:
Robert Phillips8bc06d02016-11-01 17:28:40 -040037 size_t onGpuMemorySize() const override;
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