• 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 
setMaxMipMapLevel(int maxMipMapLevel)39     void setMaxMipMapLevel(int maxMipMapLevel) const {
40         fTexture->fMaxMipMapLevel = maxMipMapLevel;
41     }
42 
maxMipMapLevel()43     int maxMipMapLevel() const {
44         return fTexture->fMaxMipMapLevel;
45     }
46 
samplerType()47     GrSLType samplerType() const { return fTexture->fSamplerType; }
48 
49     /** The filter used is clamped to this value in GrProcessor::TextureSampler. */
highestFilterMode()50     GrSamplerState::Filter highestFilterMode() const { return fTexture->fHighestFilterMode; }
51 
setMipColorMode(SkDestinationSurfaceColorMode colorMode)52     void setMipColorMode(SkDestinationSurfaceColorMode colorMode) const {
53         fTexture->fMipColorMode = colorMode;
54     }
mipColorMode()55     SkDestinationSurfaceColorMode mipColorMode() const { return fTexture->fMipColorMode; }
56 
57     static void ComputeScratchKey(const GrSurfaceDesc&, GrScratchKey*);
58     static void ComputeScratchKey(GrPixelConfig config, int width, int height,
59                                   bool isRenderTarget, int sampleCnt,
60                                   GrMipMapped, GrScratchKey* key);
61 
62 
63 private:
GrTexturePriv(GrTexture * texture)64     GrTexturePriv(GrTexture* texture) : fTexture(texture) { }
GrTexturePriv(const GrTexturePriv & that)65     GrTexturePriv(const GrTexturePriv& that) : fTexture(that.fTexture) { }
66     GrTexturePriv& operator=(const GrTexturePriv&); // unimpl
67 
68     // No taking addresses of this type.
69     const GrTexturePriv* operator&() const;
70     GrTexturePriv* operator&();
71 
72     GrTexture* fTexture;
73 
74     friend class GrTexture; // to construct/copy this type.
75 };
76 
texturePriv()77 inline GrTexturePriv GrTexture::texturePriv() { return GrTexturePriv(this); }
78 
texturePriv()79 inline const GrTexturePriv GrTexture::texturePriv () const {
80     return GrTexturePriv(const_cast<GrTexture*>(this));
81 }
82 
83 #endif
84