blob: 60be19ecefba75de42fa34aee4003d01a9b20a55 [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
Robert Phillipsd9d84852017-06-09 10:48:29 -040011#include "GrSamplerParams.h"
robertphillips76948d42016-05-04 12:47:41 -070012#include "GrSurfaceProxy.h"
robertphillips76948d42016-05-04 12:47:41 -070013
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
Robert Phillipseee4d6e2017-06-05 09:26:07 -040025 bool instantiate(GrResourceProvider*) override;
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
Brian Salomonbb5711a2017-05-17 13:49:59 -040039 bool isMipMapped() const { return fIsMipMapped; }
40
Robert Phillips84a81202016-11-04 11:59:10 -040041protected:
Robert Phillips37430132016-11-09 06:50:43 -050042 friend class GrSurfaceProxy; // for ctors
43
robertphillips8abb3702016-08-31 14:04:06 -070044 // Deferred version
45 GrTextureProxy(const GrSurfaceDesc& srcDesc, SkBackingFit, SkBudgeted,
Robert Phillipsc787e492017-02-28 11:26:32 -050046 const void* srcData, size_t srcRowBytes, uint32_t flags);
robertphillips76948d42016-05-04 12:47:41 -070047 // Wrapped version
Robert Phillips96be9df2017-07-21 14:17:45 +000048 GrTextureProxy(sk_sp<GrSurface>);
robertphillips76948d42016-05-04 12:47:41 -070049
Brian Salomon081e0e62017-05-17 14:27:58 -040050 SkDestinationSurfaceColorMode mipColorMode() const { return fMipColorMode; }
51
Robert Phillips5af44de2017-07-18 14:49:38 -040052 sk_sp<GrSurface> createSurface(GrResourceProvider*) const override;
53
Robert Phillips84a81202016-11-04 11:59:10 -040054private:
Brian Salomonbb5711a2017-05-17 13:49:59 -040055 bool fIsMipMapped;
Brian Salomon081e0e62017-05-17 14:27:58 -040056 SkDestinationSurfaceColorMode fMipColorMode;
Brian Salomonbb5711a2017-05-17 13:49:59 -040057
58 size_t onUninstantiatedGpuMemorySize() const override;
Robert Phillips8bc06d02016-11-01 17:28:40 -040059
Robert Phillipsc7635fa2016-10-28 13:25:24 -040060 // For wrapped proxies the GrTexture pointer is stored in GrIORefProxy.
Robert Phillipsa4c41b32017-03-15 13:02:45 -040061 // For deferred proxies that pointer will be filled in when we need to instantiate
Robert Phillipsc7635fa2016-10-28 13:25:24 -040062 // the deferred resource
robertphillips76948d42016-05-04 12:47:41 -070063
64 typedef GrSurfaceProxy INHERITED;
65};
66
67#endif