bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 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 GrTexturePriv_DEFINED |
| 9 | #define GrTexturePriv_DEFINED |
| 10 | |
Brian Salomon | 201cdbb | 2019-08-14 17:00:30 -0400 | [diff] [blame] | 11 | #include "src/gpu/GrSamplerState.h" |
Greg Daniel | 456f9b5 | 2020-03-05 19:14:18 +0000 | [diff] [blame] | 12 | #include "src/gpu/GrTexture.h" |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame] | 13 | |
| 14 | /** Class that adds methods to GrTexture that are only intended for use internal to Skia. |
| 15 | This class is purely a privileged window into GrTexture. It should never have additional data |
| 16 | members or virtual methods. |
| 17 | Non-static methods that are not trivial inlines should be spring-boarded (e.g. declared and |
| 18 | implemented privately in GrTexture with a inline public method here). */ |
| 19 | class GrTexturePriv { |
| 20 | public: |
Greg Daniel | 0fc4d2d | 2017-10-12 11:23:36 -0400 | [diff] [blame] | 21 | void markMipMapsDirty() { |
| 22 | fTexture->markMipMapsDirty(); |
| 23 | } |
| 24 | |
| 25 | void markMipMapsClean() { |
| 26 | fTexture->markMipMapsClean(); |
brianosman | 33f6b3f | 2016-06-02 05:49:21 -0700 | [diff] [blame] | 27 | } |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame] | 28 | |
Chris Dalton | 95d8ceb | 2019-07-30 11:17:59 -0600 | [diff] [blame] | 29 | GrMipMapsStatus mipMapsStatus() const { return fTexture->fMipMapsStatus; } |
| 30 | |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame] | 31 | bool mipMapsAreDirty() const { |
Chris Dalton | 95d8ceb | 2019-07-30 11:17:59 -0600 | [diff] [blame] | 32 | return GrMipMapsStatus::kValid != this->mipMapsStatus(); |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame] | 33 | } |
| 34 | |
Greg Daniel | e252f08 | 2017-10-23 16:05:23 -0400 | [diff] [blame] | 35 | GrMipMapped mipMapped() const { |
Chris Dalton | 95d8ceb | 2019-07-30 11:17:59 -0600 | [diff] [blame] | 36 | if (GrMipMapsStatus::kNotAllocated != this->mipMapsStatus()) { |
Greg Daniel | e252f08 | 2017-10-23 16:05:23 -0400 | [diff] [blame] | 37 | return GrMipMapped::kYes; |
| 38 | } |
| 39 | return GrMipMapped::kNo; |
Greg Daniel | 834f120 | 2017-10-09 15:06:20 -0400 | [diff] [blame] | 40 | } |
| 41 | |
cblume | 55f2d2d | 2016-02-26 13:20:48 -0800 | [diff] [blame] | 42 | int maxMipMapLevel() const { |
| 43 | return fTexture->fMaxMipMapLevel; |
| 44 | } |
| 45 | |
Brian Salomon | 60dd8c7 | 2018-07-30 10:24:13 -0400 | [diff] [blame] | 46 | GrTextureType textureType() const { return fTexture->fTextureType; } |
Brian Salomon | 7226c23 | 2018-07-30 13:13:17 -0400 | [diff] [blame] | 47 | bool hasRestrictedSampling() const { |
| 48 | return GrTextureTypeHasRestrictedSampling(this->textureType()); |
| 49 | } |
Brian Salomon | 739c5bf | 2016-11-07 09:53:44 -0500 | [diff] [blame] | 50 | |
Greg Daniel | d51fa2f | 2020-01-22 16:53:38 -0500 | [diff] [blame] | 51 | static void ComputeScratchKey(const GrCaps& caps, |
| 52 | const GrBackendFormat& format, |
Brian Salomon | 9f2b86c | 2019-10-22 10:37:46 -0400 | [diff] [blame] | 53 | SkISize dimensions, |
Brian Salomon | 14cb413 | 2019-09-16 13:14:47 -0400 | [diff] [blame] | 54 | GrRenderable, |
| 55 | int sampleCnt, |
| 56 | GrMipMapped, |
| 57 | GrProtected, |
| 58 | GrScratchKey* key); |
Brian Salomon | cfe910d | 2017-07-06 16:40:18 -0400 | [diff] [blame] | 59 | |
| 60 | private: |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame] | 61 | GrTexturePriv(GrTexture* texture) : fTexture(texture) { } |
| 62 | GrTexturePriv(const GrTexturePriv& that) : fTexture(that.fTexture) { } |
| 63 | GrTexturePriv& operator=(const GrTexturePriv&); // unimpl |
| 64 | |
| 65 | // No taking addresses of this type. |
| 66 | const GrTexturePriv* operator&() const; |
| 67 | GrTexturePriv* operator&(); |
| 68 | |
| 69 | GrTexture* fTexture; |
cblume | 6121405 | 2016-01-26 09:10:48 -0800 | [diff] [blame] | 70 | |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame] | 71 | friend class GrTexture; // to construct/copy this type. |
| 72 | }; |
| 73 | |
| 74 | inline GrTexturePriv GrTexture::texturePriv() { return GrTexturePriv(this); } |
| 75 | |
| 76 | inline const GrTexturePriv GrTexture::texturePriv () const { |
| 77 | return GrTexturePriv(const_cast<GrTexture*>(this)); |
| 78 | } |
| 79 | |
| 80 | #endif |