robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 1 | /* |
| 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 Phillips | 84a8120 | 2016-11-04 11:59:10 -0400 | [diff] [blame] | 14 | class GrCaps; |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 15 | class GrTextureProvider; |
| 16 | |
| 17 | // This class delays the acquisition of textures until they are actually required |
Robert Phillips | 84a8120 | 2016-11-04 11:59:10 -0400 | [diff] [blame] | 18 | class GrTextureProxy : virtual public GrSurfaceProxy { |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 19 | public: |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 20 | GrTextureProxy* asTextureProxy() override { return this; } |
| 21 | const GrTextureProxy* asTextureProxy() const override { return this; } |
| 22 | |
| 23 | // Actually instantiate the backing texture, if necessary |
Robert Phillips | 8bc06d0 | 2016-11-01 17:28:40 -0400 | [diff] [blame] | 24 | GrTexture* instantiate(GrTextureProvider*); |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 25 | |
Robert Phillips | 84a8120 | 2016-11-04 11:59:10 -0400 | [diff] [blame] | 26 | protected: |
Robert Phillips | 3743013 | 2016-11-09 06:50:43 -0500 | [diff] [blame] | 27 | friend class GrSurfaceProxy; // for ctors |
| 28 | |
robertphillips | 8abb370 | 2016-08-31 14:04:06 -0700 | [diff] [blame] | 29 | // Deferred version |
| 30 | GrTextureProxy(const GrSurfaceDesc& srcDesc, SkBackingFit, SkBudgeted, |
| 31 | const void* srcData, size_t srcRowBytes); |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 32 | // Wrapped version |
Robert Phillips | 3743013 | 2016-11-09 06:50:43 -0500 | [diff] [blame] | 33 | GrTextureProxy(sk_sp<GrSurface>); |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 34 | |
Robert Phillips | 84a8120 | 2016-11-04 11:59:10 -0400 | [diff] [blame] | 35 | private: |
Robert Phillips | 8bc06d0 | 2016-11-01 17:28:40 -0400 | [diff] [blame] | 36 | size_t onGpuMemorySize() const override; |
| 37 | |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 38 | // 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 |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 41 | |
| 42 | typedef GrSurfaceProxy INHERITED; |
| 43 | }; |
| 44 | |
| 45 | #endif |