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 | |
| 11 | #include "GrTexture.h" |
| 12 | |
| 13 | /** Class that adds methods to GrTexture that are only intended for use internal to Skia. |
| 14 | This class is purely a privileged window into GrTexture. It should never have additional data |
| 15 | members or virtual methods. |
| 16 | Non-static methods that are not trivial inlines should be spring-boarded (e.g. declared and |
| 17 | implemented privately in GrTexture with a inline public method here). */ |
| 18 | class GrTexturePriv { |
| 19 | public: |
Greg Daniel | 0fc4d2d | 2017-10-12 11:23:36 -0400 | [diff] [blame] | 20 | void markMipMapsDirty() { |
| 21 | fTexture->markMipMapsDirty(); |
| 22 | } |
| 23 | |
| 24 | void markMipMapsClean() { |
| 25 | fTexture->markMipMapsClean(); |
brianosman | 33f6b3f | 2016-06-02 05:49:21 -0700 | [diff] [blame] | 26 | } |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame] | 27 | |
| 28 | bool mipMapsAreDirty() const { |
Greg Daniel | 0fc4d2d | 2017-10-12 11:23:36 -0400 | [diff] [blame] | 29 | return GrMipMapsStatus::kValid != fTexture->fMipMapsStatus; |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame] | 30 | } |
| 31 | |
Greg Daniel | e252f08 | 2017-10-23 16:05:23 -0400 | [diff] [blame] | 32 | GrMipMapped mipMapped() const { |
| 33 | if (GrMipMapsStatus::kNotAllocated != fTexture->fMipMapsStatus) { |
| 34 | return GrMipMapped::kYes; |
| 35 | } |
| 36 | return GrMipMapped::kNo; |
Greg Daniel | 834f120 | 2017-10-09 15:06:20 -0400 | [diff] [blame] | 37 | } |
| 38 | |
cblume | 55f2d2d | 2016-02-26 13:20:48 -0800 | [diff] [blame] | 39 | int maxMipMapLevel() const { |
| 40 | return fTexture->fMaxMipMapLevel; |
| 41 | } |
| 42 | |
Brian Salomon | 739c5bf | 2016-11-07 09:53:44 -0500 | [diff] [blame] | 43 | GrSLType samplerType() const { return fTexture->fSamplerType; } |
| 44 | |
Brian Salomon | 0bbecb2 | 2016-11-17 11:38:22 -0500 | [diff] [blame] | 45 | /** The filter used is clamped to this value in GrProcessor::TextureSampler. */ |
Brian Salomon | 2bbdcc4 | 2017-09-07 12:36:34 -0400 | [diff] [blame] | 46 | GrSamplerState::Filter highestFilterMode() const { return fTexture->fHighestFilterMode; } |
Brian Salomon | 739c5bf | 2016-11-07 09:53:44 -0500 | [diff] [blame] | 47 | |
Greg Daniel | 2191823 | 2017-09-08 14:46:23 -0400 | [diff] [blame] | 48 | static void ComputeScratchKey(const GrSurfaceDesc&, GrScratchKey*); |
Brian Salomon | d34edf3 | 2017-05-19 15:45:48 -0400 | [diff] [blame] | 49 | static void ComputeScratchKey(GrPixelConfig config, int width, int height, |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 50 | bool isRenderTarget, int sampleCnt, |
Greg Daniel | e252f08 | 2017-10-23 16:05:23 -0400 | [diff] [blame] | 51 | GrMipMapped, GrScratchKey* key); |
Brian Salomon | d34edf3 | 2017-05-19 15:45:48 -0400 | [diff] [blame] | 52 | |
Brian Salomon | cfe910d | 2017-07-06 16:40:18 -0400 | [diff] [blame] | 53 | |
| 54 | private: |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame] | 55 | GrTexturePriv(GrTexture* texture) : fTexture(texture) { } |
| 56 | GrTexturePriv(const GrTexturePriv& that) : fTexture(that.fTexture) { } |
| 57 | GrTexturePriv& operator=(const GrTexturePriv&); // unimpl |
| 58 | |
| 59 | // No taking addresses of this type. |
| 60 | const GrTexturePriv* operator&() const; |
| 61 | GrTexturePriv* operator&(); |
| 62 | |
| 63 | GrTexture* fTexture; |
cblume | 6121405 | 2016-01-26 09:10:48 -0800 | [diff] [blame] | 64 | |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame] | 65 | friend class GrTexture; // to construct/copy this type. |
| 66 | }; |
| 67 | |
| 68 | inline GrTexturePriv GrTexture::texturePriv() { return GrTexturePriv(this); } |
| 69 | |
| 70 | inline const GrTexturePriv GrTexture::texturePriv () const { |
| 71 | return GrTexturePriv(const_cast<GrTexture*>(this)); |
| 72 | } |
| 73 | |
| 74 | #endif |