blob: ee954dcede746a2669fbe0090ff601f8ae41aa5b [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 Phillipsa4c41b32017-03-15 13:02:45 -040027 void setMipColorMode(SkDestinationSurfaceColorMode colorMode);
28
Robert Phillips84a81202016-11-04 11:59:10 -040029protected:
Robert Phillips37430132016-11-09 06:50:43 -050030 friend class GrSurfaceProxy; // for ctors
31
robertphillips8abb3702016-08-31 14:04:06 -070032 // Deferred version
33 GrTextureProxy(const GrSurfaceDesc& srcDesc, SkBackingFit, SkBudgeted,
Robert Phillipsc787e492017-02-28 11:26:32 -050034 const void* srcData, size_t srcRowBytes, uint32_t flags);
robertphillips76948d42016-05-04 12:47:41 -070035 // Wrapped version
Robert Phillips37430132016-11-09 06:50:43 -050036 GrTextureProxy(sk_sp<GrSurface>);
robertphillips76948d42016-05-04 12:47:41 -070037
Robert Phillips84a81202016-11-04 11:59:10 -040038private:
Robert Phillips8bc06d02016-11-01 17:28:40 -040039 size_t onGpuMemorySize() const override;
40
Robert Phillipsc7635fa2016-10-28 13:25:24 -040041 // For wrapped proxies the GrTexture pointer is stored in GrIORefProxy.
Robert Phillipsa4c41b32017-03-15 13:02:45 -040042 // For deferred proxies that pointer will be filled in when we need to instantiate
Robert Phillipsc7635fa2016-10-28 13:25:24 -040043 // the deferred resource
robertphillips76948d42016-05-04 12:47:41 -070044
45 typedef GrSurfaceProxy INHERITED;
46};
47
48#endif