blob: e14e285d87c51b07c41396886188a2add58c554c [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 Phillips49081d12017-05-08 13:41:35 -040029 GrSamplerParams::FilterMode highestFilterMode() const;
30
Robert Phillips8a02f652017-05-12 14:49:16 -040031 GrSLType imageStorageType() const {
32 if (GrPixelConfigIsSint(this->config())) {
33 return kIImageStorage2D_GrSLType;
34 } else {
35 return kImageStorage2D_GrSLType;
36 }
37 }
38
Robert Phillips84a81202016-11-04 11:59:10 -040039protected:
Robert Phillips37430132016-11-09 06:50:43 -050040 friend class GrSurfaceProxy; // for ctors
41
robertphillips8abb3702016-08-31 14:04:06 -070042 // Deferred version
43 GrTextureProxy(const GrSurfaceDesc& srcDesc, SkBackingFit, SkBudgeted,
Robert Phillipsc787e492017-02-28 11:26:32 -050044 const void* srcData, size_t srcRowBytes, uint32_t flags);
robertphillips76948d42016-05-04 12:47:41 -070045 // Wrapped version
Robert Phillips37430132016-11-09 06:50:43 -050046 GrTextureProxy(sk_sp<GrSurface>);
robertphillips76948d42016-05-04 12:47:41 -070047
Robert Phillips84a81202016-11-04 11:59:10 -040048private:
Robert Phillips8bc06d02016-11-01 17:28:40 -040049 size_t onGpuMemorySize() const override;
50
Robert Phillipsc7635fa2016-10-28 13:25:24 -040051 // For wrapped proxies the GrTexture pointer is stored in GrIORefProxy.
Robert Phillipsa4c41b32017-03-15 13:02:45 -040052 // For deferred proxies that pointer will be filled in when we need to instantiate
Robert Phillipsc7635fa2016-10-28 13:25:24 -040053 // the deferred resource
robertphillips76948d42016-05-04 12:47:41 -070054
55 typedef GrSurfaceProxy INHERITED;
56};
57
58#endif