• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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:
markMipMapsDirty()20     void markMipMapsDirty() {
21         fTexture->markMipMapsDirty();
22     }
23 
markMipMapsClean()24     void markMipMapsClean() {
25         fTexture->markMipMapsClean();
26     }
27 
mipMapsAreDirty()28     bool mipMapsAreDirty() const {
29         return GrMipMapsStatus::kValid != fTexture->fMipMapsStatus;
30     }
31 
mipMapped()32     GrMipMapped mipMapped() const {
33         if (GrMipMapsStatus::kNotAllocated != fTexture->fMipMapsStatus) {
34             return GrMipMapped::kYes;
35         }
36         return GrMipMapped::kNo;
37     }
38 
maxMipMapLevel()39     int maxMipMapLevel() const {
40         return fTexture->fMaxMipMapLevel;
41     }
42 
textureType()43     GrTextureType textureType() const { return fTexture->fTextureType; }
hasRestrictedSampling()44     bool hasRestrictedSampling() const {
45         return GrTextureTypeHasRestrictedSampling(this->textureType());
46     }
47     /** Filtering is clamped to this value. */
highestFilterMode()48     GrSamplerState::Filter highestFilterMode() const {
49         return this->hasRestrictedSampling() ? GrSamplerState::Filter::kBilerp
50                                              : GrSamplerState::Filter::kMipMap;
51     }
52 
53     static void ComputeScratchKey(const GrSurfaceDesc&, GrScratchKey*);
54     static void ComputeScratchKey(GrPixelConfig config, int width, int height,
55                                   bool isRenderTarget, int sampleCnt,
56                                   GrMipMapped, GrScratchKey* key);
57 
58 
59 private:
GrTexturePriv(GrTexture * texture)60     GrTexturePriv(GrTexture* texture) : fTexture(texture) { }
GrTexturePriv(const GrTexturePriv & that)61     GrTexturePriv(const GrTexturePriv& that) : fTexture(that.fTexture) { }
62     GrTexturePriv& operator=(const GrTexturePriv&); // unimpl
63 
64     // No taking addresses of this type.
65     const GrTexturePriv* operator&() const;
66     GrTexturePriv* operator&();
67 
68     GrTexture* fTexture;
69 
70     friend class GrTexture; // to construct/copy this type.
71 };
72 
texturePriv()73 inline GrTexturePriv GrTexture::texturePriv() { return GrTexturePriv(this); }
74 
texturePriv()75 inline const GrTexturePriv GrTexture::texturePriv () const {
76     return GrTexturePriv(const_cast<GrTexture*>(this));
77 }
78 
79 #endif
80